2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 local remote_dir=remote_dir
201 test_mkdir $DIR/$remote_dir ||
202 error "Create remote directory failed"
204 touch $DIR/$remote_dir/$tfile ||
205 error "Create file under remote directory failed"
207 rmdir $DIR/$remote_dir &&
208 error "Expect error removing in-use dir $DIR/$remote_dir"
210 test -d $DIR/$remote_dir || error "Remote directory disappeared"
212 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
215 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
216 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
217 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
218 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
224 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
225 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
227 error "$tfile does not have perm 0666 or UID $UID"
228 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile should be 0666 and owned by UID $UID"
232 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
237 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
238 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
239 error "$tfile should be owned by UID $RUNAS_ID"
240 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
244 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
249 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
250 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
251 error "$tfile should be owned by GID $UID"
252 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
256 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
260 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
261 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
262 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
263 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
264 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
265 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
266 error "$tdir/d/subdir should be GID $RUNAS_GID"
268 run_test 6g "Is new dir in sgid dir inheriting group?"
270 test_6h() { # bug 7331
271 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
272 touch $DIR/$tfile || error "touch failed"
273 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
274 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
275 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
276 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
277 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
279 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
282 test_mkdir $DIR/$tdir
283 $MCREATE $DIR/$tdir/$tfile
284 chmod 0666 $DIR/$tdir/$tfile
285 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
286 error "$tdir/$tfile should be mode 0666"
288 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
291 if [ ! -d $DIR/$tdir ]; then
294 $MCREATE $DIR/$tdir/$tfile
295 echo -n foo > $DIR/$tdir/$tfile
296 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
297 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
299 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
302 test_mkdir $DIR/$tdir
303 touch $DIR/$tdir/$tfile
304 chmod 0666 $DIR/$tdir/$tfile
305 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
306 error "$tfile mode not 0666"
308 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
311 test_mkdir $DIR/$tdir
312 test_mkdir $DIR/$tdir/d2
313 test_mkdir $DIR/$tdir/d2/d3
314 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
316 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
319 test_mkdir $DIR/$tdir
320 test_mkdir $DIR/$tdir/d2
321 touch $DIR/$tdir/d2/$tfile
322 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
323 error "$tdir/d2/$tfile not a file"
325 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 chmod 0666 $DIR/$tdir/d2
331 chmod 0705 $DIR/$tdir/d2
332 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
333 error "$tdir/d2 mode not 0705"
335 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
338 test_mkdir $DIR/$tdir
339 touch $DIR/$tdir/$tfile
340 chmod 0666 $DIR/$tdir/$tfile
341 chmod 0654 $DIR/$tdir/$tfile
342 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
343 error "$tdir/d2 mode not 0654"
345 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
348 test_mkdir $DIR/$tdir
349 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
351 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
352 error "$tdir/$tfile size not 0 after truncate"
354 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
357 test_mkdir $DIR/$tdir
358 touch $DIR/$tdir/$tfile
360 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
362 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
365 test_mkdir $DIR/$tdir
366 touch $DIR/$tdir/$tfile
367 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
368 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
369 error "$tdir/${tfile_2} not a file after rename"
371 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
376 rm -rf $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
382 test_mkdir -p $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
386 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
387 error "$tdir/l-exist not a symlink"
388 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
389 error "$tdir/l-exist not referencing a file"
390 rm -f $DIR/$tdir/l-exist
391 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
393 run_test 17a "symlinks: create, remove (real) =================="
396 test_mkdir -p $DIR/$tdir
397 ln -s no-such-file $DIR/$tdir/l-dangle
399 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
400 error "$tdir/l-dangle not referencing no-such-file"
401 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
402 error "$tdir/l-dangle not referencing non-existent file"
403 rm -f $DIR/$tdir/l-dangle
404 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
406 run_test 17b "symlinks: create, remove (dangling) =============="
408 test_17c() { # bug 3440 - don't save failed open RPC for replay
409 test_mkdir -p $DIR/$tdir
410 ln -s foo $DIR/$tdir/$tfile
411 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
413 run_test 17c "symlinks: open dangling (should return error) ===="
416 test_mkdir -p $DIR/$tdir
417 ln -s foo $DIR/$tdir/$tfile
418 touch $DIR/$tdir/$tfile || error "creating to new symlink"
420 run_test 17d "symlinks: create dangling ========================"
423 test_mkdir -p $DIR/$tdir
424 local foo=$DIR/$tdir/$tfile
425 ln -s $foo $foo || error "create symlink failed"
426 ls -l $foo || error "ls -l failed"
427 ls $foo && error "ls not failed" || true
429 run_test 17e "symlinks: create recursive symlink (should return error) ===="
432 test_mkdir -p $DIR/d17f
433 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
434 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
438 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
441 run_test 17f "symlinks: long and very long symlink name ========================"
443 # str_repeat(S, N) generate a string that is string S repeated N times
448 while [ $((n -= 1)) -ge 0 ]; do
454 # Long symlinks and LU-2241
456 test_mkdir -p $DIR/$tdir
457 local TESTS="59 60 61 4094 4095"
459 # Fix for inode size boundary in 2.1.4
460 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
463 # Patch not applied to 2.2 or 2.3 branches
464 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
465 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
468 # skip long symlink name for rhel6.5.
469 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
470 grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
484 test_mkdir -p $DIR/$tdir
485 if [ $MDSCOUNT -gt 1 ]; then
486 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
490 $SETSTRIPE -c -1 $DIR/$tdir
491 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
492 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
493 touch $DIR/$tdir/$tfile || true
495 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
497 test_17i() { #bug 20018
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
500 test_mkdir -p $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [ $MDSCOUNT -gt 1 ]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 rsync --help | grep -q xattr ||
518 skip_env "$(rsync --version| head -1) does not support xattrs"
519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
520 test_mkdir -p $DIR/$tdir
521 test_mkdir -p $DIR/$tdir.new
522 touch $DIR/$tdir/$tfile
523 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
524 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
525 error "rsync failed with xattrs enabled"
527 run_test 17k "symlinks: rsync with xattrs enabled ========================="
529 test_17l() { # LU-279
531 touch $DIR/$tdir/$tfile
532 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
533 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
534 # -h to not follow symlinks. -m '' to list all the xattrs.
535 # grep to remove first line: '# file: $path'.
536 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
538 lgetxattr_size_check $path $xattr ||
539 error "lgetxattr_size_check $path $xattr failed"
543 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
547 local short_sym="0123456789"
548 local WDIR=$DIR/${tdir}m
555 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
556 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
557 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
559 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
560 skip "only for ldiskfs MDT" && return 0
562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
566 # create a long symlink file
567 for ((i = 0; i < 4; ++i)); do
568 long_sym=${long_sym}${long_sym}
571 echo "create 512 short and long symlink files under $WDIR"
572 for ((i = 0; i < 256; ++i)); do
573 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
574 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
580 wait_delete_completed
582 echo "recreate the 512 symlink files with a shorter string"
583 for ((i = 0; i < 512; ++i)); do
584 # rewrite the symlink file with a shorter string
585 ln -sf ${long_sym} $WDIR/long-$i
586 ln -sf ${short_sym} $WDIR/short-$i
589 mds_index=$($LFS getstripe -M $WDIR)
590 mds_index=$((mds_index+1))
591 devname=$(mdsdevname $mds_index)
592 cmd="$E2FSCK -fnvd $devname"
594 echo "stop and checking mds${mds_index}: $cmd"
595 # e2fsck should not return error
597 do_facet mds${mds_index} $cmd || rc=$?
599 start mds${mds_index} $devname $MDS_MOUNT_OPTS
600 df $MOUNT > /dev/null 2>&1
601 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
602 "short/long symlink MDT: rc=$rc"
605 run_test 17m "run e2fsck against MDT which contains short/long symlink"
607 check_fs_consistency_17n() {
613 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
614 # so it only check MDT1/MDT2 instead of all of MDTs.
615 for mdt_index in $(seq 1 2); do
616 devname=$(mdsdevname $mdt_index)
617 cmd="$E2FSCK -fnvd $devname"
619 echo "stop and checking mds${mdt_index}: $cmd"
620 # e2fsck should not return error
622 do_facet mds${mdt_index} $cmd || rc=$?
624 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
625 df $MOUNT > /dev/null 2>&1
626 [ $rc -ne 0 ] && break
634 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
635 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
636 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
638 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
639 skip "only for ldiskfs MDT" && return 0
641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
646 for ((i=0; i<10; i++)); do
647 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
648 error "create remote dir error $i"
649 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
650 error "create files under remote dir failed $i"
653 check_fs_consistency_17n || error "e2fsck report error"
655 for ((i=0;i<10;i++)); do
656 rm -rf $DIR/$tdir/remote_dir_${i} ||
657 error "destroy remote dir error $i"
660 check_fs_consistency_17n || error "e2fsck report error"
662 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
665 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
666 skip "Need MDS version at least 2.3.64" && return
668 local WDIR=$DIR/${tdir}o
674 mdt_index=$($LFS getstripe -M $WDIR)
675 mdt_index=$((mdt_index+1))
676 mdtdevname=$(mdsdevname $mdt_index)
680 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
682 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
683 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
684 ls -l $WDIR/$tfile && rc=1
685 do_facet mds${mdt_index} lctl set_param fail_loc=0
686 [[ $rc -ne 0 ]] && error "stat file should fail"
689 run_test 17o "stat file with incompat LMA feature"
692 touch $DIR/f || error "Failed to touch $DIR/f: $?"
693 ls $DIR || error "Failed to ls $DIR: $?"
695 run_test 18 "touch .../f ; ls ... =============================="
701 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
703 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
706 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
708 run_test 19b "ls -l .../f19 (should return error) =============="
711 [ $RUNAS_ID -eq $UID ] &&
712 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
713 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
715 run_test 19c "$RUNAS touch .../f19 (should return error) =="
718 cat $DIR/f19 && error || true
720 run_test 19d "cat .../f19 (should return error) =============="
732 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
734 run_test 20 "touch .../f ; ls -l ... ==========================="
737 test_mkdir -p $DIR/$tdir
738 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
739 ln -s dangle $DIR/$tdir/link
740 echo foo >> $DIR/$tdir/link
741 cat $DIR/$tdir/dangle
742 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
743 $CHECKSTAT -f -t file $DIR/$tdir/link ||
744 error "$tdir/link not linked to a file"
746 run_test 21 "write to dangling link ============================"
750 test_mkdir -p $DIR/$tdir
751 chown $RUNAS_ID:$RUNAS_GID $WDIR
752 (cd $WDIR || error "cd $WDIR failed";
753 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
755 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
756 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
757 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
759 run_test 22 "unpack tar archive as non-root user ==============="
763 test_mkdir -p $DIR/$tdir
764 local file=$DIR/$tdir/$tfile
766 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
767 openfile -f O_CREAT:O_EXCL $file &&
768 error "$file recreate succeeded" || true
770 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
772 test_23b() { # bug 18988
773 test_mkdir -p $DIR/$tdir
774 local file=$DIR/$tdir/$tfile
777 echo foo > $file || error "write filed"
778 echo bar >> $file || error "append filed"
779 $CHECKSTAT -s 8 $file || error "wrong size"
782 run_test 23b "O_APPEND check =========================="
786 echo '-- same directory rename'
787 test_mkdir $DIR/$tdir
788 touch $DIR/$tdir/$tfile.1
789 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
790 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
792 run_test 24a "rename file to non-existent target"
795 test_mkdir $DIR/$tdir
796 touch $DIR/$tdir/$tfile.{1,2}
797 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
798 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
799 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
801 run_test 24b "rename file to existing target"
804 test_mkdir $DIR/$tdir
805 test_mkdir $DIR/$tdir/d$testnum.1
806 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
807 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
808 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
810 run_test 24c "rename directory to non-existent target"
813 test_mkdir -c1 $DIR/$tdir
814 test_mkdir -c1 $DIR/$tdir/d$testnum.1
815 test_mkdir -c1 $DIR/$tdir/d$testnum.2
816 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
817 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
818 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
820 run_test 24d "rename directory to existing target"
823 echo '-- cross directory renames --'
827 mv $DIR/R5a/f $DIR/R5b/g
828 $CHECKSTAT -a $DIR/R5a/f || error
829 $CHECKSTAT -t file $DIR/R5b/g || error
831 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
836 touch $DIR/R6a/f $DIR/R6b/g
837 mv $DIR/R6a/f $DIR/R6b/g
838 $CHECKSTAT -a $DIR/R6a/f || error
839 $CHECKSTAT -t file $DIR/R6b/g || error
841 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
846 test_mkdir $DIR/R7a/d
847 mv $DIR/R7a/d $DIR/R7b/e
848 $CHECKSTAT -a $DIR/R7a/d || error
849 $CHECKSTAT -t dir $DIR/R7b/e || error
851 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
854 test_mkdir -c1 $DIR/R8a
855 test_mkdir -c1 $DIR/R8b
856 test_mkdir -c1 $DIR/R8a/d
857 test_mkdir -c1 $DIR/R8b/e
858 mrename $DIR/R8a/d $DIR/R8b/e
859 $CHECKSTAT -a $DIR/R8a/d || error
860 $CHECKSTAT -t dir $DIR/R8b/e || error
862 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
865 echo "-- rename error cases"
869 mrename $DIR/R9/f $DIR/R9/a
870 $CHECKSTAT -t file $DIR/R9/f || error
871 $CHECKSTAT -t dir $DIR/R9/a || error
872 $CHECKSTAT -a $DIR/R9/a/f || error
874 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
878 mrename $DIR/R10/f $DIR/R10/g
879 $CHECKSTAT -t dir $DIR/R10 || error
880 $CHECKSTAT -a $DIR/R10/f || error
881 $CHECKSTAT -a $DIR/R10/g || error
883 run_test 24j "source does not exist ============================"
887 test_mkdir $DIR/R11a/d
889 mv $DIR/R11a/f $DIR/R11a/d
890 $CHECKSTAT -a $DIR/R11a/f || error
891 $CHECKSTAT -t file $DIR/R11a/d/f || error
893 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
895 # bug 2429 - rename foo foo foo creates invalid file
898 $MULTIOP $f OcNs || error
900 run_test 24l "Renaming a file to itself ========================"
904 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
905 # on ext3 this does not remove either the source or target files
906 # though the "expected" operation would be to remove the source
907 $CHECKSTAT -t file ${f} || error "${f} missing"
908 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
910 run_test 24m "Renaming a file to a hard link to itself ========="
914 # this stats the old file after it was renamed, so it should fail
918 $CHECKSTAT ${f}.rename
921 run_test 24n "Statting the old file after renaming (Posix rename 2)"
924 check_kernel_version 37 || return 0
925 test_mkdir -p $DIR/d24o
926 rename_many -s random -v -n 10 $DIR/d24o
928 run_test 24o "rename of files during htree split ==============="
933 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
934 mrename $DIR/R12a $DIR/R12b
935 $CHECKSTAT -a $DIR/R12a || error
936 $CHECKSTAT -t dir $DIR/R12b || error
937 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
938 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
940 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
942 cleanup_multiop_pause() {
948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
951 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
952 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
955 trap cleanup_multiop_pause EXIT
956 mrename $DIR/R13a $DIR/R13b
957 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
958 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
959 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
960 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
961 cleanup_multiop_pause
962 wait $MULTIPID || error "multiop close failed"
964 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
966 test_24r() { #bug 3789
968 test_mkdir $DIR/R14a/b
969 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
970 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
971 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
973 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
977 test_mkdir $DIR/R15a/b
978 test_mkdir $DIR/R15a/b/c
979 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
980 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
981 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
983 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
986 test_mkdir $DIR/R16a/b
987 test_mkdir $DIR/R16a/b/c
988 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
989 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
990 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
992 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
994 test_24u() { # bug12192
996 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
997 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
999 run_test 24u "create stripe file"
1005 simple_cleanup_common() {
1008 wait_delete_completed
1011 max_pages_per_rpc() {
1012 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1016 local NRFILES=100000
1017 local FREE_INODES=$(mdt_free_inodes 0)
1018 [ $FREE_INODES -lt $NRFILES ] && \
1019 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1023 trap simple_cleanup_common EXIT
1025 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1026 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1029 createmany -m $DIR/$tdir/$tfile $NRFILES
1031 cancel_lru_locks mdc
1032 lctl set_param mdc.*.stats clear
1034 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1036 # LU-5 large readdir
1037 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1038 # 8 bytes for name(filename is mostly 5 in this test) +
1039 # 8 bytes for luda_type
1040 # take into account of overhead in lu_dirpage header and end mark in
1041 # each page, plus one in RPC_NUM calculation.
1043 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1044 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1045 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1046 awk '/^mds_readpage/ {print $2}')
1047 [ $mds_readpage -gt $RPC_NUM ] && \
1048 error "large readdir doesn't take effect"
1050 simple_cleanup_common
1052 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1054 test_24w() { # bug21506
1056 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1057 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1058 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1059 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1060 [ "$SZ1" = "$SZ2" ] || \
1061 error "Error reading at the end of the file $tfile"
1063 run_test 24w "Reading a file larger than 4Gb"
1066 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1069 local remote_dir=$DIR/$tdir/remote_dir
1072 $LFS mkdir -i $MDTIDX $remote_dir ||
1073 error "create remote directory failed"
1075 mkdir -p $DIR/$tdir/src_dir
1076 touch $DIR/$tdir/src_file
1077 mkdir -p $remote_dir/tgt_dir
1078 touch $remote_dir/tgt_file
1080 mrename $remote_dir $DIR/ &&
1081 error "rename dir cross MDT works!"
1083 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1084 error "rename dir cross MDT works!"
1086 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1087 error "rename file cross MDT works!"
1089 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1090 error "ln file cross MDT should not work!"
1092 rm -rf $DIR/$tdir || error "Can not delete directories"
1094 run_test 24x "cross rename/link should be failed"
1097 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1100 local remote_dir=$DIR/$tdir/remote_dir
1103 $LFS mkdir -i $MDTIDX $remote_dir ||
1104 error "create remote directory failed"
1106 mkdir -p $remote_dir/src_dir
1107 touch $remote_dir/src_file
1108 mkdir -p $remote_dir/tgt_dir
1109 touch $remote_dir/tgt_file
1111 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1112 error "rename subdir in the same remote dir failed!"
1114 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1115 error "rename files in the same remote dir failed!"
1117 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1118 error "link files in the same remote dir failed!"
1120 rm -rf $DIR/$tdir || error "Can not delete directories"
1122 run_test 24y "rename/link on the same dir should succeed"
1125 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1128 local remote_src=$DIR/$tdir/remote_dir
1129 local remote_tgt=$DIR/$tdir/remote_tgt
1132 $LFS mkdir -i $MDTIDX $remote_src ||
1133 error "create remote directory failed"
1135 $LFS mkdir -i $MDTIDX $remote_tgt ||
1136 error "create remote directory failed"
1138 mrename $remote_src $remote_tgt &&
1139 error "rename remote dirs should not work!"
1141 # If target dir does not exists, it should succeed
1143 mrename $remote_src $remote_tgt ||
1144 error "rename remote dirs(tgt dir does not exists) failed!"
1146 rm -rf $DIR/$tdir || error "Can not delete directories"
1148 run_test 24z "rename one remote dir to another remote dir should fail"
1150 test_24A() { # LU-3182
1155 createmany -m $DIR/$tdir/$tfile $NFILES
1156 local t=`ls $DIR/$tdir | wc -l`
1157 local u=`ls $DIR/$tdir | sort -u | wc -l`
1158 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1159 error "Expected $NFILES files, got $t ($u unique)"
1162 rm -rf $DIR/$tdir || error "Can not delete directories"
1164 run_test 24A "readdir() returns correct number of entries."
1167 echo '== symlink sanity ============================================='
1171 touch $DIR/s25/foo || error
1173 run_test 25a "create file in symlinked directory ==============="
1176 [ ! -d $DIR/d25 ] && test_25a
1177 $CHECKSTAT -t file $DIR/s25/foo || error
1179 run_test 25b "lookup file in symlinked directory ==============="
1183 test_mkdir $DIR/d26/d26-2
1184 ln -s d26/d26-2 $DIR/s26
1185 touch $DIR/s26/foo || error
1187 run_test 26a "multiple component symlink ======================="
1190 test_mkdir -p $DIR/d26b/d26-2
1191 ln -s d26b/d26-2/foo $DIR/s26-2
1192 touch $DIR/s26-2 || error
1194 run_test 26b "multiple component symlink at end of lookup ======"
1197 test_mkdir $DIR/d26.2
1198 touch $DIR/d26.2/foo
1199 ln -s d26.2 $DIR/s26.2-1
1200 ln -s s26.2-1 $DIR/s26.2-2
1201 ln -s s26.2-2 $DIR/s26.2-3
1202 chmod 0666 $DIR/s26.2-3/foo
1204 run_test 26c "chain of symlinks ================================"
1206 # recursive symlinks (bug 439)
1208 ln -s d26-3/foo $DIR/d26-3
1210 run_test 26d "create multiple component recursive symlink ======"
1213 [ ! -h $DIR/d26-3 ] && test_26d
1216 run_test 26e "unlink multiple component recursive symlink ======"
1218 # recursive symlinks (bug 7022)
1220 test_mkdir -p $DIR/$tdir
1221 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1222 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1223 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1224 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1225 cd $tfile || error "cd $tfile failed"
1226 ln -s .. dotdot || error "ln dotdot failed"
1227 ln -s dotdot/lndir lndir || error "ln lndir failed"
1228 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1229 output=`ls $tfile/$tfile/lndir/bar1`
1230 [ "$output" = bar1 ] && error "unexpected output"
1231 rm -r $tfile || error "rm $tfile failed"
1232 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1234 run_test 26f "rm -r of a directory which has recursive symlink ="
1237 echo '== stripe sanity =============================================='
1238 test_mkdir -p $DIR/d27 || error "mkdir failed"
1240 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1241 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1243 log "== test_27a: write to one stripe file ========================="
1244 cp /etc/hosts $DIR/d27/f0 || error
1246 run_test 27a "one stripe file =================================="
1249 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1250 test_mkdir -p $DIR/d27
1251 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1252 $GETSTRIPE -c $DIR/d27/f01
1253 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1254 error "two-stripe file doesn't have two stripes"
1256 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1258 run_test 27b "create and write to two stripe file"
1261 test_mkdir -p $DIR/d27
1262 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1263 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1264 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1266 run_test 27d "create file with default settings ================"
1269 test_mkdir -p $DIR/d27
1270 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1271 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1272 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1274 run_test 27e "setstripe existing file (should return error) ======"
1277 test_mkdir -p $DIR/d27
1278 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1279 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1280 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1282 run_test 27f "setstripe with bad stripe size (should return error)"
1285 test_mkdir -p $DIR/d27
1286 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1287 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1288 error "$DIR/d27/fnone has object"
1290 run_test 27g "$GETSTRIPE with no objects"
1293 touch $DIR/d27/fsome || error "touch failed"
1294 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1296 run_test 27i "$GETSTRIPE with some objects"
1299 test_mkdir -p $DIR/d27
1300 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1302 run_test 27j "setstripe with bad stripe offset (should return error)"
1304 test_27k() { # bug 2844
1305 test_mkdir -p $DIR/d27
1307 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1308 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1309 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1310 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1311 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1312 dd if=/dev/zero of=$FILE bs=4k count=1
1313 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1314 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1316 run_test 27k "limit i_blksize for broken user apps ============="
1319 test_mkdir -p $DIR/d27
1320 mcreate $DIR/f27l || error "creating file"
1321 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1322 error "setstripe should have failed" || true
1324 run_test 27l "check setstripe permissions (should return error)"
1327 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1329 if [ $ORIGFREE -gt $MAXFREE ]; then
1330 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1333 trap simple_cleanup_common EXIT
1334 test_mkdir -p $DIR/$tdir
1335 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1336 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1337 error "dd should fill OST0"
1339 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1341 [ $i -gt 256 ] && break
1344 touch $DIR/$tdir/f27m_$i
1345 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1346 error "OST0 was full but new created file still use it"
1348 touch $DIR/$tdir/f27m_$i
1349 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1350 error "OST0 was full but new created file still use it"
1351 simple_cleanup_common
1353 run_test 27m "create file while OST0 was full =================="
1356 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1360 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1361 # if the OST isn't full anymore.
1363 local OSTIDX=${1:-""}
1365 local list=$(comma_list $(osts_nodes))
1366 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1368 do_nodes $list lctl set_param fail_loc=0
1369 sync # initiate all OST_DESTROYs from MDS to OST
1373 exhaust_precreations() {
1376 local FAILIDX=${3:-$OSTIDX}
1378 test_mkdir -p $DIR/$tdir
1379 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1380 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1382 local OST=$(ostname_from_index $OSTIDX)
1383 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1384 sed -e 's/_UUID$//;s/^.*-//')
1387 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1388 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1389 osc.$mdtosc_proc1.prealloc_last_id)
1390 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1391 osc.$mdtosc_proc1.prealloc_next_id)
1393 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1394 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1396 test_mkdir -p $DIR/$tdir/${OST}
1397 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1398 #define OBD_FAIL_OST_ENOSPC 0x215
1399 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1400 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1401 echo "Creating to objid $last_id on ost $OST..."
1402 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1403 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1404 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1408 exhaust_all_precreations() {
1410 for (( i=0; i < OSTCOUNT; i++ )) ; do
1411 exhaust_precreations $i $1 -1
1416 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1418 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1419 remote_ost_nodsh && skip "remote OST with nodsh" && return
1422 rm -f $DIR/$tdir/$tfile
1423 exhaust_precreations 0 0x80000215
1424 $SETSTRIPE -c -1 $DIR/$tdir
1425 touch $DIR/$tdir/$tfile || error
1426 $GETSTRIPE $DIR/$tdir/$tfile
1429 run_test 27n "create file with some full OSTs =================="
1432 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1434 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1435 remote_ost_nodsh && skip "remote OST with nodsh" && return
1438 rm -f $DIR/$tdir/$tfile
1439 exhaust_all_precreations 0x215
1441 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1446 run_test 27o "create file with all full OSTs (should error) ===="
1449 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1451 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1452 remote_ost_nodsh && skip "remote OST with nodsh" && return
1455 rm -f $DIR/$tdir/$tfile
1456 test_mkdir -p $DIR/$tdir
1458 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1459 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1460 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1462 exhaust_precreations 0 0x80000215
1463 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1464 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1465 $GETSTRIPE $DIR/$tdir/$tfile
1469 run_test 27p "append to a truncated file with some full OSTs ==="
1472 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1474 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1475 remote_ost_nodsh && skip "remote OST with nodsh" && return
1478 rm -f $DIR/$tdir/$tfile
1480 test_mkdir -p $DIR/$tdir
1481 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1482 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1483 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1485 exhaust_all_precreations 0x215
1487 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1488 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1492 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1495 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1497 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1498 remote_ost_nodsh && skip "remote OST with nodsh" && return
1501 rm -f $DIR/$tdir/$tfile
1502 exhaust_precreations 0 0x80000215
1504 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1508 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1510 test_27s() { # bug 10725
1511 test_mkdir -p $DIR/$tdir
1512 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1513 local stripe_count=0
1514 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1515 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1516 error "stripe width >= 2^32 succeeded" || true
1519 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1521 test_27t() { # bug 10864
1526 $WLFS getstripe $tfile
1529 run_test 27t "check that utils parse path correctly"
1531 test_27u() { # bug 4900
1532 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1533 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1535 local list=$(comma_list $(mdts_nodes))
1537 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1538 do_nodes $list $LCTL set_param fail_loc=0x139
1539 test_mkdir -p $DIR/$tdir
1541 createmany -o $DIR/$tdir/t- 1000
1542 do_nodes $list $LCTL set_param fail_loc=0
1544 TLOG=$DIR/$tfile.getstripe
1545 $GETSTRIPE $DIR/$tdir > $TLOG
1546 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1547 unlinkmany $DIR/$tdir/t- 1000
1548 [ $OBJS -gt 0 ] && \
1549 error "$OBJS objects created on OST-0. See $TLOG" || pass
1551 run_test 27u "skip object creation on OSC w/o objects =========="
1553 test_27v() { # bug 4900
1554 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return
1559 exhaust_all_precreations 0x215
1562 test_mkdir -p $DIR/$tdir
1563 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1565 touch $DIR/$tdir/$tfile
1566 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1568 for (( i=1; i < OSTCOUNT; i++ )); do
1569 do_facet ost$i lctl set_param fail_loc=0x705
1571 local START=`date +%s`
1572 createmany -o $DIR/$tdir/$tfile 32
1574 local FINISH=`date +%s`
1575 local TIMEOUT=`lctl get_param -n timeout`
1576 local PROCESS=$((FINISH - START))
1577 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1578 error "$FINISH - $START >= $TIMEOUT / 2"
1579 sleep $((TIMEOUT / 2 - PROCESS))
1582 run_test 27v "skip object creation on slow OST ================="
1584 test_27w() { # bug 10997
1585 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1586 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1587 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1588 error "stripe size $size != 65536" || true
1589 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1590 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1592 run_test 27w "check $SETSTRIPE -S option"
1595 [ "$OSTCOUNT" -lt "2" ] &&
1596 skip_env "skipping multiple stripe count/offset test" && return
1598 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1599 for i in $(seq 1 $OSTCOUNT); do
1601 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1602 error "setstripe -c $i -i $offset failed"
1603 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1604 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1605 [ $count -ne $i ] && error "stripe count $count != $i" || true
1606 [ $index -ne $offset ] &&
1607 error "stripe offset $index != $offset" || true
1610 run_test 27wa "check $SETSTRIPE -c -i options"
1613 remote_ost_nodsh && skip "remote OST with nodsh" && return
1614 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1616 OFFSET=$(($OSTCOUNT - 1))
1618 local OST=$(ostname_from_index $OSTIDX)
1620 test_mkdir -p $DIR/$tdir
1621 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1622 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1624 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1625 for i in `seq 0 $OFFSET`; do
1626 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1627 error "OST0 was degraded but new created file still use it"
1629 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1631 run_test 27x "create files while OST0 is degraded"
1634 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1636 remote_ost_nodsh && skip "remote OST with nodsh" && return
1637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1639 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1640 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1641 osc.$mdtosc.prealloc_last_id)
1642 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1643 osc.$mdtosc.prealloc_next_id)
1644 local fcount=$((last_id - next_id))
1645 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1646 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1648 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1649 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1650 local OST_DEACTIVE_IDX=-1
1655 for OSC in $MDS_OSCS; do
1656 OST=$(osc_to_ost $OSC)
1657 OSTIDX=$(index_from_ostuuid $OST)
1658 if [ $OST_DEACTIVE_IDX == -1 ]; then
1659 OST_DEACTIVE_IDX=$OSTIDX
1661 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1662 echo $OSC "is Deactivated:"
1663 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1667 OSTIDX=$(index_from_ostuuid $OST)
1669 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1671 for OSC in $MDS_OSCS; do
1672 OST=$(osc_to_ost $OSC)
1673 OSTIDX=$(index_from_ostuuid $OST)
1674 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1675 echo $OST "is degraded:"
1676 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1677 obdfilter.$OST.degraded=1
1682 createmany -o $DIR/$tdir/$tfile $fcount
1684 for OSC in $MDS_OSCS; do
1685 OST=$(osc_to_ost $OSC)
1686 OSTIDX=$(index_from_ostuuid $OST)
1687 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1688 echo $OST "is recovered from degraded:"
1689 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1690 obdfilter.$OST.degraded=0
1692 do_facet $SINGLEMDS lctl --device %$OSC activate
1696 # all osp devices get activated, hence -1 stripe count restored
1699 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1700 # devices get activated.
1702 $SETSTRIPE -c -1 $DIR/$tfile
1703 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1705 [ $stripecnt -ne $OSTCOUNT ] &&
1706 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1709 run_test 27y "create files while OST0 is degraded and the rest inactive"
1715 lmm_count=$($GETSTRIPE -c $1)
1716 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1717 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1719 local old_ifs="$IFS"
1721 fid=($($LFS path2fid $1))
1724 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1725 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1727 # compare lmm_seq and lu_fid->f_seq
1728 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1729 # compare lmm_object_id and lu_fid->oid
1730 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1732 # check the trusted.fid attribute of the OST objects of the file
1733 local have_obdidx=false
1735 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1736 # skip lines up to and including "obdidx"
1737 [ -z "$obdidx" ] && break
1738 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1739 $have_obdidx || continue
1741 local ost=$((obdidx + 1))
1742 local dev=$(ostdevname $ost)
1745 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1747 seq=$(echo $seq | sed -e "s/^0x//g")
1748 if [ $seq == 0 ]; then
1749 oid_hex=$(echo $oid)
1751 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1753 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1757 # Don't unmount/remount the OSTs if we don't need to do that.
1758 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1759 # update too, until that use mount/ll_decode_filter_fid/mount.
1760 # Re-enable when debugfs will understand new filter_fid.
1762 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1763 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1764 $dev 2>/dev/null" | grep "parent=")
1767 mount_fstype ost$ost
1768 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1769 $(facet_mntpt ost$ost)/$obj_file)
1770 unmount_fstype ost$ost
1771 start ost$ost $dev $OST_MOUNT_OPTS
1774 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1776 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1778 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1779 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1780 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1781 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1782 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1784 if echo $ff_parent | grep -q 'stripe='; then
1785 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1788 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1789 # into f_ver in this case. See the comment on
1792 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1796 # compare lmm_seq and filter_fid->ff_parent.f_seq
1797 [ $ff_pseq = $lmm_seq ] ||
1798 error "FF parent SEQ $ff_pseq != $lmm_seq"
1799 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1800 [ $ff_poid = $lmm_oid ] ||
1801 error "FF parent OID $ff_poid != $lmm_oid"
1802 (($ff_pstripe == $stripe_nr)) ||
1803 error "FF stripe $ff_pstripe != $stripe_nr"
1805 stripe_nr=$((stripe_nr + 1))
1810 remote_ost_nodsh && skip "remote OST with nodsh" && return
1811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1812 test_mkdir -p $DIR/$tdir
1814 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1815 { error "setstripe -c -1 failed"; return 1; }
1816 # We need to send a write to every object to get parent FID info set.
1817 # This _should_ also work for setattr, but does not currently.
1818 # touch $DIR/$tdir/$tfile-1 ||
1819 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1820 { error "dd $tfile-1 failed"; return 2; }
1821 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1822 { error "setstripe -c -1 failed"; return 3; }
1823 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1824 { error "dd $tfile-2 failed"; return 4; }
1826 # make sure write RPCs have been sent to OSTs
1829 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1830 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1832 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1834 test_27A() { # b=19102
1835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1836 local restore_size=$($GETSTRIPE -S $MOUNT)
1837 local restore_count=$($GETSTRIPE -c $MOUNT)
1838 local restore_offset=$($GETSTRIPE -i $MOUNT)
1839 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1840 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1841 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1842 local default_size=$($GETSTRIPE -S $MOUNT)
1843 local default_offset=$($GETSTRIPE -i $MOUNT)
1844 local dsize=$((1024 * 1024))
1845 [ $default_size -eq $dsize ] ||
1846 error "stripe size $default_size != $dsize"
1847 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1848 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1850 run_test 27A "check filesystem-wide default LOV EA values"
1852 test_27B() { # LU-2523
1853 test_mkdir -p $DIR/$tdir
1854 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1856 # open f1 with O_LOV_DELAY_CREATE
1858 # call setstripe ioctl on open file descriptor for f1
1860 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1864 # open f1 with O_LOV_DELAY_CREATE
1866 # call setstripe ioctl on open file descriptor for f1
1868 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1870 # Allow multiop to fail in imitation of NFS's busted semantics.
1873 run_test 27B "call setstripe on open unlinked file/rename victim"
1875 test_27C() { #LU-2871
1876 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1884 test_mkdir -p $DIR/$tdir
1886 for i in $(seq 0 $((OSTCOUNT - 1))); do
1887 # set stripe across all OSTs starting from OST$i
1888 $SETSTRIPE -i $i -c -1 $tfile$i
1889 # get striping information
1890 ost_idx=($($GETSTRIPE $tfile$i |
1891 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1895 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1896 error "${#ost_idx[@]} != $OSTCOUNT"
1898 for index in $(seq 0 $((OSTCOUNT - 1))); do
1900 for j in $(echo ${ost_idx[@]}); do
1901 if [ $index -eq $j ]; then
1907 error "Can not find $index in ${ost_idx[@]}"
1911 run_test 27C "check full striping across all OSTs"
1913 # createtest also checks that device nodes are created and
1914 # then visible correctly (#2091)
1915 test_28() { # bug 2091
1917 $CREATETEST $DIR/d28/ct || error
1919 run_test 28 "create/mknod/mkdir with bad file types ============"
1922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1923 cancel_lru_locks mdc
1929 declare -i LOCKCOUNTORIG=0
1930 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1931 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1933 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1935 declare -i LOCKUNUSEDCOUNTORIG=0
1936 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1937 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1944 declare -i LOCKCOUNTCURRENT=0
1945 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1946 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1949 declare -i LOCKUNUSEDCOUNTCURRENT=0
1950 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1951 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1954 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1955 lctl set_param -n ldlm.dump_namespaces ""
1956 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1957 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1958 log "dumped log to $TMP/test_29.dk (bug 5793)"
1961 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1962 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1963 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1964 log "dumped log to $TMP/test_29.dk (bug 5793)"
1968 run_test 29 "IT_GETATTR regression ============================"
1970 test_30a() { # was test_30
1971 cp `which ls` $DIR || cp /bin/ls $DIR
1975 run_test 30a "execute binary from Lustre (execve) =============="
1978 cp `which ls` $DIR || cp /bin/ls $DIR
1980 $RUNAS $DIR/ls / || error
1983 run_test 30b "execute binary from Lustre as non-root ==========="
1985 test_30c() { # b=22376
1986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1987 cp `which ls` $DIR || cp /bin/ls $DIR
1989 cancel_lru_locks mdc
1990 cancel_lru_locks osc
1991 $RUNAS $DIR/ls / || error
1994 run_test 30c "execute binary from Lustre without read perms ===="
1997 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1998 $CHECKSTAT -a $DIR/f31 || error
2000 run_test 31a "open-unlink file =================================="
2003 touch $DIR/f31 || error
2004 ln $DIR/f31 $DIR/f31b || error
2005 $MULTIOP $DIR/f31b Ouc || error
2006 $CHECKSTAT -t file $DIR/f31 || error
2008 run_test 31b "unlink file with multiple links while open ======="
2011 touch $DIR/f31 || error
2012 ln $DIR/f31 $DIR/f31c || error
2013 multiop_bg_pause $DIR/f31 O_uc || return 1
2015 $MULTIOP $DIR/f31c Ouc
2016 kill -USR1 $MULTIPID
2019 run_test 31c "open-unlink file with multiple links ============="
2022 opendirunlink $DIR/d31d $DIR/d31d || error
2023 $CHECKSTAT -a $DIR/d31d || error
2025 run_test 31d "remove of open directory ========================="
2027 test_31e() { # bug 2904
2028 check_kernel_version 34 || return 0
2029 openfilleddirunlink $DIR/d31e || error
2031 run_test 31e "remove of open non-empty directory ==============="
2033 test_31f() { # bug 4554
2034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2036 test_mkdir $DIR/d31f
2037 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2038 cp /etc/hosts $DIR/d31f
2040 $GETSTRIPE $DIR/d31f/hosts
2041 multiop_bg_pause $DIR/d31f D_c || return 1
2044 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2045 test_mkdir $DIR/d31f
2046 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2047 cp /etc/hosts $DIR/d31f
2049 $GETSTRIPE $DIR/d31f/hosts
2050 multiop_bg_pause $DIR/d31f D_c || return 1
2053 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2054 wait $MULTIPID || error "first opendir $MULTIPID failed"
2058 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2059 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2062 run_test 31f "remove of open directory with open-unlink file ==="
2065 echo "-- cross directory link --"
2066 test_mkdir -c1 $DIR/${tdir}ga
2067 test_mkdir -c1 $DIR/${tdir}gb
2068 touch $DIR/${tdir}ga/f
2069 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2070 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2071 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2072 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2073 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2075 run_test 31g "cross directory link==============="
2078 echo "-- cross directory link --"
2079 test_mkdir -c1 $DIR/${tdir}
2080 test_mkdir -c1 $DIR/${tdir}/dir
2081 touch $DIR/${tdir}/f
2082 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2083 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2084 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2085 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2086 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2088 run_test 31h "cross directory link under child==============="
2091 echo "-- cross directory link --"
2092 test_mkdir -c1 $DIR/$tdir
2093 test_mkdir -c1 $DIR/$tdir/dir
2094 touch $DIR/$tdir/dir/f
2095 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2096 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2097 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2098 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2099 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2101 run_test 31i "cross directory link under parent==============="
2104 test_mkdir -c1 -p $DIR/$tdir
2105 test_mkdir -c1 -p $DIR/$tdir/dir1
2106 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2107 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2108 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2109 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2112 run_test 31j "link for directory==============="
2115 test_mkdir -c1 -p $DIR/$tdir
2117 touch $DIR/$tdir/exist
2118 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2119 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2120 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2121 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2122 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2123 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2124 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2127 run_test 31k "link to file: the same, non-existing, dir==============="
2133 touch $DIR/d31m2/exist
2134 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2135 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2136 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2137 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2138 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2139 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2142 run_test 31m "link to file: the same, non-existing, dir==============="
2145 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2146 nlink=$(stat --format=%h $DIR/$tfile)
2147 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2149 local cmd="exec $fd<$DIR/$tfile"
2152 trap "eval $cmd" EXIT
2153 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2154 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2155 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2156 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2157 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2160 run_test 31n "check link count of unlinked file"
2163 local TEMPNAME=$(mktemp $1_XXXXXX)
2164 mlink $TEMPNAME $1 2> /dev/null &&
2165 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2169 test_31o() { # LU-2901
2171 for LOOP in $(seq 100); do
2172 rm -f $DIR/$tdir/$tfile*
2173 for THREAD in $(seq 8); do
2174 link_one $DIR/$tdir/$tfile.$LOOP &
2177 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2178 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2179 error "$LINKS duplicate links to $tfile.$LOOP" &&
2183 run_test 31o "duplicate hard links with same filename"
2185 cleanup_test32_mount() {
2187 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2192 echo "== more mountpoints and symlinks ================="
2193 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2194 trap cleanup_test32_mount EXIT
2195 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2196 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2197 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2198 cleanup_test32_mount
2200 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2204 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2205 trap cleanup_test32_mount EXIT
2206 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2207 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2208 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2209 cleanup_test32_mount
2211 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2215 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2216 trap cleanup_test32_mount EXIT
2217 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2218 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2219 test_mkdir -p $DIR/$tdir/d2/test_dir
2220 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2221 cleanup_test32_mount
2223 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2227 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2228 trap cleanup_test32_mount EXIT
2229 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2230 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2231 test_mkdir -p $DIR/$tdir/d2/test_dir
2232 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2233 cleanup_test32_mount
2235 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2238 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2239 test_mkdir -p $DIR/d32e/tmp
2240 TMP_DIR=$DIR/d32e/tmp
2241 ln -s $DIR/d32e $TMP_DIR/symlink11
2242 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2243 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2244 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2246 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2249 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2250 test_mkdir -p $DIR/d32f/tmp
2251 TMP_DIR=$DIR/d32f/tmp
2252 ln -s $DIR/d32f $TMP_DIR/symlink11
2253 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2254 ls $DIR/d32f/tmp/symlink11 || error
2255 ls $DIR/d32f/symlink01 || error
2257 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2260 TMP_DIR=$DIR/$tdir/tmp
2261 test_mkdir -p $DIR/$tdir/tmp
2262 test_mkdir $DIR/${tdir}2
2263 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2264 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2265 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2266 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2267 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2268 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2270 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2273 rm -fr $DIR/$tdir $DIR/${tdir}2
2274 TMP_DIR=$DIR/$tdir/tmp
2275 test_mkdir -p $DIR/$tdir/tmp
2276 test_mkdir $DIR/${tdir}2
2277 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2278 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2279 ls $TMP_DIR/symlink12 || error
2280 ls $DIR/$tdir/symlink02 || error
2282 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2286 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2287 trap cleanup_test32_mount EXIT
2288 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2289 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2290 touch $DIR/$tdir/test_file
2291 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2292 cleanup_test32_mount
2294 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2298 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2299 trap cleanup_test32_mount EXIT
2300 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2301 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2302 touch $DIR/$tdir/test_file
2303 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2304 cleanup_test32_mount
2306 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2311 trap cleanup_test32_mount EXIT
2312 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2313 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2314 test_mkdir -p $DIR/$tdir/d2
2315 touch $DIR/$tdir/d2/test_file || error
2316 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2317 cleanup_test32_mount
2319 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2324 trap cleanup_test32_mount EXIT
2325 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2326 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2327 test_mkdir -p $DIR/$tdir/d2
2328 touch $DIR/$tdir/d2/test_file
2329 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2330 cleanup_test32_mount
2332 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2336 test_mkdir -p $DIR/d32m/tmp
2337 TMP_DIR=$DIR/d32m/tmp
2338 ln -s $DIR $TMP_DIR/symlink11
2339 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2340 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2341 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2343 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2347 test_mkdir -p $DIR/d32n/tmp
2348 TMP_DIR=$DIR/d32n/tmp
2349 ln -s $DIR $TMP_DIR/symlink11
2350 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2351 ls -l $DIR/d32n/tmp/symlink11 || error
2352 ls -l $DIR/d32n/symlink01 || error
2354 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2357 rm -fr $DIR/d32o $DIR/$tfile
2359 test_mkdir -p $DIR/d32o/tmp
2360 TMP_DIR=$DIR/d32o/tmp
2361 ln -s $DIR/$tfile $TMP_DIR/symlink12
2362 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2363 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2364 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2365 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2366 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2368 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2378 test_mkdir -p $DIR/d32p/tmp
2380 TMP_DIR=$DIR/d32p/tmp
2382 ln -s $DIR/$tfile $TMP_DIR/symlink12
2384 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2386 cat $DIR/d32p/tmp/symlink12 || error
2388 cat $DIR/d32p/symlink02 || error
2391 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2393 cleanup_testdir_mount() {
2395 $UMOUNT -d $DIR/$tdir
2399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2400 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2401 trap cleanup_testdir_mount EXIT
2402 test_mkdir -p $DIR/$tdir
2403 touch $DIR/$tdir/under_the_mount
2404 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2405 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2406 cleanup_testdir_mount
2408 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2412 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2413 trap cleanup_testdir_mount EXIT
2414 test_mkdir -p $DIR/$tdir
2415 touch $DIR/$tdir/under_the_mount
2416 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2417 ls $DIR/$tdir | grep -q under_the_mount && error || true
2418 cleanup_testdir_mount
2420 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2425 chmod 444 $DIR/$tfile
2426 chown $RUNAS_ID $DIR/$tfile
2428 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2431 run_test 33aa "write file with mode 444 (should return error) ===="
2435 test_mkdir -p $DIR/d33
2436 chown $RUNAS_ID $DIR/d33
2437 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2438 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2439 error "open RDWR" || true
2441 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2445 test_mkdir -p $DIR/d33
2446 chown $RUNAS_ID $DIR/d33
2447 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2449 run_test 33b "test open file with malformed flags (No panic and return error)"
2452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2458 remote_ost_nodsh && skip "remote OST with nodsh" && return
2461 test_mkdir -p $DIR/d33
2462 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2465 for ostnum in $(seq $OSTCOUNT); do
2466 # test-framework's OST numbering is one-based, while Lustre's
2468 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2469 # Parsing llobdstat's output sucks; we could grep the /proc
2470 # path, but that's likely to not be as portable as using the
2471 # llobdstat utility. So we parse lctl output instead.
2472 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2473 obdfilter/$ostname/stats |
2474 awk '/^write_bytes/ {print $7}' )
2475 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2476 if (( ${write_bytes:-0} > 0 ))
2483 $all_zeros || return 0
2486 echo foo > $DIR/d33/bar
2490 # Total up write_bytes after writing. We'd better find non-zeros.
2491 for ostnum in $(seq $OSTCOUNT); do
2492 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2493 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2494 obdfilter/$ostname/stats |
2495 awk '/^write_bytes/ {print $7}' )
2496 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2497 if (( ${write_bytes:-0} > 0 ))
2506 for ostnum in $(seq $OSTCOUNT); do
2507 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2508 echo "Check that write_bytes is present in obdfilter/*/stats:"
2509 do_facet ost$ostnum lctl get_param -n \
2510 obdfilter/$ostname/stats
2512 error "OST not keeping write_bytes stats (b22312)"
2515 run_test 33c "test llobdstat and write_bytes"
2518 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2521 local remote_dir=$DIR/$tdir/remote_dir
2524 $LFS mkdir -i $MDTIDX $remote_dir ||
2525 error "create remote directory failed"
2527 touch $remote_dir/$tfile
2528 chmod 444 $remote_dir/$tfile
2529 chown $RUNAS_ID $remote_dir/$tfile
2531 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2533 chown $RUNAS_ID $remote_dir
2534 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2535 error "create" || true
2536 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2537 error "open RDWR" || true
2538 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2539 error "create" || true
2541 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2543 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2546 $MCREATE $DIR/f34 || error
2547 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2548 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2549 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2550 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2552 run_test 34a "truncate file that has not been opened ==========="
2555 [ ! -f $DIR/f34 ] && test_34a
2556 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2557 $OPENFILE -f O_RDONLY $DIR/f34
2558 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2559 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2561 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2564 [ ! -f $DIR/f34 ] && test_34a
2565 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2566 $OPENFILE -f O_RDWR $DIR/f34
2567 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2568 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2570 run_test 34c "O_RDWR opening file-with-size works =============="
2573 [ ! -f $DIR/f34 ] && test_34a
2574 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2575 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2578 run_test 34d "write to sparse file ============================="
2582 $MCREATE $DIR/f34e || error
2583 $TRUNCATE $DIR/f34e 1000 || error
2584 $CHECKSTAT -s 1000 $DIR/f34e || error
2585 $OPENFILE -f O_RDWR $DIR/f34e
2586 $CHECKSTAT -s 1000 $DIR/f34e || error
2588 run_test 34e "create objects, some with size and some without =="
2590 test_34f() { # bug 6242, 6243
2591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2594 $MCREATE $DIR/f34f || error
2595 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2596 dd if=$DIR/f34f of=$TMP/f34f
2597 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2598 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2599 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2600 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2601 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2603 run_test 34f "read from a file with no objects until EOF ======="
2606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2607 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2608 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2609 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2610 cancel_lru_locks osc
2611 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2612 error "wrong size after lock cancel"
2614 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2615 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2616 error "expanding truncate failed"
2617 cancel_lru_locks osc
2618 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2619 error "wrong expanded size after lock cancel"
2621 run_test 34g "truncate long file ==============================="
2624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2628 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2629 sync # Flush the cache so that multiop below does not block on cache
2630 # flush when getting the group lock
2631 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2634 # Since just timed wait is not good enough, let's do a sync write
2635 # that way we are sure enough time for a roundtrip + processing
2636 # passed + 2 seconds of extra margin.
2637 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2641 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2642 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2646 local nsz=`stat -c %s $DIR/$tfile`
2647 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2649 run_test 34h "ftruncate file under grouplock should not block"
2652 cp /bin/sh $DIR/f35a
2654 chown $RUNAS_ID $DIR/f35a
2655 $RUNAS $DIR/f35a && error || true
2658 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2662 utime $DIR/f36 || error
2664 run_test 36a "MDS utime check (mknod, utime) ==================="
2668 utime $DIR/f36 || error
2670 run_test 36b "OST utime check (open, utime) ===================="
2675 chown $RUNAS_ID $DIR/d36
2676 $RUNAS utime $DIR/d36/f36 || error
2678 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2681 [ ! -d $DIR/d36 ] && test_36c
2682 echo "" > $DIR/d36/f36
2683 $RUNAS utime $DIR/d36/f36 || error
2685 run_test 36d "non-root OST utime check (open, utime) ==========="
2688 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2689 test_mkdir -p $DIR/$tdir
2690 touch $DIR/$tdir/$tfile
2691 $RUNAS utime $DIR/$tdir/$tfile && \
2692 error "utime worked, expected failure" || true
2694 run_test 36e "utime on non-owned file (should return error) ===="
2698 local LANG_SAVE=$LANG
2699 local LC_LANG_SAVE=$LC_LANG
2700 export LANG=C LC_LANG=C # for date language
2702 DATESTR="Dec 20 2000"
2703 test_mkdir -p $DIR/$tdir
2704 lctl set_param fail_loc=$fl
2706 cp /etc/hosts $DIR/$tdir/$tfile
2707 sync & # write RPC generated with "current" inode timestamp, but delayed
2709 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2710 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2711 cancel_lru_locks osc
2712 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2714 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2715 echo "BEFORE: $LS_BEFORE" && \
2716 echo "AFTER : $LS_AFTER" && \
2717 echo "WANT : $DATESTR" && \
2718 error "$DIR/$tdir/$tfile timestamps changed" || true
2720 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2725 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2726 subr_36fh "0x80000214"
2728 run_test 36f "utime on file racing with OST BRW write =========="
2731 remote_ost_nodsh && skip "remote OST with nodsh" && return
2732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2737 test_mkdir -p $DIR/$tdir
2738 fmd_max_age=$(do_facet ost1 \
2739 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2742 fmd_before=$(do_facet ost1 \
2743 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2744 touch $DIR/$tdir/$tfile
2745 sleep $((fmd_max_age + 12))
2746 fmd_after=$(do_facet ost1 \
2747 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2749 echo "fmd_before: $fmd_before"
2750 echo "fmd_after: $fmd_after"
2751 [ "$fmd_after" -gt "$fmd_before" ] && \
2752 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2753 error "fmd didn't expire after ping" || true
2755 run_test 36g "filter mod data cache expiry ====================="
2758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2759 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2760 subr_36fh "0x80000227"
2762 run_test 36h "utime on file racing with OST BRW write =========="
2764 # test_37 - duplicate with tests 32q 32r
2767 local file=$DIR/$tfile
2769 openfile -f O_DIRECTORY $file
2772 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2773 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2775 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2779 touch $DIR/${tfile}2
2780 # ls -l $DIR/$tfile $DIR/${tfile}2
2781 # ls -lu $DIR/$tfile $DIR/${tfile}2
2782 # ls -lc $DIR/$tfile $DIR/${tfile}2
2784 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2785 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2787 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2789 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2791 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2792 error "O_TRUNC didn't change timestamps"
2795 run_test 39 "mtime changed on create ==========================="
2798 test_mkdir -p $DIR/$tdir
2799 cp -p /etc/passwd $DIR/$tdir/fopen
2800 cp -p /etc/passwd $DIR/$tdir/flink
2801 cp -p /etc/passwd $DIR/$tdir/funlink
2802 cp -p /etc/passwd $DIR/$tdir/frename
2803 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2806 echo "aaaaaa" >> $DIR/$tdir/fopen
2807 echo "aaaaaa" >> $DIR/$tdir/flink
2808 echo "aaaaaa" >> $DIR/$tdir/funlink
2809 echo "aaaaaa" >> $DIR/$tdir/frename
2811 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2812 local link_new=`stat -c %Y $DIR/$tdir/flink`
2813 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2814 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2816 cat $DIR/$tdir/fopen > /dev/null
2817 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2818 rm -f $DIR/$tdir/funlink2
2819 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2821 for (( i=0; i < 2; i++ )) ; do
2822 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2823 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2824 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2825 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2827 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2828 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2829 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2830 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2832 cancel_lru_locks osc
2833 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2836 run_test 39b "mtime change on open, link, unlink, rename ======"
2838 # this should be set to past
2839 TEST_39_MTIME=`date -d "1 year ago" +%s`
2845 local mtime0=`stat -c %Y $DIR1/$tfile`
2847 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2848 local mtime1=`stat -c %Y $DIR1/$tfile`
2849 [ "$mtime1" = $TEST_39_MTIME ] || \
2850 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2853 echo hello >> $DIR1/$tfile
2855 local mtime2=`stat -c %Y $DIR1/$tfile`
2856 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2857 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2859 mv $DIR1/$tfile $DIR1/$tfile-1
2861 for (( i=0; i < 2; i++ )) ; do
2862 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2863 [ "$mtime2" = "$mtime3" ] || \
2864 error "mtime ($mtime2) changed (to $mtime3) on rename"
2866 cancel_lru_locks osc
2867 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2870 run_test 39c "mtime change on rename ==========================="
2874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2877 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2879 for (( i=0; i < 2; i++ )) ; do
2880 local mtime=`stat -c %Y $DIR1/$tfile`
2881 [ $mtime = $TEST_39_MTIME ] || \
2882 error "mtime($mtime) is not set to $TEST_39_MTIME"
2884 cancel_lru_locks osc
2885 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2888 run_test 39d "create, utime, stat =============================="
2892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2894 local mtime1=`stat -c %Y $DIR1/$tfile`
2896 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2898 for (( i=0; i < 2; i++ )) ; do
2899 local mtime2=`stat -c %Y $DIR1/$tfile`
2900 [ $mtime2 = $TEST_39_MTIME ] || \
2901 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2903 cancel_lru_locks osc
2904 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2907 run_test 39e "create, stat, utime, stat ========================"
2911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2913 mtime1=`stat -c %Y $DIR1/$tfile`
2916 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2918 for (( i=0; i < 2; i++ )) ; do
2919 local mtime2=`stat -c %Y $DIR1/$tfile`
2920 [ $mtime2 = $TEST_39_MTIME ] || \
2921 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2923 cancel_lru_locks osc
2924 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2927 run_test 39f "create, stat, sleep, utime, stat ================="
2931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 echo hello >> $DIR1/$tfile
2933 local mtime1=`stat -c %Y $DIR1/$tfile`
2936 chmod o+r $DIR1/$tfile
2938 for (( i=0; i < 2; i++ )) ; do
2939 local mtime2=`stat -c %Y $DIR1/$tfile`
2940 [ "$mtime1" = "$mtime2" ] || \
2941 error "lost mtime: $mtime2, should be $mtime1"
2943 cancel_lru_locks osc
2944 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2947 run_test 39g "write, chmod, stat ==============================="
2951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2956 echo hello >> $DIR1/$tfile
2957 local mtime1=`stat -c %Y $DIR1/$tfile`
2959 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2961 if [ "$d1" != "$d2" ]; then
2962 echo "write and touch not within one second"
2964 for (( i=0; i < 2; i++ )) ; do
2965 local mtime2=`stat -c %Y $DIR1/$tfile`
2966 [ "$mtime2" = $TEST_39_MTIME ] || \
2967 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2969 cancel_lru_locks osc
2970 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2974 run_test 39h "write, utime within one second, stat ============="
2977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2981 echo hello >> $DIR1/$tfile
2982 local mtime1=`stat -c %Y $DIR1/$tfile`
2984 mv $DIR1/$tfile $DIR1/$tfile-1
2986 for (( i=0; i < 2; i++ )) ; do
2987 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2989 [ "$mtime1" = "$mtime2" ] || \
2990 error "lost mtime: $mtime2, should be $mtime1"
2992 cancel_lru_locks osc
2993 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2996 run_test 39i "write, rename, stat =============================="
2999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3000 start_full_debug_logging
3004 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3005 lctl set_param fail_loc=0x80000412
3006 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3007 error "multiop failed"
3009 local mtime1=`stat -c %Y $DIR1/$tfile`
3011 mv $DIR1/$tfile $DIR1/$tfile-1
3013 kill -USR1 $multipid
3014 wait $multipid || error "multiop close failed"
3016 for (( i=0; i < 2; i++ )) ; do
3017 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3018 [ "$mtime1" = "$mtime2" ] ||
3019 error "mtime is lost on close: $mtime2, " \
3022 cancel_lru_locks osc
3023 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3025 lctl set_param fail_loc=0
3026 stop_full_debug_logging
3028 run_test 39j "write, rename, close, stat ======================="
3031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3035 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3037 local mtime1=`stat -c %Y $DIR1/$tfile`
3039 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3041 kill -USR1 $multipid
3042 wait $multipid || error "multiop close failed"
3044 for (( i=0; i < 2; i++ )) ; do
3045 local mtime2=`stat -c %Y $DIR1/$tfile`
3047 [ "$mtime2" = $TEST_39_MTIME ] || \
3048 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3050 cancel_lru_locks osc
3051 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3054 run_test 39k "write, utime, close, stat ========================"
3056 # this should be set to future
3057 TEST_39_ATIME=`date -d "1 year" +%s`
3060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3061 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3062 local atime_diff=$(do_facet $SINGLEMDS \
3063 lctl get_param -n mdd.*MDT0000*.atime_diff)
3067 # test setting directory atime to future
3068 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3069 local atime=$(stat -c %X $DIR/$tdir)
3070 [ "$atime" = $TEST_39_ATIME ] || \
3071 error "atime is not set to future: $atime, $TEST_39_ATIME"
3073 # test setting directory atime from future to now
3074 local d1=$(date +%s)
3076 local d2=$(date +%s)
3078 cancel_lru_locks mdc
3079 atime=$(stat -c %X $DIR/$tdir)
3080 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3081 error "atime is not updated from future: $atime, $d1<atime<$d2"
3083 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3086 # test setting directory atime when now > dir atime + atime_diff
3090 cancel_lru_locks mdc
3091 atime=$(stat -c %X $DIR/$tdir)
3092 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3093 error "atime is not updated : $atime, should be $d2"
3095 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3098 # test not setting directory atime when now < dir atime + atime_diff
3100 cancel_lru_locks mdc
3101 atime=$(stat -c %X $DIR/$tdir)
3102 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3103 error "atime is updated to $atime, should remain $d1<atime<$d2"
3105 do_facet $SINGLEMDS \
3106 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3108 run_test 39l "directory atime update ==========================="
3111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3114 local far_past_mtime=$(date -d "May 29 1953" +%s)
3115 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3117 touch -m -d @$far_past_mtime $DIR1/$tfile
3118 touch -a -d @$far_past_atime $DIR1/$tfile
3120 for (( i=0; i < 2; i++ )) ; do
3121 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3122 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3123 error "atime or mtime set incorrectly"
3125 cancel_lru_locks osc
3126 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3129 run_test 39m "test atime and mtime before 1970"
3131 test_39n() { # LU-3832
3132 local atime_diff=$(do_facet $SINGLEMDS \
3133 lctl get_param -n mdd.*MDT0000*.atime_diff)
3138 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3141 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3142 atime0=$(stat -c %X $DIR/$tfile)
3145 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3146 atime1=$(stat -c %X $DIR/$tfile)
3149 cancel_lru_locks mdc
3150 cancel_lru_locks osc
3151 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3152 atime2=$(stat -c %X $DIR/$tfile)
3154 do_facet $SINGLEMDS \
3155 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3157 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3158 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3160 run_test 39n "check that O_NOATIME is honored"
3163 TESTDIR=$DIR/$tdir/$tfile
3164 [ -e $TESTDIR ] && rm -rf $TESTDIR
3165 test_mkdir -p $TESTDIR
3171 links2=$(stat -c %h .)
3172 [ $(($links1 + 2)) != $links2 ] &&
3173 error "wrong links count $(($links1 + 2)) != $links2"
3175 links3=$(stat -c %h .)
3176 [ $(($links1 + 1)) != $links3 ] &&
3177 error "wrong links count $links1 != $links3"
3180 run_test 39o "directory cached attributes updated after create ========"
3183 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3185 TESTDIR=$DIR/$tdir/$tfile
3186 [ -e $TESTDIR ] && rm -rf $TESTDIR
3191 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3192 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3194 links2=$(stat -c %h .)
3195 [ $(($links1 + 2)) != $links2 ] &&
3196 error "wrong links count $(($links1 + 2)) != $links2"
3198 links3=$(stat -c %h .)
3199 [ $(($links1 + 1)) != $links3 ] &&
3200 error "wrong links count $links1 != $links3"
3203 run_test 39p "remote directory cached attributes updated after create ========"
3207 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3208 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3209 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3210 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3211 error "$tfile is not 4096 bytes in size"
3213 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3217 small_write $DIR/f41 18
3219 run_test 41 "test small file write + fstat ====================="
3221 count_ost_writes() {
3222 lctl get_param -n osc.*.stats |
3223 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3230 BG_DIRTY_RATIO_SAVE=10
3231 MAX_BG_DIRTY_RATIO=25
3235 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3236 # dirty_ratio, dirty_background_ratio
3237 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3238 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3239 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3240 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3242 # if file not here, we are a 2.4 kernel
3243 kill -CONT `pidof kupdated`
3248 # setup the trap first, so someone cannot exit the test at the
3249 # exact wrong time and mess up a machine
3250 trap start_writeback EXIT
3251 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3252 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3253 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3254 sysctl -w vm.dirty_writeback_centisecs=0
3255 sysctl -w vm.dirty_writeback_centisecs=0
3256 # save and increase /proc/sys/vm/dirty_ratio
3257 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3258 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3259 # save and increase /proc/sys/vm/dirty_background_ratio
3260 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3261 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3263 # if file not here, we are a 2.4 kernel
3264 kill -STOP `pidof kupdated`
3268 # ensure that all stripes have some grant before we test client-side cache
3270 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3271 dd if=/dev/zero of=$i bs=4k count=1
3276 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3277 # file truncation, and file removal.
3279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3281 cancel_lru_locks osc
3283 sync; sleep 1; sync # just to be safe
3284 BEFOREWRITES=`count_ost_writes`
3285 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3286 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3287 AFTERWRITES=`count_ost_writes`
3288 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3289 error "$BEFOREWRITES < $AFTERWRITES"
3292 run_test 42a "ensure that we don't flush on close =============="
3295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3297 cancel_lru_locks osc
3300 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3301 BEFOREWRITES=`count_ost_writes`
3302 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3303 AFTERWRITES=`count_ost_writes`
3304 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3305 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3307 BEFOREWRITES=`count_ost_writes`
3308 sync || error "sync: $?"
3309 AFTERWRITES=`count_ost_writes`
3310 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3311 error "$BEFOREWRITES < $AFTERWRITES on sync"
3313 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3317 run_test 42b "test destroy of file with cached dirty data ======"
3319 # if these tests just want to test the effect of truncation,
3320 # they have to be very careful. consider:
3321 # - the first open gets a {0,EOF}PR lock
3322 # - the first write conflicts and gets a {0, count-1}PW
3323 # - the rest of the writes are under {count,EOF}PW
3324 # - the open for truncate tries to match a {0,EOF}PR
3325 # for the filesize and cancels the PWs.
3326 # any number of fixes (don't get {0,EOF} on open, match
3327 # composite locks, do smarter file size management) fix
3328 # this, but for now we want these tests to verify that
3329 # the cancellation with truncate intent works, so we
3330 # start the file with a full-file pw lock to match against
3331 # until the truncate.
3336 cancel_lru_locks osc
3338 # prime the file with 0,EOF PW to match
3342 # now the real test..
3343 dd if=/dev/zero of=$file bs=1024 count=100
3344 BEFOREWRITES=`count_ost_writes`
3345 $TRUNCATE $file $offset
3346 cancel_lru_locks osc
3347 AFTERWRITES=`count_ost_writes`
3352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3354 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3355 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3358 run_test 42c "test partial truncate of file with cached dirty data"
3361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3363 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3364 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3367 run_test 42d "test complete truncate of file with cached dirty data"
3369 test_42e() { # bug22074
3370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3371 local TDIR=$DIR/${tdir}e
3372 local pagesz=$(page_size)
3373 local pages=16 # hardcoded 16 pages, don't change it.
3374 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3375 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3379 test_mkdir -p $DIR/${tdir}e
3380 $SETSTRIPE -c 1 $TDIR
3381 createmany -o $TDIR/f $files
3383 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3385 # we assume that with $OSTCOUNT files, at least one of them will
3386 # be allocated on OST0.
3387 warmup_files=$((OSTCOUNT * max_dirty_mb))
3388 createmany -o $TDIR/w $warmup_files
3390 # write a large amount of data into one file and sync, to get good
3391 # avail_grant number from OST.
3392 for ((i=0; i<$warmup_files; i++)); do
3393 idx=$($GETSTRIPE -i $TDIR/w$i)
3394 [ $idx -ne 0 ] && continue
3395 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3398 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3400 $LCTL get_param $proc_osc0/cur_dirty_bytes
3401 $LCTL get_param $proc_osc0/cur_grant_bytes
3403 # create as much dirty pages as we can while not to trigger the actual
3404 # RPCs directly. but depends on the env, VFS may trigger flush during this
3405 # period, hopefully we are good.
3406 for ((i=0; i<$warmup_files; i++)); do
3407 idx=$($GETSTRIPE -i $TDIR/w$i)
3408 [ $idx -ne 0 ] && continue
3409 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3411 $LCTL get_param $proc_osc0/cur_dirty_bytes
3412 $LCTL get_param $proc_osc0/cur_grant_bytes
3414 # perform the real test
3415 $LCTL set_param $proc_osc0/rpc_stats 0
3416 for ((;i<$files; i++)); do
3417 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3418 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3421 $LCTL get_param $proc_osc0/rpc_stats
3424 local have_ppr=false
3425 $LCTL get_param $proc_osc0/rpc_stats |
3426 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3427 # skip lines until we are at the RPC histogram data
3428 [ "$PPR" == "pages" ] && have_ppr=true && continue
3429 $have_ppr || continue
3431 # we only want the percent stat for < 16 pages
3432 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3434 percent=$((percent + WPCT))
3435 if [ $percent -gt 15 ]; then
3436 error "less than 16-pages write RPCs" \
3443 run_test 42e "verify sub-RPC writes are not done synchronously"
3446 test_mkdir -p $DIR/$tdir
3447 cp -p /bin/ls $DIR/$tdir/$tfile
3448 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3450 # give multiop a chance to open
3453 $DIR/$tdir/$tfile && error || true
3456 run_test 43 "execution of file opened for write should return -ETXTBSY"
3459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3460 test_mkdir -p $DIR/$tdir
3461 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3462 cp -p multiop $DIR/$tdir/multiop
3463 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3466 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3467 kill -USR1 $MULTIOP_PID || return 2
3468 wait $MULTIOP_PID || return 3
3469 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3471 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3475 test_mkdir -p $DIR/$tdir
3476 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3477 cp -p multiop $DIR/$tdir/multiop
3478 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3481 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3482 kill -USR1 $MULTIOP_PID || return 2
3483 wait $MULTIOP_PID || return 3
3484 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3486 run_test 43b "truncate of file being executed should return -ETXTBSY"
3489 local testdir="$DIR/$tdir"
3490 test_mkdir -p $DIR/$tdir
3492 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3493 ( cd $testdir && md5sum -c)
3495 run_test 43c "md5sum of copy into lustre========================"
3498 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3499 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3500 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3502 run_test 44 "zero length read from a sparse stripe ============="
3505 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3507 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3508 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3509 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3511 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3512 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3515 OFFSETS="0 $((stride/2)) $((stride-1))"
3516 for offset in $OFFSETS ; do
3517 for i in `seq 0 $((nstripe-1))`; do
3518 local GLOBALOFFSETS=""
3519 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3520 local myfn=$DIR/d44a-$size
3521 echo "--------writing $myfn at $size"
3522 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3523 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3524 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3525 || error "ll_sparseness_verify $GLOBALOFFSETS"
3527 for j in `seq 0 $((nstripe-1))`; do
3528 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3529 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3530 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3532 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3533 || error "ll_sparseness_verify $GLOBALOFFSETS"
3538 run_test 44a "test sparse pwrite ==============================="
3542 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3548 before=`dirty_osc_total`
3549 echo executing "\"$*\""
3551 after=`dirty_osc_total`
3552 echo before $before, after $after
3555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3557 # Obtain grants from OST if it supports it
3558 echo blah > ${f}_grant
3561 do_dirty_record "echo blah > $f"
3562 [ $before -eq $after ] && error "write wasn't cached"
3563 do_dirty_record "> $f"
3564 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3565 do_dirty_record "echo blah > $f"
3566 [ $before -eq $after ] && error "write wasn't cached"
3567 do_dirty_record "sync"
3568 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3569 do_dirty_record "echo blah > $f"
3570 [ $before -eq $after ] && error "write wasn't cached"
3571 do_dirty_record "cancel_lru_locks osc"
3572 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3575 run_test 45 "osc io page accounting ============================"
3577 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3578 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3579 # objects offset and an assert hit when an rpc was built with 1023's mapped
3580 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3586 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3588 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3589 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3593 run_test 46 "dirtying a previously written page ================"
3595 # test_47 is removed "Device nodes check" is moved to test_28
3597 test_48a() { # bug 2399
3598 check_kernel_version 34 || return 0
3599 test_mkdir -p $DIR/$tdir
3601 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3602 test_mkdir $DIR/$tdir || error "recreate directory failed"
3603 touch foo || error "'touch foo' failed after recreating cwd"
3604 test_mkdir $DIR/$tdir/bar ||
3605 error "'mkdir foo' failed after recreating cwd"
3606 if check_kernel_version 44; then
3607 touch .foo || error "'touch .foo' failed after recreating cwd"
3608 test_mkdir $DIR/$tdir/.bar ||
3609 error "'mkdir .foo' failed after recreating cwd"
3611 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3612 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3613 cd . || error "'cd .' failed after recreating cwd"
3614 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3615 rmdir . && error "'rmdir .' worked after recreating cwd"
3616 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3617 cd .. || error "'cd ..' failed after recreating cwd"
3619 run_test 48a "Access renamed working dir (should return errors)="
3621 test_48b() { # bug 2399
3622 check_kernel_version 34 || return 0
3624 test_mkdir -p $DIR/$tdir
3626 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3627 touch foo && error "'touch foo' worked after removing cwd"
3628 test_mkdir $DIR/$tdir/foo &&
3629 error "'mkdir foo' worked after removing cwd"
3630 if check_kernel_version 44; then
3631 touch .foo && error "'touch .foo' worked after removing cwd"
3632 test_mkdir $DIR/$tdir/.foo &&
3633 error "'mkdir .foo' worked after removing cwd"
3635 ls . > /dev/null && error "'ls .' worked after removing cwd"
3636 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3637 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3638 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3639 rmdir . && error "'rmdir .' worked after removing cwd"
3640 ln -s . foo && error "'ln -s .' worked after removing cwd"
3641 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3643 run_test 48b "Access removed working dir (should return errors)="
3645 test_48c() { # bug 2350
3646 check_kernel_version 36 || return 0
3647 #lctl set_param debug=-1
3650 test_mkdir -p $DIR/$tdir/dir
3652 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3653 $TRACE touch foo && error "touch foo worked after removing cwd"
3654 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3655 if check_kernel_version 44; then
3656 touch .foo && error "touch .foo worked after removing cwd"
3657 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3659 $TRACE ls . && error "'ls .' worked after removing cwd"
3660 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3661 is_patchless || ( $TRACE cd . &&
3662 error "'cd .' worked after removing cwd" )
3663 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3664 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3665 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3666 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3668 run_test 48c "Access removed working subdir (should return errors)"
3670 test_48d() { # bug 2350
3671 check_kernel_version 36 || return 0
3672 #lctl set_param debug=-1
3675 test_mkdir -p $DIR/$tdir/dir
3677 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3678 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3679 $TRACE touch foo && error "'touch foo' worked after removing parent"
3680 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3681 if check_kernel_version 44; then
3682 touch .foo && error "'touch .foo' worked after removing parent"
3684 error "mkdir .foo worked after removing parent"
3686 $TRACE ls . && error "'ls .' worked after removing parent"
3687 $TRACE ls .. && error "'ls ..' worked after removing parent"
3688 is_patchless || ( $TRACE cd . &&
3689 error "'cd .' worked after recreate parent" )
3690 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3691 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3692 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3693 is_patchless || ( $TRACE cd .. &&
3694 error "'cd ..' worked after removing parent" || true )
3696 run_test 48d "Access removed parent subdir (should return errors)"
3698 test_48e() { # bug 4134
3699 check_kernel_version 41 || return 0
3700 #lctl set_param debug=-1
3703 test_mkdir -p $DIR/$tdir/dir
3705 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3706 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3707 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3708 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3709 # On a buggy kernel addition of "touch foo" after cd .. will
3710 # produce kernel oops in lookup_hash_it
3711 touch ../foo && error "'cd ..' worked after recreate parent"
3713 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3715 run_test 48e "Access to recreated parent subdir (should return errors)"
3717 test_49() { # LU-1030
3718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3719 # get ost1 size - lustre-OST0000
3720 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3721 # write 800M at maximum
3722 [ $ost1_size -gt 819200 ] && ost1_size=819200
3724 lfs setstripe -c 1 -i 0 $DIR/$tfile
3725 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3728 # change max_pages_per_rpc while writing the file
3729 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3730 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3731 # loop until dd process exits
3732 while ps ax -opid | grep -wq $dd_pid; do
3733 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3734 sleep $((RANDOM % 5 + 1))
3736 # restore original max_pages_per_rpc
3737 $LCTL set_param $osc1_mppc=$orig_mppc
3738 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3740 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3744 test_mkdir $DIR/$tdir
3746 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3748 run_test 50 "special situations: /proc symlinks ==============="
3750 test_51a() { # was test_51
3751 # bug 1516 - create an empty entry right after ".." then split dir
3752 test_mkdir -p $DIR/$tdir
3753 touch $DIR/$tdir/foo
3754 $MCREATE $DIR/$tdir/bar
3756 createmany -m $DIR/$tdir/longfile 201
3758 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3759 $MCREATE $DIR/$tdir/longfile$FNUM
3764 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3766 run_test 51a "special situations: split htree with empty entry =="
3768 export NUMTEST=70000
3770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3771 local BASE=$DIR/d${base}.${TESTSUITE}
3773 # cleanup the directory
3778 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3779 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3780 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3783 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3784 echo "reduced count to $NUMTEST due to inodes"
3786 # need to check free space for the directories as well
3787 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3788 numfree=$((blkfree / 4))
3789 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3790 echo "reduced count to $NUMTEST due to blocks"
3792 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3793 echo "failed" > $BASE/fnum
3795 run_test 51b "exceed 64k subdirectory nlink limit"
3797 test_51ba() { # LU-993
3798 local BASE=$DIR/d${base}.${TESTSUITE}
3799 # unlink all but 100 subdirectories, then check it still works
3801 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3803 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3804 local DELETE=$((NUMTEST - LEFT))
3806 # continue on to run this test even if 51b didn't finish,
3807 # just to delete the many subdirectories created.
3808 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3810 # for ldiskfs the nlink count should be 1, but this is OSD specific
3811 # and so this is listed for informational purposes only
3812 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3813 unlinkmany -d $BASE/d $DELETE
3816 if [ $RC -ne 0 ]; then
3817 if [ "$NUMPREV" == "failed" ]; then
3818 skip "previous setup failed"
3821 error "unlink of first $DELETE subdirs failed"
3826 echo "nlink between: $(stat -c %h $BASE)"
3827 # trim the first line of ls output
3828 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3829 [ $FOUND -ne $LEFT ] &&
3830 error "can't find subdirs: found only $FOUND/$LEFT"
3832 unlinkmany -d $BASE/d $DELETE $LEFT ||
3833 error "unlink of second $LEFT subdirs failed"
3834 # regardless of whether the backing filesystem tracks nlink accurately
3835 # or not, the nlink count shouldn't be more than "." and ".." here
3836 local AFTER=$(stat -c %h $BASE)
3837 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3838 echo "nlink after: $AFTER"
3840 run_test 51ba "verify nlink for many subdirectory cleanup"
3843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3844 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3845 test_mkdir -p $DIR/$tdir
3846 createmany -o $DIR/$tdir/t- 1000
3847 $GETSTRIPE $DIR/$tdir > $TMP/files
3848 for N in `seq 0 $((OSTCOUNT - 1))`; do
3849 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3850 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3851 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3853 unlinkmany $DIR/$tdir/t- 1000
3856 for N in `seq 1 $((OSTCOUNT - 1))`; do
3857 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3858 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3859 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3860 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3862 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3863 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3864 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3865 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3869 run_test 51d "check object distribution ===================="
3872 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3873 test_mkdir -p $DIR/$tdir
3874 touch $DIR/$tdir/foo
3875 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3876 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3877 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3878 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3879 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3881 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3882 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3883 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3885 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3886 cp -r $DIR/$tdir /tmp/
3887 rm -fr $DIR/$tdir || error "cleanup rm failed"
3889 run_test 52a "append-only flag test (should return errors) ====="
3892 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3893 test_mkdir -p $DIR/$tdir
3894 touch $DIR/$tdir/foo
3895 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3896 cat test > $DIR/$tdir/foo && error "cat test worked"
3897 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3898 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3899 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3901 echo foo >> $DIR/$tdir/foo && error "echo worked"
3902 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3903 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3904 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3905 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3907 chattr -i $DIR/$tdir/foo || error "chattr failed"
3909 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3911 run_test 52b "immutable flag test (should return errors) ======="
3914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3915 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3916 remote_ost_nodsh && skip "remote OST with nodsh" && return
3929 local support_last_seq=true
3931 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
3932 support_last_seq=false
3935 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3937 for value in $(do_facet $SINGLEMDS \
3938 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
3939 param=$(echo ${value[0]} | cut -d "=" -f1)
3940 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3942 if $support_last_seq; then
3943 param_seq=$(echo $param |
3944 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3945 mds_last_seq=$(do_facet $SINGLEMDS \
3946 $LCTL get_param -n $param_seq)
3948 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
3950 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3951 node=$(facet_active_host ost$((ostnum+1)))
3952 param="obdfilter.$ostname.last_id"
3953 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
3954 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
3955 ost_last_id=$ost_last
3957 if $support_last_seq; then
3958 ost_last_id=$(echo $ost_last |
3959 awk -F':' '{print $2}' |
3961 ost_last_seq=$(echo $ost_last |
3962 awk -F':' '{print $1}')
3963 [[ $ost_last_seq = $mds_last_seq ]] || continue
3966 if [[ $ost_last_id != $mds_last ]]; then
3967 error "$ost_last_id != $mds_last"
3974 $found || error "can not match last_seq/last_id for $mdtosc"
3977 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3980 $SOCKETSERVER $DIR/socket ||
3981 error "$SOCKETSERVER $DIR/socket failed: $?"
3982 $SOCKETCLIENT $DIR/socket ||
3983 error "$SOCKETCLIENT $DIR/socket failed: $?"
3984 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
3986 run_test 54a "unix domain socket test =========================="
3992 dd if=/dev/zero of=$f bs=$(page_size) count=1
3994 run_test 54b "char device works in lustre ======================"
3997 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3998 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3999 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4001 for i in $(seq 3 7); do
4002 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4010 loopdev="$DIR/loop54c"
4013 $UMOUNT -d $tdir || rc=$?
4014 losetup -d $loopdev || true
4020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4023 loopdev="$DIR/loop54c"
4026 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4027 mknod $loopdev b 7 $LOOPNUM
4028 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4029 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4030 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4031 trap cleanup_54c EXIT
4032 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4034 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4035 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4037 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4040 run_test 54c "block device works in lustre ====================="
4046 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4048 run_test 54d "fifo device works in lustre ======================"
4051 check_kernel_version 46 || return 0
4054 cp -aL /dev/console $f
4055 echo $string > $f || error "echo $string to $f failed"
4057 run_test 54e "console/tty device works in lustre ======================"
4059 #The test_55 used to be iopen test and it was removed by bz#24037.
4060 #run_test 55 "check iopen_connect_dentry() ======================"
4062 test_56a() { # was test_56
4065 test_mkdir -p $DIR/$tdir/dir
4067 NUMFILESx2=$(($NUMFILES * 2))
4068 for i in `seq 1 $NUMFILES` ; do
4069 touch $DIR/$tdir/file$i
4070 touch $DIR/$tdir/dir/file$i
4073 # test lfs getstripe with --recursive
4074 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
4075 [ $FILENUM -eq $NUMFILESx2 ] ||
4076 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4077 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
4078 [ $FILENUM -eq $NUMFILES ] ||
4079 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4080 echo "$GETSTRIPE --recursive passed."
4082 # test lfs getstripe with file instead of dir
4083 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
4084 [ $FILENUM -eq 1 ] || error \
4085 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4086 echo "$GETSTRIPE file1 passed."
4088 #test lfs getstripe with --verbose
4089 [ `$GETSTRIPE --verbose $DIR/$tdir |
4090 grep -c lmm_magic` -eq $NUMFILES ] ||
4091 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4092 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
4093 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4094 echo "$GETSTRIPE --verbose passed."
4096 #test lfs getstripe with --obd
4097 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4098 grep -q "unknown obduuid" ||
4099 error "$GETSTRIPE --obd wrong_uuid should return error message"
4101 [ "$OSTCOUNT" -lt 2 ] &&
4102 skip_env "skipping other $GETSTRIPE --obd test" && return
4105 OBDUUID=$(ostuuid_from_index $OSTIDX)
4106 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
4107 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
4108 [ $FOUND -eq $FILENUM ] ||
4109 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4110 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4111 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4112 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
4113 error "$GETSTRIPE --obd: should not show file on other obd"
4114 echo "$GETSTRIPE --obd passed"
4116 run_test 56a "check $GETSTRIPE"
4121 local LOCAL_NUMFILES="$1"
4122 local LOCAL_NUMDIRS="$2"
4123 local MKDIR_PARAMS="$3"
4124 local DIR_STRIPE_PARAMS="$4"
4126 if [ ! -d "$TDIR" ] ; then
4127 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4128 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4129 for i in `seq 1 $LOCAL_NUMFILES` ; do
4132 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4133 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4134 for j in `seq 1 $LOCAL_NUMFILES` ; do
4135 touch $TDIR/dir$i/file$j
4141 setup_56_special() {
4145 if [ ! -e "$TDIR/loop1b" ] ; then
4146 for i in `seq 1 $LOCAL_NUMFILES` ; do
4147 mknod $TDIR/loop${i}b b 7 $i
4148 mknod $TDIR/null${i}c c 1 3
4149 ln -s $TDIR/file1 $TDIR/link${i}l
4151 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4152 mknod $TDIR/dir$i/loop${i}b b 7 $i
4153 mknod $TDIR/dir$i/null${i}c c 1 3
4154 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4163 setup_56 $NUMFILES $NUMDIRS
4165 EXPECTED=$(($NUMDIRS + 2))
4166 # test lfs find with -name
4167 for i in $(seq 1 $NUMFILES) ; do
4168 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4169 [ $NUMS -eq $EXPECTED ] ||
4170 error "lfs find -name \"*$i\" $TDIR wrong: "\
4171 "found $NUMS, expected $EXPECTED"
4174 run_test 56g "check lfs find -name ============================="
4180 setup_56 $NUMFILES $NUMDIRS
4182 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4183 # test lfs find with ! -name
4184 for i in $(seq 1 $NUMFILES) ; do
4185 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4186 [ $NUMS -eq $EXPECTED ] ||
4187 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4188 "found $NUMS, expected $EXPECTED"
4191 run_test 56h "check lfs find ! -name ============================="
4195 test_mkdir -p $DIR/$tdir
4196 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4197 CMD="$LFIND -ost $UUID $DIR/$tdir"
4199 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4201 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4205 setup_56_special $NUMFILES $NUMDIRS
4207 EXPECTED=$((NUMDIRS + 1))
4208 CMD="$LFIND -type d $TDIR"
4209 NUMS=$($CMD | wc -l)
4210 [ $NUMS -eq $EXPECTED ] ||
4211 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4213 run_test 56j "check lfs find -type d ============================="
4217 setup_56_special $NUMFILES $NUMDIRS
4219 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4220 CMD="$LFIND -type f $TDIR"
4221 NUMS=$($CMD | wc -l)
4222 [ $NUMS -eq $EXPECTED ] ||
4223 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4225 run_test 56k "check lfs find -type f ============================="
4229 setup_56_special $NUMFILES $NUMDIRS
4231 EXPECTED=$((NUMDIRS + NUMFILES))
4232 CMD="$LFIND -type b $TDIR"
4233 NUMS=$($CMD | wc -l)
4234 [ $NUMS -eq $EXPECTED ] ||
4235 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4237 run_test 56l "check lfs find -type b ============================="
4241 setup_56_special $NUMFILES $NUMDIRS
4243 EXPECTED=$((NUMDIRS + NUMFILES))
4244 CMD="$LFIND -type c $TDIR"
4245 NUMS=$($CMD | wc -l)
4246 [ $NUMS -eq $EXPECTED ] ||
4247 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4249 run_test 56m "check lfs find -type c ============================="
4253 setup_56_special $NUMFILES $NUMDIRS
4255 EXPECTED=$((NUMDIRS + NUMFILES))
4256 CMD="$LFIND -type l $TDIR"
4257 NUMS=$($CMD | wc -l)
4258 [ $NUMS -eq $EXPECTED ] ||
4259 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4261 run_test 56n "check lfs find -type l ============================="
4265 setup_56 $NUMFILES $NUMDIRS
4266 utime $TDIR/file1 > /dev/null || error "utime (1)"
4267 utime $TDIR/file2 > /dev/null || error "utime (2)"
4268 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4269 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4270 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4271 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4274 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4275 [ $NUMS -eq $EXPECTED ] || \
4276 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4279 CMD="$LFIND -mtime 0 $TDIR"
4280 NUMS=$($CMD | wc -l)
4281 [ $NUMS -eq $EXPECTED ] ||
4282 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4284 run_test 56o "check lfs find -mtime for old files =========================="
4287 [ $RUNAS_ID -eq $UID ] &&
4288 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4291 setup_56 $NUMFILES $NUMDIRS
4293 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4295 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4296 NUMS=$($CMD | wc -l)
4297 [ $NUMS -eq $EXPECTED ] || \
4298 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4300 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4301 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4302 NUMS=$($CMD | wc -l)
4303 [ $NUMS -eq $EXPECTED ] || \
4304 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4306 run_test 56p "check lfs find -uid and ! -uid ==============================="
4309 [ $RUNAS_ID -eq $UID ] &&
4310 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4313 setup_56 $NUMFILES $NUMDIRS
4315 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4318 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4319 NUMS=$($CMD | wc -l)
4320 [ $NUMS -eq $EXPECTED ] ||
4321 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4323 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4324 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4325 NUMS=$($CMD | wc -l)
4326 [ $NUMS -eq $EXPECTED ] ||
4327 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4329 run_test 56q "check lfs find -gid and ! -gid ==============================="
4333 setup_56 $NUMFILES $NUMDIRS
4336 CMD="$LFIND -size 0 -type f $TDIR"
4337 NUMS=$($CMD | wc -l)
4338 [ $NUMS -eq $EXPECTED ] ||
4339 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4341 CMD="$LFIND ! -size 0 -type f $TDIR"
4342 NUMS=$($CMD | wc -l)
4343 [ $NUMS -eq $EXPECTED ] ||
4344 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4345 echo "test" > $TDIR/$tfile
4346 echo "test2" > $TDIR/$tfile.2 && sync
4348 CMD="$LFIND -size 5 -type f $TDIR"
4349 NUMS=$($CMD | wc -l)
4350 [ $NUMS -eq $EXPECTED ] ||
4351 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4353 CMD="$LFIND -size +5 -type f $TDIR"
4354 NUMS=$($CMD | wc -l)
4355 [ $NUMS -eq $EXPECTED ] ||
4356 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4358 CMD="$LFIND -size +0 -type f $TDIR"
4359 NUMS=$($CMD | wc -l)
4360 [ $NUMS -eq $EXPECTED ] ||
4361 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4363 CMD="$LFIND ! -size -5 -type f $TDIR"
4364 NUMS=$($CMD | wc -l)
4365 [ $NUMS -eq $EXPECTED ] ||
4366 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4368 CMD="$LFIND -size -5 -type f $TDIR"
4369 NUMS=$($CMD | wc -l)
4370 [ $NUMS -eq $EXPECTED ] ||
4371 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4373 run_test 56r "check lfs find -size works =========================="
4375 test_56s() { # LU-611
4377 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4379 if [ $OSTCOUNT -gt 1 ]; then
4380 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4384 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4388 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4389 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4390 NUMS=$($CMD | wc -l)
4391 [ $NUMS -eq $EXPECTED ] ||
4392 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4394 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4395 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4396 NUMS=$($CMD | wc -l)
4397 [ $NUMS -eq $EXPECTED ] ||
4398 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4401 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4402 NUMS=$($CMD | wc -l)
4403 [ $NUMS -eq $EXPECTED ] ||
4404 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4406 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4407 NUMS=$($CMD | wc -l)
4408 [ $NUMS -eq $EXPECTED ] ||
4409 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4412 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4413 NUMS=$($CMD | wc -l)
4414 [ $NUMS -eq $EXPECTED ] ||
4415 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4417 run_test 56s "check lfs find -stripe-count works"
4419 test_56t() { # LU-611
4421 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4423 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4425 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4426 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4427 NUMS=$($CMD | wc -l)
4428 [ $NUMS -eq $EXPECTED ] ||
4429 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4431 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4432 NUMS=$($CMD | wc -l)
4433 [ $NUMS -eq $EXPECTED ] ||
4434 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4436 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4437 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4438 NUMS=$($CMD | wc -l)
4439 [ $NUMS -eq $EXPECTED ] ||
4440 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4442 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4443 NUMS=$($CMD | wc -l)
4444 [ $NUMS -eq $EXPECTED ] ||
4445 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4448 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4449 NUMS=$($CMD | wc -l)
4450 [ $NUMS -eq $EXPECTED ] ||
4451 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4453 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4454 NUMS=$($CMD | wc -l)
4455 [ $NUMS -eq $EXPECTED ] ||
4456 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4459 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4460 NUMS=$($CMD | wc -l)
4461 [ $NUMS -eq $EXPECTED ] ||
4462 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4464 run_test 56t "check lfs find -stripe-size works"
4466 test_56u() { # LU-611
4468 setup_56 $NUMFILES $NUMDIRS "-i 0"
4470 if [ $OSTCOUNT -gt 1 ]; then
4471 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4477 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4478 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4479 NUMS=$($CMD | wc -l)
4480 [ $NUMS -eq $EXPECTED ] ||
4481 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4484 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4485 NUMS=$($CMD | wc -l)
4486 [ $NUMS -eq $EXPECTED ] ||
4487 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4489 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4490 NUMS=$($CMD | wc -l)
4491 [ $NUMS -eq $EXPECTED ] ||
4492 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4495 # This should produce an error and not return any files
4496 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4497 NUMS=$($CMD 2>/dev/null | wc -l)
4498 [ $NUMS -eq $EXPECTED ] ||
4499 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4501 if [ $OSTCOUNT -gt 1 ]; then
4502 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4503 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4504 NUMS=$($CMD | wc -l)
4505 [ $NUMS -eq $EXPECTED ] ||
4506 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4509 run_test 56u "check lfs find -stripe-index works"
4516 setup_56 $NUMFILES $NUMDIRS
4518 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4519 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4521 for file in $($LFIND -mdt $UUID $TDIR); do
4522 file_mdt_idx=$($GETSTRIPE -M $file)
4523 [ $file_mdt_idx -eq $MDT_IDX ] ||
4524 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4527 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4529 # Get and check the actual stripe count of one file.
4530 # Usage: check_stripe_count <file> <expected_stripe_count>
4531 check_stripe_count() {
4536 [[ -z "$file" || -z "$expected" ]] &&
4537 error "check_stripe_count: invalid argument!"
4539 local cmd="$GETSTRIPE -c $file"
4540 actual=$($cmd) || error "$cmd failed"
4541 actual=${actual%% *}
4543 if [[ $actual -ne $expected ]]; then
4544 [[ $expected -eq -1 ]] ||
4545 error "$cmd wrong: found $actual, expected $expected"
4546 [[ $actual -eq $OSTCOUNT ]] ||
4547 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4555 rm -rf $TDIR || error "remove $TDIR failed"
4556 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4559 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4560 error "$GETSTRIPE -S -d $TDIR failed"
4561 stripe_size=${stripe_size%% *}
4563 local file_size=$((stripe_size * OSTCOUNT))
4564 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4565 local required_space=$((file_num * file_size))
4566 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4567 [[ $free_space -le $((required_space / 1024)) ]] &&
4568 skip_env "need at least $required_space bytes free space," \
4569 "have $free_space kbytes" && return
4572 local dd_count=$((file_size / dd_bs))
4574 # write data into the files
4578 for i in $(seq 1 $NUMFILES); do
4580 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4581 error "write data into $file failed"
4583 for i in $(seq 1 $NUMDIRS); do
4584 for j in $(seq 1 $NUMFILES); do
4585 file=$TDIR/dir$i/file$j
4586 yes | dd bs=$dd_bs count=$dd_count of=$file \
4588 error "write data into $file failed"
4593 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4596 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4598 eval $cmd || error "$cmd failed"
4600 check_stripe_count $TDIR/file1 $expected
4603 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4605 eval $cmd || error "$cmd failed"
4607 for j in $(seq 1 $NUMFILES); do
4608 check_stripe_count $TDIR/dir1/file$j $expected
4611 # lfs_migrate works with lfs find
4612 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4613 $LFS_MIGRATE -y -c $expected"
4615 eval $cmd || error "$cmd failed"
4617 for i in $(seq 2 $NUMFILES); do
4618 check_stripe_count $TDIR/file$i $expected
4620 for i in $(seq 2 $NUMDIRS); do
4621 for j in $(seq 1 $NUMFILES); do
4622 check_stripe_count $TDIR/dir$i/file$j $expected
4626 run_test 56w "check lfs_migrate -c stripe_count works"
4629 check_swap_layouts_support && return 0
4630 [ "$OSTCOUNT" -lt "2" ] &&
4631 skip_env "need 2 OST, skipping test" && return
4633 local dir0=$DIR/$tdir/$testnum
4634 mkdir -p $dir0 || error "creating dir $dir0"
4636 local ref1=/etc/passwd
4637 local file1=$dir0/file1
4639 $SETSTRIPE -c 2 $file1
4641 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4642 stripe=$($GETSTRIPE -c $file1)
4643 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4644 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4649 run_test 56x "lfs migration support"
4652 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4653 skip "No HSM support on MDS of $(get_lustre_version)," \
4654 "need 2.4.53 at least" && return
4657 local dir0=$DIR/$tdir/$testnum
4658 mkdir -p $dir0 || error "creating dir $dir0"
4659 local f1=$dir0/file1
4660 local f2=$dir0/file2
4662 touch $f1 || error "creating std file $f1"
4663 $MULTIOP $f2 H2c || error "creating released file $f2"
4665 # a directory can be raid0, so ask only for files
4666 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4667 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4669 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4670 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4672 # only files can be released, so no need to force file search
4673 res=$($LFIND $dir0 -L released)
4674 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4676 res=$($LFIND $dir0 \! -L released)
4677 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4680 run_test 56y "lfs find -L raid0|released"
4683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4684 # note test will not do anything if MDS is not local
4685 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4686 skip "Only applicable to ldiskfs-based MDTs"
4690 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4691 local MNTDEV="osd*.*MDT*.mntdev"
4692 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4693 [ -z "$DEV" ] && error "can't access $MNTDEV"
4694 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4695 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4696 error "can't access $DEV"
4697 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4698 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4702 run_test 57a "verify MDS filesystem created with large inodes =="
4705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4706 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4707 skip "Only applicable to ldiskfs-based MDTs"
4711 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4716 local FILEN=$dir/f$FILECOUNT
4718 rm -rf $dir || error "removing $dir"
4719 test_mkdir -p $dir || error "creating $dir"
4720 local num=$(get_mds_dir $dir)
4723 echo "mcreating $FILECOUNT files"
4724 createmany -m $dir/f 1 $FILECOUNT || \
4725 error "creating files in $dir"
4727 # verify that files do not have EAs yet
4728 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4729 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4733 df $dir #make sure we get new statfs data
4734 local MDSFREE=$(do_facet $mymds \
4735 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4736 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4737 echo "opening files to create objects/EAs"
4739 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4740 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4743 # verify that files have EAs now
4744 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4745 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4747 sleep 1 #make sure we get new statfs data
4749 local MDSFREE2=$(do_facet $mymds \
4750 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4751 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4752 if [ "$MDCFREE2" -lt "$((MDCFREE - 16))" ]; then
4753 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4754 error "MDC before $MDCFREE != after $MDCFREE2"
4756 echo "MDC before $MDCFREE != after $MDCFREE2"
4757 echo "unable to confirm if MDS has large inodes"
4762 run_test 57b "default LOV EAs are stored inside large inodes ==="
4765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4766 [ -z "$(which wiretest 2>/dev/null)" ] &&
4767 skip_env "could not find wiretest" && return
4770 run_test 58 "verify cross-platform wire constants =============="
4773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4774 echo "touch 130 files"
4775 createmany -o $DIR/f59- 130
4777 unlinkmany $DIR/f59- 130
4779 # wait for commitment of removal
4780 wait_delete_completed
4782 run_test 59 "verify cancellation of llog records async ========="
4784 TEST60_HEAD="test_60 run $RANDOM"
4786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4787 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4788 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4789 skip_env "missing subtest run-llog.sh" && return
4790 log "$TEST60_HEAD - from kernel mode"
4791 do_facet mgs sh run-llog.sh
4793 run_test 60a "llog sanity tests run from kernel module =========="
4795 test_60b() { # bug 6411
4796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4798 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4810 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4812 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4816 echo "create 5000 files"
4817 createmany -o $DIR/f60c- 5000
4818 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4819 lctl set_param fail_loc=0x80000137
4820 unlinkmany $DIR/f60c- 5000
4821 lctl set_param fail_loc=0
4823 run_test 60c "unlink file when mds full"
4826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4827 SAVEPRINTK=$(lctl get_param -n printk)
4829 # verify "lctl mark" is even working"
4830 MESSAGE="test message ID $RANDOM $$"
4831 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4832 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4834 lctl set_param printk=0 || error "set lnet.printk failed"
4835 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4836 MESSAGE="new test message ID $RANDOM $$"
4837 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4838 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4839 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4841 lctl set_param -n printk="$SAVEPRINTK"
4843 run_test 60d "test printk console message masking"
4846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4848 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4849 cancel_lru_locks osc
4850 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4853 run_test 61 "mmap() writes don't make sync hang ================"
4855 # bug 2330 - insufficient obd_match error checking causes LBUG
4857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4860 cancel_lru_locks osc
4861 lctl set_param fail_loc=0x405
4862 cat $f && error "cat succeeded, expect -EIO"
4863 lctl set_param fail_loc=0
4865 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4866 # match every page all of the time.
4867 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4869 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4870 # Though this test is irrelevant anymore, it helped to reveal some
4871 # other grant bugs (LU-4482), let's keep it.
4872 test_63a() { # was test_63
4873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4874 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4875 for i in `seq 10` ; do
4876 dd if=/dev/zero of=$DIR/f63 bs=8k &
4882 rm -f $DIR/f63 || true
4884 run_test 63a "Verify oig_wait interruption does not crash ======="
4886 # bug 2248 - async write errors didn't return to application on sync
4887 # bug 3677 - async write errors left page locked
4889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4891 lctl set_param debug=-1
4893 # ensure we have a grant to do async writes
4894 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4897 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4898 lctl set_param fail_loc=0x80000406
4899 $MULTIOP $DIR/$tfile Owy && \
4900 error "sync didn't return ENOMEM"
4901 sync; sleep 2; sync # do a real sync this time to flush page
4902 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4903 error "locked page left in cache after async error" || true
4906 run_test 63b "async write errors should be returned to fsync ==="
4909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4911 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4913 run_test 64a "verify filter grant calculations (in kernel) ====="
4916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4917 sh oos.sh $MOUNT || error "oos.sh failed: $?"
4919 run_test 64b "check out-of-space detection on client ==========="
4922 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4924 run_test 64c "verify grant shrink ========================------"
4926 # bug 1414 - set/get directories' stripe info
4928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4929 test_mkdir -p $DIR/$tdir
4931 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4933 run_test 65a "directory with no stripe info ===================="
4936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4937 test_mkdir -p $DIR/$tdir
4938 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4941 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4943 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4947 if [ $OSTCOUNT -gt 1 ]; then
4948 test_mkdir -p $DIR/$tdir
4949 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4950 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4952 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4955 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4959 test_mkdir -p $DIR/$tdir
4960 if [ $STRIPECOUNT -le 0 ]; then
4962 elif [ $STRIPECOUNT -gt 2000 ]; then
4963 #LOV_MAX_STRIPE_COUNT is 2000
4964 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4966 sc=$(($STRIPECOUNT - 1))
4968 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4969 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4970 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4971 error "lverify failed"
4973 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4977 test_mkdir -p $DIR/$tdir
4979 $SETSTRIPE $DIR/$tdir || error "setstripe"
4980 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4981 error "no stripe info failed"
4983 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4985 run_test 65e "directory setstripe defaults ======================="
4988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4989 test_mkdir -p $DIR/${tdir}f
4990 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4992 run_test 65f "dir setstripe permission (should return error) ==="
4995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4996 test_mkdir -p $DIR/$tdir
4997 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4999 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5000 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5001 error "delete default stripe failed"
5003 run_test 65g "directory setstripe -d ==========================="
5006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5007 test_mkdir -p $DIR/$tdir
5008 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5010 test_mkdir -p $DIR/$tdir/dd1
5011 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5012 error "stripe info inherit failed"
5014 run_test 65h "directory stripe info inherit ===================="
5016 test_65i() { # bug6367
5017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5018 $SETSTRIPE -S 65536 -c -1 $MOUNT
5020 run_test 65i "set non-default striping on root directory (bug 6367)="
5022 test_65ia() { # bug12836
5023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5024 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5026 run_test 65ia "getstripe on -1 default directory striping"
5028 test_65ib() { # bug12836
5029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5030 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5032 run_test 65ib "getstripe -v on -1 default directory striping"
5034 test_65ic() { # bug12836
5035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5036 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5038 run_test 65ic "new find on -1 default directory striping"
5040 test_65j() { # bug6367
5041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5043 # if we aren't already remounting for each test, do so for this test
5044 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5045 cleanup || error "failed to unmount"
5048 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5050 run_test 65j "set default striping on root directory (bug 6367)="
5052 test_65k() { # bug11679
5053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5054 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
5055 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5057 echo "Check OST status: "
5058 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5059 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5061 for OSC in $MDS_OSCS; do
5062 echo $OSC "is activate"
5063 do_facet $SINGLEMDS lctl --device %$OSC activate
5067 for INACTIVE_OSC in $MDS_OSCS; do
5068 echo "Deactivate: " $INACTIVE_OSC
5069 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5070 for STRIPE_OSC in $MDS_OSCS; do
5071 OST=`osc_to_ost $STRIPE_OSC`
5072 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5073 awk -F: /$OST/'{ print $1 }' | head -n 1`
5075 [ -f $DIR/$tdir/$IDX ] && continue
5076 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5077 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5079 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5082 echo $INACTIVE_OSC "is Activate."
5083 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5086 run_test 65k "validate manual striping works properly with deactivated OSCs"
5088 test_65l() { # bug 12836
5089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5090 test_mkdir -p $DIR/$tdir/test_dir
5091 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5092 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5094 run_test 65l "lfs find on -1 stripe dir ========================"
5096 # bug 2543 - update blocks count on client
5098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5100 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5101 sync; sync_all_data; sync; sync_all_data
5102 cancel_lru_locks osc
5103 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5104 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5106 run_test 66 "update inode blocks count on client ==============="
5111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5113 if [ ! -z "$LLOOP" ]; then
5114 if swapon -s | grep -q $LLOOP; then
5115 swapoff $LLOOP || error "swapoff failed"
5118 $LCTL blockdev_detach $LLOOP || error "detach failed"
5122 if [ ! -z "$LLITELOOPLOAD" ]; then
5130 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5134 swapon -s | awk '($1 == "'$1'") { print $4 }'
5137 # test case for lloop driver, basic function
5139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5140 [ "$UID" != 0 ] && skip_env "must run as root" && return
5141 llite_lloop_enabled || \
5142 { skip_env "llite_lloop module disabled" && return; }
5144 trap cleanup_68 EXIT
5146 if ! module_loaded llite_lloop; then
5147 if load_module llite/llite_lloop; then
5150 skip_env "can't find module llite_lloop"
5155 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5156 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5157 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5159 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5160 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5164 run_test 68a "lloop driver - basic test ========================"
5166 # excercise swapping to lustre by adding a high priority swapfile entry
5167 # and then consuming memory until it is used.
5168 test_68b() { # was test_68
5169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5170 [ "$UID" != 0 ] && skip_env "must run as root" && return
5171 lctl get_param -n devices | grep -q obdfilter && \
5172 skip "local OST" && return
5174 grep -q llite_lloop /proc/modules
5175 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5177 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5178 skip "can't reliably test swap with TCP" && return
5180 MEMTOTAL=`meminfo MemTotal`
5181 NR_BLOCKS=$((MEMTOTAL>>8))
5182 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5184 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5185 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5188 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5190 trap cleanup_68 EXIT
5192 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5194 echo "before: `swapon -s | grep $LLOOP`"
5195 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5196 echo "after: `swapon -s | grep $LLOOP`"
5197 SWAPUSED=`swap_used $LLOOP`
5201 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5203 run_test 68b "support swapping to Lustre ========================"
5205 # bug5265, obdfilter oa2dentry return -ENOENT
5206 # #define OBD_FAIL_OST_ENOENT 0x217
5208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5209 remote_ost_nodsh && skip "remote OST with nodsh" && return
5212 $SETSTRIPE -c 1 -i 0 $f
5214 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5216 do_facet ost1 lctl set_param fail_loc=0x217
5217 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5218 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5220 do_facet ost1 lctl set_param fail_loc=0
5221 $DIRECTIO write $f 0 2 || error "write error"
5223 cancel_lru_locks osc
5224 $DIRECTIO read $f 0 1 || error "read error"
5226 do_facet ost1 lctl set_param fail_loc=0x217
5227 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5229 do_facet ost1 lctl set_param fail_loc=0
5232 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5235 test_mkdir -p $DIR/$tdir
5236 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5238 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5240 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5242 [ "$RUNAS_ID" = "$UID" ] &&
5243 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5245 # Check that testing environment is properly set up. Skip if not
5246 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5247 skip_env "User $RUNAS_ID does not exist - skipping"
5250 # We had better clear the $DIR to get enough space for dd
5253 chmod 777 $DIR/$tfile
5254 chmod ug+s $DIR/$tfile
5255 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5256 error "$RUNAS dd $DIR/$tfile failed"
5257 # See if we are still setuid/sgid
5258 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5259 error "S/gid is not dropped on write"
5260 # Now test that MDS is updated too
5261 cancel_lru_locks mdc
5262 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5263 error "S/gid is not dropped on MDS"
5266 run_test 72a "Test that remove suid works properly (bug5695) ===="
5268 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5271 [ "$RUNAS_ID" = "$UID" ] && \
5272 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5273 [ "$RUNAS_ID" -eq 0 ] && \
5274 skip_env "RUNAS_ID = 0 -- skipping" && return
5276 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5277 # Check that testing environment is properly set up. Skip if not
5278 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5279 skip_env "User $RUNAS_ID does not exist - skipping"
5282 touch $DIR/${tfile}-f{g,u}
5283 test_mkdir $DIR/${tfile}-dg
5284 test_mkdir $DIR/${tfile}-du
5285 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5286 chmod g+s $DIR/${tfile}-{f,d}g
5287 chmod u+s $DIR/${tfile}-{f,d}u
5288 for perm in 777 2777 4777; do
5289 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5290 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5291 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5292 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5296 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5298 # bug 3462 - multiple simultaneous MDC requests
5300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5301 test_mkdir $DIR/d73-1
5302 test_mkdir $DIR/d73-2
5303 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5306 lctl set_param fail_loc=0x80000129
5307 $MULTIOP $DIR/d73-1/f73-2 Oc &
5309 lctl set_param fail_loc=0
5311 $MULTIOP $DIR/d73-2/f73-3 Oc &
5315 wait $pid1 || return 1
5319 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5320 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5321 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5325 run_test 73 "multiple MDC requests (should not deadlock)"
5327 test_74a() { # bug 6149, 6184
5328 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5329 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5331 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5332 # will spin in a tight reconnection loop
5334 lctl set_param fail_loc=0x8000030e
5335 # get any lock that won't be difficult - lookup works.
5337 lctl set_param fail_loc=0
5341 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5343 test_74b() { # bug 13310
5344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5345 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5347 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5348 # will spin in a tight reconnection loop
5349 lctl set_param fail_loc=0x8000030e
5350 # get a "difficult" lock
5352 lctl set_param fail_loc=0
5356 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5360 #define OBD_FAIL_LDLM_NEW_LOCK
5361 lctl set_param fail_loc=0x80000319
5362 touch $DIR/$tfile && error "Touch successful"
5365 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5368 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5371 get_inode_slab_tunables() {
5372 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5375 set_inode_slab_tunables() {
5376 echo "lustre_inode_cache $1" > /proc/slabinfo
5379 test_76() { # Now for bug 20433, added originally in bug 1443
5380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5381 local SLAB_SETTINGS=`get_inode_slab_tunables`
5382 local CPUS=`getconf _NPROCESSORS_ONLN`
5383 # we cannot set limit below 1 which means 1 inode in each
5384 # per-cpu cache is still allowed
5385 set_inode_slab_tunables "1 1 0"
5386 cancel_lru_locks osc
5387 BEFORE_INODES=`num_inodes`
5388 echo "before inodes: $BEFORE_INODES"
5390 [ "$SLOW" = "no" ] && COUNT=100
5391 for i in `seq $COUNT`; do
5395 cancel_lru_locks osc
5396 AFTER_INODES=`num_inodes`
5397 echo "after inodes: $AFTER_INODES"
5399 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5401 AFTER_INODES=`num_inodes`
5403 echo "wait $wait seconds inodes: $AFTER_INODES"
5404 if [ $wait -gt 30 ]; then
5405 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5408 set_inode_slab_tunables "$SLAB_SETTINGS"
5410 run_test 76 "confirm clients recycle inodes properly ===="
5416 # Note: in sptlrpc modes which enable its own bulk checksum, the
5417 # original crc32_le bulk checksum will be automatically disabled,
5418 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5419 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5420 # In this case set_checksums() will not be no-op, because sptlrpc
5421 # bulk checksum will be enabled all through the test.
5423 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5424 lctl set_param -n osc.*.checksums $1
5428 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5429 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5430 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5431 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5434 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5435 log "set checksum type to $1"
5438 F77_TMP=$TMP/f77-temp
5441 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5442 error "error writing to $F77_TMP"
5445 test_77a() { # bug 10889
5446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5447 $GSS && skip "could not run with gss" && return
5448 [ ! -f $F77_TMP ] && setup_f77
5450 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5454 run_test 77a "normal checksum read/write operation"
5456 test_77b() { # bug 10889
5457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5458 $GSS && skip "could not run with gss" && return
5459 [ ! -f $F77_TMP ] && setup_f77
5460 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5461 $LCTL set_param fail_loc=0x80000409
5464 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5465 error "dd error: $?"
5466 $LCTL set_param fail_loc=0
5468 for algo in $CKSUM_TYPES; do
5469 cancel_lru_locks osc
5470 set_checksum_type $algo
5471 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5472 $LCTL set_param fail_loc=0x80000408
5473 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5474 $LCTL set_param fail_loc=0
5477 set_checksum_type $ORIG_CSUM_TYPE
5480 run_test 77b "checksum error on client write, read"
5482 test_77d() { # bug 10889
5483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5484 $GSS && skip "could not run with gss" && return
5485 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5486 $LCTL set_param fail_loc=0x80000409
5488 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5489 error "direct write: rc=$?"
5490 $LCTL set_param fail_loc=0
5493 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5494 $LCTL set_param fail_loc=0x80000408
5496 cancel_lru_locks osc
5497 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5498 error "direct read: rc=$?"
5499 $LCTL set_param fail_loc=0
5502 run_test 77d "checksum error on OST direct write, read"
5504 test_77f() { # bug 10889
5505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5506 $GSS && skip "could not run with gss" && return
5508 for algo in $CKSUM_TYPES; do
5509 cancel_lru_locks osc
5510 set_checksum_type $algo
5511 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5512 $LCTL set_param fail_loc=0x409
5513 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5514 error "direct write succeeded"
5515 $LCTL set_param fail_loc=0
5517 set_checksum_type $ORIG_CSUM_TYPE
5520 run_test 77f "repeat checksum error on write (expect error)"
5522 test_77g() { # bug 10889
5523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5524 $GSS && skip "could not run with gss" && return
5525 remote_ost_nodsh && skip "remote OST with nodsh" && return
5527 [ ! -f $F77_TMP ] && setup_f77
5529 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5530 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5531 do_facet ost1 lctl set_param fail_loc=0x8000021a
5533 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5534 error "write error: rc=$?"
5535 do_facet ost1 lctl set_param fail_loc=0
5538 cancel_lru_locks osc
5539 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5540 do_facet ost1 lctl set_param fail_loc=0x8000021b
5542 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5543 do_facet ost1 lctl set_param fail_loc=0
5546 run_test 77g "checksum error on OST write, read"
5548 test_77i() { # bug 13805
5549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5550 $GSS && skip "could not run with gss" && return
5551 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5552 lctl set_param fail_loc=0x40b
5553 remount_client $MOUNT
5554 lctl set_param fail_loc=0
5555 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5556 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5557 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5558 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5560 remount_client $MOUNT
5562 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5564 test_77j() { # bug 13805
5565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5566 $GSS && skip "could not run with gss" && return
5567 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5568 lctl set_param fail_loc=0x40c
5569 remount_client $MOUNT
5570 lctl set_param fail_loc=0
5571 sleep 2 # wait async osc connect to finish
5572 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5573 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5574 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5575 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5577 remount_client $MOUNT
5579 run_test 77j "client only supporting ADLER32"
5581 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5585 test_78() { # bug 10901
5586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5587 remote_ost || { skip_env "local OST" && return; }
5590 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5591 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5592 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5593 echo "MemTotal: $MEMTOTAL"
5594 # reserve 256MB of memory for the kernel and other running processes,
5595 # and then take 1/2 of the remaining memory for the read/write buffers.
5596 if [ $MEMTOTAL -gt 512 ] ;then
5597 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5599 # for those poor memory-starved high-end clusters...
5600 MEMTOTAL=$((MEMTOTAL / 2))
5602 echo "Mem to use for directio: $MEMTOTAL"
5603 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5604 [ $F78SIZE -gt 512 ] && F78SIZE=512
5605 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5606 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5607 echo "Smallest OST: $SMALLESTOST"
5608 [ $SMALLESTOST -lt 10240 ] && \
5609 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5611 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5612 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5614 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5615 echo "File size: $F78SIZE"
5616 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5617 for i in `seq 1 $NSEQ`
5619 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5620 echo directIO rdwr round $i of $NSEQ
5621 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5626 run_test 78 "handle large O_DIRECT writes correctly ============"
5628 test_79() { # bug 12743
5629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5630 wait_delete_completed
5632 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5633 BKFREE=$(calc_osc_kbytes kbytesfree)
5634 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5636 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5637 DFTOTAL=`echo $STRING | cut -d, -f1`
5638 DFUSED=`echo $STRING | cut -d, -f2`
5639 DFAVAIL=`echo $STRING | cut -d, -f3`
5640 DFFREE=$(($DFTOTAL - $DFUSED))
5642 ALLOWANCE=$((64 * $OSTCOUNT))
5644 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5645 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5646 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5648 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5649 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5650 error "df free($DFFREE) mismatch OST free($BKFREE)"
5652 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5653 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5654 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5657 run_test 79 "df report consistency check ======================="
5659 test_80() { # bug 10718
5660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5661 # relax strong synchronous semantics for slow backends like ZFS
5662 local soc="obdfilter.*.sync_on_lock_cancel"
5663 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5665 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5666 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5667 facet_active_host $host; done | sort -u)
5668 do_nodes $hosts lctl set_param $soc=never
5671 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5673 local BEFORE=`date +%s`
5674 cancel_lru_locks osc
5675 local AFTER=`date +%s`
5676 local DIFF=$((AFTER-BEFORE))
5677 if [ $DIFF -gt 1 ] ; then
5678 error "elapsed for 1M@1T = $DIFF"
5681 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5685 run_test 80 "Page eviction is equally fast at high offsets too ===="
5687 test_81a() { # LU-456
5688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5689 remote_ost_nodsh && skip "remote OST with nodsh" && return
5690 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5691 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5692 do_facet ost1 lctl set_param fail_loc=0x80000228
5694 # write should trigger a retry and success
5695 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5696 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5698 if [ $RC -ne 0 ] ; then
5699 error "write should success, but failed for $RC"
5702 run_test 81a "OST should retry write when get -ENOSPC ==============="
5704 test_81b() { # LU-456
5705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5706 remote_ost_nodsh && skip "remote OST with nodsh" && return
5707 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5708 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5709 do_facet ost1 lctl set_param fail_loc=0x228
5711 # write should retry several times and return -ENOSPC finally
5712 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5713 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5716 if [ $RC -ne $ENOSPC ] ; then
5717 error "dd should fail for -ENOSPC, but succeed."
5720 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5722 test_82() { # LU-1031
5723 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5727 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5729 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5731 kill -USR1 $MULTIPID2
5733 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5734 error "First grouplock does not block second one"
5736 echo "Second grouplock blocks first one"
5738 kill -USR1 $MULTIPID1
5742 run_test 82 "Basic grouplock test ==============================="
5745 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5747 test_mkdir -p $DIR/d99cvsroot
5748 chown $RUNAS_ID $DIR/d99cvsroot
5749 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5752 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5755 run_test 99a "cvs init ========================================="
5758 [ -z "$(which cvs 2>/dev/null)" ] &&
5759 skip_env "could not find cvs" && return
5760 [ ! -d $DIR/d99cvsroot ] && test_99a
5762 # some versions of cvs import exit(1) when asked to import links or
5763 # files they can't read. ignore those files.
5764 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5765 ! -perm +4 -printf '-I %f\n')
5766 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5767 d99reposname vtag rtag
5769 run_test 99b "cvs import ======================================="
5772 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5773 [ ! -d $DIR/d99cvsroot ] && test_99b
5775 test_mkdir -p $DIR/d99reposname
5776 chown $RUNAS_ID $DIR/d99reposname
5777 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5779 run_test 99c "cvs checkout ====================================="
5782 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5783 [ ! -d $DIR/d99cvsroot ] && test_99c
5784 cd $DIR/d99reposname
5786 $RUNAS cvs add -m 'addmsg' foo99
5788 run_test 99d "cvs add =========================================="
5791 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5792 [ ! -d $DIR/d99cvsroot ] && test_99c
5793 cd $DIR/d99reposname
5796 run_test 99e "cvs update ======================================="
5799 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5800 [ ! -d $DIR/d99cvsroot ] && test_99d
5801 cd $DIR/d99reposname
5802 $RUNAS cvs commit -m 'nomsg' foo99
5803 rm -fr $DIR/d99cvsroot
5805 run_test 99f "cvs commit ======================================="
5808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5809 [ "$NETTYPE" = tcp ] || \
5810 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5813 remote_ost_nodsh && skip "remote OST with nodsh" && return
5814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5816 { skip "useless for local single node setup" && return; }
5818 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5819 [ "$PROT" != "tcp" ] && continue
5820 RPORT=$(echo $REMOTE | cut -d: -f2)
5821 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5824 LPORT=`echo $LOCAL | cut -d: -f2`
5825 if [ $LPORT -ge 1024 ]; then
5826 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5828 error_exit "local: $LPORT > 1024, remote: $RPORT"
5831 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5833 run_test 100 "check local port using privileged port ==========="
5835 function get_named_value()
5844 echo $line | sed "s/^$tag[ ]*//"
5851 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5852 awk '/^max_cached_mb/ { print $2 }')
5855 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5861 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5865 local cache_limit=32
5867 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5868 trap cleanup_101a EXIT
5869 $LCTL set_param -n llite.*.read_ahead_stats 0
5870 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5873 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5875 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5876 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5879 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5880 get_named_value 'read but discarded' | cut -d" " -f1`; do
5881 discard=$(($discard + $s))
5885 if [ $(($discard * 10)) -gt $nreads ] ;then
5886 $LCTL get_param osc.*-osc*.rpc_stats
5887 $LCTL get_param llite.*.read_ahead_stats
5888 error "too many ($discard) discarded pages"
5890 rm -f $DIR/$tfile || true
5892 run_test 101a "check read-ahead for random reads ================"
5895 test_mkdir -p $DIR/$tdir
5897 STRIPE_COUNT=$OSTCOUNT
5900 local list=$(comma_list $(osts_nodes))
5901 set_osd_param $list '' read_cache_enable 0
5902 set_osd_param $list '' writethrough_cache_enable 0
5904 trap cleanup_test101bc EXIT
5905 # prepare the read-ahead file
5906 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5908 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5911 cleanup_test101bc() {
5916 local list=$(comma_list $(osts_nodes))
5917 set_osd_param $list '' read_cache_enable 1
5918 set_osd_param $list '' writethrough_cache_enable 1
5922 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5927 local STRIPE_SIZE=1048576
5928 local RA_INC=1048576
5929 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5930 local FILE_LENGTH=$((64*100))
5931 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5932 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5933 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5934 get_named_value 'read but discarded' | \
5935 cut -d" " -f1 | calc_total`
5936 if [ $DISCARD -gt $discard_limit ]; then
5937 $LCTL get_param llite.*.read_ahead_stats
5938 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5940 echo "Read-ahead success for size ${READ_SIZE}"
5945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5946 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5947 local STRIPE_SIZE=1048576
5948 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5949 local FILE_LENGTH=$((STRIPE_SIZE*100))
5950 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5951 # prepare the read-ahead file
5953 cancel_lru_locks osc
5954 for BIDX in 2 4 8 16 32 64 128 256
5956 local BSIZE=$((BIDX*4096))
5957 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5958 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5959 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5960 $LCTL set_param -n llite.*.read_ahead_stats 0
5961 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5962 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5963 cancel_lru_locks osc
5969 run_test 101b "check stride-io mode read-ahead ================="
5972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5973 local STRIPE_SIZE=1048576
5974 local FILE_LENGTH=$((STRIPE_SIZE*100))
5980 cancel_lru_locks osc
5981 $LCTL set_param osc.*.rpc_stats 0
5982 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5983 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
5984 local stats=$($LCTL get_param -n $osc_rpc_stats)
5985 local lines=$(echo "$stats" | awk 'END {print NR;}')
5988 if [ $lines -le 20 ]; then
5991 for size in 1 2 4 8; do
5992 local rpc=$(echo "$stats" |
5993 awk '($1 == "'$size':") {print $2; exit; }')
5995 error "Small $((size*4))k read IO $rpc !"
5997 echo "$osc_rpc_stats check passed!"
6002 run_test 101c "check stripe_size aligned read-ahead ================="
6005 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6006 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6011 local file=$DIR/$tfile
6012 local sz_MB=${FILESIZE_101d:-500}
6013 local ra_MB=${READAHEAD_MB:-40}
6015 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6016 [ $free_MB -lt $sz_MB ] &&
6017 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6019 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6020 $SETSTRIPE -c -1 $file || error "setstripe failed"
6022 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6023 echo Cancel LRU locks on lustre client to flush the client cache
6024 cancel_lru_locks osc
6026 echo Disable read-ahead
6027 local old_READAHEAD=$(set_read_ahead 0)
6029 echo Reading the test file $file with read-ahead disabled
6030 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6032 echo Cancel LRU locks on lustre client to flush the client cache
6033 cancel_lru_locks osc
6034 echo Enable read-ahead with ${ra_MB}MB
6035 set_read_ahead $ra_MB
6037 echo Reading the test file $file with read-ahead enabled
6038 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6040 echo "read-ahead disabled time read $raOFF"
6041 echo "read-ahead enabled time read $raON"
6043 set_read_ahead $old_READAHEAD
6045 wait_delete_completed
6047 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6048 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6050 run_test 101d "file read with and without read-ahead enabled"
6053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6054 local file=$DIR/$tfile
6055 local size_KB=500 #KB
6059 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6060 local need_KB=$((count * size_KB))
6061 [ $free_KB -le $need_KB ] &&
6062 skip_env "Need free space $need_KB, have $free_KB" && return
6064 echo "Creating $count ${size_KB}K test files"
6065 for ((i = 0; i < $count; i++)); do
6066 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6069 echo "Cancel LRU locks on lustre client to flush the client cache"
6070 cancel_lru_locks osc
6072 echo "Reset readahead stats"
6073 $LCTL set_param -n llite.*.read_ahead_stats 0
6075 for ((i = 0; i < $count; i++)); do
6076 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6079 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6080 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6082 for ((i = 0; i < $count; i++)); do
6083 rm -rf $file.$i 2>/dev/null
6086 #10000 means 20% reads are missing in readahead
6087 [ $miss -lt 10000 ] || error "misses too much for small reads"
6089 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6091 cleanup_test101f() {
6093 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6094 rm -rf $DIR/$tfile 2>/dev/null
6098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6099 local file=$DIR/$tfile
6102 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6103 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6104 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6105 trap cleanup_test101f EXIT
6107 echo Cancel LRU locks on lustre client to flush the client cache
6108 cancel_lru_locks osc
6110 echo Reset readahead stats
6111 $LCTL set_param -n llite.*.read_ahead_stats 0
6112 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6113 # readahead should read in 2M file on second read, so only miss
6115 echo Random 4K reads on 2M file for 1000 times
6116 $READS -f $file -s 2097152 -b 4096 -n $nreads
6118 echo checking missing pages
6119 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6120 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6122 [ $miss -lt 3 ] || error "misses too much pages!"
6125 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6128 test_mkdir -p $DIR/$tdir
6129 chown $RUNAS_ID $DIR/$tdir
6132 STRIPE_COUNT=$OSTCOUNT
6133 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
6135 trap cleanup_test102 EXIT
6137 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6139 for num in 1 2 3 4; do
6140 for count in $(seq 1 $STRIPE_COUNT); do
6141 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6142 local size=`expr $STRIPE_SIZE \* $num`
6143 local file=file"$num-$idx-$count"
6144 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6150 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6156 rm -rf $DIR/d0.sanity/d102
6160 local testfile=$DIR/xattr_testfile
6164 [ "$UID" != 0 ] && skip_env "must run as root" && return
6165 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6166 skip_env "must have user_xattr" && return
6168 [ -z "$(which setfattr 2>/dev/null)" ] &&
6169 skip_env "could not find setfattr" && return
6171 echo "set/get xattr..."
6172 setfattr -n trusted.name1 -v value1 $testfile ||
6173 error "setfattr -n trusted.name1=value1 $testfile failed"
6174 getfattr -n trusted.name1 $testfile 2> /dev/null |
6175 grep "trusted.name1=.value1" ||
6176 error "$testfile missing trusted.name1=value1"
6178 setfattr -n user.author1 -v author1 $testfile ||
6179 error "setfattr -n user.author1=author1 $testfile failed"
6180 getfattr -n user.author1 $testfile 2> /dev/null |
6181 grep "user.author1=.author1" ||
6182 error "$testfile missing trusted.author1=author1"
6185 setfattr -n trusted.name2 -v value2 $testfile ||
6186 error "$testfile unable to set trusted.name2"
6187 setfattr -n trusted.name3 -v value3 $testfile ||
6188 error "$testfile unable to set trusted.name3"
6189 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6190 grep "trusted.name" | wc -l) -eq 3 ] ||
6191 error "$testfile missing 3 trusted.name xattrs"
6193 setfattr -n user.author2 -v author2 $testfile ||
6194 error "$testfile unable to set user.author2"
6195 setfattr -n user.author3 -v author3 $testfile ||
6196 error "$testfile unable to set user.author3"
6197 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6198 grep "user.author" | wc -l) -eq 3 ] ||
6199 error "$testfile missing 3 user.author xattrs"
6201 echo "remove xattr..."
6202 setfattr -x trusted.name1 $testfile ||
6203 error "$testfile error deleting trusted.name1"
6204 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6205 error "$testfile did not delete trusted.name1 xattr"
6207 setfattr -x user.author1 $testfile ||
6208 error "$testfile error deleting user.author1"
6209 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6210 error "$testfile did not delete trusted.name1 xattr"
6212 # b10667: setting lustre special xattr be silently discarded
6213 echo "set lustre special xattr ..."
6214 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6215 error "$testfile allowed setting trusted.lov"
6217 run_test 102a "user xattr test =================================="
6220 # b10930: get/set/list trusted.lov xattr
6221 echo "get/set/list trusted.lov xattr ..."
6222 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6223 local testfile=$DIR/$tfile
6224 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6225 error "setstripe failed"
6226 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6227 error "getstripe failed"
6228 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6229 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6231 local testfile2=${testfile}2
6232 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6233 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6236 setfattr -n trusted.lov -v $value $testfile2
6237 local stripe_size=$($GETSTRIPE -S $testfile2)
6238 local stripe_count=$($GETSTRIPE -c $testfile2)
6239 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6240 [ $stripe_count -eq $STRIPECOUNT ] ||
6241 error "stripe count $stripe_count != $STRIPECOUNT"
6244 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6247 # b10930: get/set/list lustre.lov xattr
6248 echo "get/set/list lustre.lov xattr ..."
6249 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6250 test_mkdir -p $DIR/$tdir
6251 chown $RUNAS_ID $DIR/$tdir
6252 local testfile=$DIR/$tdir/$tfile
6253 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6254 error "setstripe failed"
6255 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6256 error "getstripe failed"
6257 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6258 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6260 local testfile2=${testfile}2
6261 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6262 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6264 $RUNAS $MCREATE $testfile2
6265 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6266 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6267 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6268 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6269 [ $stripe_count -eq $STRIPECOUNT ] ||
6270 error "stripe count $stripe_count != $STRIPECOUNT"
6272 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6274 compare_stripe_info1() {
6275 local stripe_index_all_zero=true
6277 for num in 1 2 3 4; do
6278 for count in $(seq 1 $STRIPE_COUNT); do
6279 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6280 local size=$((STRIPE_SIZE * num))
6281 local file=file"$num-$offset-$count"
6282 stripe_size=$(lfs getstripe -S $PWD/$file)
6283 [ $stripe_size -ne $size ] &&
6284 error "$file: size $stripe_size != $size"
6285 stripe_count=$(lfs getstripe -c $PWD/$file)
6286 # allow fewer stripes to be created, ORI-601
6287 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6288 error "$file: count $stripe_count != $count"
6289 stripe_index=$(lfs getstripe -i $PWD/$file)
6290 [ $stripe_index -ne 0 ] &&
6291 stripe_index_all_zero=false
6295 $stripe_index_all_zero &&
6296 error "all files are being extracted starting from OST index 0"
6301 [ -n "$(which tar 2>/dev/null)" ] &&
6302 strings $(which tar) | grep -q "lustre" && echo tar
6306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6307 # b10930: tar test for trusted.lov xattr
6308 TAR=$(find_lustre_tar)
6309 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6310 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6312 test_mkdir -p $DIR/d102d
6313 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6315 compare_stripe_info1
6317 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6321 # b10930: tar test for trusted.lov xattr
6322 TAR=$(find_lustre_tar)
6323 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6324 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6326 test_mkdir -p $DIR/d102f
6328 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6330 compare_stripe_info1
6332 run_test 102f "tar copy files, not keep osts ==========="
6335 local xsize=${1:-1024} # in bytes
6336 local file=$DIR/$tfile
6338 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6339 skip "must have user_xattr" && return 0
6340 [ -z "$(which setfattr 2>/dev/null)" ] &&
6341 skip_env "could not find setfattr" && return 0
6342 [ -z "$(which getfattr 2>/dev/null)" ] &&
6343 skip_env "could not find getfattr" && return 0
6347 local value="$(generate_string $xsize)"
6349 local xbig=trusted.big
6350 log "save $xbig on $file"
6351 setfattr -n $xbig -v $value $file ||
6352 error "saving $xbig on $file failed"
6354 local orig=$(get_xattr_value $xbig $file)
6355 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6357 local xsml=trusted.sml
6358 log "save $xsml on $file"
6359 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6361 local new=$(get_xattr_value $xbig $file)
6362 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6364 log "grow $xsml on $file"
6365 setfattr -n $xsml -v "$value" $file ||
6366 error "growing $xsml on $file failed"
6368 new=$(get_xattr_value $xbig $file)
6369 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6370 log "$xbig still valid after growing $xsml"
6375 test_102h() { # bug 15777
6378 run_test 102h "grow xattr from inside inode to external block"
6381 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6382 grow_xattr $(max_xattr_size)
6384 run_test 102ha "grow xattr from inside inode to external inode"
6386 test_102i() { # bug 17038
6388 ln -s $DIR/$tfile $DIR/${tfile}link
6389 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6390 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"
6391 rm -f $DIR/$tfile $DIR/${tfile}link
6393 run_test 102i "lgetxattr test on symbolic link ============"
6396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6397 TAR=$(find_lustre_tar)
6398 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6399 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6400 setup_test102 "$RUNAS"
6401 test_mkdir -p $DIR/d102j
6402 chown $RUNAS_ID $DIR/d102j
6403 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6405 compare_stripe_info1 "$RUNAS"
6407 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6411 # b22187 just check that does not crash for regular file.
6412 setfattr -n trusted.lov $DIR/$tfile
6413 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6414 local test_kdir=$DIR/d102k
6415 test_mkdir $test_kdir
6416 local default_size=`$GETSTRIPE -S $test_kdir`
6417 local default_count=`$GETSTRIPE -c $test_kdir`
6418 local default_offset=`$GETSTRIPE -i $test_kdir`
6419 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6420 error 'dir setstripe failed'
6421 setfattr -n trusted.lov $test_kdir
6422 local stripe_size=`$GETSTRIPE -S $test_kdir`
6423 local stripe_count=`$GETSTRIPE -c $test_kdir`
6424 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6425 [ $stripe_size -eq $default_size ] ||
6426 error "stripe size $stripe_size != $default_size"
6427 [ $stripe_count -eq $default_count ] ||
6428 error "stripe count $stripe_count != $default_count"
6429 [ $stripe_offset -eq $default_offset ] ||
6430 error "stripe offset $stripe_offset != $default_offset"
6431 rm -rf $DIR/$tfile $test_kdir
6433 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6436 # LU-532 trusted. xattr is invisible to non-root
6437 local testfile=$DIR/$tfile
6441 echo "listxattr as user..."
6442 chown $RUNAS_ID $testfile
6443 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6444 grep -q "trusted" &&
6445 error "$testfile trusted xattrs are user visible"
6449 run_test 102l "listxattr size test =================================="
6451 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6452 local path=$DIR/$tfile
6455 listxattr_size_check $path || error "listattr_size_check $path failed"
6457 run_test 102m "Ensure listxattr fails on small bufffer ========"
6461 getxattr() { # getxattr path name
6462 # Return the base64 encoding of the value of xattr name on path.
6466 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6468 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6470 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6472 getfattr --absolute-names --encoding=base64 --name=$name $path |
6473 awk -F= -v name=$name '$1 == name {
6474 print substr($0, index($0, "=") + 1);
6478 test_102n() { # LU-4101 mdt: protect internal xattrs
6479 local file0=$DIR/$tfile.0
6480 local file1=$DIR/$tfile.1
6481 local xattr0=$TMP/$tfile.0
6482 local xattr1=$TMP/$tfile.1
6486 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6488 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6492 rm -rf $file0 $file1 $xattr0 $xattr1
6495 # Get 'before' xattrs of $file1.
6496 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6498 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6499 # Try to copy xattr from $file0 to $file1.
6500 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6502 setfattr --name=trusted.$name --value="$value" $file1 ||
6503 error "setxattr 'trusted.$name' failed"
6505 # Try to set a garbage xattr.
6506 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6508 setfattr --name=trusted.$name --value="$value" $file1 ||
6509 error "setxattr 'trusted.$name' failed"
6511 # Try to remove the xattr from $file1. We don't care if this
6512 # appears to succeed or fail, we just don't want there to be
6513 # any changes or crashes.
6514 setfattr --remove=$trusted.$name $file1 2> /dev/null
6517 # Get 'after' xattrs of file1.
6518 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6520 if ! diff $xattr0 $xattr1; then
6521 error "before and after xattrs of '$file1' differ"
6524 rm -rf $file0 $file1 $xattr0 $xattr1
6528 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6532 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6537 [ "$UID" != 0 ] && skip_env "must run as root" && return
6538 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6539 skip "must have acl enabled" && return
6540 [ -z "$(which setfacl 2>/dev/null)" ] &&
6541 skip_env "could not find setfacl" && return
6542 $GSS && skip "could not run under gss" && return
6544 declare -a identity_old
6546 for num in $(seq $MDSCOUNT); do
6547 switch_identity $num true || identity_old[$num]=$?
6554 echo "performing cp ..."
6555 run_acl_subtest cp || error "run_acl_subtest cp failed"
6556 echo "performing getfacl-noacl..."
6557 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6558 echo "performing misc..."
6559 run_acl_subtest misc || error "misc test failed"
6560 echo "performing permissions..."
6561 run_acl_subtest permissions || error "permissions failed"
6562 echo "performing setfacl..."
6563 run_acl_subtest setfacl || error "setfacl test failed"
6565 # inheritance test got from HP
6566 echo "performing inheritance..."
6567 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6568 chmod +x make-tree || error "chmod +x failed"
6569 run_acl_subtest inheritance || error "inheritance test failed"
6572 echo "LU-974 ignore umask when acl is enabled..."
6573 run_acl_subtest 974 || error "LU-974 umask test failed"
6574 if [ $MDSCOUNT -ge 2 ]; then
6575 run_acl_subtest 974_remote ||
6576 error "LU-974 umask test failed under remote dir"
6579 echo "LU-2561 newly created file is same size as directory..."
6580 run_acl_subtest 2561 || error "LU-2561 test failed"
6585 for num in $(seq $MDSCOUNT); do
6586 if [ "${identity_old[$num]}" = 1 ]; then
6587 switch_identity $num false || identity_old[$num]=$?
6591 run_test 103 "acl test ========================================="
6594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6596 lfs df || error "lfs df failed"
6597 lfs df -ih || error "lfs df -ih failed"
6598 lfs df -h $DIR || error "lfs df -h $DIR failed"
6599 lfs df -i $DIR || error "lfs df -i $DIR failed"
6600 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6601 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6603 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6604 lctl --device %$OSC deactivate
6605 lfs df || error "lfs df with deactivated OSC failed"
6606 lctl --device %$OSC activate
6607 # wait the osc back to normal
6608 wait_osc_import_state client ost FULL
6610 lfs df || error "lfs df with reactivated OSC failed"
6613 run_test 104a "lfs df [-ih] [path] test ========================="
6616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6617 [ $RUNAS_ID -eq $UID ] &&
6618 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6620 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6621 grep "Permission denied" | wc -l)))
6622 if [ $denied_cnt -ne 0 ]; then
6623 error "lfs check servers test failed"
6626 run_test 104b "$RUNAS lfs check servers test ===================="
6629 # doesn't work on 2.4 kernels
6631 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6632 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6634 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6638 run_test 105a "flock when mounted without -o flock test ========"
6642 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6643 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6645 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6649 run_test 105b "fcntl when mounted without -o flock test ========"
6653 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6654 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6656 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6660 run_test 105c "lockf when mounted without -o flock test ========"
6662 test_105d() { # bug 15924
6663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6664 test_mkdir -p $DIR/$tdir
6665 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6666 skip "mount w/o flock enabled" && return
6667 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6668 $LCTL set_param fail_loc=0x80000315
6669 flocks_test 2 $DIR/$tdir
6671 run_test 105d "flock race (should not freeze) ========"
6673 test_105e() { # bug 22660 && 22040
6674 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6675 skip "mount w/o flock enabled" && return
6677 flocks_test 3 $DIR/$tfile
6679 run_test 105e "Two conflicting flocks from same process ======="
6681 test_106() { #bug 10921
6682 test_mkdir -p $DIR/$tdir
6683 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6684 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6686 run_test 106 "attempt exec of dir followed by chown of that dir"
6689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6696 local save_pattern=$(sysctl -n kernel.core_pattern)
6697 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6698 sysctl -w kernel.core_pattern=$file
6699 sysctl -w kernel.core_uses_pid=0
6707 kill -s 11 $SLEEPPID
6709 if [ -e $file ]; then
6710 size=`stat -c%s $file`
6711 [ $size -eq 0 ] && error "Fail to create core file $file"
6713 error "Fail to create core file $file"
6716 sysctl -w kernel.core_pattern=$save_pattern
6717 sysctl -w kernel.core_uses_pid=$save_uses_pid
6720 run_test 107 "Coredump on SIG"
6723 test_mkdir -p $DIR/$tdir
6724 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6725 error "mkdir with 255 char failed"
6726 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6727 error "mkdir with 256 char should fail, but did not"
6728 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6729 error "create with 255 char failed"
6730 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6731 error "create with 256 char should fail, but did not"
6736 run_test 110 "filename length checking"
6739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6740 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6742 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6744 echo "Starting with $OSTIO_pre threads"
6747 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6748 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6749 echo "$NUMTEST creates/unlinks"
6750 test_mkdir -p $DIR/$tdir
6751 createmany -o $DIR/$tdir/$tfile $NUMTEST
6752 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6754 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6757 # don't return an error
6758 [ $OSTIO_post == $OSTIO_pre ] && echo \
6759 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6760 echo "This may be fine, depending on what ran before this test" &&
6761 echo "and how fast this system is." && return
6763 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6765 run_test 115 "verify dynamic thread creation===================="
6768 wait_delete_completed
6769 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6770 echo OST kbytes available: ${AVAIL[@]}
6771 MAXI=0; MAXV=${AVAIL[0]}
6772 MINI=0; MINV=${AVAIL[0]}
6773 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6774 #echo OST $i: ${AVAIL[i]}kb
6775 if [ ${AVAIL[i]} -gt $MAXV ]; then
6776 MAXV=${AVAIL[i]}; MAXI=$i
6778 if [ ${AVAIL[i]} -lt $MINV ]; then
6779 MINV=${AVAIL[i]}; MINI=$i
6782 echo Min free space: OST $MINI: $MINV
6783 echo Max free space: OST $MAXI: $MAXV
6786 test_116a() { # was previously test_116()
6787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6788 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6790 echo -n "Free space priority "
6791 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6796 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6797 trap simple_cleanup_common EXIT
6799 # Check if we need to generate uneven OSTs
6800 test_mkdir -p $DIR/$tdir/OST${MINI}
6801 local FILL=$(($MINV / 4))
6802 local DIFF=$(($MAXV - $MINV))
6803 local DIFF2=$(($DIFF * 100 / $MINV))
6805 local threshold=$(do_facet $SINGLEMDS \
6806 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -1)
6807 threshold=${threshold%%%}
6808 echo -n "Check for uneven OSTs: "
6809 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6811 if [ $DIFF2 -gt $threshold ]; then
6813 echo "Don't need to fill OST$MINI"
6815 # generate uneven OSTs. Write 2% over the QOS threshold value
6817 DIFF=$(($threshold - $DIFF2 + 2))
6818 DIFF2=$(( ($MINV * $DIFF)/100 ))
6819 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6820 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6821 error "setstripe failed"
6822 DIFF=$(($DIFF2 / 2048))
6824 while [ $i -lt $DIFF ]; do
6826 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6827 bs=2M count=1 2>/dev/null
6836 DIFF=$(($MAXV - $MINV))
6837 DIFF2=$(($DIFF * 100 / $MINV))
6838 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6839 if [ $DIFF2 -gt $threshold ]; then
6842 echo "failed - QOS mode won't be used"
6843 skip "QOS imbalance criteria not met"
6844 simple_cleanup_common
6848 MINI1=$MINI; MINV1=$MINV
6849 MAXI1=$MAXI; MAXV1=$MAXV
6851 # now fill using QOS
6852 $SETSTRIPE -c 1 $DIR/$tdir
6853 FILL=$(($FILL / 200))
6854 if [ $FILL -gt 600 ]; then
6857 echo "writing $FILL files to QOS-assigned OSTs"
6859 while [ $i -lt $FILL ]; do
6861 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
6865 echo "wrote $i 200k files"
6869 echo "Note: free space may not be updated, so measurements might be off"
6871 DIFF2=$(($MAXV - $MINV))
6872 echo "free space delta: orig $DIFF final $DIFF2"
6873 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6874 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6875 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
6876 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6877 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
6878 FILL=$(($DIFF2 * 100 / $DIFF - 100))
6880 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
6882 # Figure out which files were written where
6883 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6884 awk '/'$MINI1': / {print $2; exit}')
6886 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6887 echo "$MINC files created on smaller OST $MINI1"
6888 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6889 awk '/'$MAXI1': / {print $2; exit}')
6891 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6892 echo "$MAXC files created on larger OST $MAXI1"
6893 FILL=$(($MAXC * 100 / $MINC - 100))
6895 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
6896 [ $MAXC -gt $MINC ] ||
6897 error_ignore LU-9 "stripe QOS didn't balance free space"
6898 simple_cleanup_common
6900 run_test 116a "stripe QOS: free space balance ==================="
6902 test_116b() { # LU-2093
6903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6904 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6906 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6907 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6909 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6910 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6911 do_facet $SINGLEMDS lctl set_param fail_loc=0
6913 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6915 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6917 test_117() # bug 10891
6919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6920 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6921 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6922 lctl set_param fail_loc=0x21e
6923 > $DIR/$tfile || error "truncate failed"
6924 lctl set_param fail_loc=0
6925 echo "Truncate succeeded."
6928 run_test 117 "verify osd extend =========="
6930 NO_SLOW_RESENDCOUNT=4
6931 export OLD_RESENDCOUNT=""
6932 set_resend_count () {
6933 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6934 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6935 lctl set_param -n $PROC_RESENDCOUNT $1
6936 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6939 # for reduce test_118* time (b=14842)
6940 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6942 # Reset async IO behavior after error case
6944 FILE=$DIR/reset_async
6946 # Ensure all OSCs are cleared
6947 $SETSTRIPE -c -1 $FILE
6948 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6953 test_118a() #bug 11710
6955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6958 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6959 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6960 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6962 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6963 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6968 run_test 118a "verify O_SYNC works =========="
6972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6973 remote_ost_nodsh && skip "remote OST with nodsh" && return
6977 #define OBD_FAIL_OST_ENOENT 0x217
6978 set_nodes_failloc "$(osts_nodes)" 0x217
6979 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6981 set_nodes_failloc "$(osts_nodes)" 0
6982 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6983 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6986 if [[ $RC -eq 0 ]]; then
6987 error "Must return error due to dropped pages, rc=$RC"
6991 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6992 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6996 echo "Dirty pages not leaked on ENOENT"
6998 # Due to the above error the OSC will issue all RPCs syncronously
6999 # until a subsequent RPC completes successfully without error.
7000 $MULTIOP $DIR/$tfile Ow4096yc
7005 run_test 118b "Reclaim dirty pages on fatal error =========="
7009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7011 # for 118c, restore the original resend count, LU-1940
7012 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7013 set_resend_count $OLD_RESENDCOUNT
7014 remote_ost_nodsh && skip "remote OST with nodsh" && return
7018 #define OBD_FAIL_OST_EROFS 0x216
7019 set_nodes_failloc "$(osts_nodes)" 0x216
7021 # multiop should block due to fsync until pages are written
7022 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7026 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7027 error "Multiop failed to block on fsync, pid=$MULTIPID"
7030 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7032 if [[ $WRITEBACK -eq 0 ]]; then
7033 error "No page in writeback, writeback=$WRITEBACK"
7036 set_nodes_failloc "$(osts_nodes)" 0
7039 if [[ $RC -ne 0 ]]; then
7040 error "Multiop fsync failed, rc=$RC"
7043 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7044 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7046 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7047 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7051 echo "Dirty pages flushed via fsync on EROFS"
7054 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7056 # continue to use small resend count to reduce test_118* time (b=14842)
7057 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7062 remote_ost_nodsh && skip "remote OST with nodsh" && return
7066 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7067 set_nodes_failloc "$(osts_nodes)" 0x214
7068 # multiop should block due to fsync until pages are written
7069 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7073 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7074 error "Multiop failed to block on fsync, pid=$MULTIPID"
7077 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7079 if [[ $WRITEBACK -eq 0 ]]; then
7080 error "No page in writeback, writeback=$WRITEBACK"
7083 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7084 set_nodes_failloc "$(osts_nodes)" 0
7086 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7087 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7089 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7090 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7094 echo "Dirty pages gaurenteed flushed via fsync"
7097 run_test 118d "Fsync validation inject a delay of the bulk =========="
7100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7103 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7104 lctl set_param fail_loc=0x8000040a
7106 # Should simulate EINVAL error which is fatal
7107 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7109 if [[ $RC -eq 0 ]]; then
7110 error "Must return error due to dropped pages, rc=$RC"
7113 lctl set_param fail_loc=0x0
7115 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7116 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7117 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7119 if [[ $LOCKED -ne 0 ]]; then
7120 error "Locked pages remain in cache, locked=$LOCKED"
7123 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7124 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7128 echo "No pages locked after fsync"
7133 run_test 118f "Simulate unrecoverable OSC side error =========="
7136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7139 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7140 lctl set_param fail_loc=0x406
7142 # simulate local -ENOMEM
7143 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7146 lctl set_param fail_loc=0
7147 if [[ $RC -eq 0 ]]; then
7148 error "Must return error due to dropped pages, rc=$RC"
7151 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7152 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7153 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7155 if [[ $LOCKED -ne 0 ]]; then
7156 error "Locked pages remain in cache, locked=$LOCKED"
7159 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7160 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7164 echo "No pages locked after fsync"
7169 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7173 remote_ost_nodsh && skip "remote OST with nodsh" && return
7177 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7178 set_nodes_failloc "$(osts_nodes)" 0x20e
7179 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7180 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7183 set_nodes_failloc "$(osts_nodes)" 0
7184 if [[ $RC -eq 0 ]]; then
7185 error "Must return error due to dropped pages, rc=$RC"
7188 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7189 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7190 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7192 if [[ $LOCKED -ne 0 ]]; then
7193 error "Locked pages remain in cache, locked=$LOCKED"
7196 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7197 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7201 echo "No pages locked after fsync"
7205 run_test 118h "Verify timeout in handling recoverables errors =========="
7207 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7211 remote_ost_nodsh && skip "remote OST with nodsh" && return
7215 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7216 set_nodes_failloc "$(osts_nodes)" 0x20e
7218 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7219 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7222 set_nodes_failloc "$(osts_nodes)" 0
7226 if [[ $RC -ne 0 ]]; then
7227 error "got error, but should be not, rc=$RC"
7230 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7231 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7232 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7233 if [[ $LOCKED -ne 0 ]]; then
7234 error "Locked pages remain in cache, locked=$LOCKED"
7237 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7238 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7242 echo "No pages locked after fsync"
7246 run_test 118i "Fix error before timeout in recoverable error =========="
7248 [ "$SLOW" = "no" ] && set_resend_count 4
7251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7252 remote_ost_nodsh && skip "remote OST with nodsh" && return
7256 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7257 set_nodes_failloc "$(osts_nodes)" 0x220
7259 # return -EIO from OST
7260 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7262 set_nodes_failloc "$(osts_nodes)" 0x0
7263 if [[ $RC -eq 0 ]]; then
7264 error "Must return error due to dropped pages, rc=$RC"
7267 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7268 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7269 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7270 if [[ $LOCKED -ne 0 ]]; then
7271 error "Locked pages remain in cache, locked=$LOCKED"
7274 # in recoverable error on OST we want resend and stay until it finished
7275 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7276 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7280 echo "No pages locked after fsync"
7284 run_test 118j "Simulate unrecoverable OST side error =========="
7288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7289 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7291 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7292 set_nodes_failloc "$(osts_nodes)" 0x20e
7293 test_mkdir -p $DIR/$tdir
7295 for ((i=0;i<10;i++)); do
7296 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7297 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7304 set_nodes_failloc "$(osts_nodes)" 0
7307 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7313 test_mkdir -p $DIR/$tdir
7314 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7317 run_test 118l "fsync dir ========="
7319 test_118m() # LU-3066
7321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7322 test_mkdir -p $DIR/$tdir
7323 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7326 run_test 118m "fdatasync dir ========="
7328 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7330 test_119a() # bug 11737
7332 BSIZE=$((512 * 1024))
7333 directio write $DIR/$tfile 0 1 $BSIZE
7334 # We ask to read two blocks, which is more than a file size.
7335 # directio will indicate an error when requested and actual
7336 # sizes aren't equeal (a normal situation in this case) and
7337 # print actual read amount.
7338 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7339 if [ "$NOB" != "$BSIZE" ]; then
7340 error "read $NOB bytes instead of $BSIZE"
7344 run_test 119a "Short directIO read must return actual read amount"
7346 test_119b() # bug 11737
7348 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7350 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7351 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7353 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7354 error "direct read failed"
7357 run_test 119b "Sparse directIO read must return actual read amount"
7359 test_119c() # bug 13099
7362 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7363 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7366 run_test 119c "Testing for direct read hitting hole"
7368 test_119d() # bug 15950
7370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7371 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7372 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7374 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7375 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7376 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7377 lctl set_param fail_loc=0x40d
7378 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7381 cat $DIR/$tfile > /dev/null &
7382 lctl set_param fail_loc=0
7385 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7387 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7388 error "the read rpcs have not completed in 2s"
7390 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7392 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7396 test_mkdir -p $DIR/$tdir
7397 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7398 skip "no early lock cancel on server" && return 0
7400 lru_resize_disable mdc
7401 lru_resize_disable osc
7402 cancel_lru_locks mdc
7403 # asynchronous object destroy at MDT could cause bl ast to client
7404 cancel_lru_locks osc
7406 stat $DIR/$tdir > /dev/null
7407 can1=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
7408 awk '/ldlm_cancel/ {print $2}')
7409 blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
7410 awk '/ldlm_bl_callback/ {print $2}')
7411 test_mkdir -c1 $DIR/$tdir/d1
7412 can2=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
7413 awk '/ldlm_cancel/ {print $2}')
7414 blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
7415 awk '/ldlm_bl_callback/ {print $2}')
7416 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7417 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7418 lru_resize_enable mdc
7419 lru_resize_enable osc
7421 run_test 120a "Early Lock Cancel: mkdir test"
7424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7425 test_mkdir $DIR/$tdir
7426 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7427 skip "no early lock cancel on server" && return 0
7428 lru_resize_disable mdc
7429 lru_resize_disable osc
7430 cancel_lru_locks mdc
7431 stat $DIR/$tdir > /dev/null
7432 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7433 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7435 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7436 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7437 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7438 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7439 lru_resize_enable mdc
7440 lru_resize_enable osc
7442 run_test 120b "Early Lock Cancel: create test"
7445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7446 test_mkdir -c1 $DIR/$tdir
7447 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7448 skip "no early lock cancel on server" && return 0
7449 lru_resize_disable mdc
7450 lru_resize_disable osc
7451 test_mkdir -p -c1 $DIR/$tdir/d1
7452 test_mkdir -p -c1 $DIR/$tdir/d2
7453 touch $DIR/$tdir/d1/f1
7454 cancel_lru_locks mdc
7455 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7456 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7457 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7458 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7459 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7460 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7461 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7462 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7463 lru_resize_enable mdc
7464 lru_resize_enable osc
7466 run_test 120c "Early Lock Cancel: link test"
7469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7470 test_mkdir -p -c1 $DIR/$tdir
7471 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7472 skip "no early lock cancel on server" && return 0
7473 lru_resize_disable mdc
7474 lru_resize_disable osc
7476 cancel_lru_locks mdc
7477 stat $DIR/$tdir > /dev/null
7478 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7479 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7480 chmod a+x $DIR/$tdir
7481 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7482 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7483 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7484 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7485 lru_resize_enable mdc
7486 lru_resize_enable osc
7488 run_test 120d "Early Lock Cancel: setattr test"
7491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7492 test_mkdir -p -c1 $DIR/$tdir
7493 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7494 skip "no early lock cancel on server" && return 0
7495 lru_resize_disable mdc
7496 lru_resize_disable osc
7497 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7498 cancel_lru_locks mdc
7499 cancel_lru_locks osc
7500 dd if=$DIR/$tdir/f1 of=/dev/null
7501 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7502 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7503 awk '/ldlm_cancel/ {print $2}'`
7504 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7505 awk '/ldlm_bl_callback/ {print $2}'`
7506 unlink $DIR/$tdir/f1
7507 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7508 awk '/ldlm_cancel/ {print $2}'`
7509 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7510 awk '/ldlm_bl_callback/ {print $2}'`
7511 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7512 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7513 lru_resize_enable mdc
7514 lru_resize_enable osc
7516 run_test 120e "Early Lock Cancel: unlink test"
7519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7520 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7521 skip "no early lock cancel on server" && return 0
7522 test_mkdir -p -c1 $DIR/$tdir
7523 lru_resize_disable mdc
7524 lru_resize_disable osc
7525 test_mkdir -p -c1 $DIR/$tdir/d1
7526 test_mkdir -p -c1 $DIR/$tdir/d2
7527 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7528 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7529 cancel_lru_locks mdc
7530 cancel_lru_locks osc
7531 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7532 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7533 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7534 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7535 awk '/ldlm_cancel/ {print $2}'`
7536 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7537 awk '/ldlm_bl_callback/ {print $2}'`
7538 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7539 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7540 awk '/ldlm_cancel/ {print $2}'`
7541 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7542 awk '/ldlm_bl_callback/ {print $2}'`
7543 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7544 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7545 lru_resize_enable mdc
7546 lru_resize_enable osc
7548 run_test 120f "Early Lock Cancel: rename test"
7551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7552 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7553 skip "no early lock cancel on server" && return 0
7554 lru_resize_disable mdc
7555 lru_resize_disable osc
7557 echo create $count files
7558 test_mkdir -p $DIR/$tdir
7559 cancel_lru_locks mdc
7560 cancel_lru_locks osc
7563 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7564 awk '/ldlm_cancel/ {print $2}'`
7565 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7566 awk '/ldlm_bl_callback/ {print $2}'`
7567 createmany -o $DIR/$tdir/f $count
7569 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7570 awk '/ldlm_cancel/ {print $2}'`
7571 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7572 awk '/ldlm_bl_callback/ {print $2}'`
7574 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7575 echo rm $count files
7578 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7579 awk '/ldlm_cancel/ {print $2}'`
7580 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7581 awk '/ldlm_bl_callback/ {print $2}'`
7583 echo total: $count removes in $((t2-t1))
7584 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7586 # wait for commitment of removal
7587 lru_resize_enable mdc
7588 lru_resize_enable osc
7590 run_test 120g "Early Lock Cancel: performance test"
7592 test_121() { #bug #10589
7593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7595 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7596 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7597 lctl set_param fail_loc=0x310
7598 cancel_lru_locks osc > /dev/null
7599 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7600 lctl set_param fail_loc=0
7601 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7603 run_test 121 "read cancel race ========="
7605 test_123a() { # was test 123, statahead(bug 11401)
7606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7608 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7609 log "testing on UP system. Performance may be not as good as expected."
7614 test_mkdir -p $DIR/$tdir
7615 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7616 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7618 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7619 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7621 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7622 lctl set_param -n llite.*.statahead_max 0
7623 lctl get_param llite.*.statahead_max
7624 cancel_lru_locks mdc
7625 cancel_lru_locks osc
7627 time ls -l $DIR/$tdir | wc -l
7629 delta=$((etime - stime))
7630 log "ls $i files without statahead: $delta sec"
7631 lctl set_param llite.*.statahead_max=$max
7633 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7634 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7635 cancel_lru_locks mdc
7636 cancel_lru_locks osc
7638 time ls -l $DIR/$tdir | wc -l
7640 delta_sa=$((etime - stime))
7641 log "ls $i files with statahead: $delta_sa sec"
7642 lctl get_param -n llite.*.statahead_stats
7643 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7645 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7646 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7648 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7649 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7650 lctl set_param -n llite.*.statahead_max 0
7651 lctl get_param llite.*.statahead_max
7652 cancel_lru_locks mdc
7653 cancel_lru_locks osc
7655 time ls -l $DIR/$tdir | wc -l
7657 delta=$((etime - stime))
7658 log "ls $i files again without statahead: $delta sec"
7659 lctl set_param llite.*.statahead_max=$max
7660 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7661 if [ $SLOWOK -eq 0 ]; then
7662 error "ls $i files is slower with statahead!"
7664 log "ls $i files is slower with statahead!"
7670 [ $delta -gt 20 ] && break
7671 [ $delta -gt 8 ] && MULT=$((50 / delta))
7672 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7680 delta=$((etime - stime))
7681 log "rm -r $DIR/$tdir/: $delta seconds"
7683 lctl get_param -n llite.*.statahead_stats
7685 run_test 123a "verify statahead work"
7687 test_123b () { # statahead(bug 15027)
7688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7689 test_mkdir -p $DIR/$tdir
7690 createmany -o $DIR/$tdir/$tfile-%d 1000
7692 cancel_lru_locks mdc
7693 cancel_lru_locks osc
7695 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7696 lctl set_param fail_loc=0x80000803
7697 ls -lR $DIR/$tdir > /dev/null
7699 lctl set_param fail_loc=0x0
7700 lctl get_param -n llite.*.statahead_stats
7705 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7709 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7710 skip "no lru resize on server" && return 0
7712 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7714 log "create $NR files at $DIR/$tdir"
7715 createmany -o $DIR/$tdir/f $NR ||
7716 error "failed to create $NR files in $DIR/$tdir"
7718 cancel_lru_locks mdc
7719 ls -l $DIR/$tdir > /dev/null
7723 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7724 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7725 LRU_SIZE=$(lctl get_param -n $PARAM)
7726 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7727 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7729 log "NS=$(basename $NSDIR)"
7734 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7735 skip "Not enough cached locks created!"
7742 # We know that lru resize allows one client to hold $LIMIT locks
7743 # for 10h. After that locks begin to be killed by client.
7745 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7748 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7749 # killing locks. Some time was spent for creating locks. This means
7750 # that up to the moment of sleep finish we must have killed some of
7751 # them (10-100 locks). This depends on how fast ther were created.
7752 # Many of them were touched in almost the same moment and thus will
7753 # be killed in groups.
7754 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7756 # Use $LRU_SIZE_B here to take into account real number of locks
7757 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7758 local LRU_SIZE_B=$LRU_SIZE
7760 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7761 log "OLD_LVF=$OLD_LVF"
7762 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7764 # Let's make sure that we really have some margin. Client checks
7765 # cached locks every 10 sec.
7767 log "Sleep ${SLEEP} sec"
7769 while ((SEC<$SLEEP)); do
7773 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7777 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7778 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7780 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7781 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7782 unlinkmany $DIR/$tdir/f $NR
7786 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7787 log "unlink $NR files at $DIR/$tdir"
7788 unlinkmany $DIR/$tdir/f $NR
7790 run_test 124a "lru resize ======================================="
7792 get_max_pool_limit()
7794 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7797 if test $l -gt $max; then
7805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7806 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7807 skip "no lru resize on server" && return 0
7809 LIMIT=`get_max_pool_limit`
7811 NR=$(($(default_lru_size)*20))
7812 if [ $NR -gt $LIMIT ]; then
7813 log "Limit lock number by $LIMIT locks"
7816 lru_resize_disable mdc
7817 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7818 error "failed to create $DIR/$tdir/disable_lru_resize"
7820 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7821 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7822 cancel_lru_locks mdc
7825 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7828 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7831 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7835 nolruresize_delta=$((etime-stime))
7836 log "ls -la time: $nolruresize_delta seconds"
7837 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7838 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7840 lru_resize_enable mdc
7841 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7842 error "failed to create $DIR/$tdir/enable_lru_resize"
7844 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7845 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7846 cancel_lru_locks mdc
7849 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7852 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7855 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7859 lruresize_delta=$((etime-stime))
7860 log "ls -la time: $lruresize_delta seconds"
7861 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7863 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7864 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7865 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7866 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7868 log "lru resize performs the same with no lru resize"
7870 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7872 run_test 124b "lru resize (performance test) ======================="
7874 test_125() { # 13358
7875 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7876 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7877 test_mkdir -p $DIR/d125 || error "mkdir failed"
7878 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7879 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7880 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7882 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7884 test_126() { # bug 12829/13455
7885 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7886 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7887 $GSS && skip "must run as gss disabled" && return
7889 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7890 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7892 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7894 run_test 126 "check that the fsgid provided by the client is taken into account"
7896 test_127a() { # bug 15521
7897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7898 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7899 $LCTL set_param osc.*.stats=0
7900 FSIZE=$((2048 * 1024))
7901 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7902 cancel_lru_locks osc
7903 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7905 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7906 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7907 echo "got $COUNT $NAME"
7908 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7909 eval $NAME=$COUNT || error "Wrong proc format"
7912 read_bytes|write_bytes)
7913 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7914 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7915 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7916 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7917 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7918 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7919 error "sumsquare is too small: $SUMSQ"
7920 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7921 error "sumsquare is too big: $SUMSQ"
7925 done < $DIR/${tfile}.tmp
7927 #check that we actually got some stats
7928 [ "$read_bytes" ] || error "Missing read_bytes stats"
7929 [ "$write_bytes" ] || error "Missing write_bytes stats"
7930 [ "$read_bytes" != 0 ] || error "no read done"
7931 [ "$write_bytes" != 0 ] || error "no write done"
7933 run_test 127a "verify the client stats are sane"
7935 test_127b() { # bug LU-333
7936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7937 $LCTL set_param llite.*.stats=0
7938 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7939 # perform 2 reads and writes so MAX is different from SUM.
7940 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7941 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7942 cancel_lru_locks osc
7943 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7944 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7946 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7947 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7948 echo "got $COUNT $NAME"
7949 eval $NAME=$COUNT || error "Wrong proc format"
7953 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7954 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7955 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7956 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7959 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7960 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7961 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7962 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7966 done < $TMP/${tfile}.tmp
7968 #check that we actually got some stats
7969 [ "$read_bytes" ] || error "Missing read_bytes stats"
7970 [ "$write_bytes" ] || error "Missing write_bytes stats"
7971 [ "$read_bytes" != 0 ] || error "no read done"
7972 [ "$write_bytes" != 0 ] || error "no write done"
7974 run_test 127b "verify the llite client stats are sane"
7976 test_128() { # bug 15212
7978 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7983 result=$(grep error $TMP/$tfile.log)
7985 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7987 run_test 128 "interactive lfs for 2 consecutive find's"
7994 local LDPROC=/proc/fs/ldiskfs
7995 local facets=$(get_facets MDS)
7997 for facet in ${facets//,/ }; do
7998 canondev=$(ldiskfs_canon \
7999 *.$(convert_facet2label $facet).mntdev $facet)
8000 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8001 LDPROC=/sys/fs/ldiskfs
8002 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8008 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8009 skip "Only applicable to ldiskfs-based MDTs"
8012 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8017 test_mkdir -p $DIR/$tdir
8019 # block size of mds1
8020 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8021 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8022 local MAX=$((MDSBLOCKSIZE * 3))
8024 local I=$(stat -c%s "$DIR/$tdir")
8026 local STRIPE_COUNT=1
8027 [ $MDSCOUNT -ge 2 ] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8028 MAX=$((MAX*STRIPE_COUNT))
8029 while [ ! $I -gt $MAX ]; do
8030 $MULTIOP $DIR/$tdir/$J Oc
8032 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8033 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8034 #and EFBIG for previous versions
8035 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8037 echo "return code $rc received as expected"
8038 multiop $DIR/$tdir/$J Oc ||
8039 error_exit "multiop failed w/o dir size limit"
8041 I=$(stat -c%s "$DIR/$tdir")
8043 if [ $(lustre_version_code $SINGLEMDS) -lt \
8044 $(version_code 2.4.51) ]
8046 [ $I -eq $MAX ] && return 0
8048 [ $I -gt $MAX ] && return 0
8050 error_exit "current dir size $I, previous limit $MAX"
8051 elif [ $rc -ne 0 ]; then
8053 error_exit "return code $rc received instead of expected " \
8054 "$EFBIG or $ENOSPC, files in dir $I"
8057 I=$(stat -c%s "$DIR/$tdir")
8061 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8063 run_test 129 "test directory size limit ========================"
8072 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8073 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8076 trap cleanup_130 EXIT RETURN
8078 local fm_file=$DIR/$tfile
8079 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8080 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8081 error "dd failed for $fm_file"
8083 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8084 filefrag -ves $fm_file
8086 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8087 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8088 [ $RC != 0 ] && error "filefrag $fm_file failed"
8090 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8091 grep -v "ext:" | grep -v "found")
8092 lun=$($GETSTRIPE -i $fm_file)
8094 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8097 for line in $filefrag_op
8099 frag_lun=`echo $line | cut -d: -f5`
8100 ext_len=`echo $line | cut -d: -f4`
8101 if (( $frag_lun != $lun )); then
8103 error "FIEMAP on 1-stripe file($fm_file) failed"
8106 (( tot_len += ext_len ))
8109 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8111 error "FIEMAP on 1-stripe file($fm_file) failed;"
8117 echo "FIEMAP on single striped file succeeded"
8119 run_test 130a "FIEMAP (1-stripe file)"
8122 [ "$OSTCOUNT" -lt "2" ] &&
8123 skip_env "skipping FIEMAP on 2-stripe file test" && return
8125 [ "$OSTCOUNT" -ge "10" ] &&
8126 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8128 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8129 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8132 trap cleanup_130 EXIT RETURN
8134 local fm_file=$DIR/$tfile
8135 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8136 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8137 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8139 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8140 error "dd failed on $fm_file"
8142 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8143 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8144 grep -v "ext:" | grep -v "found")
8146 last_lun=$(echo $filefrag_op | cut -d: -f5)
8151 for line in $filefrag_op
8153 frag_lun=`echo $line | cut -d: -f5`
8154 ext_len=`echo $line | cut -d: -f4`
8155 if (( $frag_lun != $last_lun )); then
8156 if (( tot_len != 1024 )); then
8158 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8165 (( tot_len += ext_len ))
8168 if (( num_luns != 2 || tot_len != 1024 )); then
8170 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8176 echo "FIEMAP on 2-stripe file succeeded"
8178 run_test 130b "FIEMAP (2-stripe file)"
8181 [ "$OSTCOUNT" -lt "2" ] &&
8182 skip_env "skipping FIEMAP on 2-stripe file" && return
8184 [ "$OSTCOUNT" -ge "10" ] &&
8185 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8187 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8188 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8191 trap cleanup_130 EXIT RETURN
8193 local fm_file=$DIR/$tfile
8194 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8195 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8196 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8198 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8200 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8201 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8203 last_lun=`echo $filefrag_op | cut -d: -f5`
8208 for line in $filefrag_op
8210 frag_lun=`echo $line | cut -d: -f5`
8211 ext_len=`echo $line | cut -d: -f4`
8212 if (( $frag_lun != $last_lun )); then
8213 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8214 if (( logical != 512 )); then
8216 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8219 if (( tot_len != 512 )); then
8221 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8228 (( tot_len += ext_len ))
8231 if (( num_luns != 2 || tot_len != 512 )); then
8233 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8239 echo "FIEMAP on 2-stripe file with hole succeeded"
8241 run_test 130c "FIEMAP (2-stripe file with hole)"
8244 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8246 [ "$OSTCOUNT" -ge "10" ] &&
8247 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8249 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8250 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8252 trap cleanup_130 EXIT RETURN
8254 local fm_file=$DIR/$tfile
8255 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8256 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8257 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8259 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8260 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8261 error "dd failed on $fm_file"
8263 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8264 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8265 grep -v "ext:" | grep -v "found"`
8267 last_lun=`echo $filefrag_op | cut -d: -f5`
8272 for line in $filefrag_op
8274 frag_lun=`echo $line | cut -d: -f5`
8275 ext_len=`echo $line | cut -d: -f4`
8276 if (( $frag_lun != $last_lun )); then
8277 if (( tot_len != 1024 )); then
8279 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8286 (( tot_len += ext_len ))
8289 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8291 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8297 echo "FIEMAP on N-stripe file succeeded"
8299 run_test 130d "FIEMAP (N-stripe file)"
8302 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8304 [ "$OSTCOUNT" -ge "10" ] &&
8305 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8307 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8308 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8310 trap cleanup_130 EXIT RETURN
8312 local fm_file=$DIR/$tfile
8313 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8314 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8315 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8318 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8319 for ((i = 0; i < $NUM_BLKS; i++))
8321 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8324 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8325 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8327 last_lun=`echo $filefrag_op | cut -d: -f5`
8332 for line in $filefrag_op
8334 frag_lun=`echo $line | cut -d: -f5`
8335 ext_len=`echo $line | cut -d: -f4`
8336 if (( $frag_lun != $last_lun )); then
8337 if (( tot_len != $EXPECTED_LEN )); then
8339 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8346 (( tot_len += ext_len ))
8349 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8351 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8357 echo "FIEMAP with continuation calls succeeded"
8359 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8361 # Test for writev/readv
8363 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8364 error "writev test failed"
8365 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8366 error "readv failed"
8369 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8372 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8373 error "append writev test failed"
8374 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8375 error "append writev test failed"
8378 run_test 131b "test append writev"
8381 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8384 run_test 131c "test read/write on file w/o objects"
8387 rwv -f $DIR/$tfile -w -n 1 1572864
8388 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8389 if [ "$NOB" != 1572864 ]; then
8390 error "Short read filed: read $NOB bytes instead of 1572864"
8394 run_test 131d "test short read"
8397 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8398 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8399 error "read hitting hole failed"
8402 run_test 131e "test read hitting hole"
8407 for node in $(osts_nodes); do
8408 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8409 [ x$gl = x"" ] && gl=0
8410 gl_sum=$((gl_sum + gl))
8420 if [ x$som = x"enabled" ]; then
8421 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8422 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8423 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8425 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8426 MOUNTOPT="$MOUNTOPT,som_preview"
8427 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8430 # do remount to make new mount-conf parameters actual
8437 test_132() { #1028, SOM
8438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8439 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8440 local num=$(get_mds_dir $DIR)
8441 local mymds=mds${num}
8442 local MOUNTOPT_SAVE=$MOUNTOPT
8444 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8445 cancel_lru_locks osc
8447 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8449 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8450 stat $DIR/$tfile >/dev/null
8451 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8452 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8454 som_mode_switch $som1 $gl1 $gl2
8456 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8457 cancel_lru_locks osc
8459 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8460 if [ $som1 == $som2 ]; then
8461 error "som is still "$som2
8462 if [ x$som2 = x"enabled" ]; then
8469 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8470 stat $DIR/$tfile >/dev/null
8471 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8472 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8473 som_mode_switch $som2 $gl1 $gl2
8474 MOUNTOPT=$MOUNTOPT_SAVE
8476 run_test 132 "som avoids glimpse rpc"
8482 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8484 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8486 *) error "Wrong argument $1" ;;
8489 count=`echo $res | awk '{print $2}'`
8490 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8491 # if the argument $3 is zero, it means any stat increment is ok.
8492 if [ $3 -gt 0 ] ; then
8493 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8499 remote_ost_nodsh && skip "remote OST with nodsh" && return
8500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8502 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8503 { skip "MDS doesn't support rename stats"; return; }
8504 local testdir=$DIR/${tdir}/stats_testdir
8505 mkdir -p $DIR/${tdir}
8508 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8509 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8511 # verify mdt stats first.
8512 mkdir ${testdir} || error "mkdir failed"
8513 check_stats $SINGLEMDS "mkdir" 1
8514 touch ${testdir}/${tfile} || "touch failed"
8515 check_stats $SINGLEMDS "open" 1
8516 check_stats $SINGLEMDS "close" 1
8517 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8518 check_stats $SINGLEMDS "mknod" 1
8519 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8520 check_stats $SINGLEMDS "unlink" 1
8521 rm -f ${testdir}/${tfile} || error "file remove failed"
8522 check_stats $SINGLEMDS "unlink" 2
8524 # remove working dir and check mdt stats again.
8525 rmdir ${testdir} || error "rmdir failed"
8526 check_stats $SINGLEMDS "rmdir" 1
8528 local testdir1=$DIR/${tdir}/stats_testdir1
8530 mkdir -p ${testdir1}
8531 touch ${testdir1}/test1
8532 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8533 check_stats $SINGLEMDS "crossdir_rename" 1
8535 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8536 check_stats $SINGLEMDS "samedir_rename" 1
8540 run_test 133a "Verifying MDT stats ========================================"
8543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8544 remote_ost_nodsh && skip "remote OST with nodsh" && return
8545 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8546 local testdir=$DIR/${tdir}/stats_testdir
8547 mkdir -p ${testdir} || error "mkdir failed"
8548 touch ${testdir}/${tfile} || "touch failed"
8549 cancel_lru_locks mdc
8552 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8553 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8555 # extra mdt stats verification.
8556 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8557 check_stats $SINGLEMDS "setattr" 1
8558 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8559 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8561 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8562 check_stats $SINGLEMDS "getattr" 1
8564 $LFS df || error "lfs failed"
8565 check_stats $SINGLEMDS "statfs" 1
8569 run_test 133b "Verifying extra MDT stats =================================="
8572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8573 remote_ost_nodsh && skip "remote OST with nodsh" && return
8574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8575 local testdir=$DIR/${tdir}/stats_testdir
8576 test_mkdir -p ${testdir} || error "mkdir failed"
8578 # verify obdfilter stats.
8579 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8581 cancel_lru_locks osc
8582 wait_delete_completed
8585 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8586 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8588 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8590 cancel_lru_locks osc
8591 check_stats ost "write" 1
8593 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8594 check_stats ost "read" 1
8596 > ${testdir}/${tfile} || error "truncate failed"
8597 check_stats ost "punch" 1
8599 rm -f ${testdir}/${tfile} || error "file remove failed"
8600 wait_delete_completed
8601 check_stats ost "destroy" 1
8605 run_test 133c "Verifying OST stats ========================================"
8612 while [ $value -ge 2 ]; do
8617 if [ $orig -gt $order ]; then
8625 local size=('K' 'M' 'G' 'T');
8627 local size_string=$value
8629 while [ $value -ge 1024 ]; do
8630 if [ $i -gt 3 ]; then
8631 #T is the biggest unit we get here, if that is bigger,
8633 size_string=${value}T
8636 value=$((value >> 10))
8637 if [ $value -lt 1024 ]; then
8638 size_string=${value}${size[$i]}
8649 local context=${2:-.}
8650 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8652 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8658 remote_ost_nodsh && skip "remote OST with nodsh" && return
8659 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8660 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8661 { skip "MDS doesn't support rename stats"; return; }
8663 local testdir1=$DIR/${tdir}/stats_testdir1
8664 local testdir2=$DIR/${tdir}/stats_testdir2
8666 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8668 mkdir -p ${testdir1} || error "mkdir failed"
8669 mkdir -p ${testdir2} || error "mkdir failed"
8671 createmany -o $testdir1/test 512 || error "createmany failed"
8673 # check samedir rename size
8674 mv ${testdir1}/test0 ${testdir1}/test_0
8676 local testdir1_size=$(ls -l $DIR/${tdir} |
8677 awk '/stats_testdir1/ {print $5}')
8678 local testdir2_size=$(ls -l $DIR/${tdir} |
8679 awk '/stats_testdir2/ {print $5}')
8681 testdir1_size=$(order_2 $testdir1_size)
8682 testdir2_size=$(order_2 $testdir2_size)
8684 testdir1_size=$(size_in_KMGT $testdir1_size)
8685 testdir2_size=$(size_in_KMGT $testdir2_size)
8687 echo "source rename dir size: ${testdir1_size}"
8688 echo "target rename dir size: ${testdir2_size}"
8690 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8691 eval $cmd || error "$cmd failed"
8692 local samedir=$($cmd | grep 'same_dir')
8693 local same_sample=$(get_rename_size $testdir1_size)
8694 [ -z "$samedir" ] && error "samedir_rename_size count error"
8695 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8696 echo "Check same dir rename stats success"
8698 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8700 # check crossdir rename size
8701 mv ${testdir1}/test_0 ${testdir2}/test_0
8703 testdir1_size=$(ls -l $DIR/${tdir} |
8704 awk '/stats_testdir1/ {print $5}')
8705 testdir2_size=$(ls -l $DIR/${tdir} |
8706 awk '/stats_testdir2/ {print $5}')
8708 testdir1_size=$(order_2 $testdir1_size)
8709 testdir2_size=$(order_2 $testdir2_size)
8711 testdir1_size=$(size_in_KMGT $testdir1_size)
8712 testdir2_size=$(size_in_KMGT $testdir2_size)
8714 echo "source rename dir size: ${testdir1_size}"
8715 echo "target rename dir size: ${testdir2_size}"
8717 eval $cmd || error "$cmd failed"
8718 local crossdir=$($cmd | grep 'crossdir')
8719 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8720 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8721 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8722 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8723 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8724 echo "Check cross dir rename stats success"
8727 run_test 133d "Verifying rename_stats ========================================"
8730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8731 local testdir=$DIR/${tdir}/stats_testdir
8732 local ctr f0 f1 bs=32768 count=42 sum
8734 remote_ost_nodsh && skip "remote OST with nodsh" && return
8735 mkdir -p ${testdir} || error "mkdir failed"
8737 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8739 for ctr in {write,read}_bytes; do
8741 cancel_lru_locks osc
8743 do_facet ost1 $LCTL set_param -n \
8744 "obdfilter.*.exports.clear=clear"
8746 if [ $ctr = write_bytes ]; then
8748 f1=${testdir}/${tfile}
8750 f0=${testdir}/${tfile}
8754 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8757 cancel_lru_locks osc
8759 sum=$(do_facet ost1 $LCTL get_param \
8760 "obdfilter.*.exports.*.stats" | \
8763 $1 == ctr { sum += $7 }
8766 if ((sum != bs * count)); then
8767 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8773 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8776 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8779 # First without trusting modes.
8781 -exec cat '{}' \; &> /dev/null
8783 # Second verifying readability.
8787 -exec cat '{}' \; > /dev/null ||
8788 error "proc file read failed"
8790 for facet in $SINGLEMDS ost1; do
8791 do_facet $facet find $proc_dirs \
8792 -not -name req_history \
8793 -exec cat '{}' \\\; &> /dev/null
8795 do_facet $facet find $proc_dirs \
8796 -not -name req_history \
8799 -exec cat '{}' \\\; > /dev/null ||
8800 error "proc file read failed"
8803 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8805 test_140() { #bug-17379
8806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8807 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8808 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8809 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8811 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8812 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8814 while i=`expr $i + 1`; do
8815 test_mkdir -p $i || error "Creating dir $i"
8816 cd $i || error "Changing to $i"
8817 ln -s ../stat stat || error "Creating stat symlink"
8818 # Read the symlink until ELOOP present,
8819 # not LBUGing the system is considered success,
8820 # we didn't overrun the stack.
8821 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8823 if [ $ret -eq 40 ]; then
8826 error "Open stat symlink"
8832 echo "The symlink depth = $i"
8833 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8834 error "Invalid symlink depth"
8836 # Test recursive symlink
8837 ln -s symlink_self symlink_self
8838 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8839 echo "open symlink_self returns $ret"
8840 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8842 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8846 local TF="$TMP/$tfile"
8848 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8850 cancel_lru_locks osc
8851 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8852 remount_client $MOUNT
8854 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8857 $TRUNCATE $DIR/$tfile 6000
8858 cancel_lru_locks osc
8859 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8862 echo "12345" >>$DIR/$tfile
8863 cancel_lru_locks osc
8864 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8867 echo "12345" >>$DIR/$tfile
8868 cancel_lru_locks osc
8869 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8874 run_test 150 "truncate/append tests"
8876 #LU-2902 roc_hit was not able to read all values from lproc
8877 function roc_hit_init() {
8878 local list=$(comma_list $(osts_nodes))
8879 local dir=$DIR/$tdir-check
8880 local file=$dir/file
8886 #use setstripe to do a write to every ost
8887 for i in $(seq 0 $((OSTCOUNT-1))); do
8888 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
8889 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
8890 idx=$(printf %04x $i)
8891 BEFORE=$(get_osd_param $list *OST*$idx stats |
8892 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8893 if [ -z "$BEFORE" ]; then
8897 cancel_lru_locks osc
8898 cat $file >/dev/null
8900 AFTER=$(get_osd_param $list *OST*$idx stats |
8901 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8903 echo BEFORE:$BEFORE AFTER:$AFTER
8904 if ! let "AFTER - BEFORE == 4"; then
8906 error "roc_hit is not safe to use"
8914 function roc_hit() {
8915 local list=$(comma_list $(osts_nodes))
8916 echo $(get_osd_param $list '' stats |
8917 awk '$1 == "cache_hit" {sum += $2} END { print sum }')
8920 function set_cache() {
8923 if [ "$2" == "off" ]; then
8926 local list=$(comma_list $(osts_nodes))
8927 set_osd_param $list '' $1_cache_enable $on
8929 cancel_lru_locks osc
8933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8934 remote_ost_nodsh && skip "remote OST with nodsh" && return
8937 local list=$(comma_list $(osts_nodes))
8939 # check whether obdfilter is cache capable at all
8940 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8941 echo "not cache-capable obdfilter"
8945 # check cache is enabled on all obdfilters
8946 if get_osd_param $list '' read_cache_enable | grep 0; then
8947 echo "oss cache is disabled"
8951 set_osd_param $list '' writethrough_cache_enable 1
8953 # check write cache is enabled on all obdfilters
8954 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8955 echo "oss write cache is NOT enabled"
8961 #define OBD_FAIL_OBD_NO_LRU 0x609
8962 do_nodes $list $LCTL set_param fail_loc=0x609
8964 # pages should be in the case right after write
8965 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
8968 local BEFORE=$(roc_hit)
8969 cancel_lru_locks osc
8970 cat $DIR/$tfile >/dev/null
8971 local AFTER=$(roc_hit)
8973 do_nodes $list $LCTL set_param fail_loc=0
8975 if ! let "AFTER - BEFORE == CPAGES"; then
8976 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8979 # the following read invalidates the cache
8980 cancel_lru_locks osc
8981 set_osd_param $list '' read_cache_enable 0
8982 cat $DIR/$tfile >/dev/null
8984 # now data shouldn't be found in the cache
8986 cancel_lru_locks osc
8987 cat $DIR/$tfile >/dev/null
8989 if let "AFTER - BEFORE != 0"; then
8990 error "IN CACHE: before: $BEFORE, after: $AFTER"
8993 set_osd_param $list '' read_cache_enable 1
8996 run_test 151 "test cache on oss and controls ==============================="
8999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9000 local TF="$TMP/$tfile"
9002 # simulate ENOMEM during write
9003 #define OBD_FAIL_OST_NOMEM 0x226
9004 lctl set_param fail_loc=0x80000226
9005 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9007 sync || error "sync failed"
9008 lctl set_param fail_loc=0
9010 # discard client's cache
9011 cancel_lru_locks osc
9013 # simulate ENOMEM during read
9014 lctl set_param fail_loc=0x80000226
9015 cmp $TF $DIR/$tfile || error "cmp failed"
9016 lctl set_param fail_loc=0
9020 run_test 152 "test read/write with enomem ============================"
9023 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9025 run_test 153 "test if fdatasync does not crash ======================="
9027 dot_lustre_fid_permission_check() {
9029 local ffid=$MOUNT/.lustre/fid/$fid
9032 echo "stat fid $fid"
9033 stat $ffid > /dev/null || error "stat $ffid failed."
9034 echo "touch fid $fid"
9035 touch $ffid || error "touch $ffid failed."
9036 echo "write to fid $fid"
9037 cat /etc/hosts > $ffid || error "write $ffid failed."
9038 echo "read fid $fid"
9039 diff /etc/hosts $ffid || error "read $ffid failed."
9040 echo "append write to fid $fid"
9041 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9042 echo "rename fid $fid"
9043 mv $ffid $test_dir/$tfile.1 &&
9044 error "rename $ffid to $tfile.1 should fail."
9045 touch $test_dir/$tfile.1
9046 mv $test_dir/$tfile.1 $ffid &&
9047 error "rename $tfile.1 to $ffid should fail."
9048 rm -f $test_dir/$tfile.1
9049 echo "truncate fid $fid"
9050 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9051 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9052 echo "link fid $fid"
9053 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9055 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9056 echo "setfacl fid $fid"
9057 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9058 echo "getfacl fid $fid"
9059 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9061 echo "unlink fid $fid"
9062 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9063 echo "mknod fid $fid"
9064 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9066 fid=[0xf00000400:0x1:0x0]
9067 ffid=$MOUNT/.lustre/fid/$fid
9069 echo "stat non-exist fid $fid"
9070 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9071 echo "write to non-exist fid $fid"
9072 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9073 echo "link new fid $fid"
9074 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9076 mkdir -p $test_dir/$tdir
9077 touch $test_dir/$tdir/$tfile
9078 fid=$($LFS path2fid $test_dir/$tdir)
9081 error "error: could not get fid for $test_dir/$dir/$tfile."
9083 ffid=$MOUNT/.lustre/fid/$fid
9086 ls $ffid > /dev/null || error "ls $ffid failed."
9087 echo "touch $fid/$tfile.1"
9088 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9090 echo "touch $MOUNT/.lustre/fid/$tfile"
9091 touch $MOUNT/.lustre/fid/$tfile && \
9092 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9094 echo "setxattr to $MOUNT/.lustre/fid"
9095 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9097 echo "listxattr for $MOUNT/.lustre/fid"
9098 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9100 echo "delxattr from $MOUNT/.lustre/fid"
9101 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9103 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9104 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9105 error "touch invalid fid should fail."
9107 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9108 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9109 error "touch non-normal fid should fail."
9111 echo "rename $tdir to $MOUNT/.lustre/fid"
9112 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9113 error "rename to $MOUNT/.lustre/fid should fail."
9115 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9117 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9118 local new_obf_mode=777
9120 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9121 chmod $new_obf_mode $DIR/.lustre/fid ||
9122 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9124 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9125 [ $obf_mode -eq $new_obf_mode ] ||
9126 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9128 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9129 chmod $old_obf_mode $DIR/.lustre/fid ||
9130 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9133 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9134 fid=$($LFS path2fid $test_dir/$tfile-2)
9135 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9136 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9137 error "create lov data thru .lustre should fail."
9138 echo "cp /etc/passwd $test_dir/$tfile-2"
9139 cp /etc/passwd $test_dir/$tfile-2 ||
9140 error "copy to $test_dir/$tfile-2 failed."
9141 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9142 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9143 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9145 rm -rf $test_dir/tfile.lnk
9146 rm -rf $test_dir/$tfile-2
9150 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9151 skip "Need MDS version at least 2.4.1" && return
9154 local FID=$($LFS path2fid $DIR/$tfile)
9155 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9157 # check that we get the same pathname back
9158 local FOUND=$($LFS fid2path $MOUNT $FID)
9159 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9160 [ "$FOUND" != "$DIR/$tfile" ] &&
9161 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9165 run_test 154A "lfs path2fid and fid2path basic checks"
9168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9169 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9170 { skip "Need MDS version at least 2.2.51"; return 0; }
9172 cp /etc/hosts $DIR/$tfile
9174 fid=$($LFS path2fid $DIR/$tfile)
9176 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9178 dot_lustre_fid_permission_check "$fid" $DIR ||
9179 error "dot lustre permission check $fid failed"
9181 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9183 touch $MOUNT/.lustre/file &&
9184 error "creation is not allowed under .lustre"
9186 mkdir $MOUNT/.lustre/dir &&
9187 error "mkdir is not allowed under .lustre"
9191 run_test 154a "Open-by-FID"
9194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9195 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9196 { skip "Need MDS version at least 2.2.51"; return 0; }
9198 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9200 local remote_dir=$DIR/$tdir/remote_dir
9205 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9206 error "create remote directory failed"
9208 cp /etc/hosts $remote_dir/$tfile
9210 fid=$($LFS path2fid $remote_dir/$tfile)
9212 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9214 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9215 error "dot lustre permission check $fid failed"
9218 run_test 154b "Open-by-FID for remote directory"
9221 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9222 skip "Need MDS version at least 2.4.1" && return
9224 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9225 local FID1=$($LFS path2fid $DIR/$tfile.1)
9226 local FID2=$($LFS path2fid $DIR/$tfile.2)
9227 local FID3=$($LFS path2fid $DIR/$tfile.3)
9230 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9231 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9232 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9234 [ "$FID" = "${!want}" ] ||
9235 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9239 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9240 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9241 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9245 run_test 154c "lfs path2fid and fid2path multiple arguments"
9248 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9249 skip "Need MDS version at least 2.5.53" && return
9252 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9256 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9263 fid=$($LFS path2fid $DIR/$tfile)
9266 cmd="exec $fd<$DIR/$tfile"
9268 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9269 echo $fid_list | grep $fid
9272 cmd="exec $fd>/dev/null"
9274 if [ $rc -ne 0 ]; then
9275 error "FID $fid not found in open files list $fid_list"
9278 run_test 154d "Verify open file fid"
9280 test_155_small_load() {
9281 local temp=$TMP/$tfile
9282 local file=$DIR/$tfile
9284 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9285 error "dd of=$temp bs=6096 count=1 failed"
9287 cancel_lru_locks osc
9288 cmp $temp $file || error "$temp $file differ"
9290 $TRUNCATE $temp 6000
9291 $TRUNCATE $file 6000
9292 cmp $temp $file || error "$temp $file differ (truncate1)"
9294 echo "12345" >>$temp
9295 echo "12345" >>$file
9296 cmp $temp $file || error "$temp $file differ (append1)"
9298 echo "12345" >>$temp
9299 echo "12345" >>$file
9300 cmp $temp $file || error "$temp $file differ (append2)"
9306 test_155_big_load() {
9307 remote_ost_nodsh && skip "remote OST with nodsh" && return
9308 local temp=$TMP/$tfile
9309 local file=$DIR/$tfile
9312 local cache_size=$(do_facet ost$((MAXI+1)) \
9313 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9314 local large_file_size=$((cache_size * 2))
9316 echo "OSS cache size: $cache_size KB"
9317 echo "Large file size: $large_file_size KB"
9319 [ $MAXV -le $large_file_size ] && \
9320 skip_env "max available OST size needs > $large_file_size KB" && \
9323 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9325 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9326 error "dd of=$temp bs=$large_file_size count=1k failed"
9329 cancel_lru_locks osc
9330 cmp $temp $file || error "$temp $file differ"
9337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9339 set_cache writethrough on
9342 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9347 set_cache writethrough off
9350 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9355 set_cache writethrough on
9358 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9363 set_cache writethrough off
9366 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9371 set_cache writethrough on
9374 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9379 set_cache writethrough off
9382 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9387 set_cache writethrough on
9390 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9395 set_cache writethrough off
9398 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9405 local file="$DIR/$tfile"
9407 [ "$(facet_fstype ost1)" = "zfs" ] &&
9408 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9413 log "Turn on read and write cache"
9415 set_cache writethrough on
9417 log "Write data and read it back."
9418 log "Read should be satisfied from the cache."
9419 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9421 cancel_lru_locks osc
9422 cat $file >/dev/null
9424 if ! let "AFTER - BEFORE == CPAGES"; then
9425 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9427 log "cache hits:: before: $BEFORE, after: $AFTER"
9430 log "Read again; it should be satisfied from the cache."
9432 cancel_lru_locks osc
9433 cat $file >/dev/null
9435 if ! let "AFTER - BEFORE == CPAGES"; then
9436 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9438 log "cache hits:: before: $BEFORE, after: $AFTER"
9442 log "Turn off the read cache and turn on the write cache"
9444 set_cache writethrough on
9446 log "Read again; it should be satisfied from the cache."
9448 cancel_lru_locks osc
9449 cat $file >/dev/null
9451 if ! let "AFTER - BEFORE == CPAGES"; then
9452 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9454 log "cache hits:: before: $BEFORE, after: $AFTER"
9457 log "Read again; it should not be satisfied from the cache."
9459 cancel_lru_locks osc
9460 cat $file >/dev/null
9462 if ! let "AFTER - BEFORE == 0"; then
9463 error "IN CACHE: before: $BEFORE, after: $AFTER"
9465 log "cache hits:: before: $BEFORE, after: $AFTER"
9468 log "Write data and read it back."
9469 log "Read should be satisfied from the cache."
9470 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9472 cancel_lru_locks osc
9473 cat $file >/dev/null
9475 if ! let "AFTER - BEFORE == CPAGES"; then
9476 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9478 log "cache hits:: before: $BEFORE, after: $AFTER"
9481 log "Read again; it should not be satisfied from the cache."
9483 cancel_lru_locks osc
9484 cat $file >/dev/null
9486 if ! let "AFTER - BEFORE == 0"; then
9487 error "IN CACHE: before: $BEFORE, after: $AFTER"
9489 log "cache hits:: before: $BEFORE, after: $AFTER"
9493 log "Turn off read and write cache"
9495 set_cache writethrough off
9497 log "Write data and read it back"
9498 log "It should not be satisfied from the cache."
9500 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9501 cancel_lru_locks osc
9503 cat $file >/dev/null
9505 if ! let "AFTER - BEFORE == 0"; then
9506 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9508 log "cache hits:: before: $BEFORE, after: $AFTER"
9511 log "Turn on the read cache and turn off the write cache"
9513 set_cache writethrough off
9515 log "Write data and read it back"
9516 log "It should not be satisfied from the cache."
9518 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9520 cancel_lru_locks osc
9521 cat $file >/dev/null
9523 if ! let "AFTER - BEFORE == 0"; then
9524 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9526 log "cache hits:: before: $BEFORE, after: $AFTER"
9529 log "Read again; it should be satisfied from the cache."
9531 cancel_lru_locks osc
9532 cat $file >/dev/null
9534 if ! let "AFTER - BEFORE == CPAGES"; then
9535 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9537 log "cache hits:: before: $BEFORE, after: $AFTER"
9542 run_test 156 "Verification of tunables ============================"
9546 if [ $MDSCOUNT -gt 1 ]; then
9547 error_ignore bz17935 $*
9555 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9557 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9559 if [ $MASK -eq 1 ]; then
9560 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9562 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9566 changelog_extract_field() {
9572 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9573 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9580 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9581 { skip "Need MDS version at least 2.2.0"; return; }
9583 local CL_USERS="mdd.$MDT0.changelog_users"
9584 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9585 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9586 echo "Registered as changelog user $USER"
9587 $GET_CL_USERS | grep -q $USER ||
9588 error "User $USER not found in changelog_users"
9591 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9592 touch $DIR/$tdir/pics/2008/zachy/timestamp
9593 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9594 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9595 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9596 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9597 rm $DIR/$tdir/pics/desktop.jpg
9599 $LFS changelog $MDT0 | tail -5
9601 echo "verifying changelog mask"
9602 changelog_chmask "MKDIR"
9603 changelog_chmask "CLOSE"
9605 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9606 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9608 changelog_chmask "MKDIR"
9609 changelog_chmask "CLOSE"
9611 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9612 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9614 $LFS changelog $MDT0
9615 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9616 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9617 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9618 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9621 echo "verifying target fid"
9622 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9623 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9624 [ "$fidc" == "$fidf" ] ||
9625 err17935 "fid in changelog $fidc != file fid $fidf"
9626 echo "verifying parent fid"
9627 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9628 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9629 [ "$fidc" == "$fidf" ] ||
9630 err17935 "pfid in changelog $fidc != dir fid $fidf"
9632 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9633 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9634 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9635 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9636 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9637 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9639 MIN_REC=$($GET_CL_USERS |
9640 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9641 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9642 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9643 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9644 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9646 # LU-3446 changelog index reset on MDT restart
9647 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9648 CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9649 $LFS changelog_clear $MDT0 $USER 0
9650 stop $SINGLEMDS || error "Fail to stop MDT."
9651 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9652 CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9653 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9654 [ $CUR_REC1 == $CUR_REC2 ] ||
9655 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9657 echo "verifying user deregister"
9658 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9659 $GET_CL_USERS | grep -q $USER &&
9660 error "User $USER still in changelog_users"
9662 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9663 if [ $USERS -eq 0 ]; then
9664 LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9665 touch $DIR/$tdir/chloe
9666 LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9667 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9668 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9670 echo "$USERS other changelog users; can't verify off"
9673 run_test 160a "changelog sanity"
9675 test_160b() { # LU-3587
9676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9677 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9678 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9679 { skip "Need MDS version at least 2.2.0"; return; }
9681 local CL_USERS="mdd.$MDT0.changelog_users"
9682 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9683 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9684 echo "Registered as changelog user $USER"
9685 $GET_CL_USERS | grep -q $USER ||
9686 error "User $USER not found in changelog_users"
9688 local LONGNAME1=$(str_repeat a 255)
9689 local LONGNAME2=$(str_repeat b 255)
9692 echo "creating very long named file"
9693 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9694 echo "moving very long named file"
9695 mv $LONGNAME1 $LONGNAME2
9697 $LFS changelog $MDT0 | grep RENME
9699 echo "deregistering $USER"
9700 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9704 run_test 160b "Verify that very long rename doesn't crash in changelog"
9707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9708 test_mkdir -p -c1 $DIR/$tdir
9709 cp /etc/hosts $DIR/$tdir/$tfile
9710 test_mkdir -c1 $DIR/$tdir/foo1
9711 test_mkdir -c1 $DIR/$tdir/foo2
9712 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9713 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9714 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9715 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9716 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9717 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9718 $LFS fid2path $DIR $FID
9719 err17935 "bad link ea"
9722 rm $DIR/$tdir/foo2/zachary
9724 rm $DIR/$tdir/foo2/thor
9726 rm $DIR/$tdir/$tfile
9728 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9729 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9731 $LFS fid2path $DIR $FID
9732 err17935 "bad link rename"
9734 rm $DIR/$tdir/foo2/maggie
9737 local longname=filename_avg_len_is_thirty_two_
9738 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9739 error "failed to hardlink many files"
9740 links=$($LFS fid2path $DIR $FID | wc -l)
9741 echo -n "${links}/1000 links in link EA"
9742 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9743 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9744 error "failed to unlink many hardlinks"
9746 run_test 161a "link ea sanity"
9749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9750 [ $MDSCOUNT -lt 2 ] &&
9751 skip "skipping remote directory test" && return
9753 local remote_dir=$DIR/$tdir/remote_dir
9756 $LFS mkdir -i $MDTIDX $remote_dir ||
9757 error "create remote directory failed"
9759 cp /etc/hosts $remote_dir/$tfile
9760 mkdir -p $remote_dir/foo1
9761 mkdir -p $remote_dir/foo2
9762 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9763 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9764 ln $remote_dir/$tfile $remote_dir/foo1/luna
9765 ln $remote_dir/$tfile $remote_dir/foo2/thor
9767 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9769 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9770 $LFS fid2path $DIR $FID
9771 err17935 "bad link ea"
9774 rm $remote_dir/foo2/zachary
9776 rm $remote_dir/foo2/thor
9778 rm $remote_dir/$tfile
9780 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9781 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9782 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9783 $LFS fid2path $DIR $FID
9784 err17935 "bad link rename"
9786 rm $remote_dir/foo2/maggie
9789 local longname=filename_avg_len_is_thirty_two_
9790 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9791 error "failed to hardlink many files"
9792 links=$($LFS fid2path $DIR $FID | wc -l)
9793 echo -n "${links}/1000 links in link EA"
9794 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9795 unlinkmany $remote_dir/foo2/$longname 1000 ||
9796 error "failed to unlink many hardlinks"
9798 run_test 161b "link ea sanity under remote directory"
9801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9802 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
9803 skip "Need MDS version at least 2.1.5" && return
9805 # define CLF_RENAME_LAST 0x0001
9806 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
9807 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9808 changelog_register -n)
9811 touch $DIR/$tdir/foo_161c
9812 touch $DIR/$tdir/bar_161c
9813 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9814 $LFS changelog $MDT0 | grep RENME
9815 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
9817 $LFS changelog_clear $MDT0 $USER 0
9818 if [ x$flags != "x0x1" ]; then
9819 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9821 error "flag $flags is not 0x1"
9823 echo "rename overwrite a target having nlink = 1," \
9824 "changelog record has flags of $flags"
9826 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
9827 touch $DIR/$tdir/foo_161c
9828 touch $DIR/$tdir/bar_161c
9829 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9830 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9831 $LFS changelog $MDT0 | grep RENME
9832 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9833 $LFS changelog_clear $MDT0 $USER 0
9834 if [ x$flags != "x0x0" ]; then
9835 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9837 error "flag $flags is not 0x0"
9839 echo "rename overwrite a target having nlink > 1," \
9840 "changelog record has flags of $flags"
9842 # rename doesn't overwrite a target (changelog flag 0x0)
9843 touch $DIR/$tdir/foo_161c
9844 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
9845 $LFS changelog $MDT0 | grep RENME
9846 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9847 $LFS changelog_clear $MDT0 $USER 0
9848 if [ x$flags != "x0x0" ]; then
9849 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9851 error "flag $flags is not 0x0"
9853 echo "rename doesn't overwrite a target," \
9854 "changelog record has flags of $flags"
9856 # define CLF_UNLINK_LAST 0x0001
9857 # unlink a file having nlink = 1 (changelog flag 0x1)
9858 rm -f $DIR/$tdir/foo2_161c
9859 $LFS changelog $MDT0 | grep UNLNK
9860 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9861 $LFS changelog_clear $MDT0 $USER 0
9862 if [ x$flags != "x0x1" ]; then
9863 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9865 error "flag $flags is not 0x1"
9867 echo "unlink a file having nlink = 1," \
9868 "changelog record has flags of $flags"
9870 # unlink a file having nlink > 1 (changelog flag 0x0)
9871 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9872 rm -f $DIR/$tdir/foobar_161c
9873 $LFS changelog $MDT0 | grep UNLNK
9874 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9875 $LFS changelog_clear $MDT0 $USER 0
9876 if [ x$flags != "x0x0" ]; then
9877 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9879 error "flag $flags is not 0x0"
9881 echo "unlink a file having nlink > 1," \
9882 "changelog record has flags of $flags"
9883 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9885 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
9892 local path=$(${LFS} fid2path $*)
9895 if [ $RC -ne 0 ]; then
9896 err17935 "path looked up of $expected failed. Error $RC"
9898 elif [ "${path}" != "${expected}" ]; then
9899 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9902 echo "fid $fid resolves to path $path (expected $expected)"
9906 # Make changes to filesystem
9907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9908 test_mkdir -p $DIR/$tdir/d2
9909 touch $DIR/$tdir/d2/$tfile
9910 touch $DIR/$tdir/d2/x1
9911 touch $DIR/$tdir/d2/x2
9912 test_mkdir -p $DIR/$tdir/d2/a/b/c
9913 test_mkdir -p $DIR/$tdir/d2/p/q/r
9915 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9916 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9919 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9920 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9921 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9923 # softlink to wrong file
9924 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9925 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9926 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9929 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9930 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9931 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9932 # fid2path dir/fsname should both work
9933 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9934 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9936 # hardlink count: check that there are 2 links
9937 # Doesnt work with CMD yet: 17935
9938 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9939 err17935 "expected 2 links"
9941 # hardlink indexing: remove the first link
9942 rm $DIR/$tdir/d2/p/q/r/hlink
9943 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9947 run_test 162 "path lookup sanity"
9950 # do directio so as not to populate the page cache
9951 log "creating a 10 Mb file"
9952 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9953 log "starting reads"
9954 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9955 log "truncating the file"
9956 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9958 kill %+ || true # reads might have finished
9959 echo "wait until dd is finished"
9961 log "removing the temporary file"
9962 rm -rf $DIR/$tfile || error "tmp file removal failed"
9964 run_test 169 "parallel read and truncate should not deadlock"
9967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9968 $LCTL clear # bug 18514
9969 $LCTL debug_daemon start $TMP/${tfile}_log_good
9971 $LCTL debug_daemon stop
9972 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9973 error "sed failed to read log_good"
9975 $LCTL debug_daemon start $TMP/${tfile}_log_good
9977 $LCTL debug_daemon stop
9979 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9980 error "lctl df log_bad failed"
9982 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9983 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9985 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9986 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9988 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9989 error "bad_line good_line1 good_line2 are empty"
9991 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9992 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9993 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9995 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9996 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9997 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9999 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10000 error "bad_line_new good_line_new are empty"
10002 local expected_good=$((good_line1 + good_line2*2))
10004 rm -f $TMP/${tfile}*
10005 # LU-231, short malformed line may not be counted into bad lines
10006 if [ $bad_line -ne $bad_line_new ] &&
10007 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10008 error "expected $bad_line bad lines, but got $bad_line_new"
10012 if [ $expected_good -ne $good_line_new ]; then
10013 error "expected $expected_good good lines, but got $good_line_new"
10018 run_test 170 "test lctl df to handle corrupted log ====================="
10020 test_171() { # bug20592
10021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10022 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10023 $LCTL set_param fail_loc=0x50e
10024 $LCTL set_param fail_val=3000
10025 multiop_bg_pause $DIR/$tfile O_s || true
10027 kill -USR1 $MULTIPID
10031 if dmesg | grep "recursive fault"; then
10032 error "caught a recursive fault"
10034 $LCTL set_param fail_loc=0
10037 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10039 # it would be good to share it with obdfilter-survey/libecho code
10040 setup_obdecho_osc () {
10043 local obdfilter_name=$2
10044 echo "Creating new osc for $obdfilter_name on $ost_nid"
10045 # make sure we can find loopback nid
10046 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10048 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10049 ${obdfilter_name}_osc_UUID || rc=2; }
10050 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10051 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10055 cleanup_obdecho_osc () {
10056 local obdfilter_name=$1
10057 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10058 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10065 local pages=${3:-64}
10070 local obd_size=$(get_obd_size $node $OBD)
10071 local page_size=$(get_page_size $node)
10072 if [[ -n "$obd_size" ]]; then
10073 local new_count=$((obd_size / (pages * page_size / 1024)))
10074 [[ $new_count -ge $count ]] || count=$new_count
10077 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10078 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10080 if [ $rc -eq 0 ]; then
10081 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10082 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10084 echo "New object id is $id"
10085 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10087 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10088 "test_brw $count w v $pages $id" || rc=4; }
10089 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10091 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10092 "cleanup" || rc=5; }
10093 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10094 "detach" || rc=6; }
10095 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10101 remote_ost_nodsh && skip "remote OST with nodsh" && return
10103 local rmmod_local=0
10105 if ! module_loaded obdecho; then
10106 load_module obdecho/obdecho
10110 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10111 local host=$(lctl get_param -n osc.$osc.import |
10112 awk '/current_connection:/ {print $2}' )
10113 local target=$(lctl get_param -n osc.$osc.import |
10114 awk '/target:/ {print $2}' )
10115 target=${target%_UUID}
10117 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10118 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10119 [[ -n $target ]] && cleanup_obdecho_osc $target
10120 [ $rmmod_local -eq 1 ] && rmmod obdecho
10123 run_test 180a "test obdecho on osc"
10126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10127 remote_ost_nodsh && skip "remote OST with nodsh" && return
10129 local rmmod_remote=0
10131 do_facet ost1 "lsmod | grep -q obdecho || " \
10132 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10133 "modprobe obdecho; }" && rmmod_remote=1
10134 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10135 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10136 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10139 run_test 180b "test obdecho directly on obdfilter"
10141 test_180c() { # LU-2598
10142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10143 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10144 skip "Need MDS version at least 2.4.0" && return
10147 local rmmod_remote=false
10148 local pages=16384 # 64MB bulk I/O RPC size
10151 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10152 rmmod_remote=true || error "failed to load module obdecho"
10154 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4}'|head -1)
10155 if [[ -n $target ]]; then
10156 obdecho_test "$target" ost1 "$pages" ||
10157 rc=${PIPESTATUS[0]}
10159 echo "there is no obdfilter target on ost1"
10162 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10165 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10167 test_181() { # bug 22177
10168 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10169 # create enough files to index the directory
10170 createmany -o $DIR/$tdir/foobar 4000
10171 # print attributes for debug purpose
10174 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10176 # remove the files & current working dir
10177 unlinkmany $DIR/$tdir/foobar 4000
10179 kill -USR1 $MULTIPID
10181 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10184 run_test 181 "Test open-unlinked dir ========================"
10187 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10188 # disable MDC RPC lock wouldn't crash client
10192 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10193 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10194 $LCTL set_param fail_loc=0x804
10196 for (( i=0; i < $tcount; i++ )) ; do
10197 mkdir $DIR/$tdir/$i
10198 createmany -o $DIR/$tdir/$i/f- $fcount &
10202 for (( i=0; i < $tcount; i++ )) ; do
10203 unlinkmany $DIR/$tdir/$i/f- $fcount &
10209 $LCTL set_param fail_loc=0
10211 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10213 test_183() { # LU-2275
10214 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10215 skip "Need MDS version at least 2.3.56" && return
10217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10218 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10219 echo aaa > $DIR/$tdir/$tfile
10221 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10222 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10224 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10225 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10227 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10229 # Flush negative dentry cache
10230 touch $DIR/$tdir/$tfile
10232 # We are not checking for any leaked references here, they'll
10233 # become evident next time we do cleanup with module unload.
10236 run_test 183 "No crash or request leak in case of strange dispositions ========"
10238 # test suite 184 is for LU-2016, LU-2017
10240 check_swap_layouts_support && return 0
10242 dir0=$DIR/$tdir/$testnum
10243 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10248 $SETSTRIPE -c1 $file1
10250 $SETSTRIPE -c2 $file2
10252 gen1=$($GETSTRIPE -g $file1)
10253 gen2=$($GETSTRIPE -g $file2)
10255 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10256 gen=$($GETSTRIPE -g $file1)
10257 [[ $gen1 != $gen ]] ||
10258 "Layout generation on $file1 does not change"
10259 gen=$($GETSTRIPE -g $file2)
10260 [[ $gen2 != $gen ]] ||
10261 "Layout generation on $file2 does not change"
10263 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10264 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10266 run_test 184a "Basic layout swap"
10269 check_swap_layouts_support && return 0
10271 dir0=$DIR/$tdir/$testnum
10272 mkdir -p $dir0 || error "creating dir $dir0"
10279 $SETSTRIPE -c1 $file1
10280 $SETSTRIPE -c2 $file2
10281 $SETSTRIPE -c1 $file3
10282 chown $RUNAS_ID $file3
10283 gen1=$($GETSTRIPE -g $file1)
10284 gen2=$($GETSTRIPE -g $file2)
10286 $LFS swap_layouts $dir1 $dir2 &&
10287 error "swap of directories layouts should fail"
10288 $LFS swap_layouts $dir1 $file1 &&
10289 error "swap of directory and file layouts should fail"
10290 $RUNAS $LFS swap_layouts $file1 $file2 &&
10291 error "swap of file we cannot write should fail"
10292 $LFS swap_layouts $file1 $file3 &&
10293 error "swap of file with different owner should fail"
10294 /bin/true # to clear error code
10296 run_test 184b "Forbidden layout swap (will generate errors)"
10299 check_swap_layouts_support && return 0
10301 local dir0=$DIR/$tdir/$testnum
10302 mkdir -p $dir0 || error "creating dir $dir0"
10304 local ref1=$dir0/ref1
10305 local ref2=$dir0/ref2
10306 local file1=$dir0/file1
10307 local file2=$dir0/file2
10308 # create a file large enough for the concurent test
10309 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10310 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10311 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
10314 dd if=$ref1 of=$file1 bs=16k &
10317 # Make sure dd starts to copy file
10318 while [ ! -f $file1 ]; do sleep 0.1; done
10320 $LFS swap_layouts $file1 $file2
10323 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10324 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10326 # how many bytes copied before swapping layout
10327 local copied=`stat -c %s $file2`
10328 local remaining=`stat -c %s $ref1`
10329 remaining=$((remaining - copied))
10330 echo "Copied $copied bytes before swapping layout..."
10332 cmp -n $copied $file1 $ref2 | grep differ &&
10333 error "Content mismatch [0, $copied) of ref2 and file1"
10334 cmp -n $copied $file2 $ref1 ||
10335 error "Content mismatch [0, $copied) of ref1 and file2"
10336 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10337 error "Content mismatch [$copied, EOF) of ref1 and file1"
10340 rm -f $ref1 $ref2 $file1 $file2
10342 run_test 184c "Concurrent write and layout swap"
10345 check_swap_layouts_support && return 0
10347 local file1=$DIR/$tdir/$tfile-1
10348 local file2=$DIR/$tdir/$tfile-2
10349 local file3=$DIR/$tdir/$tfile-3
10353 mkdir -p $DIR/$tdir
10354 touch $file1 || error "create $file1 failed"
10355 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10356 error "create $file2 failed"
10357 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10358 error "create $file3 failed"
10359 lovea1=$($LFS getstripe $file1 | sed 1d)
10361 $LFS swap_layouts $file2 $file3 ||
10362 error "swap $file2 $file3 layouts failed"
10363 $LFS swap_layouts $file1 $file2 ||
10364 error "swap $file1 $file2 layouts failed"
10366 lovea2=$($LFS getstripe $file2 | sed 1d)
10367 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10369 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10370 [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
10372 run_test 184d "allow stripeless layouts swap"
10375 test_185() { # LU-2441
10376 # LU-3553 - no volatile file support in old servers
10377 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10378 { skip "Need MDS version at least 2.3.60"; return 0; }
10380 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10381 touch $DIR/$tdir/spoo
10382 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10383 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10384 error "cannot create/write a volatile file"
10385 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10386 error "FID is still valid after close"
10388 multiop_bg_pause $DIR/$tdir vVw4096_c
10395 # assume that the next FID for this client is sequential, since stdout
10396 # is unfortunately eaten by multiop_bg_pause
10397 local n=$((${fidv[1]} + 1))
10398 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10399 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10400 error "FID is missing before close"
10401 kill -USR1 $multi_pid
10402 # 1 second delay, so if mtime change we will see it
10404 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10405 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10407 run_test 185 "Volatile file support"
10410 local dir0=$DIR/$tdir/$testnum
10411 mkdir -p $dir0 || error "creating dir $dir0"
10413 local file=$dir0/file1
10414 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10415 local dv1=$($LFS data_version $file)
10416 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10417 local dv2=$($LFS data_version $file)
10418 [[ $dv1 != $dv2 ]] ||
10419 error "data version did not change on write $dv1 == $dv2"
10424 run_test 187a "Test data version change"
10427 local dir0=$DIR/$tdir/$testnum
10428 mkdir -p $dir0 || error "creating dir $dir0"
10430 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10431 [[ ${DV[0]} != ${DV[1]} ]] ||
10432 error "data version did not change on write"\
10433 " ${DV[0]} == ${DV[1]}"
10438 run_test 187b "Test data version change on volatile file"
10441 check_file_in_pool()
10446 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10449 for t in $tlist ; do
10450 [ "$i" -eq "$t" ] && continue 2
10453 echo "pool list: $tlist"
10454 echo "striping: $res"
10455 error_noexit "$file not allocated in $pool"
10462 echo "Creating new pool"
10465 create_pool $FSNAME.$pool ||
10466 { error_noexit "No pool created, result code $?"; return 1; }
10467 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10468 { error_noexit "$pool not in lfs pool_list"; return 2; }
10471 pool_add_targets() {
10472 echo "Adding targets to pool"
10478 local list=$(seq $first $step $last)
10480 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10481 do_facet mgs $LCTL pool_add \
10482 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10483 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10484 | sort -u | tr '\n' ' ' " "$t" || {
10485 error_noexit "Add to pool failed"
10488 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10489 local addcount=$(((last - first) / step + 1))
10490 [ $lfscount -eq $addcount ] || {
10491 error_noexit "lfs pool_list bad ost count" \
10492 "$lfscount != $addcount"
10500 echo "Setting pool on directory $tdir"
10502 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10504 error_noexit "Cannot set pool $pool to $tdir"
10511 echo "Checking pool on directory $tdir"
10513 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10514 [ "$res" = "$pool" ] && return 0
10516 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10520 pool_dir_rel_path() {
10521 echo "Testing relative path works well"
10526 mkdir -p $root/$tdir/$tdir
10528 pool_set_dir $pool $tdir || return 1
10529 pool_set_dir $pool ./$tdir || return 2
10530 pool_set_dir $pool ../$tdir || return 3
10531 pool_set_dir $pool ../$tdir/$tdir || return 4
10532 rm -rf $tdir; cd - > /dev/null
10535 pool_alloc_files() {
10536 echo "Checking files allocation from directory pool"
10543 for i in $(seq -w 1 $count)
10545 local file=$tdir/file-$i
10547 check_file_in_pool $file $pool "$tlist" || \
10548 failed=$((failed + 1))
10550 [ "$failed" = 0 ] && return 0
10552 error_noexit "$failed files not allocated in $pool"
10556 pool_create_files() {
10557 echo "Creating files in pool"
10565 for i in $(seq -w 1 $count)
10567 local file=$tdir/spoo-$i
10568 $SETSTRIPE -p $pool $file
10569 check_file_in_pool $file $pool "$tlist" || \
10570 failed=$((failed + 1))
10572 [ "$failed" = 0 ] && return 0
10574 error_noexit "$failed files not allocated in $pool"
10579 echo "Checking 'lfs df' output"
10582 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10584 local res=$($LFS df --pool $FSNAME.$pool |
10586 grep "$FSNAME-OST" |
10588 [ "$res" = "$t" ] && return 0
10590 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10594 pool_file_rel_path() {
10595 echo "Creating files in a pool with relative pathname"
10600 { error_noexit "unable to create $tdir"; return 1 ; }
10601 local file="/..$tdir/$tfile-1"
10602 $SETSTRIPE -p $pool $file ||
10603 { error_noexit "unable to create $file" ; return 2 ; }
10606 $SETSTRIPE -p $pool $tfile-2 || {
10607 error_noexit "unable to create $tfile-2 in $tdir"
10612 pool_remove_first_target() {
10613 echo "Removing first target from a pool"
10616 local pname="lov.$FSNAME-*.pools.$pool"
10617 local t=$($LCTL get_param -n $pname | head -1)
10618 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10619 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10620 error_noexit "$t not removed from $FSNAME.$pool"
10625 pool_remove_all_targets() {
10626 echo "Removing all targets from pool"
10629 local pname="lov.$FSNAME-*.pools.$pool"
10630 for t in $($LCTL get_param -n $pname | sort -u)
10632 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10634 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10635 error_noexit "Pool $FSNAME.$pool cannot be drained"
10638 # striping on an empty/nonexistant pool should fall back
10639 # to "pool of everything"
10641 error_noexit "failed to use fallback striping for empty pool"
10644 # setstripe on an empty pool should fail
10645 $SETSTRIPE -p $pool $file 2>/dev/null && {
10646 error_noexit "expected failure when creating file" \
10654 echo "Destroying pool"
10658 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10661 # striping on an empty/nonexistant pool should fall back
10662 # to "pool of everything"
10664 error_noexit "failed to use fallback striping for missing pool"
10667 # setstripe on an empty pool should fail
10668 $SETSTRIPE -p $pool $file 2>/dev/null && {
10669 error_noexit "expected failure when creating file" \
10670 "with missing pool"
10674 # get param should return err once pool is gone
10675 if wait_update $HOSTNAME "lctl get_param -n \
10676 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10678 remove_pool_from_list $FSNAME.$pool
10681 error_noexit "Pool $FSNAME.$pool is not destroyed"
10686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10687 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10689 local POOL=${POOL:-cea1}
10690 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10691 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10694 local last_ost=$(($OSTCOUNT - 1))
10696 local ost_list=$(seq $first_ost $ost_step $last_ost)
10697 local ost_range="$first_ost $last_ost $ost_step"
10698 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10699 local file_dir=$POOL_ROOT/file_tst
10703 # former test_200a test_200b
10704 pool_add $POOL || { rc=$? ; break; }
10705 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10706 # former test_200c test_200d
10707 mkdir -p $test_path
10708 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10709 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10710 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10711 || { rc=$? ; break; }
10712 # former test_200e test_200f
10713 local files=$((OSTCOUNT*3))
10714 pool_alloc_files $POOL $test_path $files "$ost_list" \
10715 || { rc=$? ; break; }
10716 pool_create_files $POOL $file_dir $files "$ost_list" \
10717 || { rc=$? ; break; }
10718 # former test_200g test_200h
10719 pool_lfs_df $POOL || { rc=$? ; break; }
10720 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10722 # former test_201a test_201b test_201c
10723 pool_remove_first_target $POOL || { rc=$? ; break; }
10725 local f=$test_path/$tfile
10726 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10727 pool_remove $POOL $f || { rc=$? ; break; }
10734 run_test 200 "OST pools"
10736 # usage: default_attr <count | size | offset>
10738 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10741 # usage: check_default_stripe_attr
10742 check_default_stripe_attr() {
10743 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10745 --stripe-count|--count)
10746 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10747 --stripe-size|--size)
10748 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10749 --stripe-index|--index)
10752 error "unknown getstripe attr '$1'"
10755 [ $ACTUAL != $EXPECTED ] &&
10756 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10760 test_mkdir -p $DIR/$tdir
10761 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10763 check_default_stripe_attr --stripe-count
10764 check_default_stripe_attr --stripe-size
10765 check_default_stripe_attr --stripe-index
10769 run_test 204a "Print default stripe attributes ================="
10772 test_mkdir -p $DIR/$tdir
10773 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10775 check_default_stripe_attr --stripe-size
10776 check_default_stripe_attr --stripe-index
10780 run_test 204b "Print default stripe size and offset ==========="
10783 test_mkdir -p $DIR/$tdir
10784 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10786 check_default_stripe_attr --stripe-count
10787 check_default_stripe_attr --stripe-index
10791 run_test 204c "Print default stripe count and offset ==========="
10794 test_mkdir -p $DIR/$tdir
10795 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10797 check_default_stripe_attr --stripe-count
10798 check_default_stripe_attr --stripe-size
10802 run_test 204d "Print default stripe count and size ============="
10805 test_mkdir -p $DIR/$tdir
10806 $SETSTRIPE -d $DIR/$tdir
10808 check_default_stripe_attr --stripe-count --raw
10809 check_default_stripe_attr --stripe-size --raw
10810 check_default_stripe_attr --stripe-index --raw
10814 run_test 204e "Print raw stripe attributes ================="
10817 test_mkdir -p $DIR/$tdir
10818 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10820 check_default_stripe_attr --stripe-size --raw
10821 check_default_stripe_attr --stripe-index --raw
10825 run_test 204f "Print raw stripe size and offset ==========="
10828 test_mkdir -p $DIR/$tdir
10829 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10831 check_default_stripe_attr --stripe-count --raw
10832 check_default_stripe_attr --stripe-index --raw
10836 run_test 204g "Print raw stripe count and offset ==========="
10839 test_mkdir -p $DIR/$tdir
10840 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10842 check_default_stripe_attr --stripe-count --raw
10843 check_default_stripe_attr --stripe-size --raw
10847 run_test 204h "Print raw stripe count and size ============="
10849 # Figure out which job scheduler is being used, if any,
10850 # or use a fake one
10851 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10852 JOBENV=SLURM_JOB_ID
10853 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10855 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10857 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10858 JOBENV=LOADL_STEP_ID
10859 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10865 verify_jobstats() {
10869 # clear old jobstats
10870 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10871 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10873 # use a new JobID for this test, or we might see an old one
10874 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10878 log "Using JobID environment variable $JOBENV=$JOBVAL"
10880 if [ $JOBENV = "FAKE_JOBID" ]; then
10881 FAKE_JOBID=$JOBVAL $cmd
10886 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10887 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10888 do_facet $FACET lctl get_param mdt.*.job_stats |
10889 grep $JOBVAL || error "No job stats found on MDT $FACET"
10891 if [ "$target" = "ost" -o "$target" = "both" ]; then
10893 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10894 grep $JOBVAL || error "No job stats found on OST $FACET"
10900 NEW_JOBENV=${1:-$OLD_JOBENV}
10901 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10902 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10905 test_205() { # Job stats
10906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10907 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10908 skip "Server doesn't support jobstats" && return 0
10911 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10912 if [ $OLD_JOBENV != $JOBENV ]; then
10913 jobstats_set $JOBENV
10914 trap jobstats_set EXIT
10918 cmd="mkdir $DIR/$tfile"
10919 verify_jobstats "$cmd" "mdt"
10921 cmd="rm -fr $DIR/$tfile"
10922 verify_jobstats "$cmd" "mdt"
10924 cmd="mknod $DIR/$tfile c 1 3"
10925 verify_jobstats "$cmd" "mdt"
10927 cmd="rm -f $DIR/$tfile"
10928 verify_jobstats "$cmd" "mdt"
10930 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10931 verify_jobstats "$cmd" "mdt"
10933 cmd="touch $DIR/$tfile"
10934 verify_jobstats "$cmd" "both"
10936 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10937 verify_jobstats "$cmd" "ost"
10939 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10940 verify_jobstats "$cmd" "ost"
10942 cmd="$TRUNCATE $DIR/$tfile 0"
10943 verify_jobstats "$cmd" "both"
10945 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10946 verify_jobstats "$cmd" "mdt"
10949 rm -f $DIR/jobstats_test_rename
10951 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10953 run_test 205 "Verify job stats"
10955 # LU-1480, LU-1773 and LU-1657
10957 mkdir -p $DIR/$tdir
10958 lfs setstripe -c -1 $DIR/$tdir
10959 #define OBD_FAIL_LOV_INIT 0x1403
10960 $LCTL set_param fail_loc=0xa0001403
10961 $LCTL set_param fail_val=1
10962 touch $DIR/$tdir/$tfile || true
10964 run_test 206 "fail lov_init_raid0() doesn't lbug"
10967 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10968 local fsz=`stat -c %s $DIR/$tfile`
10969 cancel_lru_locks mdc
10971 # do not return layout in getattr intent
10972 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10973 $LCTL set_param fail_loc=0x170
10974 local sz=`stat -c %s $DIR/$tfile`
10976 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
10980 run_test 207a "can refresh layout at glimpse"
10983 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10984 local cksum=`md5sum $DIR/$tfile`
10985 local fsz=`stat -c %s $DIR/$tfile`
10986 cancel_lru_locks mdc
10987 cancel_lru_locks osc
10989 # do not return layout in getattr intent
10990 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
10991 $LCTL set_param fail_loc=0x171
10993 # it will refresh layout after the file is opened but before read issues
10994 echo checksum is "$cksum"
10995 echo "$cksum" |md5sum -c --quiet || error "file differs"
10999 run_test 207b "can refresh layout at open"
11002 # FIXME: in this test suite, only RD lease is used. This is okay
11003 # for now as only exclusive open is supported. After generic lease
11004 # is done, this test suite should be revised. - Jinshan
11006 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11007 { skip "Need MDS version at least 2.4.52"; return 0; }
11009 echo "==== test 1: verify get lease work"
11010 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11012 echo "==== test 2: verify lease can be broken by upcoming open"
11013 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11017 $MULTIOP $DIR/$tfile oO_RDONLY:c
11018 kill -USR1 $PID && wait $PID || error "break lease error"
11020 echo "==== test 3: verify lease can't be granted if an open already exists"
11021 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11025 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11026 kill -USR1 $PID && wait $PID || error "open file error"
11028 echo "==== test 4: lease can sustain over recovery"
11029 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11035 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11037 echo "==== test 5: lease broken can't be regained by replay"
11038 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11042 # open file to break lease and then recovery
11043 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11046 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11050 run_test 208 "Exclusive open"
11053 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11054 skip_env "must have disp_stripe" && return
11057 sync; sleep 5; sync;
11059 echo 3 > /proc/sys/vm/drop_caches
11060 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11062 # open/close 500 times
11063 for i in $(seq 500); do
11067 echo 3 > /proc/sys/vm/drop_caches
11068 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11070 echo "before: $req_before, after: $req_after"
11071 [ $((req_after - req_before)) -ge 300 ] &&
11072 error "open/close requests are not freed"
11075 run_test 209 "read-only open/close requests should be freed promptly"
11079 size=$((size % 8192 + 1))
11080 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11081 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11082 rm -f $DIR/f212 $DIR/f212.xyz
11084 run_test 212 "Sendfile test ============================================"
11087 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11088 cancel_lru_locks osc
11089 lctl set_param fail_loc=0x8000040f
11090 # generate a read lock
11091 cat $DIR/$tfile > /dev/null
11092 # write to the file, it will try to cancel the above read lock.
11093 cat /etc/hosts >> $DIR/$tfile
11095 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11097 test_214() { # for bug 20133
11098 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11099 for (( i=0; i < 340; i++ )) ; do
11100 touch $DIR/$tdir/d214c/a$i
11103 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11104 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11105 ls $DIR/d214c || error "ls $DIR/d214c failed"
11106 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11107 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11109 run_test 214 "hash-indexed directory test - bug 20133"
11111 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11112 create_lnet_proc_files() {
11113 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11114 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11116 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11117 rm -f "$TMP/lnet_$1.sys_tmp"
11120 # counterpart of create_lnet_proc_files
11121 remove_lnet_proc_files() {
11122 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11125 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11126 # 3rd arg as regexp for body
11127 check_lnet_proc_stats() {
11128 local l=$(cat "$TMP/lnet_$1" |wc -l)
11129 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11131 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11134 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11135 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11136 # optional and can be regexp for 2nd line (lnet.routes case)
11137 check_lnet_proc_entry() {
11138 local blp=2 # blp stands for 'position of 1st line of body'
11139 [ "$5" = "" ] || blp=3 # lnet.routes case
11141 local l=$(cat "$TMP/lnet_$1" |wc -l)
11142 # subtracting one from $blp because the body can be empty
11143 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11145 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11146 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11148 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11149 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11151 # bail out if any unexpected line happened
11152 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
11153 [ "$?" != 0 ] || error "$2 misformatted"
11156 test_215() { # for bugs 18102, 21079, 21517
11157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11158 local N='(0|[1-9][0-9]*)' # non-negative numeric
11159 local P='[1-9][0-9]*' # positive numeric
11160 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11161 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11162 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11163 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11165 local L1 # regexp for 1st line
11166 local L2 # regexp for 2nd line (optional)
11167 local BR # regexp for the rest (body)
11169 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11170 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11171 create_lnet_proc_files "stats"
11172 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11173 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11174 remove_lnet_proc_files "stats"
11176 # /proc/sys/lnet/routes should look like this:
11177 # Routing disabled/enabled
11178 # net hops priority state router
11179 # where net is a string like tcp0, hops > 0, priority >= 0,
11180 # state is up/down,
11181 # router is a string like 192.168.1.1@tcp2
11182 L1="^Routing (disabled|enabled)$"
11183 L2="^net +hops +priority +state +router$"
11184 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11185 create_lnet_proc_files "routes"
11186 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11187 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11188 remove_lnet_proc_files "routes"
11190 # /proc/sys/lnet/routers should look like this:
11191 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11192 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11193 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11194 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11195 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11196 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11197 create_lnet_proc_files "routers"
11198 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11199 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11200 remove_lnet_proc_files "routers"
11202 # /proc/sys/lnet/peers should look like this:
11203 # nid refs state last max rtr min tx min queue
11204 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11205 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11206 # numeric (0 or >0 or <0), queue >= 0.
11207 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11208 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11209 create_lnet_proc_files "peers"
11210 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11211 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11212 remove_lnet_proc_files "peers"
11214 # /proc/sys/lnet/buffers should look like this:
11215 # pages count credits min
11216 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11217 L1="^pages +count +credits +min$"
11218 BR="^ +$N +$N +$I +$I$"
11219 create_lnet_proc_files "buffers"
11220 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11221 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11222 remove_lnet_proc_files "buffers"
11224 # /proc/sys/lnet/nis should look like this:
11225 # nid status alive refs peer rtr max tx min
11226 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11227 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11228 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11229 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11230 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11231 create_lnet_proc_files "nis"
11232 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11233 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11234 remove_lnet_proc_files "nis"
11236 # can we successfully write to /proc/sys/lnet/stats?
11237 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11238 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11240 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11242 test_216() { # bug 20317
11243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11244 remote_ost_nodsh && skip "remote OST with nodsh" && return
11247 local facets=$(get_facets OST)
11248 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11250 save_lustre_params client "osc.*.contention_seconds" > $p
11251 save_lustre_params $facets \
11252 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11253 save_lustre_params $facets \
11254 "ldlm.namespaces.filter-*.contended_locks" >> $p
11255 save_lustre_params $facets \
11256 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11259 # agressive lockless i/o settings
11260 for node in $(osts_nodes); do
11261 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'
11263 lctl set_param -n osc.*.contention_seconds 60
11265 $DIRECTIO write $DIR/$tfile 0 10 4096
11266 $CHECKSTAT -s 40960 $DIR/$tfile
11268 # disable lockless i/o
11269 for node in $(osts_nodes); do
11270 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'
11272 lctl set_param -n osc.*.contention_seconds 0
11275 dd if=/dev/zero of=$DIR/$tfile count=0
11276 $CHECKSTAT -s 0 $DIR/$tfile
11278 restore_lustre_params <$p
11282 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11284 test_217() { # bug 22430
11285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11289 for node in $(nodes_list); do
11290 nid=$(host_nids_address $node $NETTYPE)
11291 if [[ $nid = *-* ]] ; then
11292 echo "lctl ping $nid@$NETTYPE"
11293 lctl ping $nid@$NETTYPE
11295 echo "skipping $node (no hyphen detected)"
11299 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11302 # do directio so as not to populate the page cache
11303 log "creating a 10 Mb file"
11304 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11305 log "starting reads"
11306 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11307 log "truncating the file"
11308 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11310 kill %+ || true # reads might have finished
11311 echo "wait until dd is finished"
11313 log "removing the temporary file"
11314 rm -rf $DIR/$tfile || error "tmp file removal failed"
11316 run_test 218 "parallel read and truncate should not deadlock ======================="
11319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11320 # write one partial page
11321 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11322 # set no grant so vvp_io_commit_write will do sync write
11323 $LCTL set_param fail_loc=0x411
11324 # write a full page at the end of file
11325 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11327 $LCTL set_param fail_loc=0
11328 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11329 $LCTL set_param fail_loc=0x411
11330 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11333 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11334 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11336 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11338 test_220() { #LU-325
11339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11340 remote_ost_nodsh && skip "remote OST with nodsh" && return
11343 test_mkdir -p $DIR/$tdir
11344 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11345 awk '{print $2}' | sed -e 's/_UUID$//')
11348 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11349 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11350 osc.$mdtosc_proc1.prealloc_last_id)
11351 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11352 osc.$mdtosc_proc1.prealloc_next_id)
11356 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11357 #define OBD_FAIL_OST_ENOINO 0x229
11358 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11359 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11360 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11362 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11364 MDSOBJS=$((last_id - next_id))
11365 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11367 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11368 echo "OST still has $count kbytes free"
11370 echo "create $MDSOBJS files @next_id..."
11371 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11373 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11374 osc.$mdtosc_proc1.prealloc_last_id)
11375 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11376 osc.$mdtosc_proc1.prealloc_next_id)
11378 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11383 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11384 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11386 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11387 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11388 echo "unlink $MDSOBJS files @$next_id..."
11389 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11391 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11395 dd if=`which date` of=$MOUNT/date oflag=sync
11396 chmod +x $MOUNT/date
11398 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11399 $LCTL set_param fail_loc=0x80001401
11401 $MOUNT/date > /dev/null
11404 run_test 221 "make sure fault and truncate race to not cause OOM"
11407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11409 test_mkdir -p $DIR/$tdir
11410 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11411 createmany -o $DIR/$tdir/$tfile 10
11412 cancel_lru_locks mdc
11413 cancel_lru_locks osc
11414 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11415 $LCTL set_param fail_loc=0x31a
11416 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11417 $LCTL set_param fail_loc=0
11420 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11425 test_mkdir -p $DIR/$tdir
11426 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11427 createmany -o $DIR/$tdir/$tfile 10
11428 cancel_lru_locks mdc
11429 cancel_lru_locks osc
11430 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11431 $LCTL set_param fail_loc=0x31a
11432 rm -r $DIR/$tdir || "AGL for rmdir failed"
11433 $LCTL set_param fail_loc=0
11435 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11440 test_mkdir -p $DIR/$tdir
11441 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11442 createmany -o $DIR/$tdir/$tfile 10
11443 cancel_lru_locks mdc
11444 cancel_lru_locks osc
11445 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11446 $LCTL set_param fail_loc=0x31b
11447 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11448 $LCTL set_param fail_loc=0
11451 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11453 test_224a() { # LU-1039, MRP-303
11454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11455 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11456 $LCTL set_param fail_loc=0x508
11457 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11458 $LCTL set_param fail_loc=0
11461 run_test 224a "Don't panic on bulk IO failure"
11463 test_224b() { # LU-1039, MRP-303
11464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11465 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11466 cancel_lru_locks osc
11467 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11468 $LCTL set_param fail_loc=0x515
11469 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11470 $LCTL set_param fail_loc=0
11473 run_test 224b "Don't panic on bulk IO failure"
11475 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11478 if [ -z ${MDSSURVEY} ]; then
11479 skip_env "mds-survey not found" && return
11482 [ $MDSCOUNT -ge 2 ] &&
11483 skip "skipping now for more than one MDT" && return
11485 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11486 { skip "Need MDS version at least 2.2.51"; return; }
11488 local mds=$(facet_host $SINGLEMDS)
11489 local target=$(do_nodes $mds 'lctl dl' | \
11490 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11492 local cmd1="file_count=1000 thrhi=4"
11493 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11494 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11495 local cmd="$cmd1 $cmd2 $cmd3"
11497 rm -f ${TMP}/mds_survey*
11499 eval $cmd || error "mds-survey with zero-stripe failed"
11500 cat ${TMP}/mds_survey*
11501 rm -f ${TMP}/mds_survey*
11503 run_test 225a "Metadata survey sanity with zero-stripe"
11506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11508 if [ -z ${MDSSURVEY} ]; then
11509 skip_env "mds-survey not found" && return
11511 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11512 { skip "Need MDS version at least 2.2.51"; return; }
11514 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11515 skip_env "Need to mount OST to test" && return
11518 [ $MDSCOUNT -ge 2 ] &&
11519 skip "skipping now for more than one MDT" && return
11520 local mds=$(facet_host $SINGLEMDS)
11521 local target=$(do_nodes $mds 'lctl dl' | \
11522 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11524 local cmd1="file_count=1000 thrhi=4"
11525 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11526 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11527 local cmd="$cmd1 $cmd2 $cmd3"
11529 rm -f ${TMP}/mds_survey*
11531 eval $cmd || error "mds-survey with stripe_count failed"
11532 cat ${TMP}/mds_survey*
11533 rm -f ${TMP}/mds_survey*
11535 run_test 225b "Metadata survey sanity with stripe_count = 1"
11537 mcreate_path2fid () {
11543 local path=$DIR/$tdir/$name
11548 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11549 error "cannot create $desc"
11551 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11553 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11555 fid_path=$($LFS fid2path $MOUNT $fid)
11557 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11559 [ "$path" == "$fid_path" ] ||
11560 error "fid2path returned $fid_path, expected $path"
11562 echo "pass with $path and $fid"
11567 mkdir -p $DIR/$tdir
11569 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11570 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11571 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11572 mcreate_path2fid 0040666 0 0 dir "directory"
11573 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11574 mcreate_path2fid 0100666 0 0 file "regular file"
11575 mcreate_path2fid 0120666 0 0 link "symbolic link"
11576 mcreate_path2fid 0140666 0 0 sock "socket"
11578 run_test 226a "call path2fid and fid2path on files of all type"
11581 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11585 mkdir -p $DIR/$tdir
11586 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11587 error "create remote directory failed"
11588 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11589 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11590 "character special file (null)"
11591 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11592 "character special file (no device)"
11593 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11594 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11595 "block special file (loop)"
11596 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11597 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11598 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11600 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11602 # LU-1299 Executing or running ldd on a truncated executable does not
11603 # cause an out-of-memory condition.
11605 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11606 dd if=`which date` of=$MOUNT/date bs=1k count=1
11607 chmod +x $MOUNT/date
11609 $MOUNT/date > /dev/null
11610 ldd $MOUNT/date > /dev/null
11613 run_test 227 "running truncated executable does not cause OOM"
11615 # LU-1512 try to reuse idle OI blocks
11617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11618 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11619 skip "non-ldiskfs backend" && return
11621 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11622 local myDIR=$DIR/$tdir
11625 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11626 $LCTL set_param fail_loc=0x80001002
11627 createmany -o $myDIR/t- 10000
11628 $LCTL set_param fail_loc=0
11629 # The guard is current the largest FID holder
11631 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11633 local IDX=$(($SEQ % 64))
11635 do_facet $SINGLEMDS sync
11636 # Make sure journal flushed.
11638 local blk1=$(do_facet $SINGLEMDS \
11639 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11640 grep Blockcount | awk '{print $4}')
11642 # Remove old files, some OI blocks will become idle.
11643 unlinkmany $myDIR/t- 10000
11644 # Create new files, idle OI blocks should be reused.
11645 createmany -o $myDIR/t- 2000
11646 do_facet $SINGLEMDS sync
11647 # Make sure journal flushed.
11649 local blk2=$(do_facet $SINGLEMDS \
11650 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11651 grep Blockcount | awk '{print $4}')
11653 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11655 run_test 228a "try to reuse idle OI blocks"
11658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11659 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11660 skip "non-ldiskfs backend" && return
11662 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11663 local myDIR=$DIR/$tdir
11666 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11667 $LCTL set_param fail_loc=0x80001002
11668 createmany -o $myDIR/t- 10000
11669 $LCTL set_param fail_loc=0
11670 # The guard is current the largest FID holder
11672 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11674 local IDX=$(($SEQ % 64))
11676 do_facet $SINGLEMDS sync
11677 # Make sure journal flushed.
11679 local blk1=$(do_facet $SINGLEMDS \
11680 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11681 grep Blockcount | awk '{print $4}')
11683 # Remove old files, some OI blocks will become idle.
11684 unlinkmany $myDIR/t- 10000
11687 stop $SINGLEMDS || error "Fail to stop MDT."
11689 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11691 df $MOUNT || error "Fail to df."
11692 # Create new files, idle OI blocks should be reused.
11693 createmany -o $myDIR/t- 2000
11694 do_facet $SINGLEMDS sync
11695 # Make sure journal flushed.
11697 local blk2=$(do_facet $SINGLEMDS \
11698 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11699 grep Blockcount | awk '{print $4}')
11701 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11703 run_test 228b "idle OI blocks can be reused after MDT restart"
11707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11708 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11709 skip "non-ldiskfs backend" && return
11711 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11712 local myDIR=$DIR/$tdir
11715 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11716 $LCTL set_param fail_loc=0x80001002
11717 # 20000 files can guarantee there are index nodes in the OI file
11718 createmany -o $myDIR/t- 20000
11719 $LCTL set_param fail_loc=0
11720 # The guard is current the largest FID holder
11722 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11724 local IDX=$(($SEQ % 64))
11726 do_facet $SINGLEMDS sync
11727 # Make sure journal flushed.
11729 local blk1=$(do_facet $SINGLEMDS \
11730 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11731 grep Blockcount | awk '{print $4}')
11733 # Remove old files, some OI blocks will become idle.
11734 unlinkmany $myDIR/t- 20000
11736 # The OI file should become empty now
11738 # Create new files, idle OI blocks should be reused.
11739 createmany -o $myDIR/t- 2000
11740 do_facet $SINGLEMDS sync
11741 # Make sure journal flushed.
11743 local blk2=$(do_facet $SINGLEMDS \
11744 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11745 grep Blockcount | awk '{print $4}')
11747 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11749 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11751 test_229() { # LU-2482, LU-3448
11752 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
11753 skip "No HSM support on MDS of $(get_lustre_version)," \
11754 "need 2.4.53 at least" && return
11755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11756 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
11760 # Create a file with a released layout and stripe count 2.
11761 $MULTIOP $DIR/$tfile H2c ||
11762 error "failed to create file with released layout"
11764 $GETSTRIPE -v $DIR/$tfile
11766 local pattern=$($GETSTRIPE -L $DIR/$tfile)
11767 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
11769 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
11770 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
11771 stat $DIR/$tfile || error "failed to stat released file"
11773 chown $RUNAS_ID $DIR/$tfile ||
11774 error "chown $RUNAS_ID $DIR/$tfile failed"
11776 chgrp $RUNAS_ID $DIR/$tfile ||
11777 error "chgrp $RUNAS_ID $DIR/$tfile failed"
11779 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
11780 rm $DIR/$tfile || error "failed to remove released file"
11782 run_test 229 "getstripe/stat/rm/attr changes work on released files"
11785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11786 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11789 mkdir -p $DIR/$tdir/test_230_local
11790 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11791 [ $mdt_idx -ne 0 ] &&
11792 error "create local directory on wrong MDT $mdt_idx"
11794 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11795 error "create remote directory failed"
11796 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11797 [ $mdt_idx -ne $MDTIDX ] &&
11798 error "create remote directory on wrong MDT $mdt_idx"
11800 createmany -o $DIR/$tdir/test_230/t- 10 ||
11801 error "create files on remote directory failed"
11802 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11803 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11804 rm -r $DIR/$tdir || error "unlink remote directory failed"
11806 run_test 230a "Create remote directory and files under the remote directory"
11810 # For simplicity this test assumes that max_pages_per_rpc
11811 # is the same across all OSCs
11812 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
11813 local bulk_size=$((max_pages * 4096))
11815 mkdir -p $DIR/$tdir
11817 # clear the OSC stats
11818 $LCTL set_param osc.*.stats=0 &>/dev/null
11820 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
11821 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
11822 oflag=direct &>/dev/null || error "dd failed"
11824 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
11825 if [ x$nrpcs != "x1" ]; then
11826 error "found $nrpc ost_write RPCs, not 1 as expected"
11829 # Drop the OSC cache, otherwise we will read from it
11830 cancel_lru_locks osc
11832 # clear the OSC stats
11833 $LCTL set_param osc.*.stats=0 &>/dev/null
11835 # Client reads $bulk_size.
11836 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
11837 iflag=direct &>/dev/null || error "dd failed"
11839 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
11840 if [ x$nrpcs != "x1" ]; then
11841 error "found $nrpc ost_read RPCs, not 1 as expected"
11844 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
11847 mkdir -p $DIR/$tdir
11849 for i in {0..1023}; do
11850 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
11851 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
11852 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
11856 run_test 231b "must not assert on fully utilized OST request buffer"
11859 mkdir -p $DIR/$tdir
11860 #define OBD_FAIL_LDLM_OST_LVB 0x31c
11861 $LCTL set_param fail_loc=0x31c
11863 # ignore dd failure
11864 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
11866 $LCTL set_param fail_loc=0
11867 umount_client $MOUNT || error "umount failed"
11868 mount_client $MOUNT || error "mount failed"
11870 run_test 232 "failed lock should not block umount"
11873 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
11874 { skip "Need MDS version at least 2.3.64"; return; }
11876 local fid=$($LFS path2fid $MOUNT)
11877 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11878 error "cannot access $MOUNT using its FID '$fid'"
11880 run_test 233a "checking that OBF of the FS root succeeds"
11883 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
11884 { skip "Need MDS version at least 2.5.90"; return; }
11886 local fid=$($LFS path2fid $MOUNT/.lustre)
11887 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11888 error "cannot access $MOUNT/.lustre using its FID '$fid'"
11890 fid=$($LFS path2fid $MOUNT/.lustre/fid)
11891 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11892 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
11894 run_test 233b "checking that OBF of the FS .lustre succeeds"
11897 local p="$TMP/sanityN-$TESTNAME.parameters"
11898 save_lustre_params client "llite.*.xattr_cache" > $p
11899 lctl set_param llite.*.xattr_cache 1 ||
11900 { skip "xattr cache is not supported"; return 0; }
11902 mkdir -p $DIR/$tdir || error "mkdir failed"
11903 touch $DIR/$tdir/$tfile || error "touch failed"
11904 # OBD_FAIL_LLITE_XATTR_ENOMEM
11905 $LCTL set_param fail_loc=0x1405
11906 if [ ! -f /etc/SuSE-release ]; then
11907 # attr pre-2.4.44-7 had a bug with rc
11908 # LU-3703 - SLES clients have older attr
11909 getfattr -n user.attr $DIR/$tdir/$tfile &&
11910 error "getfattr should have failed with ENOMEM"
11912 $LCTL set_param fail_loc=0x0
11915 restore_lustre_params < $p
11918 run_test 234 "xattr cache should not crash on ENOMEM"
11921 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
11922 skip "Need MDS version at least 2.4.52" && return
11923 flock_deadlock $DIR/$tfile
11928 124) error "process hangs on a deadlock"
11930 *) error "error executing flock_deadlock $DIR/$tfile"
11934 run_test 235 "LU-1715: flock deadlock detection does not work properly"
11938 check_swap_layouts_support && return 0
11939 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
11941 local ref1=/etc/passwd
11942 local ref2=/etc/group
11943 local file1=$DIR/$tdir/f1
11944 local file2=$DIR/$tdir/f2
11946 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
11947 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
11948 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
11949 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
11950 local fd=$(free_fd)
11951 local cmd="exec $fd<>$file2"
11954 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
11955 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
11958 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11963 run_test 236 "Layout swap on open unlinked file"
11965 # test to verify file handle related system calls
11966 # (name_to_handle_at/open_by_handle_at)
11967 # The new system calls are supported in glibc >= 2.14.
11970 echo "Test file_handle syscalls" > $DIR/$tfile
11971 check_fhandle_syscalls $DIR/$tfile ||
11972 error "check_fhandle_syscalls failed"
11974 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
11976 test_striped_dir() {
11981 mkdir -p $DIR/$tdir
11982 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
11983 error "set striped dir error"
11985 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
11986 if [ "$stripe_count" != "2" ]; then
11987 error "stripe_count is $stripe_count, expect 2"
11990 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
11991 if [ "$stripe_index" != "$mdt_index" ]; then
11992 error "stripe_index is $stripe_index, expect $mdt_index"
11995 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
11996 error "nlink error after create striped dir"
11998 mkdir $DIR/$tdir/striped_dir/a
11999 mkdir $DIR/$tdir/striped_dir/b
12001 stat $DIR/$tdir/striped_dir/a ||
12002 error "create dir under striped dir failed"
12003 stat $DIR/$tdir/striped_dir/b ||
12004 error "create dir under striped dir failed"
12006 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12007 error "nlink error after mkdir"
12009 rmdir $DIR/$tdir/striped_dir/a
12010 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12011 error "nlink error after rmdir"
12013 rmdir $DIR/$tdir/striped_dir/b
12014 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12015 error "nlink error after rmdir"
12017 rmdir $DIR/$tdir/striped_dir ||
12018 error "rmdir striped dir error"
12023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12024 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12026 test_striped_dir 0 || error "failed on striped dir on MDT0"
12027 test_striped_dir 1 || error "failed on striped dir on MDT0"
12029 run_test 300a "basic striped dir sanity test"
12032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12033 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12039 test_mkdir $DIR/$tdir || error "mkdir fail"
12040 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12041 error "set striped dir error"
12042 for ((i=0; i<10; i++)); do
12043 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12045 touch $DIR/$tdir/striped_dir/file_$i ||
12046 error "touch error $i"
12047 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12048 [ $mtime1 -eq $mtime2 ] &&
12049 error "mtime not change after create"
12051 rm -f $DIR/$tdir/striped_dir/file_$i ||
12052 error "unlink error $i"
12053 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12054 [ $mtime2 -eq $mtime3 ] &&
12055 error "mtime did not change after unlink"
12059 run_test 300b "check ctime/mtime for striped dir"
12062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12063 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12066 mkdir -p $DIR/$tdir
12067 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12068 error "set striped dir error"
12070 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12071 error "chown striped dir failed"
12073 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12074 error "create 5k files failed"
12076 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12078 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12082 run_test 300c "chown && check ls under striped directory"
12085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12090 mkdir -p $DIR/$tdir
12091 $SETSTRIPE -c 2 $DIR/$tdir
12093 #local striped directory
12094 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12095 error "set striped dir error"
12096 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12097 error "create 10 files failed"
12099 #remote striped directory
12100 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12101 error "set striped dir error"
12102 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12103 error "create 10 files failed"
12105 for file in $(find $DIR/$tdir); do
12106 stripe_count=$($GETSTRIPE -c $file)
12107 [ $stripe_count -eq 2 ] ||
12108 error "wrong stripe $stripe_count for $file"
12113 run_test 300d "check default stripe under striped directory"
12116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12117 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12121 mkdir -p $DIR/$tdir
12123 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12124 error "set striped dir error"
12126 touch $DIR/$tdir/striped_dir/a
12127 touch $DIR/$tdir/striped_dir/b
12128 touch $DIR/$tdir/striped_dir/c
12130 mkdir $DIR/$tdir/striped_dir/dir_a
12131 mkdir $DIR/$tdir/striped_dir/dir_b
12132 mkdir $DIR/$tdir/striped_dir/dir_c
12134 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12135 error "set striped dir under striped dir error"
12137 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12138 error "set striped dir under striped dir error"
12140 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12141 error "set striped dir under striped dir error"
12143 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12144 error "rename file under striped dir should fail"
12146 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12147 error "rename dir under striped dir should fail"
12149 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12150 error "rename dir under different stripes should fail"
12152 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12153 error "rename file under striped dir should succeed"
12155 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12156 error "rename dir under striped dir should succeed"
12160 run_test 300e "check rename under striped directory"
12163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12169 mkdir -p $DIR/$tdir
12171 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12172 error "set striped dir error"
12174 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12175 error "set striped dir error"
12177 touch $DIR/$tdir/striped_dir/a
12178 mkdir $DIR/$tdir/striped_dir/dir_a
12179 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12180 error "create striped dir under striped dir fails"
12182 touch $DIR/$tdir/striped_dir1/b
12183 mkdir $DIR/$tdir/striped_dir1/dir_b
12184 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12185 error "create striped dir under striped dir fails"
12187 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12188 error "rename file under different striped dir should fail"
12190 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12191 error "rename dir under different striped dir should fail"
12193 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12194 error "rename striped dir under diff striped dir should fail"
12196 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12197 error "rename file under diff striped dirs fails"
12199 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12200 error "rename dir under diff striped dirs fails"
12204 run_test 300f "check rename cross striped directory"
12207 # tests that do cleanup/setup should be run at the end
12211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12213 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12214 $LCTL set_param fail_loc=0x903
12215 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12216 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12219 FAIL_ON_ERROR=true cleanup
12220 FAIL_ON_ERROR=true setup
12222 run_test 900 "umount should not race with any mgc requeue thread"
12225 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12226 check_and_cleanup_lustre
12227 if [ "$I_MOUNTED" != "yes" ]; then
12228 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true