2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
42 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
43 CREATETEST=${CREATETEST:-createtest}
45 LFIND=${LFIND:-"$LFS find"}
46 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
48 MCREATE=${MCREATE:-mcreate}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
59 UMOUNT=${UMOUNT:-"umount -d"}
61 CHECK_GRANT=${CHECK_GRANT:-"yes"}
62 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
63 export PARALLEL=${PARALLEL:-"no"}
65 export NAME=${NAME:-local}
72 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
73 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
74 . $LUSTRE/tests/test-framework.sh
76 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
81 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
82 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
89 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
90 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
99 check_kernel_version() {
101 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
103 patchless|patchless_client) return 0;;
104 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
106 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
110 check_swap_layouts_support()
112 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
113 { skip "Does not support layout lock."; return 0; }
117 if [ "$ONLY" == "cleanup" ]; then
122 check_and_setup_lustre
127 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
128 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
129 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
130 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
131 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
132 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
133 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
134 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
136 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
137 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
138 rm -rf $DIR/[Rdfs][0-9]*
140 # $RUNAS_ID may get set incorrectly somewhere else
141 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
143 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
147 if [ "${ONLY}" = "MOUNT" ] ; then
148 echo "Lustre is up, please go on"
152 echo "preparing for tests involving mounts"
153 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
155 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
156 echo # add a newline after mke2fs.
160 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
161 lctl set_param debug=-1 2> /dev/null || true
164 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
166 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
168 run_test 0a "touch; rm ====================="
171 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
172 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
174 run_test 0b "chmod 0755 $DIR ============================="
177 $LCTL get_param mdc.*.import | grep "state: FULL" ||
178 error "import not FULL"
179 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
182 run_test 0c "check import proc ============================="
185 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
186 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
187 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
188 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
191 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
193 run_test 1 "mkdir; remkdir; rmdir =============================="
196 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
197 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
198 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
200 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
202 run_test 2 "mkdir; touch; rmdir; check file ===================="
205 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
206 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
207 touch $DIR/$tdir/$tfile
208 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
210 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
212 run_test 3 "mkdir; touch; rmdir; check dir ====================="
214 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
217 local remote_dir=remote_dir
219 test_mkdir $DIR/$remote_dir ||
220 error "Create remote directory failed"
222 touch $DIR/$remote_dir/$tfile ||
223 error "Create file under remote directory failed"
225 rmdir $DIR/$remote_dir &&
226 error "Expect error removing in-use dir $DIR/$remote_dir"
228 test -d $DIR/$remote_dir || error "Remote directory disappeared"
230 rm -rf $DIR/$remote_dir || error "remove remote dir error"
232 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
235 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
236 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
237 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
238 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
239 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
241 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
244 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
245 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
246 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
247 error "$tfile does not have perm 0666 or UID $UID"
248 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
249 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
250 error "$tfile should be 0666 and owned by UID $UID"
252 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
257 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
258 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by UID $RUNAS_ID"
260 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
261 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
262 error "$tfile should be owned by UID $RUNAS_ID"
264 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
267 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
269 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
271 error "$tfile should be owned by GID $UID"
272 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
273 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
274 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
276 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
279 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
280 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
281 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
282 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
283 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
284 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
285 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
286 error "$tdir/d/subdir should be GID $RUNAS_GID"
288 run_test 6g "Is new dir in sgid dir inheriting group?"
290 test_6h() { # bug 7331
291 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
292 touch $DIR/$tfile || error "touch failed"
293 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
294 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
295 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
296 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
297 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
299 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
302 test_mkdir $DIR/$tdir
303 $MCREATE $DIR/$tdir/$tfile
304 chmod 0666 $DIR/$tdir/$tfile
305 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
306 error "$tdir/$tfile should be mode 0666"
308 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
311 if [ ! -d $DIR/$tdir ]; then
314 $MCREATE $DIR/$tdir/$tfile
315 echo -n foo > $DIR/$tdir/$tfile
316 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
317 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
319 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
322 test_mkdir $DIR/$tdir
323 touch $DIR/$tdir/$tfile
324 chmod 0666 $DIR/$tdir/$tfile
325 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
326 error "$tfile mode not 0666"
328 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 test_mkdir $DIR/$tdir/d2/d3
334 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
336 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
339 test_mkdir $DIR/$tdir
340 test_mkdir $DIR/$tdir/d2
341 touch $DIR/$tdir/d2/$tfile
342 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
343 error "$tdir/d2/$tfile not a file"
345 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
348 test_mkdir $DIR/$tdir
349 test_mkdir $DIR/$tdir/d2
350 chmod 0666 $DIR/$tdir/d2
351 chmod 0705 $DIR/$tdir/d2
352 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
353 error "$tdir/d2 mode not 0705"
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
360 chmod 0666 $DIR/$tdir/$tfile
361 chmod 0654 $DIR/$tdir/$tfile
362 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
363 error "$tdir/d2 mode not 0654"
365 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 test_mkdir $DIR/$tdir
369 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
371 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
372 error "$tdir/$tfile size not 0 after truncate"
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
388 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
389 error "$tdir/${tfile_2} not a file after rename"
391 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 test_mkdir $DIR/$tdir
395 touch $DIR/$tdir/$tfile
396 rm -rf $DIR/$tdir/$tfile
397 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
399 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
402 test_mkdir -p $DIR/$tdir
403 touch $DIR/$tdir/$tfile
404 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
406 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
407 error "$tdir/l-exist not a symlink"
408 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
409 error "$tdir/l-exist not referencing a file"
410 rm -f $DIR/$tdir/l-exist
411 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
413 run_test 17a "symlinks: create, remove (real) =================="
416 test_mkdir -p $DIR/$tdir
417 ln -s no-such-file $DIR/$tdir/l-dangle
419 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
420 error "$tdir/l-dangle not referencing no-such-file"
421 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
422 error "$tdir/l-dangle not referencing non-existent file"
423 rm -f $DIR/$tdir/l-dangle
424 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
426 run_test 17b "symlinks: create, remove (dangling) =============="
428 test_17c() { # bug 3440 - don't save failed open RPC for replay
429 test_mkdir -p $DIR/$tdir
430 ln -s foo $DIR/$tdir/$tfile
431 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
433 run_test 17c "symlinks: open dangling (should return error) ===="
436 test_mkdir -p $DIR/$tdir
437 ln -s foo $DIR/$tdir/$tfile
438 touch $DIR/$tdir/$tfile || error "creating to new symlink"
440 run_test 17d "symlinks: create dangling ========================"
443 test_mkdir -p $DIR/$tdir
444 local foo=$DIR/$tdir/$tfile
445 ln -s $foo $foo || error "create symlink failed"
446 ls -l $foo || error "ls -l failed"
447 ls $foo && error "ls not failed" || true
449 run_test 17e "symlinks: create recursive symlink (should return error) ===="
452 test_mkdir -p $DIR/d17f
453 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
456 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
457 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
458 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
461 run_test 17f "symlinks: long and very long symlink name ========================"
463 # str_repeat(S, N) generate a string that is string S repeated N times
468 while [ $((n -= 1)) -ge 0 ]; do
474 # Long symlinks and LU-2241
476 test_mkdir -p $DIR/$tdir
477 local TESTS="59 60 61 4094 4095"
479 # Fix for inode size boundary in 2.1.4
480 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
483 # Patch not applied to 2.2 or 2.3 branches
484 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
485 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
488 # skip long symlink name for rhel6.5.
489 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
490 grep -q '6.5' /etc/redhat-release &>/dev/null &&
491 TESTS="59 60 61 4062 4063"
494 local SYMNAME=$(str_repeat 'x' $i)
495 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
496 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
499 run_test 17g "symlinks: really long symlink name and inode boundaries"
501 test_17h() { #bug 17378
502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
505 test_mkdir -p $DIR/$tdir
506 if [[ $MDSCOUNT -gt 1 ]]; then
507 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
511 $SETSTRIPE -c -1 $DIR/$tdir
512 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
513 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
514 touch $DIR/$tdir/$tfile || true
516 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
518 test_17i() { #bug 20018
519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
521 test_mkdir -c1 $DIR/$tdir
522 local foo=$DIR/$tdir/$tfile
524 if [[ $MDSCOUNT -gt 1 ]]; then
525 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
529 ln -s $foo $foo || error "create symlink failed"
530 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
531 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
532 ls -l $foo && error "error not detected"
535 run_test 17i "don't panic on short symlink"
537 test_17k() { #bug 22301
538 [[ -z "$(which rsync 2>/dev/null)" ]] &&
539 skip "no rsync command" && return 0
540 rsync --help | grep -q xattr ||
541 skip_env "$(rsync --version | head -n1) does not support xattrs"
542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
543 test_mkdir -p $DIR/$tdir
544 test_mkdir -p $DIR/$tdir.new
545 touch $DIR/$tdir/$tfile
546 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
547 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
548 error "rsync failed with xattrs enabled"
550 run_test 17k "symlinks: rsync with xattrs enabled ========================="
552 test_17l() { # LU-279
553 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
554 skip "no getfattr command" && return 0
556 touch $DIR/$tdir/$tfile
557 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
558 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
559 # -h to not follow symlinks. -m '' to list all the xattrs.
560 # grep to remove first line: '# file: $path'.
561 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
563 lgetxattr_size_check $path $xattr ||
564 error "lgetxattr_size_check $path $xattr failed"
568 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
572 local short_sym="0123456789"
573 local WDIR=$DIR/${tdir}m
580 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
581 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
582 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
584 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
585 skip "only for ldiskfs MDT" && return 0
587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
591 # create a long symlink file
592 for ((i = 0; i < 4; ++i)); do
593 long_sym=${long_sym}${long_sym}
596 echo "create 512 short and long symlink files under $WDIR"
597 for ((i = 0; i < 256; ++i)); do
598 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
599 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
605 wait_delete_completed
607 echo "recreate the 512 symlink files with a shorter string"
608 for ((i = 0; i < 512; ++i)); do
609 # rewrite the symlink file with a shorter string
610 ln -sf ${long_sym} $WDIR/long-$i
611 ln -sf ${short_sym} $WDIR/short-$i
614 mds_index=$($LFS getstripe -M $WDIR)
615 mds_index=$((mds_index+1))
616 devname=$(mdsdevname $mds_index)
617 cmd="$E2FSCK -fnvd $devname"
619 echo "stop and checking mds${mds_index}: $cmd"
620 # e2fsck should not return error
622 do_facet mds${mds_index} $cmd || rc=$?
624 start mds${mds_index} $devname $MDS_MOUNT_OPTS
625 df $MOUNT > /dev/null 2>&1
626 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
627 "short/long symlink MDT: rc=$rc"
630 run_test 17m "run e2fsck against MDT which contains short/long symlink"
632 check_fs_consistency_17n() {
638 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
639 # so it only check MDT1/MDT2 instead of all of MDTs.
640 for mdt_index in $(seq 1 2); do
641 devname=$(mdsdevname $mdt_index)
642 cmd="$E2FSCK -fnvd $devname"
644 echo "stop and checking mds${mdt_index}: $cmd"
645 # e2fsck should not return error
647 do_facet mds${mdt_index} $cmd || rc=$?
649 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
650 df $MOUNT > /dev/null 2>&1
651 [ $rc -ne 0 ] && break
659 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
660 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
661 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
663 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
664 skip "only for ldiskfs MDT" && return 0
666 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
671 for ((i=0; i<10; i++)); do
672 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
673 error "create remote dir error $i"
674 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
675 error "create files under remote dir failed $i"
678 check_fs_consistency_17n ||
679 error "e2fsck report error after create files under remote dir"
681 for ((i=0;i<10;i++)); do
682 rm -rf $DIR/$tdir/remote_dir_${i} ||
683 error "destroy remote dir error $i"
686 check_fs_consistency_17n ||
687 error "e2fsck report error after unlink files under remote dir"
689 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
690 skip "lustre < 2.4.50 does not support migrate mv " && return
692 for ((i=0; i<10; i++)); do
693 mkdir -p $DIR/$tdir/remote_dir_${i}
694 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
695 error "create files under remote dir failed $i"
696 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
697 error "migrate remote dir error $i"
699 check_fs_consistency_17n || error "e2fsck report error after migration"
701 for ((i=0;i<10;i++)); do
702 rm -rf $DIR/$tdir/remote_dir_${i} ||
703 error "destroy remote dir error $i"
706 check_fs_consistency_17n || error "e2fsck report error after unlink"
708 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
711 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
712 skip "Need MDS version at least 2.3.64" && return
714 local WDIR=$DIR/${tdir}o
720 mdt_index=$($LFS getstripe -M $WDIR)
721 mdt_index=$((mdt_index+1))
722 mdtdevname=$(mdsdevname $mdt_index)
726 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
728 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
729 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
730 ls -l $WDIR/$tfile && rc=1
731 do_facet mds${mdt_index} lctl set_param fail_loc=0
732 [[ $rc -ne 0 ]] && error "stat file should fail"
735 run_test 17o "stat file with incompat LMA feature"
738 touch $DIR/f || error "Failed to touch $DIR/f: $?"
739 ls $DIR || error "Failed to ls $DIR: $?"
741 run_test 18 "touch .../f ; ls ... =============================="
747 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
749 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
752 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
754 run_test 19b "ls -l .../f19 (should return error) =============="
757 [ $RUNAS_ID -eq $UID ] &&
758 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
759 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
761 run_test 19c "$RUNAS touch .../f19 (should return error) =="
764 cat $DIR/f19 && error || true
766 run_test 19d "cat .../f19 (should return error) =============="
778 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
780 run_test 20 "touch .../f ; ls -l ... ==========================="
783 test_mkdir -p $DIR/$tdir
784 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
785 ln -s dangle $DIR/$tdir/link
786 echo foo >> $DIR/$tdir/link
787 cat $DIR/$tdir/dangle
788 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
789 $CHECKSTAT -f -t file $DIR/$tdir/link ||
790 error "$tdir/link not linked to a file"
792 run_test 21 "write to dangling link ============================"
796 test_mkdir -p $DIR/$tdir
797 chown $RUNAS_ID:$RUNAS_GID $WDIR
798 (cd $WDIR || error "cd $WDIR failed";
799 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
801 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
802 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
803 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
805 run_test 22 "unpack tar archive as non-root user ==============="
809 test_mkdir -p $DIR/$tdir
810 local file=$DIR/$tdir/$tfile
812 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
813 openfile -f O_CREAT:O_EXCL $file &&
814 error "$file recreate succeeded" || true
816 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
818 test_23b() { # bug 18988
819 test_mkdir -p $DIR/$tdir
820 local file=$DIR/$tdir/$tfile
823 echo foo > $file || error "write filed"
824 echo bar >> $file || error "append filed"
825 $CHECKSTAT -s 8 $file || error "wrong size"
828 run_test 23b "O_APPEND check =========================="
832 echo '-- same directory rename'
833 test_mkdir $DIR/$tdir
834 touch $DIR/$tdir/$tfile.1
835 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
836 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
838 run_test 24a "rename file to non-existent target"
841 test_mkdir $DIR/$tdir
842 touch $DIR/$tdir/$tfile.{1,2}
843 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
844 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
845 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
847 run_test 24b "rename file to existing target"
850 test_mkdir $DIR/$tdir
851 test_mkdir $DIR/$tdir/d$testnum.1
852 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
853 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
854 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
856 run_test 24c "rename directory to non-existent target"
859 test_mkdir -c1 $DIR/$tdir
860 test_mkdir -c1 $DIR/$tdir/d$testnum.1
861 test_mkdir -c1 $DIR/$tdir/d$testnum.2
862 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
863 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
864 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
866 run_test 24d "rename directory to existing target"
869 echo '-- cross directory renames --'
873 mv $DIR/R5a/f $DIR/R5b/g
874 $CHECKSTAT -a $DIR/R5a/f || error
875 $CHECKSTAT -t file $DIR/R5b/g || error
877 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
882 touch $DIR/R6a/f $DIR/R6b/g
883 mv $DIR/R6a/f $DIR/R6b/g
884 $CHECKSTAT -a $DIR/R6a/f || error
885 $CHECKSTAT -t file $DIR/R6b/g || error
887 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
892 test_mkdir $DIR/R7a/d
893 mv $DIR/R7a/d $DIR/R7b/e
894 $CHECKSTAT -a $DIR/R7a/d || error
895 $CHECKSTAT -t dir $DIR/R7b/e || error
897 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
900 test_mkdir -c1 $DIR/R8a
901 test_mkdir -c1 $DIR/R8b
902 test_mkdir -c1 $DIR/R8a/d
903 test_mkdir -c1 $DIR/R8b/e
904 mrename $DIR/R8a/d $DIR/R8b/e
905 $CHECKSTAT -a $DIR/R8a/d || error
906 $CHECKSTAT -t dir $DIR/R8b/e || error
908 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
911 echo "-- rename error cases"
915 mrename $DIR/R9/f $DIR/R9/a
916 $CHECKSTAT -t file $DIR/R9/f || error
917 $CHECKSTAT -t dir $DIR/R9/a || error
918 $CHECKSTAT -a $DIR/R9/a/f || error
920 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
924 mrename $DIR/R10/f $DIR/R10/g
925 $CHECKSTAT -t dir $DIR/R10 || error
926 $CHECKSTAT -a $DIR/R10/f || error
927 $CHECKSTAT -a $DIR/R10/g || error
929 run_test 24j "source does not exist ============================"
933 test_mkdir $DIR/R11a/d
935 mv $DIR/R11a/f $DIR/R11a/d
936 $CHECKSTAT -a $DIR/R11a/f || error
937 $CHECKSTAT -t file $DIR/R11a/d/f || error
939 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
941 # bug 2429 - rename foo foo foo creates invalid file
944 $MULTIOP $f OcNs || error
946 run_test 24l "Renaming a file to itself ========================"
950 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
951 # on ext3 this does not remove either the source or target files
952 # though the "expected" operation would be to remove the source
953 $CHECKSTAT -t file ${f} || error "${f} missing"
954 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
956 run_test 24m "Renaming a file to a hard link to itself ========="
960 # this stats the old file after it was renamed, so it should fail
964 $CHECKSTAT ${f}.rename
967 run_test 24n "Statting the old file after renaming (Posix rename 2)"
970 check_kernel_version 37 || return 0
971 test_mkdir -p $DIR/d24o
972 rename_many -s random -v -n 10 $DIR/d24o
974 run_test 24o "rename of files during htree split ==============="
979 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
980 mrename $DIR/R12a $DIR/R12b
981 $CHECKSTAT -a $DIR/R12a || error
982 $CHECKSTAT -t dir $DIR/R12b || error
983 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
984 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
986 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
988 cleanup_multiop_pause() {
994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
997 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
998 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1001 trap cleanup_multiop_pause EXIT
1002 mrename $DIR/R13a $DIR/R13b
1003 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1004 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1005 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1006 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1007 cleanup_multiop_pause
1008 wait $MULTIPID || error "multiop close failed"
1010 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1012 test_24r() { #bug 3789
1013 test_mkdir $DIR/R14a
1014 test_mkdir $DIR/R14a/b
1015 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1016 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1017 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1019 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1022 test_mkdir $DIR/R15a
1023 test_mkdir $DIR/R15a/b
1024 test_mkdir $DIR/R15a/b/c
1025 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1026 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1027 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1029 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1031 test_mkdir $DIR/R16a
1032 test_mkdir $DIR/R16a/b
1033 test_mkdir $DIR/R16a/b/c
1034 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1035 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1036 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1038 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1040 test_24u() { # bug12192
1042 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1043 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1045 run_test 24u "create stripe file"
1051 simple_cleanup_common() {
1054 wait_delete_completed
1057 max_pages_per_rpc() {
1058 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1062 local NRFILES=100000
1063 local FREE_INODES=$(mdt_free_inodes 0)
1064 [[ $FREE_INODES -lt $NRFILES ]] &&
1065 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1069 trap simple_cleanup_common EXIT
1071 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1072 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1075 createmany -m $DIR/$tdir/$tfile $NRFILES
1077 cancel_lru_locks mdc
1078 lctl set_param mdc.*.stats clear
1080 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1082 # LU-5 large readdir
1083 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1084 # 8 bytes for name(filename is mostly 5 in this test) +
1085 # 8 bytes for luda_type
1086 # take into account of overhead in lu_dirpage header and end mark in
1087 # each page, plus one in RPC_NUM calculation.
1089 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1090 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1091 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1092 awk '/^mds_readpage/ {print $2}')
1093 [[ $mds_readpage -gt $RPC_NUM ]] &&
1094 error "large readdir doesn't take effect"
1096 simple_cleanup_common
1098 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1100 test_24w() { # bug21506
1102 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1103 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1104 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1105 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1106 [ "$SZ1" = "$SZ2" ] || \
1107 error "Error reading at the end of the file $tfile"
1109 run_test 24w "Reading a file larger than 4Gb"
1112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1115 local remote_dir=$DIR/$tdir/remote_dir
1118 $LFS mkdir -i $MDTIDX $remote_dir ||
1119 error "create remote directory failed"
1121 mkdir -p $DIR/$tdir/src_dir
1122 touch $DIR/$tdir/src_file
1123 mkdir -p $remote_dir/tgt_dir
1124 touch $remote_dir/tgt_file
1126 mrename $remote_dir $DIR/ &&
1127 error "rename dir cross MDT works!"
1129 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1130 error "rename dir cross MDT works!"
1132 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1133 error "rename file cross MDT works!"
1135 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1136 error "ln file cross MDT should not work!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24x "cross rename/link should be failed"
1143 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1146 local remote_dir=$DIR/$tdir/remote_dir
1149 $LFS mkdir -i $MDTIDX $remote_dir ||
1150 error "create remote directory failed"
1152 mkdir -p $remote_dir/src_dir
1153 touch $remote_dir/src_file
1154 mkdir -p $remote_dir/tgt_dir
1155 touch $remote_dir/tgt_file
1157 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1158 error "rename subdir in the same remote dir failed!"
1160 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1161 error "rename files in the same remote dir failed!"
1163 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1164 error "link files in the same remote dir failed!"
1166 rm -rf $DIR/$tdir || error "Can not delete directories"
1168 run_test 24y "rename/link on the same dir should succeed"
1171 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1174 local remote_src=$DIR/$tdir/remote_dir
1175 local remote_tgt=$DIR/$tdir/remote_tgt
1178 $LFS mkdir -i $MDTIDX $remote_src ||
1179 error "create remote directory failed"
1181 $LFS mkdir -i $MDTIDX $remote_tgt ||
1182 error "create remote directory failed"
1184 mrename $remote_src $remote_tgt &&
1185 error "rename remote dirs should not work!"
1187 # If target dir does not exists, it should succeed
1189 mrename $remote_src $remote_tgt ||
1190 error "rename remote dirs(tgt dir does not exists) failed!"
1192 rm -rf $DIR/$tdir || error "Can not delete directories"
1194 run_test 24z "rename one remote dir to another remote dir should fail"
1196 test_24A() { # LU-3182
1201 createmany -m $DIR/$tdir/$tfile $NFILES
1202 local t=`ls $DIR/$tdir | wc -l`
1203 local u=`ls $DIR/$tdir | sort -u | wc -l`
1204 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1205 error "Expected $NFILES files, got $t ($u unique)"
1208 rm -rf $DIR/$tdir || error "Can not delete directories"
1210 run_test 24A "readdir() returns correct number of entries."
1213 echo '== symlink sanity ============================================='
1217 touch $DIR/s25/foo || error
1219 run_test 25a "create file in symlinked directory ==============="
1222 [ ! -d $DIR/d25 ] && test_25a
1223 $CHECKSTAT -t file $DIR/s25/foo || error
1225 run_test 25b "lookup file in symlinked directory ==============="
1229 test_mkdir $DIR/d26/d26-2
1230 ln -s d26/d26-2 $DIR/s26
1231 touch $DIR/s26/foo || error
1233 run_test 26a "multiple component symlink ======================="
1236 test_mkdir -p $DIR/d26b/d26-2
1237 ln -s d26b/d26-2/foo $DIR/s26-2
1238 touch $DIR/s26-2 || error
1240 run_test 26b "multiple component symlink at end of lookup ======"
1243 test_mkdir $DIR/d26.2
1244 touch $DIR/d26.2/foo
1245 ln -s d26.2 $DIR/s26.2-1
1246 ln -s s26.2-1 $DIR/s26.2-2
1247 ln -s s26.2-2 $DIR/s26.2-3
1248 chmod 0666 $DIR/s26.2-3/foo
1250 run_test 26c "chain of symlinks ================================"
1252 # recursive symlinks (bug 439)
1254 ln -s d26-3/foo $DIR/d26-3
1256 run_test 26d "create multiple component recursive symlink ======"
1259 [ ! -h $DIR/d26-3 ] && test_26d
1262 run_test 26e "unlink multiple component recursive symlink ======"
1264 # recursive symlinks (bug 7022)
1266 test_mkdir -p $DIR/$tdir
1267 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1268 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1269 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1270 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1271 cd $tfile || error "cd $tfile failed"
1272 ln -s .. dotdot || error "ln dotdot failed"
1273 ln -s dotdot/lndir lndir || error "ln lndir failed"
1274 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1275 output=`ls $tfile/$tfile/lndir/bar1`
1276 [ "$output" = bar1 ] && error "unexpected output"
1277 rm -r $tfile || error "rm $tfile failed"
1278 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1280 run_test 26f "rm -r of a directory which has recursive symlink ="
1283 echo '== stripe sanity =============================================='
1284 test_mkdir -p $DIR/d27 || error "mkdir failed"
1286 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1287 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1288 log "== test_27a: write to one stripe file ========================="
1289 cp /etc/hosts $DIR/d27/f0 || error
1291 run_test 27a "one stripe file =================================="
1294 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1295 test_mkdir -p $DIR/d27
1296 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1297 $GETSTRIPE -c $DIR/d27/f01
1298 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1299 error "two-stripe file doesn't have two stripes"
1301 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1303 run_test 27b "create and write to two stripe file"
1306 test_mkdir -p $DIR/d27
1307 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1308 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1309 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1311 run_test 27d "create file with default settings ================"
1314 test_mkdir -p $DIR/d27
1315 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1316 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1317 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1319 run_test 27e "setstripe existing file (should return error) ======"
1322 test_mkdir -p $DIR/d27
1323 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1324 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1325 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1327 run_test 27f "setstripe with bad stripe size (should return error)"
1330 test_mkdir -p $DIR/d27
1331 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1332 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1333 error "$DIR/d27/fnone has object"
1335 run_test 27g "$GETSTRIPE with no objects"
1338 touch $DIR/d27/fsome || error "touch failed"
1339 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1341 run_test 27i "$GETSTRIPE with some objects"
1344 test_mkdir -p $DIR/d27
1345 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1347 run_test 27j "setstripe with bad stripe offset (should return error)"
1349 test_27k() { # bug 2844
1350 test_mkdir -p $DIR/d27
1352 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1353 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1354 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1355 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1356 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1357 dd if=/dev/zero of=$FILE bs=4k count=1
1358 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1359 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1361 run_test 27k "limit i_blksize for broken user apps ============="
1364 test_mkdir -p $DIR/d27
1365 mcreate $DIR/f27l || error "creating file"
1366 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1367 error "setstripe should have failed" || true
1369 run_test 27l "check setstripe permissions (should return error)"
1372 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1374 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1375 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1378 trap simple_cleanup_common EXIT
1379 test_mkdir -p $DIR/$tdir
1380 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1381 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1382 error "dd should fill OST0"
1384 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1386 [ $i -gt 256 ] && break
1389 touch $DIR/$tdir/f27m_$i
1390 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1391 error "OST0 was full but new created file still use it"
1393 touch $DIR/$tdir/f27m_$i
1394 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1395 error "OST0 was full but new created file still use it"
1396 simple_cleanup_common
1398 run_test 27m "create file while OST0 was full =================="
1401 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1405 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1406 # if the OST isn't full anymore.
1408 local OSTIDX=${1:-""}
1410 local list=$(comma_list $(osts_nodes))
1411 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1413 do_nodes $list lctl set_param fail_loc=0
1414 sync # initiate all OST_DESTROYs from MDS to OST
1418 exhaust_precreations() {
1421 local FAILIDX=${3:-$OSTIDX}
1423 test_mkdir -p $DIR/$tdir
1424 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1425 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1427 local OST=$(ostname_from_index $OSTIDX)
1428 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1429 sed -e 's/_UUID$//;s/^.*-//')
1432 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1433 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1434 osc.$mdtosc_proc1.prealloc_last_id)
1435 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1436 osc.$mdtosc_proc1.prealloc_next_id)
1438 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1439 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1441 test_mkdir -p $DIR/$tdir/${OST}
1442 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1443 #define OBD_FAIL_OST_ENOSPC 0x215
1444 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1445 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1446 echo "Creating to objid $last_id on ost $OST..."
1447 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1448 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1449 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1453 exhaust_all_precreations() {
1455 for (( i=0; i < OSTCOUNT; i++ )) ; do
1456 exhaust_precreations $i $1 -1
1461 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1463 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1464 remote_ost_nodsh && skip "remote OST with nodsh" && return
1467 rm -f $DIR/$tdir/$tfile
1468 exhaust_precreations 0 0x80000215
1469 $SETSTRIPE -c -1 $DIR/$tdir
1470 touch $DIR/$tdir/$tfile || error
1471 $GETSTRIPE $DIR/$tdir/$tfile
1474 run_test 27n "create file with some full OSTs =================="
1477 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1480 remote_ost_nodsh && skip "remote OST with nodsh" && return
1483 rm -f $DIR/$tdir/$tfile
1484 exhaust_all_precreations 0x215
1486 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1491 run_test 27o "create file with all full OSTs (should error) ===="
1494 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1497 remote_ost_nodsh && skip "remote OST with nodsh" && return
1500 rm -f $DIR/$tdir/$tfile
1501 test_mkdir -p $DIR/$tdir
1503 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1504 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1505 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1507 exhaust_precreations 0 0x80000215
1508 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1509 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1510 $GETSTRIPE $DIR/$tdir/$tfile
1514 run_test 27p "append to a truncated file with some full OSTs ==="
1517 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 remote_ost_nodsh && skip "remote OST with nodsh" && return
1523 rm -f $DIR/$tdir/$tfile
1525 test_mkdir -p $DIR/$tdir
1526 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1527 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1528 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1530 exhaust_all_precreations 0x215
1532 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1533 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1537 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1540 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1543 remote_ost_nodsh && skip "remote OST with nodsh" && return
1546 rm -f $DIR/$tdir/$tfile
1547 exhaust_precreations 0 0x80000215
1549 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1553 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1555 test_27s() { # bug 10725
1556 test_mkdir -p $DIR/$tdir
1557 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1558 local stripe_count=0
1559 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1560 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1561 error "stripe width >= 2^32 succeeded" || true
1564 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1566 test_27t() { # bug 10864
1571 $WLFS getstripe $tfile
1574 run_test 27t "check that utils parse path correctly"
1576 test_27u() { # bug 4900
1577 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1580 local list=$(comma_list $(mdts_nodes))
1582 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1583 do_nodes $list $LCTL set_param fail_loc=0x139
1584 test_mkdir -p $DIR/$tdir
1586 createmany -o $DIR/$tdir/t- 1000
1587 do_nodes $list $LCTL set_param fail_loc=0
1589 TLOG=$DIR/$tfile.getstripe
1590 $GETSTRIPE $DIR/$tdir > $TLOG
1591 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1592 unlinkmany $DIR/$tdir/t- 1000
1593 [[ $OBJS -gt 0 ]] &&
1594 error "$OBJS objects created on OST-0. See $TLOG" || pass
1596 run_test 27u "skip object creation on OSC w/o objects =========="
1598 test_27v() { # bug 4900
1599 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1601 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1602 remote_ost_nodsh && skip "remote OST with nodsh" && return
1604 exhaust_all_precreations 0x215
1607 test_mkdir -p $DIR/$tdir
1608 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1610 touch $DIR/$tdir/$tfile
1611 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1613 for (( i=1; i < OSTCOUNT; i++ )); do
1614 do_facet ost$i lctl set_param fail_loc=0x705
1616 local START=`date +%s`
1617 createmany -o $DIR/$tdir/$tfile 32
1619 local FINISH=`date +%s`
1620 local TIMEOUT=`lctl get_param -n timeout`
1621 local PROCESS=$((FINISH - START))
1622 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1623 error "$FINISH - $START >= $TIMEOUT / 2"
1624 sleep $((TIMEOUT / 2 - PROCESS))
1627 run_test 27v "skip object creation on slow OST ================="
1629 test_27w() { # bug 10997
1630 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1631 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1632 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1633 error "stripe size $size != 65536" || true
1634 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1635 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1637 run_test 27w "check $SETSTRIPE -S option"
1640 [[ $OSTCOUNT -lt 2 ]] &&
1641 skip_env "skipping multiple stripe count/offset test" && return
1643 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1644 for i in $(seq 1 $OSTCOUNT); do
1646 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1647 error "setstripe -c $i -i $offset failed"
1648 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1649 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1650 [ $count -ne $i ] && error "stripe count $count != $i" || true
1651 [ $index -ne $offset ] &&
1652 error "stripe offset $index != $offset" || true
1655 run_test 27wa "check $SETSTRIPE -c -i options"
1658 remote_ost_nodsh && skip "remote OST with nodsh" && return
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 OFFSET=$(($OSTCOUNT - 1))
1663 local OST=$(ostname_from_index $OSTIDX)
1665 test_mkdir -p $DIR/$tdir
1666 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1667 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1669 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1670 for i in `seq 0 $OFFSET`; do
1671 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1672 error "OST0 was degraded but new created file still use it"
1674 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1676 run_test 27x "create files while OST0 is degraded"
1679 [[ $OSTCOUNT -lt 2 ]] &&
1680 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1681 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1682 remote_ost_nodsh && skip "remote OST with nodsh" && return
1683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1685 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1686 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1687 osc.$mdtosc.prealloc_last_id)
1688 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1689 osc.$mdtosc.prealloc_next_id)
1690 local fcount=$((last_id - next_id))
1691 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1692 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1694 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1695 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1696 local OST_DEACTIVE_IDX=-1
1701 for OSC in $MDS_OSCS; do
1702 OST=$(osc_to_ost $OSC)
1703 OSTIDX=$(index_from_ostuuid $OST)
1704 if [ $OST_DEACTIVE_IDX == -1 ]; then
1705 OST_DEACTIVE_IDX=$OSTIDX
1707 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1708 echo $OSC "is Deactivated:"
1709 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1713 OSTIDX=$(index_from_ostuuid $OST)
1715 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1717 for OSC in $MDS_OSCS; do
1718 OST=$(osc_to_ost $OSC)
1719 OSTIDX=$(index_from_ostuuid $OST)
1720 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1721 echo $OST "is degraded:"
1722 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1723 obdfilter.$OST.degraded=1
1728 createmany -o $DIR/$tdir/$tfile $fcount
1730 for OSC in $MDS_OSCS; do
1731 OST=$(osc_to_ost $OSC)
1732 OSTIDX=$(index_from_ostuuid $OST)
1733 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1734 echo $OST "is recovered from degraded:"
1735 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1736 obdfilter.$OST.degraded=0
1738 do_facet $SINGLEMDS lctl --device %$OSC activate
1742 # all osp devices get activated, hence -1 stripe count restored
1745 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1746 # devices get activated.
1748 $SETSTRIPE -c -1 $DIR/$tfile
1749 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1751 [ $stripecnt -ne $OSTCOUNT ] &&
1752 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1755 run_test 27y "create files while OST0 is degraded and the rest inactive"
1761 lmm_count=$($GETSTRIPE -c $1)
1762 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1763 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1765 local old_ifs="$IFS"
1767 fid=($($LFS path2fid $1))
1770 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1771 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1773 # compare lmm_seq and lu_fid->f_seq
1774 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1775 # compare lmm_object_id and lu_fid->oid
1776 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1778 # check the trusted.fid attribute of the OST objects of the file
1779 local have_obdidx=false
1781 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1782 # skip lines up to and including "obdidx"
1783 [ -z "$obdidx" ] && break
1784 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1785 $have_obdidx || continue
1787 local ost=$((obdidx + 1))
1788 local dev=$(ostdevname $ost)
1791 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1793 seq=$(echo $seq | sed -e "s/^0x//g")
1794 if [ $seq == 0 ]; then
1795 oid_hex=$(echo $oid)
1797 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1799 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1803 # Don't unmount/remount the OSTs if we don't need to do that.
1804 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1805 # update too, until that use mount/ll_decode_filter_fid/mount.
1806 # Re-enable when debugfs will understand new filter_fid.
1808 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1809 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1810 $dev 2>/dev/null" | grep "parent=")
1813 mount_fstype ost$ost
1814 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1815 $(facet_mntpt ost$ost)/$obj_file)
1816 unmount_fstype ost$ost
1817 start ost$ost $dev $OST_MOUNT_OPTS
1820 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1822 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1824 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1825 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1826 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1827 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1828 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1830 if echo $ff_parent | grep -q 'stripe='; then
1831 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1834 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1835 # into f_ver in this case. See the comment on
1838 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1842 # compare lmm_seq and filter_fid->ff_parent.f_seq
1843 [ $ff_pseq = $lmm_seq ] ||
1844 error "FF parent SEQ $ff_pseq != $lmm_seq"
1845 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1846 [ $ff_poid = $lmm_oid ] ||
1847 error "FF parent OID $ff_poid != $lmm_oid"
1848 (($ff_pstripe == $stripe_nr)) ||
1849 error "FF stripe $ff_pstripe != $stripe_nr"
1851 stripe_nr=$((stripe_nr + 1))
1856 remote_ost_nodsh && skip "remote OST with nodsh" && return
1857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1858 test_mkdir -p $DIR/$tdir
1860 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1861 { error "setstripe -c -1 failed"; return 1; }
1862 # We need to send a write to every object to get parent FID info set.
1863 # This _should_ also work for setattr, but does not currently.
1864 # touch $DIR/$tdir/$tfile-1 ||
1865 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1866 { error "dd $tfile-1 failed"; return 2; }
1867 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1868 { error "setstripe -c -1 failed"; return 3; }
1869 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1870 { error "dd $tfile-2 failed"; return 4; }
1872 # make sure write RPCs have been sent to OSTs
1875 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1876 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1878 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1880 test_27A() { # b=19102
1881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1882 local restore_size=$($GETSTRIPE -S $MOUNT)
1883 local restore_count=$($GETSTRIPE -c $MOUNT)
1884 local restore_offset=$($GETSTRIPE -i $MOUNT)
1885 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1886 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1887 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1888 local default_size=$($GETSTRIPE -S $MOUNT)
1889 local default_offset=$($GETSTRIPE -i $MOUNT)
1890 local dsize=$((1024 * 1024))
1891 [ $default_size -eq $dsize ] ||
1892 error "stripe size $default_size != $dsize"
1893 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1894 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1896 run_test 27A "check filesystem-wide default LOV EA values"
1898 test_27B() { # LU-2523
1899 test_mkdir -p $DIR/$tdir
1900 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1902 # open f1 with O_LOV_DELAY_CREATE
1904 # call setstripe ioctl on open file descriptor for f1
1906 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1910 # open f1 with O_LOV_DELAY_CREATE
1912 # call setstripe ioctl on open file descriptor for f1
1914 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1916 # Allow multiop to fail in imitation of NFS's busted semantics.
1919 run_test 27B "call setstripe on open unlinked file/rename victim"
1921 test_27C() { #LU-2871
1922 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1930 test_mkdir -p $DIR/$tdir
1932 for i in $(seq 0 $((OSTCOUNT - 1))); do
1933 # set stripe across all OSTs starting from OST$i
1934 $SETSTRIPE -i $i -c -1 $tfile$i
1935 # get striping information
1936 ost_idx=($($GETSTRIPE $tfile$i |
1937 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1941 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1942 error "${#ost_idx[@]} != $OSTCOUNT"
1944 for index in $(seq 0 $((OSTCOUNT - 1))); do
1946 for j in $(echo ${ost_idx[@]}); do
1947 if [ $index -eq $j ]; then
1953 error "Can not find $index in ${ost_idx[@]}"
1957 run_test 27C "check full striping across all OSTs"
1959 # createtest also checks that device nodes are created and
1960 # then visible correctly (#2091)
1961 test_28() { # bug 2091
1963 $CREATETEST $DIR/d28/ct || error
1965 run_test 28 "create/mknod/mkdir with bad file types ============"
1968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1969 cancel_lru_locks mdc
1975 declare -i LOCKCOUNTORIG=0
1976 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1977 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1979 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1981 declare -i LOCKUNUSEDCOUNTORIG=0
1982 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1983 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1990 declare -i LOCKCOUNTCURRENT=0
1991 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1992 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1995 declare -i LOCKUNUSEDCOUNTCURRENT=0
1996 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1997 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2000 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2001 $LCTL set_param -n ldlm.dump_namespaces ""
2002 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2003 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2004 log "dumped log to $TMP/test_29.dk (bug 5793)"
2007 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2008 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2009 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2010 log "dumped log to $TMP/test_29.dk (bug 5793)"
2014 run_test 29 "IT_GETATTR regression ============================"
2016 test_30a() { # was test_30
2017 cp $(which ls) $DIR || cp /bin/ls $DIR
2021 run_test 30a "execute binary from Lustre (execve) =============="
2024 cp `which ls` $DIR || cp /bin/ls $DIR
2026 $RUNAS $DIR/ls / || error
2029 run_test 30b "execute binary from Lustre as non-root ==========="
2031 test_30c() { # b=22376
2032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2033 cp `which ls` $DIR || cp /bin/ls $DIR
2035 cancel_lru_locks mdc
2036 cancel_lru_locks osc
2037 $RUNAS $DIR/ls / || error
2040 run_test 30c "execute binary from Lustre without read perms ===="
2043 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2044 $CHECKSTAT -a $DIR/f31 || error
2046 run_test 31a "open-unlink file =================================="
2049 touch $DIR/f31 || error
2050 ln $DIR/f31 $DIR/f31b || error
2051 $MULTIOP $DIR/f31b Ouc || error
2052 $CHECKSTAT -t file $DIR/f31 || error
2054 run_test 31b "unlink file with multiple links while open ======="
2057 touch $DIR/f31 || error
2058 ln $DIR/f31 $DIR/f31c || error
2059 multiop_bg_pause $DIR/f31 O_uc || return 1
2061 $MULTIOP $DIR/f31c Ouc
2062 kill -USR1 $MULTIPID
2065 run_test 31c "open-unlink file with multiple links ============="
2068 opendirunlink $DIR/d31d $DIR/d31d || error
2069 $CHECKSTAT -a $DIR/d31d || error
2071 run_test 31d "remove of open directory ========================="
2073 test_31e() { # bug 2904
2074 check_kernel_version 34 || return 0
2075 openfilleddirunlink $DIR/d31e || error
2077 run_test 31e "remove of open non-empty directory ==============="
2079 test_31f() { # bug 4554
2080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2082 test_mkdir $DIR/d31f
2083 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2084 cp /etc/hosts $DIR/d31f
2086 $GETSTRIPE $DIR/d31f/hosts
2087 multiop_bg_pause $DIR/d31f D_c || return 1
2090 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2091 test_mkdir $DIR/d31f
2092 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2093 cp /etc/hosts $DIR/d31f
2095 $GETSTRIPE $DIR/d31f/hosts
2096 multiop_bg_pause $DIR/d31f D_c || return 1
2099 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2100 wait $MULTIPID || error "first opendir $MULTIPID failed"
2104 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2105 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2108 run_test 31f "remove of open directory with open-unlink file ==="
2111 echo "-- cross directory link --"
2112 test_mkdir -c1 $DIR/${tdir}ga
2113 test_mkdir -c1 $DIR/${tdir}gb
2114 touch $DIR/${tdir}ga/f
2115 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2116 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2117 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2118 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2119 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2121 run_test 31g "cross directory link==============="
2124 echo "-- cross directory link --"
2125 test_mkdir -c1 $DIR/${tdir}
2126 test_mkdir -c1 $DIR/${tdir}/dir
2127 touch $DIR/${tdir}/f
2128 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2129 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2130 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2131 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2132 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2134 run_test 31h "cross directory link under child==============="
2137 echo "-- cross directory link --"
2138 test_mkdir -c1 $DIR/$tdir
2139 test_mkdir -c1 $DIR/$tdir/dir
2140 touch $DIR/$tdir/dir/f
2141 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2142 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2143 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2144 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2145 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2147 run_test 31i "cross directory link under parent==============="
2150 test_mkdir -c1 -p $DIR/$tdir
2151 test_mkdir -c1 -p $DIR/$tdir/dir1
2152 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2153 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2154 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2155 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2158 run_test 31j "link for directory==============="
2161 test_mkdir -c1 -p $DIR/$tdir
2163 touch $DIR/$tdir/exist
2164 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2165 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2166 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2167 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2168 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2169 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2170 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2173 run_test 31k "link to file: the same, non-existing, dir==============="
2179 touch $DIR/d31m2/exist
2180 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2181 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2182 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2183 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2184 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2185 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2188 run_test 31m "link to file: the same, non-existing, dir==============="
2191 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2192 nlink=$(stat --format=%h $DIR/$tfile)
2193 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2195 local cmd="exec $fd<$DIR/$tfile"
2198 trap "eval $cmd" EXIT
2199 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2200 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2201 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2202 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2203 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2206 run_test 31n "check link count of unlinked file"
2209 local TEMPNAME=$(mktemp $1_XXXXXX)
2210 mlink $TEMPNAME $1 2> /dev/null &&
2211 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2215 test_31o() { # LU-2901
2217 for LOOP in $(seq 100); do
2218 rm -f $DIR/$tdir/$tfile*
2219 for THREAD in $(seq 8); do
2220 link_one $DIR/$tdir/$tfile.$LOOP &
2223 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2224 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2225 error "$LINKS duplicate links to $tfile.$LOOP" &&
2229 run_test 31o "duplicate hard links with same filename"
2232 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2235 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2236 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2238 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2239 error "open unlink test1 failed"
2240 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2241 error "open unlink test2 failed"
2243 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2244 error "test1 still exists"
2245 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2246 error "test2 still exists"
2248 run_test 31p "remove of open striped directory"
2250 cleanup_test32_mount() {
2252 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2257 echo "== more mountpoints and symlinks ================="
2258 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2259 trap cleanup_test32_mount EXIT
2260 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2261 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2262 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2263 cleanup_test32_mount
2265 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2269 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2270 trap cleanup_test32_mount EXIT
2271 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2272 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2273 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2274 cleanup_test32_mount
2276 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2280 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2281 trap cleanup_test32_mount EXIT
2282 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2283 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2284 test_mkdir -p $DIR/$tdir/d2/test_dir
2285 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2286 cleanup_test32_mount
2288 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2292 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2293 trap cleanup_test32_mount EXIT
2294 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2295 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2296 test_mkdir -p $DIR/$tdir/d2/test_dir
2297 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2298 cleanup_test32_mount
2300 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2303 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2304 test_mkdir -p $DIR/d32e/tmp
2305 TMP_DIR=$DIR/d32e/tmp
2306 ln -s $DIR/d32e $TMP_DIR/symlink11
2307 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2308 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2309 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2311 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2314 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2315 test_mkdir -p $DIR/d32f/tmp
2316 TMP_DIR=$DIR/d32f/tmp
2317 ln -s $DIR/d32f $TMP_DIR/symlink11
2318 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2319 ls $DIR/d32f/tmp/symlink11 || error
2320 ls $DIR/d32f/symlink01 || error
2322 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2325 TMP_DIR=$DIR/$tdir/tmp
2326 test_mkdir -p $DIR/$tdir/tmp
2327 test_mkdir $DIR/${tdir}2
2328 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2329 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2330 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2331 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2332 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2333 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2335 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2338 rm -fr $DIR/$tdir $DIR/${tdir}2
2339 TMP_DIR=$DIR/$tdir/tmp
2340 test_mkdir -p $DIR/$tdir/tmp
2341 test_mkdir $DIR/${tdir}2
2342 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2343 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2344 ls $TMP_DIR/symlink12 || error
2345 ls $DIR/$tdir/symlink02 || error
2347 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2351 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2352 trap cleanup_test32_mount EXIT
2353 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2354 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2355 touch $DIR/$tdir/test_file
2356 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2357 cleanup_test32_mount
2359 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2363 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2364 trap cleanup_test32_mount EXIT
2365 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2366 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2367 touch $DIR/$tdir/test_file
2368 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2369 cleanup_test32_mount
2371 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2376 trap cleanup_test32_mount EXIT
2377 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2378 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2379 test_mkdir -p $DIR/$tdir/d2
2380 touch $DIR/$tdir/d2/test_file || error
2381 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2382 cleanup_test32_mount
2384 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2389 trap cleanup_test32_mount EXIT
2390 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2391 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2392 test_mkdir -p $DIR/$tdir/d2
2393 touch $DIR/$tdir/d2/test_file
2394 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2395 cleanup_test32_mount
2397 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2401 test_mkdir -p $DIR/d32m/tmp
2402 TMP_DIR=$DIR/d32m/tmp
2403 ln -s $DIR $TMP_DIR/symlink11
2404 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2405 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2406 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2408 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2412 test_mkdir -p $DIR/d32n/tmp
2413 TMP_DIR=$DIR/d32n/tmp
2414 ln -s $DIR $TMP_DIR/symlink11
2415 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2416 ls -l $DIR/d32n/tmp/symlink11 || error
2417 ls -l $DIR/d32n/symlink01 || error
2419 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2422 rm -fr $DIR/d32o $DIR/$tfile
2424 test_mkdir -p $DIR/d32o/tmp
2425 TMP_DIR=$DIR/d32o/tmp
2426 ln -s $DIR/$tfile $TMP_DIR/symlink12
2427 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2428 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2429 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2430 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2431 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2433 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2443 test_mkdir -p $DIR/d32p/tmp
2445 TMP_DIR=$DIR/d32p/tmp
2447 ln -s $DIR/$tfile $TMP_DIR/symlink12
2449 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2451 cat $DIR/d32p/tmp/symlink12 || error
2453 cat $DIR/d32p/symlink02 || error
2456 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2458 cleanup_testdir_mount() {
2460 $UMOUNT -d $DIR/$tdir
2464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2465 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2466 trap cleanup_testdir_mount EXIT
2467 test_mkdir -p $DIR/$tdir
2468 touch $DIR/$tdir/under_the_mount
2469 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2470 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2471 cleanup_testdir_mount
2473 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2477 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2478 trap cleanup_testdir_mount EXIT
2479 test_mkdir -p $DIR/$tdir
2480 touch $DIR/$tdir/under_the_mount
2481 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2482 ls $DIR/$tdir | grep -q under_the_mount && error || true
2483 cleanup_testdir_mount
2485 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2490 chmod 444 $DIR/$tfile
2491 chown $RUNAS_ID $DIR/$tfile
2493 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2496 run_test 33aa "write file with mode 444 (should return error) ===="
2500 test_mkdir -p $DIR/d33
2501 chown $RUNAS_ID $DIR/d33
2502 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2503 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2504 error "open RDWR" || true
2506 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2510 test_mkdir -p $DIR/d33
2511 chown $RUNAS_ID $DIR/d33
2512 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2514 run_test 33b "test open file with malformed flags (No panic and return error)"
2517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2523 remote_ost_nodsh && skip "remote OST with nodsh" && return
2526 test_mkdir -p $DIR/d33
2527 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2530 for ostnum in $(seq $OSTCOUNT); do
2531 # test-framework's OST numbering is one-based, while Lustre's
2533 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2534 # Parsing llobdstat's output sucks; we could grep the /proc
2535 # path, but that's likely to not be as portable as using the
2536 # llobdstat utility. So we parse lctl output instead.
2537 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2538 obdfilter/$ostname/stats |
2539 awk '/^write_bytes/ {print $7}' )
2540 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2541 if (( ${write_bytes:-0} > 0 ))
2548 $all_zeros || return 0
2551 echo foo > $DIR/d33/bar
2555 # Total up write_bytes after writing. We'd better find non-zeros.
2556 for ostnum in $(seq $OSTCOUNT); do
2557 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2558 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2559 obdfilter/$ostname/stats |
2560 awk '/^write_bytes/ {print $7}' )
2561 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2562 if (( ${write_bytes:-0} > 0 ))
2571 for ostnum in $(seq $OSTCOUNT); do
2572 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2573 echo "Check that write_bytes is present in obdfilter/*/stats:"
2574 do_facet ost$ostnum lctl get_param -n \
2575 obdfilter/$ostname/stats
2577 error "OST not keeping write_bytes stats (b22312)"
2580 run_test 33c "test llobdstat and write_bytes"
2583 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2586 local remote_dir=$DIR/$tdir/remote_dir
2589 $LFS mkdir -i $MDTIDX $remote_dir ||
2590 error "create remote directory failed"
2592 touch $remote_dir/$tfile
2593 chmod 444 $remote_dir/$tfile
2594 chown $RUNAS_ID $remote_dir/$tfile
2596 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2598 chown $RUNAS_ID $remote_dir
2599 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2600 error "create" || true
2601 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2602 error "open RDWR" || true
2603 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2604 error "create" || true
2606 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2608 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2611 $MCREATE $DIR/f34 || error
2612 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2613 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2614 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2615 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2617 run_test 34a "truncate file that has not been opened ==========="
2620 [ ! -f $DIR/f34 ] && test_34a
2621 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2622 $OPENFILE -f O_RDONLY $DIR/f34
2623 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2624 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2626 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2629 [ ! -f $DIR/f34 ] && test_34a
2630 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2631 $OPENFILE -f O_RDWR $DIR/f34
2632 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2633 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2635 run_test 34c "O_RDWR opening file-with-size works =============="
2638 [ ! -f $DIR/f34 ] && test_34a
2639 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2640 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2643 run_test 34d "write to sparse file ============================="
2647 $MCREATE $DIR/f34e || error
2648 $TRUNCATE $DIR/f34e 1000 || error
2649 $CHECKSTAT -s 1000 $DIR/f34e || error
2650 $OPENFILE -f O_RDWR $DIR/f34e
2651 $CHECKSTAT -s 1000 $DIR/f34e || error
2653 run_test 34e "create objects, some with size and some without =="
2655 test_34f() { # bug 6242, 6243
2656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2659 $MCREATE $DIR/f34f || error
2660 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2661 dd if=$DIR/f34f of=$TMP/f34f
2662 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2663 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2664 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2665 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2666 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2668 run_test 34f "read from a file with no objects until EOF ======="
2671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2672 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2673 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2674 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2675 cancel_lru_locks osc
2676 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2677 error "wrong size after lock cancel"
2679 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2680 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2681 error "expanding truncate failed"
2682 cancel_lru_locks osc
2683 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2684 error "wrong expanded size after lock cancel"
2686 run_test 34g "truncate long file ==============================="
2689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2693 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2694 sync # Flush the cache so that multiop below does not block on cache
2695 # flush when getting the group lock
2696 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2699 # Since just timed wait is not good enough, let's do a sync write
2700 # that way we are sure enough time for a roundtrip + processing
2701 # passed + 2 seconds of extra margin.
2702 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2706 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2707 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2711 local nsz=`stat -c %s $DIR/$tfile`
2712 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2714 run_test 34h "ftruncate file under grouplock should not block"
2717 cp /bin/sh $DIR/f35a
2719 chown $RUNAS_ID $DIR/f35a
2720 $RUNAS $DIR/f35a && error || true
2723 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2727 utime $DIR/f36 || error
2729 run_test 36a "MDS utime check (mknod, utime) ==================="
2733 utime $DIR/f36 || error
2735 run_test 36b "OST utime check (open, utime) ===================="
2740 chown $RUNAS_ID $DIR/d36
2741 $RUNAS utime $DIR/d36/f36 || error
2743 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2746 [ ! -d $DIR/d36 ] && test_36c
2747 echo "" > $DIR/d36/f36
2748 $RUNAS utime $DIR/d36/f36 || error
2750 run_test 36d "non-root OST utime check (open, utime) ==========="
2753 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2754 test_mkdir -p $DIR/$tdir
2755 touch $DIR/$tdir/$tfile
2756 $RUNAS utime $DIR/$tdir/$tfile && \
2757 error "utime worked, expected failure" || true
2759 run_test 36e "utime on non-owned file (should return error) ===="
2763 local LANG_SAVE=$LANG
2764 local LC_LANG_SAVE=$LC_LANG
2765 export LANG=C LC_LANG=C # for date language
2767 DATESTR="Dec 20 2000"
2768 test_mkdir -p $DIR/$tdir
2769 lctl set_param fail_loc=$fl
2771 cp /etc/hosts $DIR/$tdir/$tfile
2772 sync & # write RPC generated with "current" inode timestamp, but delayed
2774 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2775 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2776 cancel_lru_locks osc
2777 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2779 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2780 echo "BEFORE: $LS_BEFORE" && \
2781 echo "AFTER : $LS_AFTER" && \
2782 echo "WANT : $DATESTR" && \
2783 error "$DIR/$tdir/$tfile timestamps changed" || true
2785 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2790 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2791 subr_36fh "0x80000214"
2793 run_test 36f "utime on file racing with OST BRW write =========="
2796 remote_ost_nodsh && skip "remote OST with nodsh" && return
2797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2802 test_mkdir -p $DIR/$tdir
2803 fmd_max_age=$(do_facet ost1 \
2804 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2807 fmd_before=$(do_facet ost1 \
2808 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2809 touch $DIR/$tdir/$tfile
2810 sleep $((fmd_max_age + 12))
2811 fmd_after=$(do_facet ost1 \
2812 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2814 echo "fmd_before: $fmd_before"
2815 echo "fmd_after: $fmd_after"
2816 [[ $fmd_after -gt $fmd_before ]] &&
2817 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2818 error "fmd didn't expire after ping" || true
2820 run_test 36g "filter mod data cache expiry ====================="
2823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2824 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2825 subr_36fh "0x80000227"
2827 run_test 36h "utime on file racing with OST BRW write =========="
2830 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2833 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2835 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2836 local new_mtime=$((mtime + 200))
2838 #change Modify time of striped dir
2839 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2840 error "change mtime failed"
2842 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2844 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2846 run_test 36i "change mtime on striped directory"
2848 # test_37 - duplicate with tests 32q 32r
2851 local file=$DIR/$tfile
2853 openfile -f O_DIRECTORY $file
2856 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2857 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2859 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2863 touch $DIR/${tfile}2
2864 # ls -l $DIR/$tfile $DIR/${tfile}2
2865 # ls -lu $DIR/$tfile $DIR/${tfile}2
2866 # ls -lc $DIR/$tfile $DIR/${tfile}2
2868 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2869 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2871 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2873 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2875 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2876 error "O_TRUNC didn't change timestamps"
2879 run_test 39 "mtime changed on create ==========================="
2882 test_mkdir -p -c1 $DIR/$tdir
2883 cp -p /etc/passwd $DIR/$tdir/fopen
2884 cp -p /etc/passwd $DIR/$tdir/flink
2885 cp -p /etc/passwd $DIR/$tdir/funlink
2886 cp -p /etc/passwd $DIR/$tdir/frename
2887 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2890 echo "aaaaaa" >> $DIR/$tdir/fopen
2891 echo "aaaaaa" >> $DIR/$tdir/flink
2892 echo "aaaaaa" >> $DIR/$tdir/funlink
2893 echo "aaaaaa" >> $DIR/$tdir/frename
2895 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2896 local link_new=`stat -c %Y $DIR/$tdir/flink`
2897 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2898 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2900 cat $DIR/$tdir/fopen > /dev/null
2901 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2902 rm -f $DIR/$tdir/funlink2
2903 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2905 for (( i=0; i < 2; i++ )) ; do
2906 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2907 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2908 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2909 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2911 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2912 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2913 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2914 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2916 cancel_lru_locks osc
2917 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2920 run_test 39b "mtime change on open, link, unlink, rename ======"
2922 # this should be set to past
2923 TEST_39_MTIME=`date -d "1 year ago" +%s`
2929 local mtime0=`stat -c %Y $DIR1/$tfile`
2931 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2932 local mtime1=`stat -c %Y $DIR1/$tfile`
2933 [ "$mtime1" = $TEST_39_MTIME ] || \
2934 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2937 echo hello >> $DIR1/$tfile
2939 local mtime2=`stat -c %Y $DIR1/$tfile`
2940 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2941 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2943 mv $DIR1/$tfile $DIR1/$tfile-1
2945 for (( i=0; i < 2; i++ )) ; do
2946 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2947 [ "$mtime2" = "$mtime3" ] || \
2948 error "mtime ($mtime2) changed (to $mtime3) on rename"
2950 cancel_lru_locks osc
2951 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2954 run_test 39c "mtime change on rename ==========================="
2958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2961 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2963 for (( i=0; i < 2; i++ )) ; do
2964 local mtime=`stat -c %Y $DIR1/$tfile`
2965 [ $mtime = $TEST_39_MTIME ] || \
2966 error "mtime($mtime) is not set to $TEST_39_MTIME"
2968 cancel_lru_locks osc
2969 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2972 run_test 39d "create, utime, stat =============================="
2976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2978 local mtime1=`stat -c %Y $DIR1/$tfile`
2980 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2982 for (( i=0; i < 2; i++ )) ; do
2983 local mtime2=`stat -c %Y $DIR1/$tfile`
2984 [ $mtime2 = $TEST_39_MTIME ] || \
2985 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2987 cancel_lru_locks osc
2988 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2991 run_test 39e "create, stat, utime, stat ========================"
2995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2997 mtime1=`stat -c %Y $DIR1/$tfile`
3000 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3002 for (( i=0; i < 2; i++ )) ; do
3003 local mtime2=`stat -c %Y $DIR1/$tfile`
3004 [ $mtime2 = $TEST_39_MTIME ] || \
3005 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3007 cancel_lru_locks osc
3008 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3011 run_test 39f "create, stat, sleep, utime, stat ================="
3015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3016 echo hello >> $DIR1/$tfile
3017 local mtime1=`stat -c %Y $DIR1/$tfile`
3020 chmod o+r $DIR1/$tfile
3022 for (( i=0; i < 2; i++ )) ; do
3023 local mtime2=`stat -c %Y $DIR1/$tfile`
3024 [ "$mtime1" = "$mtime2" ] || \
3025 error "lost mtime: $mtime2, should be $mtime1"
3027 cancel_lru_locks osc
3028 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3031 run_test 39g "write, chmod, stat ==============================="
3035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3040 echo hello >> $DIR1/$tfile
3041 local mtime1=`stat -c %Y $DIR1/$tfile`
3043 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3045 if [ "$d1" != "$d2" ]; then
3046 echo "write and touch not within one second"
3048 for (( i=0; i < 2; i++ )) ; do
3049 local mtime2=`stat -c %Y $DIR1/$tfile`
3050 [ "$mtime2" = $TEST_39_MTIME ] || \
3051 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3053 cancel_lru_locks osc
3054 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3058 run_test 39h "write, utime within one second, stat ============="
3061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3065 echo hello >> $DIR1/$tfile
3066 local mtime1=`stat -c %Y $DIR1/$tfile`
3068 mv $DIR1/$tfile $DIR1/$tfile-1
3070 for (( i=0; i < 2; i++ )) ; do
3071 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3073 [ "$mtime1" = "$mtime2" ] || \
3074 error "lost mtime: $mtime2, should be $mtime1"
3076 cancel_lru_locks osc
3077 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3080 run_test 39i "write, rename, stat =============================="
3083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 start_full_debug_logging
3088 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3089 lctl set_param fail_loc=0x80000412
3090 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3091 error "multiop failed"
3093 local mtime1=`stat -c %Y $DIR1/$tfile`
3095 mv $DIR1/$tfile $DIR1/$tfile-1
3097 kill -USR1 $multipid
3098 wait $multipid || error "multiop close failed"
3100 for (( i=0; i < 2; i++ )) ; do
3101 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3102 [ "$mtime1" = "$mtime2" ] ||
3103 error "mtime is lost on close: $mtime2, " \
3106 cancel_lru_locks osc
3107 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3109 lctl set_param fail_loc=0
3110 stop_full_debug_logging
3112 run_test 39j "write, rename, close, stat ======================="
3115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3119 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3121 local mtime1=`stat -c %Y $DIR1/$tfile`
3123 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3125 kill -USR1 $multipid
3126 wait $multipid || error "multiop close failed"
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3131 [ "$mtime2" = $TEST_39_MTIME ] || \
3132 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3134 cancel_lru_locks osc
3135 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39k "write, utime, close, stat ========================"
3140 # this should be set to future
3141 TEST_39_ATIME=`date -d "1 year" +%s`
3144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3145 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3146 local atime_diff=$(do_facet $SINGLEMDS \
3147 lctl get_param -n mdd.*MDT0000*.atime_diff)
3151 # test setting directory atime to future
3152 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3153 local atime=$(stat -c %X $DIR/$tdir)
3154 [ "$atime" = $TEST_39_ATIME ] || \
3155 error "atime is not set to future: $atime, $TEST_39_ATIME"
3157 # test setting directory atime from future to now
3158 local d1=$(date +%s)
3160 local d2=$(date +%s)
3162 cancel_lru_locks mdc
3163 atime=$(stat -c %X $DIR/$tdir)
3164 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3165 error "atime is not updated from future: $atime, $d1<atime<$d2"
3167 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3170 # test setting directory atime when now > dir atime + atime_diff
3174 cancel_lru_locks mdc
3175 atime=$(stat -c %X $DIR/$tdir)
3176 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3177 error "atime is not updated : $atime, should be $d2"
3179 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3182 # test not setting directory atime when now < dir atime + atime_diff
3184 cancel_lru_locks mdc
3185 atime=$(stat -c %X $DIR/$tdir)
3186 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3187 error "atime is updated to $atime, should remain $d1<atime<$d2"
3189 do_facet $SINGLEMDS \
3190 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3192 run_test 39l "directory atime update ==========================="
3195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3198 local far_past_mtime=$(date -d "May 29 1953" +%s)
3199 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3201 touch -m -d @$far_past_mtime $DIR1/$tfile
3202 touch -a -d @$far_past_atime $DIR1/$tfile
3204 for (( i=0; i < 2; i++ )) ; do
3205 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3206 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3207 error "atime or mtime set incorrectly"
3209 cancel_lru_locks osc
3210 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3213 run_test 39m "test atime and mtime before 1970"
3215 test_39n() { # LU-3832
3216 local atime_diff=$(do_facet $SINGLEMDS \
3217 lctl get_param -n mdd.*MDT0000*.atime_diff)
3222 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3225 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3226 atime0=$(stat -c %X $DIR/$tfile)
3229 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3230 atime1=$(stat -c %X $DIR/$tfile)
3233 cancel_lru_locks mdc
3234 cancel_lru_locks osc
3235 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3236 atime2=$(stat -c %X $DIR/$tfile)
3238 do_facet $SINGLEMDS \
3239 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3241 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3242 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3244 run_test 39n "check that O_NOATIME is honored"
3247 TESTDIR=$DIR/$tdir/$tfile
3248 [ -e $TESTDIR ] && rm -rf $TESTDIR
3249 test_mkdir -p $TESTDIR
3255 links2=$(stat -c %h .)
3256 [ $(($links1 + 2)) != $links2 ] &&
3257 error "wrong links count $(($links1 + 2)) != $links2"
3259 links3=$(stat -c %h .)
3260 [ $(($links1 + 1)) != $links3 ] &&
3261 error "wrong links count $links1 != $links3"
3264 run_test 39o "directory cached attributes updated after create ========"
3267 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3269 TESTDIR=$DIR/$tdir/$tfile
3270 [ -e $TESTDIR ] && rm -rf $TESTDIR
3275 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3276 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3278 links2=$(stat -c %h .)
3279 [ $(($links1 + 2)) != $links2 ] &&
3280 error "wrong links count $(($links1 + 2)) != $links2"
3282 links3=$(stat -c %h .)
3283 [ $(($links1 + 1)) != $links3 ] &&
3284 error "wrong links count $links1 != $links3"
3287 run_test 39p "remote directory cached attributes updated after create ========"
3291 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3292 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3293 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3294 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3295 error "$tfile is not 4096 bytes in size"
3297 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3301 small_write $DIR/f41 18
3303 run_test 41 "test small file write + fstat ====================="
3305 count_ost_writes() {
3306 lctl get_param -n osc.*.stats |
3307 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3308 END { printf("%0.0f", writes) }'
3315 BG_DIRTY_RATIO_SAVE=10
3316 MAX_BG_DIRTY_RATIO=25
3320 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3321 # dirty_ratio, dirty_background_ratio
3322 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3323 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3324 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3325 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3327 # if file not here, we are a 2.4 kernel
3328 kill -CONT `pidof kupdated`
3333 # setup the trap first, so someone cannot exit the test at the
3334 # exact wrong time and mess up a machine
3335 trap start_writeback EXIT
3336 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3337 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3338 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3339 sysctl -w vm.dirty_writeback_centisecs=0
3340 sysctl -w vm.dirty_writeback_centisecs=0
3341 # save and increase /proc/sys/vm/dirty_ratio
3342 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3343 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3344 # save and increase /proc/sys/vm/dirty_background_ratio
3345 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3346 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3348 # if file not here, we are a 2.4 kernel
3349 kill -STOP `pidof kupdated`
3353 # ensure that all stripes have some grant before we test client-side cache
3355 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3356 dd if=/dev/zero of=$i bs=4k count=1
3361 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3362 # file truncation, and file removal.
3364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3366 cancel_lru_locks osc
3368 sync; sleep 1; sync # just to be safe
3369 BEFOREWRITES=`count_ost_writes`
3370 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3371 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3372 AFTERWRITES=`count_ost_writes`
3373 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3374 error "$BEFOREWRITES < $AFTERWRITES"
3377 run_test 42a "ensure that we don't flush on close =============="
3380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3382 cancel_lru_locks osc
3385 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3386 BEFOREWRITES=$(count_ost_writes)
3387 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3388 AFTERWRITES=$(count_ost_writes)
3389 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3390 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3392 BEFOREWRITES=$(count_ost_writes)
3393 sync || error "sync: $?"
3394 AFTERWRITES=$(count_ost_writes)
3395 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3396 error "$BEFOREWRITES < $AFTERWRITES on sync"
3398 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3402 run_test 42b "test destroy of file with cached dirty data ======"
3404 # if these tests just want to test the effect of truncation,
3405 # they have to be very careful. consider:
3406 # - the first open gets a {0,EOF}PR lock
3407 # - the first write conflicts and gets a {0, count-1}PW
3408 # - the rest of the writes are under {count,EOF}PW
3409 # - the open for truncate tries to match a {0,EOF}PR
3410 # for the filesize and cancels the PWs.
3411 # any number of fixes (don't get {0,EOF} on open, match
3412 # composite locks, do smarter file size management) fix
3413 # this, but for now we want these tests to verify that
3414 # the cancellation with truncate intent works, so we
3415 # start the file with a full-file pw lock to match against
3416 # until the truncate.
3421 cancel_lru_locks osc
3423 # prime the file with 0,EOF PW to match
3427 # now the real test..
3428 dd if=/dev/zero of=$file bs=1024 count=100
3429 BEFOREWRITES=`count_ost_writes`
3430 $TRUNCATE $file $offset
3431 cancel_lru_locks osc
3432 AFTERWRITES=`count_ost_writes`
3437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3439 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3440 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3443 run_test 42c "test partial truncate of file with cached dirty data"
3446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3448 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3449 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3452 run_test 42d "test complete truncate of file with cached dirty data"
3454 test_42e() { # bug22074
3455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3456 local TDIR=$DIR/${tdir}e
3457 local pagesz=$(page_size)
3458 local pages=16 # hardcoded 16 pages, don't change it.
3459 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3460 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3464 test_mkdir -p $DIR/${tdir}e
3465 $SETSTRIPE -c 1 $TDIR
3466 createmany -o $TDIR/f $files
3468 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3470 # we assume that with $OSTCOUNT files, at least one of them will
3471 # be allocated on OST0.
3472 warmup_files=$((OSTCOUNT * max_dirty_mb))
3473 createmany -o $TDIR/w $warmup_files
3475 # write a large amount of data into one file and sync, to get good
3476 # avail_grant number from OST.
3477 for ((i=0; i<$warmup_files; i++)); do
3478 idx=$($GETSTRIPE -i $TDIR/w$i)
3479 [ $idx -ne 0 ] && continue
3480 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3483 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3485 $LCTL get_param $proc_osc0/cur_dirty_bytes
3486 $LCTL get_param $proc_osc0/cur_grant_bytes
3488 # create as much dirty pages as we can while not to trigger the actual
3489 # RPCs directly. but depends on the env, VFS may trigger flush during this
3490 # period, hopefully we are good.
3491 for ((i=0; i<$warmup_files; i++)); do
3492 idx=$($GETSTRIPE -i $TDIR/w$i)
3493 [ $idx -ne 0 ] && continue
3494 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3496 $LCTL get_param $proc_osc0/cur_dirty_bytes
3497 $LCTL get_param $proc_osc0/cur_grant_bytes
3499 # perform the real test
3500 $LCTL set_param $proc_osc0/rpc_stats 0
3501 for ((;i<$files; i++)); do
3502 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3503 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3506 $LCTL get_param $proc_osc0/rpc_stats
3509 local have_ppr=false
3510 $LCTL get_param $proc_osc0/rpc_stats |
3511 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3512 # skip lines until we are at the RPC histogram data
3513 [ "$PPR" == "pages" ] && have_ppr=true && continue
3514 $have_ppr || continue
3516 # we only want the percent stat for < 16 pages
3517 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3519 percent=$((percent + WPCT))
3520 if [[ $percent -gt 15 ]]; then
3521 error "less than 16-pages write RPCs" \
3528 run_test 42e "verify sub-RPC writes are not done synchronously"
3531 test_mkdir -p $DIR/$tdir
3532 cp -p /bin/ls $DIR/$tdir/$tfile
3533 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3535 # give multiop a chance to open
3538 $DIR/$tdir/$tfile && error || true
3541 run_test 43 "execution of file opened for write should return -ETXTBSY"
3544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3545 test_mkdir -p $DIR/$tdir
3546 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3547 cp -p multiop $DIR/$tdir/multiop
3548 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3551 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3552 kill -USR1 $MULTIOP_PID || return 2
3553 wait $MULTIOP_PID || return 3
3554 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3556 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3560 test_mkdir -p $DIR/$tdir
3561 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3562 cp -p multiop $DIR/$tdir/multiop
3563 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3566 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3567 kill -USR1 $MULTIOP_PID || return 2
3568 wait $MULTIOP_PID || return 3
3569 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3571 run_test 43b "truncate of file being executed should return -ETXTBSY"
3574 local testdir="$DIR/$tdir"
3575 test_mkdir -p $DIR/$tdir
3577 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3578 ( cd $testdir && md5sum -c)
3580 run_test 43c "md5sum of copy into lustre========================"
3583 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3584 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3585 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3587 run_test 44 "zero length read from a sparse stripe ============="
3590 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3592 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3593 [[ $nstripe -gt $OSTCOUNT ]] &&
3594 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3596 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3598 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3599 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3603 OFFSETS="0 $((stride/2)) $((stride-1))"
3604 for offset in $OFFSETS; do
3605 for i in $(seq 0 $((nstripe-1))); do
3606 local GLOBALOFFSETS=""
3608 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3609 local myfn=$DIR/d44a-$size
3610 echo "--------writing $myfn at $size"
3611 ll_sparseness_write $myfn $size ||
3612 error "ll_sparseness_write"
3613 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3614 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3615 error "ll_sparseness_verify $GLOBALOFFSETS"
3617 for j in $(seq 0 $((nstripe-1))); do
3619 size=$((((j + $nstripe )*$stride + $offset)))
3620 ll_sparseness_write $myfn $size ||
3621 error "ll_sparseness_write"
3622 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3624 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3625 error "ll_sparseness_verify $GLOBALOFFSETS"
3630 run_test 44a "test sparse pwrite ==============================="
3634 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3640 before=`dirty_osc_total`
3641 echo executing "\"$*\""
3643 after=`dirty_osc_total`
3644 echo before $before, after $after
3647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3649 # Obtain grants from OST if it supports it
3650 echo blah > ${f}_grant
3653 do_dirty_record "echo blah > $f"
3654 [[ $before -eq $after ]] && error "write wasn't cached"
3655 do_dirty_record "> $f"
3656 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3657 do_dirty_record "echo blah > $f"
3658 [[ $before -eq $after ]] && error "write wasn't cached"
3659 do_dirty_record "sync"
3660 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3661 do_dirty_record "echo blah > $f"
3662 [[ $before -eq $after ]] && error "write wasn't cached"
3663 do_dirty_record "cancel_lru_locks osc"
3664 [[ $before -gt $after ]] ||
3665 error "lock cancellation didn't lower dirty count"
3668 run_test 45 "osc io page accounting ============================"
3670 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3671 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3672 # objects offset and an assert hit when an rpc was built with 1023's mapped
3673 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3679 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3681 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3682 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3686 run_test 46 "dirtying a previously written page ================"
3688 # test_47 is removed "Device nodes check" is moved to test_28
3690 test_48a() { # bug 2399
3691 check_kernel_version 34 || return 0
3692 test_mkdir -p $DIR/$tdir
3694 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3695 test_mkdir $DIR/$tdir || error "recreate directory failed"
3696 touch foo || error "'touch foo' failed after recreating cwd"
3697 test_mkdir $DIR/$tdir/bar ||
3698 error "'mkdir foo' failed after recreating cwd"
3699 if check_kernel_version 44; then
3700 touch .foo || error "'touch .foo' failed after recreating cwd"
3701 test_mkdir $DIR/$tdir/.bar ||
3702 error "'mkdir .foo' failed after recreating cwd"
3704 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3705 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3706 cd . || error "'cd .' failed after recreating cwd"
3707 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3708 rmdir . && error "'rmdir .' worked after recreating cwd"
3709 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3710 cd .. || error "'cd ..' failed after recreating cwd"
3712 run_test 48a "Access renamed working dir (should return errors)="
3714 test_48b() { # bug 2399
3715 check_kernel_version 34 || return 0
3717 test_mkdir -p $DIR/$tdir
3719 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3720 touch foo && error "'touch foo' worked after removing cwd"
3721 test_mkdir $DIR/$tdir/foo &&
3722 error "'mkdir foo' worked after removing cwd"
3723 if check_kernel_version 44; then
3724 touch .foo && error "'touch .foo' worked after removing cwd"
3725 test_mkdir $DIR/$tdir/.foo &&
3726 error "'mkdir .foo' worked after removing cwd"
3728 ls . > /dev/null && error "'ls .' worked after removing cwd"
3729 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3730 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3731 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3732 rmdir . && error "'rmdir .' worked after removing cwd"
3733 ln -s . foo && error "'ln -s .' worked after removing cwd"
3734 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3736 run_test 48b "Access removed working dir (should return errors)="
3738 test_48c() { # bug 2350
3739 check_kernel_version 36 || return 0
3740 #lctl set_param debug=-1
3743 test_mkdir -p $DIR/$tdir/dir
3745 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3746 $TRACE touch foo && error "touch foo worked after removing cwd"
3747 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3748 if check_kernel_version 44; then
3749 touch .foo && error "touch .foo worked after removing cwd"
3750 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3752 $TRACE ls . && error "'ls .' worked after removing cwd"
3753 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3754 is_patchless || ( $TRACE cd . &&
3755 error "'cd .' worked after removing cwd" )
3756 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3757 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3758 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3759 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3761 run_test 48c "Access removed working subdir (should return errors)"
3763 test_48d() { # bug 2350
3764 check_kernel_version 36 || return 0
3765 #lctl set_param debug=-1
3768 test_mkdir -p $DIR/$tdir/dir
3770 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3771 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3772 $TRACE touch foo && error "'touch foo' worked after removing parent"
3773 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3774 if check_kernel_version 44; then
3775 touch .foo && error "'touch .foo' worked after removing parent"
3777 error "mkdir .foo worked after removing parent"
3779 $TRACE ls . && error "'ls .' worked after removing parent"
3780 $TRACE ls .. && error "'ls ..' worked after removing parent"
3781 is_patchless || ( $TRACE cd . &&
3782 error "'cd .' worked after recreate parent" )
3783 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3784 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3785 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3786 is_patchless || ( $TRACE cd .. &&
3787 error "'cd ..' worked after removing parent" || true )
3789 run_test 48d "Access removed parent subdir (should return errors)"
3791 test_48e() { # bug 4134
3792 check_kernel_version 41 || return 0
3793 #lctl set_param debug=-1
3796 test_mkdir -p $DIR/$tdir/dir
3798 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3799 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3800 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3801 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3802 # On a buggy kernel addition of "touch foo" after cd .. will
3803 # produce kernel oops in lookup_hash_it
3804 touch ../foo && error "'cd ..' worked after recreate parent"
3806 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3808 run_test 48e "Access to recreated parent subdir (should return errors)"
3810 test_49() { # LU-1030
3811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3812 # get ost1 size - lustre-OST0000
3813 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3815 # write 800M at maximum
3816 [[ $ost1_size -lt 2 ]] && ost1_size=2
3817 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3819 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3820 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3823 # change max_pages_per_rpc while writing the file
3824 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3825 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3826 # loop until dd process exits
3827 while ps ax -opid | grep -wq $dd_pid; do
3828 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3829 sleep $((RANDOM % 5 + 1))
3831 # restore original max_pages_per_rpc
3832 $LCTL set_param $osc1_mppc=$orig_mppc
3833 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3835 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3839 test_mkdir $DIR/$tdir
3841 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3843 run_test 50 "special situations: /proc symlinks ==============="
3845 test_51a() { # was test_51
3846 # bug 1516 - create an empty entry right after ".." then split dir
3847 test_mkdir -c1 $DIR/$tdir
3848 touch $DIR/$tdir/foo
3849 $MCREATE $DIR/$tdir/bar
3851 createmany -m $DIR/$tdir/longfile 201
3853 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3854 $MCREATE $DIR/$tdir/longfile$FNUM
3859 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3861 run_test 51a "special situations: split htree with empty entry =="
3863 export NUMTEST=70000
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3866 local BASE=$DIR/d${base}.${TESTSUITE}
3868 # cleanup the directory
3871 test_mkdir -p -c1 $BASE
3873 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3874 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3875 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3878 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3879 echo "reduced count to $NUMTEST due to inodes"
3881 # need to check free space for the directories as well
3882 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3883 numfree=$((blkfree / 4))
3884 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3885 echo "reduced count to $NUMTEST due to blocks"
3887 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3888 echo "failed" > $BASE/fnum
3890 run_test 51b "exceed 64k subdirectory nlink limit"
3892 test_51ba() { # LU-993
3893 local BASE=$DIR/d${base}.${TESTSUITE}
3894 # unlink all but 100 subdirectories, then check it still works
3896 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3898 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3899 local DELETE=$((NUMTEST - LEFT))
3901 # continue on to run this test even if 51b didn't finish,
3902 # just to delete the many subdirectories created.
3903 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3905 # for ldiskfs the nlink count should be 1, but this is OSD specific
3906 # and so this is listed for informational purposes only
3907 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3908 unlinkmany -d $BASE/d $DELETE
3911 if [ $RC -ne 0 ]; then
3912 if [ "$NUMPREV" == "failed" ]; then
3913 skip "previous setup failed"
3916 error "unlink of first $DELETE subdirs failed"
3921 echo "nlink between: $(stat -c %h $BASE)"
3922 # trim the first line of ls output
3923 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3924 [ $FOUND -ne $LEFT ] &&
3925 error "can't find subdirs: found only $FOUND/$LEFT"
3927 unlinkmany -d $BASE/d $DELETE $LEFT ||
3928 error "unlink of second $LEFT subdirs failed"
3929 # regardless of whether the backing filesystem tracks nlink accurately
3930 # or not, the nlink count shouldn't be more than "." and ".." here
3931 local AFTER=$(stat -c %h $BASE)
3932 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
3933 echo "nlink after: $AFTER"
3935 run_test 51ba "verify nlink for many subdirectory cleanup"
3938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3939 [[ $OSTCOUNT -lt 3 ]] &&
3940 skip_env "skipping test with few OSTs" && return
3941 test_mkdir -p $DIR/$tdir
3942 createmany -o $DIR/$tdir/t- 1000
3943 $GETSTRIPE $DIR/$tdir > $TMP/files
3944 for N in $(seq 0 $((OSTCOUNT - 1))); do
3945 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
3946 END { printf("%0.0f", objs) }' $TMP/files)
3947 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
3948 '($1 == '$N') { objs += 1 } \
3949 END { printf("%0.0f", objs) }')
3950 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3952 unlinkmany $DIR/$tdir/t- 1000
3955 for N in $(seq 1 $((OSTCOUNT - 1))); do
3956 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
3957 error "OST $N has less objects vs OST $NLAST" \
3958 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3959 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
3960 error "OST $N has less objects vs OST $NLAST" \
3961 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3963 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
3964 error "OST $N has less #0 objects vs OST $NLAST" \
3965 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3966 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
3967 error "OST $N has less #0 objects vs OST $NLAST" \
3968 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3972 run_test 51d "check object distribution ===================="
3975 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3976 test_mkdir -p $DIR/$tdir
3977 touch $DIR/$tdir/foo
3978 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3979 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3980 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3981 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3982 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3984 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3985 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3986 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3988 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3989 cp -r $DIR/$tdir /tmp/
3990 rm -fr $DIR/$tdir || error "cleanup rm failed"
3992 run_test 52a "append-only flag test (should return errors) ====="
3995 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3996 test_mkdir -p $DIR/$tdir
3997 touch $DIR/$tdir/foo
3998 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3999 cat test > $DIR/$tdir/foo && error "cat test worked"
4000 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4001 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4002 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4004 echo foo >> $DIR/$tdir/foo && error "echo worked"
4005 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4006 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4007 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4008 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4010 chattr -i $DIR/$tdir/foo || error "chattr failed"
4012 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4014 run_test 52b "immutable flag test (should return errors) ======="
4017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4018 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4019 remote_ost_nodsh && skip "remote OST with nodsh" && return
4032 local support_last_seq=true
4034 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4035 support_last_seq=false
4038 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4040 for value in $(do_facet $SINGLEMDS \
4041 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4042 param=$(echo ${value[0]} | cut -d "=" -f1)
4043 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4045 if $support_last_seq; then
4046 param_seq=$(echo $param |
4047 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4048 mds_last_seq=$(do_facet $SINGLEMDS \
4049 $LCTL get_param -n $param_seq)
4051 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4053 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4054 node=$(facet_active_host ost$((ostnum+1)))
4055 param="obdfilter.$ostname.last_id"
4056 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4057 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4058 ost_last_id=$ost_last
4060 if $support_last_seq; then
4061 ost_last_id=$(echo $ost_last |
4062 awk -F':' '{print $2}' |
4064 ost_last_seq=$(echo $ost_last |
4065 awk -F':' '{print $1}')
4066 [[ $ost_last_seq = $mds_last_seq ]] || continue
4069 if [[ $ost_last_id != $mds_last ]]; then
4070 error "$ost_last_id != $mds_last"
4077 $found || error "can not match last_seq/last_id for $mdtosc"
4080 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4083 $SOCKETSERVER $DIR/socket ||
4084 error "$SOCKETSERVER $DIR/socket failed: $?"
4085 $SOCKETCLIENT $DIR/socket ||
4086 error "$SOCKETCLIENT $DIR/socket failed: $?"
4087 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4089 run_test 54a "unix domain socket test =========================="
4095 dd if=/dev/zero of=$f bs=$(page_size) count=1
4097 run_test 54b "char device works in lustre ======================"
4100 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4101 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4102 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4104 for i in $(seq 3 7); do
4105 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4113 loopdev="$DIR/loop54c"
4116 $UMOUNT -d $tdir || rc=$?
4117 losetup -d $loopdev || true
4123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4126 loopdev="$DIR/loop54c"
4129 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4130 mknod $loopdev b 7 $LOOPNUM
4131 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4132 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4133 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4134 trap cleanup_54c EXIT
4135 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4137 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4138 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4140 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4143 run_test 54c "block device works in lustre ====================="
4149 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4151 run_test 54d "fifo device works in lustre ======================"
4154 check_kernel_version 46 || return 0
4157 cp -aL /dev/console $f
4158 echo $string > $f || error "echo $string to $f failed"
4160 run_test 54e "console/tty device works in lustre ======================"
4162 #The test_55 used to be iopen test and it was removed by bz#24037.
4163 #run_test 55 "check iopen_connect_dentry() ======================"
4165 test_56a() { # was test_56
4168 test_mkdir -p $DIR/$tdir/dir
4170 NUMFILESx2=$(($NUMFILES * 2))
4171 for i in $(seq 1 $NUMFILES); do
4172 touch $DIR/$tdir/file$i
4173 touch $DIR/$tdir/dir/file$i
4176 # test lfs getstripe with --recursive
4177 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4178 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4179 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4180 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4181 [[ $FILENUM -eq $NUMFILES ]] ||
4182 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4183 echo "$GETSTRIPE --recursive passed."
4185 # test lfs getstripe with file instead of dir
4186 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4187 [[ $FILENUM -eq 1 ]] ||
4188 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4189 echo "$GETSTRIPE file1 passed."
4191 #test lfs getstripe with --verbose
4192 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4193 grep -c lmm_magic) -eq $NUMFILES ]] ||
4194 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4195 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4196 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4197 echo "$GETSTRIPE --verbose passed."
4199 #test lfs getstripe with --obd
4200 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4201 grep -q "unknown obduuid" ||
4202 error "$GETSTRIPE --obd wrong_uuid should return error message"
4204 [[ $OSTCOUNT -lt 2 ]] &&
4205 skip_env "skipping other $GETSTRIPE --obd test" && return
4208 OBDUUID=$(ostuuid_from_index $OSTIDX)
4209 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4210 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4211 [[ $FOUND -eq $FILENUM ]] ||
4212 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4213 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4214 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4215 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4216 error "$GETSTRIPE --obd: should not show file on other obd"
4217 echo "$GETSTRIPE --obd passed"
4219 run_test 56a "check $GETSTRIPE"
4224 local LOCAL_NUMFILES="$1"
4225 local LOCAL_NUMDIRS="$2"
4226 local MKDIR_PARAMS="$3"
4227 local DIR_STRIPE_PARAMS="$4"
4229 if [ ! -d "$TDIR" ] ; then
4230 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4231 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4232 for i in `seq 1 $LOCAL_NUMFILES` ; do
4235 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4236 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4237 for j in `seq 1 $LOCAL_NUMFILES` ; do
4238 touch $TDIR/dir$i/file$j
4244 setup_56_special() {
4248 if [ ! -e "$TDIR/loop1b" ] ; then
4249 for i in `seq 1 $LOCAL_NUMFILES` ; do
4250 mknod $TDIR/loop${i}b b 7 $i
4251 mknod $TDIR/null${i}c c 1 3
4252 ln -s $TDIR/file1 $TDIR/link${i}l
4254 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4255 mknod $TDIR/dir$i/loop${i}b b 7 $i
4256 mknod $TDIR/dir$i/null${i}c c 1 3
4257 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4266 setup_56 $NUMFILES $NUMDIRS
4268 EXPECTED=$(($NUMDIRS + 2))
4269 # test lfs find with -name
4270 for i in $(seq 1 $NUMFILES) ; do
4271 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4272 [ $NUMS -eq $EXPECTED ] ||
4273 error "lfs find -name \"*$i\" $TDIR wrong: "\
4274 "found $NUMS, expected $EXPECTED"
4277 run_test 56g "check lfs find -name ============================="
4283 setup_56 $NUMFILES $NUMDIRS
4285 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4286 # test lfs find with ! -name
4287 for i in $(seq 1 $NUMFILES) ; do
4288 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4289 [ $NUMS -eq $EXPECTED ] ||
4290 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4291 "found $NUMS, expected $EXPECTED"
4294 run_test 56h "check lfs find ! -name ============================="
4298 test_mkdir -p $DIR/$tdir
4299 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4300 CMD="$LFIND -ost $UUID $DIR/$tdir"
4302 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4304 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4308 setup_56_special $NUMFILES $NUMDIRS
4310 EXPECTED=$((NUMDIRS + 1))
4311 CMD="$LFIND -type d $TDIR"
4312 NUMS=$($CMD | wc -l)
4313 [ $NUMS -eq $EXPECTED ] ||
4314 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4316 run_test 56j "check lfs find -type d ============================="
4320 setup_56_special $NUMFILES $NUMDIRS
4322 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4323 CMD="$LFIND -type f $TDIR"
4324 NUMS=$($CMD | wc -l)
4325 [ $NUMS -eq $EXPECTED ] ||
4326 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4328 run_test 56k "check lfs find -type f ============================="
4332 setup_56_special $NUMFILES $NUMDIRS
4334 EXPECTED=$((NUMDIRS + NUMFILES))
4335 CMD="$LFIND -type b $TDIR"
4336 NUMS=$($CMD | wc -l)
4337 [ $NUMS -eq $EXPECTED ] ||
4338 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4340 run_test 56l "check lfs find -type b ============================="
4344 setup_56_special $NUMFILES $NUMDIRS
4346 EXPECTED=$((NUMDIRS + NUMFILES))
4347 CMD="$LFIND -type c $TDIR"
4348 NUMS=$($CMD | wc -l)
4349 [ $NUMS -eq $EXPECTED ] ||
4350 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4352 run_test 56m "check lfs find -type c ============================="
4356 setup_56_special $NUMFILES $NUMDIRS
4358 EXPECTED=$((NUMDIRS + NUMFILES))
4359 CMD="$LFIND -type l $TDIR"
4360 NUMS=$($CMD | wc -l)
4361 [ $NUMS -eq $EXPECTED ] ||
4362 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4364 run_test 56n "check lfs find -type l ============================="
4368 setup_56 $NUMFILES $NUMDIRS
4369 utime $TDIR/file1 > /dev/null || error "utime (1)"
4370 utime $TDIR/file2 > /dev/null || error "utime (2)"
4371 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4372 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4373 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4374 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4377 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4378 [ $NUMS -eq $EXPECTED ] || \
4379 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4382 CMD="$LFIND -mtime 0 $TDIR"
4383 NUMS=$($CMD | wc -l)
4384 [ $NUMS -eq $EXPECTED ] ||
4385 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4387 run_test 56o "check lfs find -mtime for old files =========================="
4390 [ $RUNAS_ID -eq $UID ] &&
4391 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4394 setup_56 $NUMFILES $NUMDIRS
4396 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4398 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4399 NUMS=$($CMD | wc -l)
4400 [ $NUMS -eq $EXPECTED ] || \
4401 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4403 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4404 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4405 NUMS=$($CMD | wc -l)
4406 [ $NUMS -eq $EXPECTED ] || \
4407 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4409 run_test 56p "check lfs find -uid and ! -uid ==============================="
4412 [ $RUNAS_ID -eq $UID ] &&
4413 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4416 setup_56 $NUMFILES $NUMDIRS
4418 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4421 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4422 NUMS=$($CMD | wc -l)
4423 [ $NUMS -eq $EXPECTED ] ||
4424 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4426 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4427 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4428 NUMS=$($CMD | wc -l)
4429 [ $NUMS -eq $EXPECTED ] ||
4430 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4432 run_test 56q "check lfs find -gid and ! -gid ==============================="
4436 setup_56 $NUMFILES $NUMDIRS
4439 CMD="$LFIND -size 0 -type f $TDIR"
4440 NUMS=$($CMD | wc -l)
4441 [ $NUMS -eq $EXPECTED ] ||
4442 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4444 CMD="$LFIND ! -size 0 -type f $TDIR"
4445 NUMS=$($CMD | wc -l)
4446 [ $NUMS -eq $EXPECTED ] ||
4447 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4448 echo "test" > $TDIR/$tfile
4449 echo "test2" > $TDIR/$tfile.2 && sync
4451 CMD="$LFIND -size 5 -type f $TDIR"
4452 NUMS=$($CMD | wc -l)
4453 [ $NUMS -eq $EXPECTED ] ||
4454 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4456 CMD="$LFIND -size +5 -type f $TDIR"
4457 NUMS=$($CMD | wc -l)
4458 [ $NUMS -eq $EXPECTED ] ||
4459 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4461 CMD="$LFIND -size +0 -type f $TDIR"
4462 NUMS=$($CMD | wc -l)
4463 [ $NUMS -eq $EXPECTED ] ||
4464 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4466 CMD="$LFIND ! -size -5 -type f $TDIR"
4467 NUMS=$($CMD | wc -l)
4468 [ $NUMS -eq $EXPECTED ] ||
4469 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4471 CMD="$LFIND -size -5 -type f $TDIR"
4472 NUMS=$($CMD | wc -l)
4473 [ $NUMS -eq $EXPECTED ] ||
4474 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4476 run_test 56r "check lfs find -size works =========================="
4478 test_56s() { # LU-611
4480 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4482 if [[ $OSTCOUNT -gt 1 ]]; then
4483 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4487 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4491 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4492 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4493 NUMS=$($CMD | wc -l)
4494 [ $NUMS -eq $EXPECTED ] ||
4495 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4497 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4498 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4499 NUMS=$($CMD | wc -l)
4500 [ $NUMS -eq $EXPECTED ] ||
4501 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4504 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4505 NUMS=$($CMD | wc -l)
4506 [ $NUMS -eq $EXPECTED ] ||
4507 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4509 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4510 NUMS=$($CMD | wc -l)
4511 [ $NUMS -eq $EXPECTED ] ||
4512 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4515 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4516 NUMS=$($CMD | wc -l)
4517 [ $NUMS -eq $EXPECTED ] ||
4518 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4520 run_test 56s "check lfs find -stripe-count works"
4522 test_56t() { # LU-611
4524 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4526 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4528 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4529 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4530 NUMS=$($CMD | wc -l)
4531 [ $NUMS -eq $EXPECTED ] ||
4532 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4534 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4535 NUMS=$($CMD | wc -l)
4536 [ $NUMS -eq $EXPECTED ] ||
4537 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4539 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4540 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4541 NUMS=$($CMD | wc -l)
4542 [ $NUMS -eq $EXPECTED ] ||
4543 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4545 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4546 NUMS=$($CMD | wc -l)
4547 [ $NUMS -eq $EXPECTED ] ||
4548 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4551 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4552 NUMS=$($CMD | wc -l)
4553 [ $NUMS -eq $EXPECTED ] ||
4554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4556 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4557 NUMS=$($CMD | wc -l)
4558 [ $NUMS -eq $EXPECTED ] ||
4559 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4562 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4563 NUMS=$($CMD | wc -l)
4564 [ $NUMS -eq $EXPECTED ] ||
4565 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4567 run_test 56t "check lfs find -stripe-size works"
4569 test_56u() { # LU-611
4571 setup_56 $NUMFILES $NUMDIRS "-i 0"
4573 if [[ $OSTCOUNT -gt 1 ]]; then
4574 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4580 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4581 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4582 NUMS=$($CMD | wc -l)
4583 [ $NUMS -eq $EXPECTED ] ||
4584 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4587 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4588 NUMS=$($CMD | wc -l)
4589 [ $NUMS -eq $EXPECTED ] ||
4590 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4592 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4593 NUMS=$($CMD | wc -l)
4594 [ $NUMS -eq $EXPECTED ] ||
4595 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4598 # This should produce an error and not return any files
4599 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4600 NUMS=$($CMD 2>/dev/null | wc -l)
4601 [ $NUMS -eq $EXPECTED ] ||
4602 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4604 if [[ $OSTCOUNT -gt 1 ]]; then
4605 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4606 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] ||
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4612 run_test 56u "check lfs find -stripe-index works"
4619 setup_56 $NUMFILES $NUMDIRS
4621 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4622 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4624 for file in $($LFIND -mdt $UUID $TDIR); do
4625 file_mdt_idx=$($GETSTRIPE -M $file)
4626 [ $file_mdt_idx -eq $MDT_IDX ] ||
4627 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4630 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4632 # Get and check the actual stripe count of one file.
4633 # Usage: check_stripe_count <file> <expected_stripe_count>
4634 check_stripe_count() {
4639 [[ -z "$file" || -z "$expected" ]] &&
4640 error "check_stripe_count: invalid argument!"
4642 local cmd="$GETSTRIPE -c $file"
4643 actual=$($cmd) || error "$cmd failed"
4644 actual=${actual%% *}
4646 if [[ $actual -ne $expected ]]; then
4647 [[ $expected -eq -1 ]] ||
4648 error "$cmd wrong: found $actual, expected $expected"
4649 [[ $actual -eq $OSTCOUNT ]] ||
4650 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4658 rm -rf $TDIR || error "remove $TDIR failed"
4659 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4662 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4663 error "$GETSTRIPE -S -d $TDIR failed"
4664 stripe_size=${stripe_size%% *}
4666 local file_size=$((stripe_size * OSTCOUNT))
4667 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4668 local required_space=$((file_num * file_size))
4669 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4670 [[ $free_space -le $((required_space / 1024)) ]] &&
4671 skip_env "need at least $required_space bytes free space," \
4672 "have $free_space kbytes" && return
4675 local dd_count=$((file_size / dd_bs))
4677 # write data into the files
4681 for i in $(seq 1 $NUMFILES); do
4683 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4684 error "write data into $file failed"
4686 for i in $(seq 1 $NUMDIRS); do
4687 for j in $(seq 1 $NUMFILES); do
4688 file=$TDIR/dir$i/file$j
4689 yes | dd bs=$dd_bs count=$dd_count of=$file \
4691 error "write data into $file failed"
4696 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4699 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4701 eval $cmd || error "$cmd failed"
4703 check_stripe_count $TDIR/file1 $expected
4706 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4708 eval $cmd || error "$cmd failed"
4710 for j in $(seq 1 $NUMFILES); do
4711 check_stripe_count $TDIR/dir1/file$j $expected
4714 # lfs_migrate works with lfs find
4715 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4716 $LFS_MIGRATE -y -c $expected"
4718 eval $cmd || error "$cmd failed"
4720 for i in $(seq 2 $NUMFILES); do
4721 check_stripe_count $TDIR/file$i $expected
4723 for i in $(seq 2 $NUMDIRS); do
4724 for j in $(seq 1 $NUMFILES); do
4725 check_stripe_count $TDIR/dir$i/file$j $expected
4729 run_test 56w "check lfs_migrate -c stripe_count works"
4732 check_swap_layouts_support && return 0
4733 [[ $OSTCOUNT -lt 2 ]] &&
4734 skip_env "need 2 OST, skipping test" && return
4736 local dir0=$DIR/$tdir/$testnum
4737 mkdir -p $dir0 || error "creating dir $dir0"
4739 local ref1=/etc/passwd
4740 local file1=$dir0/file1
4742 $SETSTRIPE -c 2 $file1
4744 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4745 stripe=$($GETSTRIPE -c $file1)
4746 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4747 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4752 run_test 56x "lfs migration support"
4755 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4756 skip "No HSM support on MDS of $(get_lustre_version)," \
4757 "need 2.4.53 at least" && return
4760 local dir0=$DIR/$tdir/$testnum
4761 mkdir -p $dir0 || error "creating dir $dir0"
4762 local f1=$dir0/file1
4763 local f2=$dir0/file2
4765 touch $f1 || error "creating std file $f1"
4766 $MULTIOP $f2 H2c || error "creating released file $f2"
4768 # a directory can be raid0, so ask only for files
4769 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4770 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4772 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4773 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4775 # only files can be released, so no need to force file search
4776 res=$($LFIND $dir0 -L released)
4777 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4779 res=$($LFIND $dir0 \! -L released)
4780 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4783 run_test 56y "lfs find -L raid0|released"
4786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4787 # note test will not do anything if MDS is not local
4788 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4789 skip "Only applicable to ldiskfs-based MDTs"
4793 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4794 local MNTDEV="osd*.*MDT*.mntdev"
4795 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4796 [ -z "$DEV" ] && error "can't access $MNTDEV"
4797 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4798 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4799 error "can't access $DEV"
4800 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4801 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4805 run_test 57a "verify MDS filesystem created with large inodes =="
4808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4809 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4810 skip "Only applicable to ldiskfs-based MDTs"
4814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4819 local FILEN=$dir/f$FILECOUNT
4821 rm -rf $dir || error "removing $dir"
4822 test_mkdir -p $dir || error "creating $dir"
4823 local num=$(get_mds_dir $dir)
4826 echo "mcreating $FILECOUNT files"
4827 createmany -m $dir/f 1 $FILECOUNT || \
4828 error "creating files in $dir"
4830 # verify that files do not have EAs yet
4831 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4832 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4836 df $dir #make sure we get new statfs data
4837 local MDSFREE=$(do_facet $mymds \
4838 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4839 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4840 echo "opening files to create objects/EAs"
4842 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4843 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4846 # verify that files have EAs now
4847 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4848 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4850 sleep 1 #make sure we get new statfs data
4852 local MDSFREE2=$(do_facet $mymds \
4853 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4854 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4855 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4856 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4857 error "MDC before $MDCFREE != after $MDCFREE2"
4859 echo "MDC before $MDCFREE != after $MDCFREE2"
4860 echo "unable to confirm if MDS has large inodes"
4865 run_test 57b "default LOV EAs are stored inside large inodes ==="
4868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4869 [ -z "$(which wiretest 2>/dev/null)" ] &&
4870 skip_env "could not find wiretest" && return
4873 run_test 58 "verify cross-platform wire constants =============="
4876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4877 echo "touch 130 files"
4878 createmany -o $DIR/f59- 130
4880 unlinkmany $DIR/f59- 130
4882 # wait for commitment of removal
4883 wait_delete_completed
4885 run_test 59 "verify cancellation of llog records async ========="
4887 TEST60_HEAD="test_60 run $RANDOM"
4889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4890 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4891 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4892 skip_env "missing subtest run-llog.sh" && return
4893 log "$TEST60_HEAD - from kernel mode"
4894 do_facet mgs sh run-llog.sh
4896 run_test 60a "llog sanity tests run from kernel module =========="
4898 test_60b() { # bug 6411
4899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4901 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4913 [[ $LLOG_COUNT -gt 50 ]] &&
4914 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
4916 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4920 echo "create 5000 files"
4921 createmany -o $DIR/f60c- 5000
4922 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4923 lctl set_param fail_loc=0x80000137
4924 unlinkmany $DIR/f60c- 5000
4925 lctl set_param fail_loc=0
4927 run_test 60c "unlink file when mds full"
4930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4931 SAVEPRINTK=$(lctl get_param -n printk)
4933 # verify "lctl mark" is even working"
4934 MESSAGE="test message ID $RANDOM $$"
4935 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4936 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4938 lctl set_param printk=0 || error "set lnet.printk failed"
4939 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4940 MESSAGE="new test message ID $RANDOM $$"
4941 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4942 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4943 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4945 lctl set_param -n printk="$SAVEPRINTK"
4947 run_test 60d "test printk console message masking"
4950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4952 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4953 cancel_lru_locks osc
4954 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4957 run_test 61 "mmap() writes don't make sync hang ================"
4959 # bug 2330 - insufficient obd_match error checking causes LBUG
4961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4964 cancel_lru_locks osc
4965 lctl set_param fail_loc=0x405
4966 cat $f && error "cat succeeded, expect -EIO"
4967 lctl set_param fail_loc=0
4969 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4970 # match every page all of the time.
4971 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4973 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4974 # Though this test is irrelevant anymore, it helped to reveal some
4975 # other grant bugs (LU-4482), let's keep it.
4976 test_63a() { # was test_63
4977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4978 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4979 for i in `seq 10` ; do
4980 dd if=/dev/zero of=$DIR/f63 bs=8k &
4986 rm -f $DIR/f63 || true
4988 run_test 63a "Verify oig_wait interruption does not crash ======="
4990 # bug 2248 - async write errors didn't return to application on sync
4991 # bug 3677 - async write errors left page locked
4993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4995 lctl set_param debug=-1
4997 # ensure we have a grant to do async writes
4998 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5001 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5002 lctl set_param fail_loc=0x80000406
5003 $MULTIOP $DIR/$tfile Owy && \
5004 error "sync didn't return ENOMEM"
5005 sync; sleep 2; sync # do a real sync this time to flush page
5006 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5007 error "locked page left in cache after async error" || true
5010 run_test 63b "async write errors should be returned to fsync ==="
5013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5015 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5017 run_test 64a "verify filter grant calculations (in kernel) ====="
5020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5021 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5023 run_test 64b "check out-of-space detection on client ==========="
5026 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5028 run_test 64c "verify grant shrink ========================------"
5030 # bug 1414 - set/get directories' stripe info
5032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5033 test_mkdir -p $DIR/$tdir
5035 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5037 run_test 65a "directory with no stripe info ===================="
5040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5041 test_mkdir -p $DIR/$tdir
5042 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5045 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5047 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 if [[ $OSTCOUNT -gt 1 ]]; then
5052 test_mkdir -p $DIR/$tdir
5053 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5054 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5056 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5059 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5063 test_mkdir -p $DIR/$tdir
5064 if [[ $STRIPECOUNT -le 0 ]]; then
5066 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5067 #LOV_MAX_STRIPE_COUNT is 2000
5068 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5070 sc=$(($STRIPECOUNT - 1))
5072 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5073 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5074 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5075 error "lverify failed"
5077 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5081 test_mkdir -p $DIR/$tdir
5083 $SETSTRIPE $DIR/$tdir || error "setstripe"
5084 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5085 error "no stripe info failed"
5087 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5089 run_test 65e "directory setstripe defaults ======================="
5092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5093 test_mkdir -p $DIR/${tdir}f
5094 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5096 run_test 65f "dir setstripe permission (should return error) ==="
5099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5100 test_mkdir -p $DIR/$tdir
5101 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5103 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5104 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5105 error "delete default stripe failed"
5107 run_test 65g "directory setstripe -d ==========================="
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5111 test_mkdir -p $DIR/$tdir
5112 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5114 test_mkdir -p $DIR/$tdir/dd1
5115 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5116 error "stripe info inherit failed"
5118 run_test 65h "directory stripe info inherit ===================="
5120 test_65i() { # bug6367
5121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5122 $SETSTRIPE -S 65536 -c -1 $MOUNT
5124 run_test 65i "set non-default striping on root directory (bug 6367)="
5126 test_65ia() { # bug12836
5127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5128 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5130 run_test 65ia "getstripe on -1 default directory striping"
5132 test_65ib() { # bug12836
5133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5134 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5136 run_test 65ib "getstripe -v on -1 default directory striping"
5138 test_65ic() { # bug12836
5139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5140 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5142 run_test 65ic "new find on -1 default directory striping"
5144 test_65j() { # bug6367
5145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5147 # if we aren't already remounting for each test, do so for this test
5148 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5149 cleanup || error "failed to unmount"
5152 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5154 run_test 65j "set default striping on root directory (bug 6367)="
5156 test_65k() { # bug11679
5157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5158 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5159 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5161 echo "Check OST status: "
5162 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5163 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5165 for OSC in $MDS_OSCS; do
5166 echo $OSC "is activate"
5167 do_facet $SINGLEMDS lctl --device %$OSC activate
5171 for INACTIVE_OSC in $MDS_OSCS; do
5172 echo "Deactivate: " $INACTIVE_OSC
5173 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5174 for STRIPE_OSC in $MDS_OSCS; do
5175 OST=`osc_to_ost $STRIPE_OSC`
5176 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5177 awk -F: /$OST/'{ print $1 }' | head -n 1`
5179 [ -f $DIR/$tdir/$IDX ] && continue
5180 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5181 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5183 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5186 echo $INACTIVE_OSC "is Activate."
5187 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5190 run_test 65k "validate manual striping works properly with deactivated OSCs"
5192 test_65l() { # bug 12836
5193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5194 test_mkdir -p $DIR/$tdir/test_dir
5195 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5196 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5198 run_test 65l "lfs find on -1 stripe dir ========================"
5200 # bug 2543 - update blocks count on client
5202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5204 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5205 sync; sync_all_data; sync; sync_all_data
5206 cancel_lru_locks osc
5207 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5208 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5210 run_test 66 "update inode blocks count on client ==============="
5215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5217 if [ ! -z "$LLOOP" ]; then
5218 if swapon -s | grep -q $LLOOP; then
5219 swapoff $LLOOP || error "swapoff failed"
5222 $LCTL blockdev_detach $LLOOP || error "detach failed"
5226 if [ ! -z "$LLITELOOPLOAD" ]; then
5234 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5238 swapon -s | awk '($1 == "'$1'") { print $4 }'
5241 # test case for lloop driver, basic function
5243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5244 [ "$UID" != 0 ] && skip_env "must run as root" && return
5245 llite_lloop_enabled || \
5246 { skip_env "llite_lloop module disabled" && return; }
5248 trap cleanup_68 EXIT
5250 if ! module_loaded llite_lloop; then
5251 if load_module llite/llite_lloop; then
5254 skip_env "can't find module llite_lloop"
5259 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5260 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5261 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5263 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5264 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5268 run_test 68a "lloop driver - basic test ========================"
5270 # excercise swapping to lustre by adding a high priority swapfile entry
5271 # and then consuming memory until it is used.
5272 test_68b() { # was test_68
5273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5274 [ "$UID" != 0 ] && skip_env "must run as root" && return
5275 lctl get_param -n devices | grep -q obdfilter && \
5276 skip "local OST" && return
5278 grep -q llite_lloop /proc/modules
5279 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5281 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5282 skip "can't reliably test swap with TCP" && return
5284 MEMTOTAL=`meminfo MemTotal`
5285 NR_BLOCKS=$((MEMTOTAL>>8))
5286 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5288 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5289 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5292 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5294 trap cleanup_68 EXIT
5296 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5298 echo "before: `swapon -s | grep $LLOOP`"
5299 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5300 echo "after: `swapon -s | grep $LLOOP`"
5301 SWAPUSED=`swap_used $LLOOP`
5305 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5307 run_test 68b "support swapping to Lustre ========================"
5309 # bug5265, obdfilter oa2dentry return -ENOENT
5310 # #define OBD_FAIL_OST_ENOENT 0x217
5312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5313 remote_ost_nodsh && skip "remote OST with nodsh" && return
5316 $SETSTRIPE -c 1 -i 0 $f
5318 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5320 do_facet ost1 lctl set_param fail_loc=0x217
5321 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5322 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5324 do_facet ost1 lctl set_param fail_loc=0
5325 $DIRECTIO write $f 0 2 || error "write error"
5327 cancel_lru_locks osc
5328 $DIRECTIO read $f 0 1 || error "read error"
5330 do_facet ost1 lctl set_param fail_loc=0x217
5331 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5333 do_facet ost1 lctl set_param fail_loc=0
5336 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5339 test_mkdir -p $DIR/$tdir
5340 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5342 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5344 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5346 [ "$RUNAS_ID" = "$UID" ] &&
5347 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5349 # Check that testing environment is properly set up. Skip if not
5350 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5351 skip_env "User $RUNAS_ID does not exist - skipping"
5354 # We had better clear the $DIR to get enough space for dd
5357 chmod 777 $DIR/$tfile
5358 chmod ug+s $DIR/$tfile
5359 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5360 error "$RUNAS dd $DIR/$tfile failed"
5361 # See if we are still setuid/sgid
5362 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5363 error "S/gid is not dropped on write"
5364 # Now test that MDS is updated too
5365 cancel_lru_locks mdc
5366 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5367 error "S/gid is not dropped on MDS"
5370 run_test 72a "Test that remove suid works properly (bug5695) ===="
5372 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5375 [ "$RUNAS_ID" = "$UID" ] && \
5376 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5377 [ "$RUNAS_ID" -eq 0 ] && \
5378 skip_env "RUNAS_ID = 0 -- skipping" && return
5380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5381 # Check that testing environment is properly set up. Skip if not
5382 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5383 skip_env "User $RUNAS_ID does not exist - skipping"
5386 touch $DIR/${tfile}-f{g,u}
5387 test_mkdir $DIR/${tfile}-dg
5388 test_mkdir $DIR/${tfile}-du
5389 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5390 chmod g+s $DIR/${tfile}-{f,d}g
5391 chmod u+s $DIR/${tfile}-{f,d}u
5392 for perm in 777 2777 4777; do
5393 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5394 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5395 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5396 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5400 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5402 # bug 3462 - multiple simultaneous MDC requests
5404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5405 test_mkdir $DIR/d73-1
5406 test_mkdir $DIR/d73-2
5407 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5410 lctl set_param fail_loc=0x80000129
5411 $MULTIOP $DIR/d73-1/f73-2 Oc &
5413 lctl set_param fail_loc=0
5415 $MULTIOP $DIR/d73-2/f73-3 Oc &
5419 wait $pid1 || return 1
5423 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5424 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5425 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5429 run_test 73 "multiple MDC requests (should not deadlock)"
5431 test_74a() { # bug 6149, 6184
5432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5433 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5435 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5436 # will spin in a tight reconnection loop
5438 $LCTL set_param fail_loc=0x8000030e
5439 # get any lock that won't be difficult - lookup works.
5441 $LCTL set_param fail_loc=0
5445 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5447 test_74b() { # bug 13310
5448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5449 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5451 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5452 # will spin in a tight reconnection loop
5453 $LCTL set_param fail_loc=0x8000030e
5454 # get a "difficult" lock
5456 $LCTL set_param fail_loc=0
5460 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5464 #define OBD_FAIL_LDLM_NEW_LOCK
5465 $LCTL set_param fail_loc=0x319
5466 touch $DIR/$tfile && error "touch successful"
5467 $LCTL set_param fail_loc=0
5470 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5473 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5476 get_inode_slab_tunables() {
5477 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5480 set_inode_slab_tunables() {
5481 echo "lustre_inode_cache $1" > /proc/slabinfo
5484 test_76() { # Now for bug 20433, added originally in bug 1443
5485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5486 local SLAB_SETTINGS=`get_inode_slab_tunables`
5487 local CPUS=`getconf _NPROCESSORS_ONLN`
5488 # we cannot set limit below 1 which means 1 inode in each
5489 # per-cpu cache is still allowed
5490 set_inode_slab_tunables "1 1 0"
5491 cancel_lru_locks osc
5492 BEFORE_INODES=$(num_inodes)
5493 echo "before inodes: $BEFORE_INODES"
5495 [ "$SLOW" = "no" ] && COUNT=100
5496 for i in $(seq $COUNT); do
5500 cancel_lru_locks osc
5501 AFTER_INODES=$(num_inodes)
5502 echo "after inodes: $AFTER_INODES"
5504 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5506 AFTER_INODES=$(num_inodes)
5508 echo "wait $wait seconds inodes: $AFTER_INODES"
5509 if [ $wait -gt 30 ]; then
5510 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5513 set_inode_slab_tunables "$SLAB_SETTINGS"
5515 run_test 76 "confirm clients recycle inodes properly ===="
5521 # Note: in sptlrpc modes which enable its own bulk checksum, the
5522 # original crc32_le bulk checksum will be automatically disabled,
5523 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5524 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5525 # In this case set_checksums() will not be no-op, because sptlrpc
5526 # bulk checksum will be enabled all through the test.
5528 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5529 lctl set_param -n osc.*.checksums $1
5533 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5534 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5535 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5536 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5539 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5540 log "set checksum type to $1"
5543 F77_TMP=$TMP/f77-temp
5546 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5547 error "error writing to $F77_TMP"
5550 test_77a() { # bug 10889
5551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5552 $GSS && skip "could not run with gss" && return
5553 [ ! -f $F77_TMP ] && setup_f77
5555 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5559 run_test 77a "normal checksum read/write operation"
5561 test_77b() { # bug 10889
5562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5563 $GSS && skip "could not run with gss" && return
5564 [ ! -f $F77_TMP ] && setup_f77
5565 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5566 $LCTL set_param fail_loc=0x80000409
5569 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5570 error "dd error: $?"
5571 $LCTL set_param fail_loc=0
5573 for algo in $CKSUM_TYPES; do
5574 cancel_lru_locks osc
5575 set_checksum_type $algo
5576 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5577 $LCTL set_param fail_loc=0x80000408
5578 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5579 $LCTL set_param fail_loc=0
5582 set_checksum_type $ORIG_CSUM_TYPE
5585 run_test 77b "checksum error on client write, read"
5587 test_77d() { # bug 10889
5588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5589 $GSS && skip "could not run with gss" && return
5590 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5591 $LCTL set_param fail_loc=0x80000409
5593 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5594 error "direct write: rc=$?"
5595 $LCTL set_param fail_loc=0
5598 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5599 $LCTL set_param fail_loc=0x80000408
5601 cancel_lru_locks osc
5602 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5603 error "direct read: rc=$?"
5604 $LCTL set_param fail_loc=0
5607 run_test 77d "checksum error on OST direct write, read"
5609 test_77f() { # bug 10889
5610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5611 $GSS && skip "could not run with gss" && return
5613 for algo in $CKSUM_TYPES; do
5614 cancel_lru_locks osc
5615 set_checksum_type $algo
5616 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5617 $LCTL set_param fail_loc=0x409
5618 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5619 error "direct write succeeded"
5620 $LCTL set_param fail_loc=0
5622 set_checksum_type $ORIG_CSUM_TYPE
5625 run_test 77f "repeat checksum error on write (expect error)"
5627 test_77g() { # bug 10889
5628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5629 $GSS && skip "could not run with gss" && return
5630 remote_ost_nodsh && skip "remote OST with nodsh" && return
5632 [ ! -f $F77_TMP ] && setup_f77
5634 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5635 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5636 do_facet ost1 lctl set_param fail_loc=0x8000021a
5638 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5639 error "write error: rc=$?"
5640 do_facet ost1 lctl set_param fail_loc=0
5643 cancel_lru_locks osc
5644 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5645 do_facet ost1 lctl set_param fail_loc=0x8000021b
5647 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5648 do_facet ost1 lctl set_param fail_loc=0
5651 run_test 77g "checksum error on OST write, read"
5653 test_77i() { # bug 13805
5654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5655 $GSS && skip "could not run with gss" && return
5656 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5657 lctl set_param fail_loc=0x40b
5658 remount_client $MOUNT
5659 lctl set_param fail_loc=0
5660 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5661 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5662 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5663 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5665 remount_client $MOUNT
5667 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5669 test_77j() { # bug 13805
5670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5671 $GSS && skip "could not run with gss" && return
5672 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5673 lctl set_param fail_loc=0x40c
5674 remount_client $MOUNT
5675 lctl set_param fail_loc=0
5676 sleep 2 # wait async osc connect to finish
5677 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5678 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5679 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5680 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5682 remount_client $MOUNT
5684 run_test 77j "client only supporting ADLER32"
5686 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5690 test_78() { # bug 10901
5691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5692 remote_ost || { skip_env "local OST" && return; }
5695 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5696 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5697 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5698 echo "MemTotal: $MEMTOTAL"
5700 # reserve 256MB of memory for the kernel and other running processes,
5701 # and then take 1/2 of the remaining memory for the read/write buffers.
5702 if [ $MEMTOTAL -gt 512 ] ;then
5703 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5705 # for those poor memory-starved high-end clusters...
5706 MEMTOTAL=$((MEMTOTAL / 2))
5708 echo "Mem to use for directio: $MEMTOTAL"
5710 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5711 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5712 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5713 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5715 echo "Smallest OST: $SMALLESTOST"
5716 [[ $SMALLESTOST -lt 10240 ]] &&
5717 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5719 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5720 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5722 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5723 echo "File size: $F78SIZE"
5724 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5725 for i in $(seq 1 $NSEQ); do
5726 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5727 echo directIO rdwr round $i of $NSEQ
5728 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5733 run_test 78 "handle large O_DIRECT writes correctly ============"
5735 test_79() { # bug 12743
5736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5737 wait_delete_completed
5739 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5740 BKFREE=$(calc_osc_kbytes kbytesfree)
5741 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5743 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5744 DFTOTAL=`echo $STRING | cut -d, -f1`
5745 DFUSED=`echo $STRING | cut -d, -f2`
5746 DFAVAIL=`echo $STRING | cut -d, -f3`
5747 DFFREE=$(($DFTOTAL - $DFUSED))
5749 ALLOWANCE=$((64 * $OSTCOUNT))
5751 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5752 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5753 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5755 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5756 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5757 error "df free($DFFREE) mismatch OST free($BKFREE)"
5759 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5760 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5761 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5764 run_test 79 "df report consistency check ======================="
5766 test_80() { # bug 10718
5767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5768 # relax strong synchronous semantics for slow backends like ZFS
5769 local soc="obdfilter.*.sync_on_lock_cancel"
5770 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5772 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5773 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5774 facet_active_host $host; done | sort -u)
5775 do_nodes $hosts lctl set_param $soc=never
5778 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5780 local BEFORE=`date +%s`
5781 cancel_lru_locks osc
5782 local AFTER=`date +%s`
5783 local DIFF=$((AFTER-BEFORE))
5784 if [ $DIFF -gt 1 ] ; then
5785 error "elapsed for 1M@1T = $DIFF"
5788 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5792 run_test 80 "Page eviction is equally fast at high offsets too ===="
5794 test_81a() { # LU-456
5795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5796 remote_ost_nodsh && skip "remote OST with nodsh" && return
5797 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5798 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5799 do_facet ost1 lctl set_param fail_loc=0x80000228
5801 # write should trigger a retry and success
5802 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5803 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5805 if [ $RC -ne 0 ] ; then
5806 error "write should success, but failed for $RC"
5809 run_test 81a "OST should retry write when get -ENOSPC ==============="
5811 test_81b() { # LU-456
5812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5813 remote_ost_nodsh && skip "remote OST with nodsh" && return
5814 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5815 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5816 do_facet ost1 lctl set_param fail_loc=0x228
5818 # write should retry several times and return -ENOSPC finally
5819 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5820 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5823 if [ $RC -ne $ENOSPC ] ; then
5824 error "dd should fail for -ENOSPC, but succeed."
5827 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5829 test_82() { # LU-1031
5830 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5834 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5836 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5838 kill -USR1 $MULTIPID2
5840 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5841 error "First grouplock does not block second one"
5843 echo "Second grouplock blocks first one"
5845 kill -USR1 $MULTIPID1
5849 run_test 82 "Basic grouplock test ==============================="
5852 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5854 test_mkdir -p $DIR/d99cvsroot
5855 chown $RUNAS_ID $DIR/d99cvsroot
5856 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5859 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5862 run_test 99a "cvs init ========================================="
5865 [ -z "$(which cvs 2>/dev/null)" ] &&
5866 skip_env "could not find cvs" && return
5867 [ ! -d $DIR/d99cvsroot ] && test_99a
5869 # some versions of cvs import exit(1) when asked to import links or
5870 # files they can't read. ignore those files.
5871 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5872 ! -perm +4 -printf '-I %f\n')
5873 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5874 d99reposname vtag rtag
5876 run_test 99b "cvs import ======================================="
5879 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5880 [ ! -d $DIR/d99cvsroot ] && test_99b
5882 test_mkdir -p $DIR/d99reposname
5883 chown $RUNAS_ID $DIR/d99reposname
5884 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5886 run_test 99c "cvs checkout ====================================="
5889 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5890 [ ! -d $DIR/d99cvsroot ] && test_99c
5891 cd $DIR/d99reposname
5893 $RUNAS cvs add -m 'addmsg' foo99
5895 run_test 99d "cvs add =========================================="
5898 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5899 [ ! -d $DIR/d99cvsroot ] && test_99c
5900 cd $DIR/d99reposname
5903 run_test 99e "cvs update ======================================="
5906 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5907 [ ! -d $DIR/d99cvsroot ] && test_99d
5908 cd $DIR/d99reposname
5909 $RUNAS cvs commit -m 'nomsg' foo99
5910 rm -fr $DIR/d99cvsroot
5912 run_test 99f "cvs commit ======================================="
5915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5916 [ "$NETTYPE" = tcp ] || \
5917 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5920 remote_ost_nodsh && skip "remote OST with nodsh" && return
5921 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5923 { skip "useless for local single node setup" && return; }
5925 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5926 [ "$PROT" != "tcp" ] && continue
5927 RPORT=$(echo $REMOTE | cut -d: -f2)
5928 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5931 LPORT=`echo $LOCAL | cut -d: -f2`
5932 if [ $LPORT -ge 1024 ]; then
5933 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5935 error_exit "local: $LPORT > 1024, remote: $RPORT"
5938 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5940 run_test 100 "check local port using privileged port ==========="
5942 function get_named_value()
5951 echo $line | sed "s/^$tag[ ]*//"
5958 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5959 awk '/^max_cached_mb/ { print $2 }')
5962 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5968 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5972 local cache_limit=32
5974 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5975 trap cleanup_101a EXIT
5976 $LCTL set_param -n llite.*.read_ahead_stats 0
5977 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5980 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5982 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5983 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5986 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
5987 get_named_value 'read but discarded' | cut -d" " -f1); do
5988 discard=$(($discard + $s))
5992 if [[ $(($discard * 10)) -gt $nreads ]]; then
5993 $LCTL get_param osc.*-osc*.rpc_stats
5994 $LCTL get_param llite.*.read_ahead_stats
5995 error "too many ($discard) discarded pages"
5997 rm -f $DIR/$tfile || true
5999 run_test 101a "check read-ahead for random reads ================"
6002 test_mkdir -p $DIR/$tdir
6003 local STRIPE_SIZE=$1
6004 local FILE_LENGTH=$2
6007 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6009 local list=$(comma_list $(osts_nodes))
6010 set_osd_param $list '' read_cache_enable 0
6011 set_osd_param $list '' writethrough_cache_enable 0
6013 trap cleanup_test101bc EXIT
6014 # prepare the read-ahead file
6015 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6017 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6018 count=$FILE_SIZE_MB 2> /dev/null
6022 cleanup_test101bc() {
6027 local list=$(comma_list $(osts_nodes))
6028 set_osd_param $list '' read_cache_enable 1
6029 set_osd_param $list '' writethrough_cache_enable 1
6033 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6038 local STRIPE_SIZE=$2
6039 local FILE_LENGTH=$3
6040 local RA_INC=1048576
6041 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6042 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6043 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6044 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6045 get_named_value 'read but discarded' |
6046 cut -d" " -f1 | calc_total)
6047 if [[ $DISCARD -gt $discard_limit ]]; then
6048 $LCTL get_param llite.*.read_ahead_stats
6049 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6051 echo "Read-ahead success for size ${READ_SIZE}"
6056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6057 [[ $OSTCOUNT -lt 2 ]] &&
6058 skip_env "skipping stride IO stride-ahead test" && return
6059 local STRIPE_SIZE=1048576
6060 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6061 if [ $SLOW == "yes" ]; then
6062 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6064 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6067 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6069 # prepare the read-ahead file
6070 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6071 cancel_lru_locks osc
6072 for BIDX in 2 4 8 16 32 64 128 256
6074 local BSIZE=$((BIDX*4096))
6075 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6076 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6077 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6078 $LCTL set_param -n llite.*.read_ahead_stats 0
6079 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6080 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6081 cancel_lru_locks osc
6082 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6087 run_test 101b "check stride-io mode read-ahead ================="
6090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6091 local STRIPE_SIZE=1048576
6092 local FILE_LENGTH=$((STRIPE_SIZE*100))
6096 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6098 cancel_lru_locks osc
6099 $LCTL set_param osc.*.rpc_stats 0
6100 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6101 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6102 local stats=$($LCTL get_param -n $osc_rpc_stats)
6103 local lines=$(echo "$stats" | awk 'END {print NR;}')
6106 if [ $lines -le 20 ]; then
6109 for size in 1 2 4 8; do
6110 local rpc=$(echo "$stats" |
6111 awk '($1 == "'$size':") {print $2; exit; }')
6113 error "Small $((size*4))k read IO $rpc !"
6115 echo "$osc_rpc_stats check passed!"
6120 run_test 101c "check stripe_size aligned read-ahead ================="
6123 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6124 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6129 local file=$DIR/$tfile
6130 local sz_MB=${FILESIZE_101d:-500}
6131 local ra_MB=${READAHEAD_MB:-40}
6133 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6134 [ $free_MB -lt $sz_MB ] &&
6135 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6137 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6138 $SETSTRIPE -c -1 $file || error "setstripe failed"
6140 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6141 echo Cancel LRU locks on lustre client to flush the client cache
6142 cancel_lru_locks osc
6144 echo Disable read-ahead
6145 local old_READAHEAD=$(set_read_ahead 0)
6147 echo Reading the test file $file with read-ahead disabled
6148 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6150 echo Cancel LRU locks on lustre client to flush the client cache
6151 cancel_lru_locks osc
6152 echo Enable read-ahead with ${ra_MB}MB
6153 set_read_ahead $ra_MB
6155 echo Reading the test file $file with read-ahead enabled
6156 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6158 echo "read-ahead disabled time read $raOFF"
6159 echo "read-ahead enabled time read $raON"
6161 set_read_ahead $old_READAHEAD
6163 wait_delete_completed
6165 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6166 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6168 run_test 101d "file read with and without read-ahead enabled"
6171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6172 local file=$DIR/$tfile
6173 local size_KB=500 #KB
6177 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6178 local need_KB=$((count * size_KB))
6179 [[ $free_KB -le $need_KB ]] &&
6180 skip_env "Need free space $need_KB, have $free_KB" && return
6182 echo "Creating $count ${size_KB}K test files"
6183 for ((i = 0; i < $count; i++)); do
6184 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6187 echo "Cancel LRU locks on lustre client to flush the client cache"
6188 cancel_lru_locks osc
6190 echo "Reset readahead stats"
6191 $LCTL set_param -n llite.*.read_ahead_stats 0
6193 for ((i = 0; i < $count; i++)); do
6194 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6197 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6198 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6200 for ((i = 0; i < $count; i++)); do
6201 rm -rf $file.$i 2>/dev/null
6204 #10000 means 20% reads are missing in readahead
6205 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6207 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6209 cleanup_test101f() {
6211 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6212 rm -rf $DIR/$tfile 2>/dev/null
6216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6217 local file=$DIR/$tfile
6220 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6221 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6222 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6223 trap cleanup_test101f EXIT
6225 echo Cancel LRU locks on lustre client to flush the client cache
6226 cancel_lru_locks osc
6228 echo Reset readahead stats
6229 $LCTL set_param -n llite.*.read_ahead_stats 0
6230 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6231 # readahead should read in 2M file on second read, so only miss
6233 echo Random 4K reads on 2M file for 1000 times
6234 $READS -f $file -s 2097152 -b 4096 -n $nreads
6236 echo checking missing pages
6237 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6238 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6240 [ $miss -lt 3 ] || error "misses too much pages!"
6243 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6246 test_mkdir -p $DIR/$tdir
6247 chown $RUNAS_ID $DIR/$tdir
6250 STRIPE_COUNT=$OSTCOUNT
6251 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6253 trap cleanup_test102 EXIT
6255 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6257 for num in 1 2 3 4; do
6258 for count in $(seq 1 $STRIPE_COUNT); do
6259 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6260 local size=`expr $STRIPE_SIZE \* $num`
6261 local file=file"$num-$idx-$count"
6262 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6268 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6274 rm -rf $DIR/d0.sanity/d102
6278 local testfile=$DIR/xattr_testfile
6282 [ "$UID" != 0 ] && skip_env "must run as root" && return
6283 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6284 skip_env "must have user_xattr" && return
6286 [ -z "$(which setfattr 2>/dev/null)" ] &&
6287 skip_env "could not find setfattr" && return
6289 echo "set/get xattr..."
6290 setfattr -n trusted.name1 -v value1 $testfile ||
6291 error "setfattr -n trusted.name1=value1 $testfile failed"
6292 getfattr -n trusted.name1 $testfile 2> /dev/null |
6293 grep "trusted.name1=.value1" ||
6294 error "$testfile missing trusted.name1=value1"
6296 setfattr -n user.author1 -v author1 $testfile ||
6297 error "setfattr -n user.author1=author1 $testfile failed"
6298 getfattr -n user.author1 $testfile 2> /dev/null |
6299 grep "user.author1=.author1" ||
6300 error "$testfile missing trusted.author1=author1"
6303 setfattr -n trusted.name2 -v value2 $testfile ||
6304 error "$testfile unable to set trusted.name2"
6305 setfattr -n trusted.name3 -v value3 $testfile ||
6306 error "$testfile unable to set trusted.name3"
6307 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6308 grep "trusted.name" | wc -l) -eq 3 ] ||
6309 error "$testfile missing 3 trusted.name xattrs"
6311 setfattr -n user.author2 -v author2 $testfile ||
6312 error "$testfile unable to set user.author2"
6313 setfattr -n user.author3 -v author3 $testfile ||
6314 error "$testfile unable to set user.author3"
6315 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6316 grep "user.author" | wc -l) -eq 3 ] ||
6317 error "$testfile missing 3 user.author xattrs"
6319 echo "remove xattr..."
6320 setfattr -x trusted.name1 $testfile ||
6321 error "$testfile error deleting trusted.name1"
6322 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6323 error "$testfile did not delete trusted.name1 xattr"
6325 setfattr -x user.author1 $testfile ||
6326 error "$testfile error deleting user.author1"
6327 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6328 error "$testfile did not delete trusted.name1 xattr"
6330 # b10667: setting lustre special xattr be silently discarded
6331 echo "set lustre special xattr ..."
6332 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6333 error "$testfile allowed setting trusted.lov"
6335 run_test 102a "user xattr test =================================="
6338 [ -z "$(which setfattr 2>/dev/null)" ] &&
6339 skip_env "could not find setfattr" && return
6341 # b10930: get/set/list trusted.lov xattr
6342 echo "get/set/list trusted.lov xattr ..."
6343 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6344 local testfile=$DIR/$tfile
6345 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6346 error "setstripe failed"
6347 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6348 error "getstripe failed"
6349 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6350 error "can't get trusted.lov from $testfile"
6352 local testfile2=${testfile}2
6353 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6354 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6357 setfattr -n trusted.lov -v $value $testfile2
6358 local stripe_size=$($GETSTRIPE -S $testfile2)
6359 local stripe_count=$($GETSTRIPE -c $testfile2)
6360 [[ $stripe_size -eq 65536 ]] ||
6361 error "stripe size $stripe_size != 65536"
6362 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6363 error "stripe count $stripe_count != $STRIPECOUNT"
6366 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6369 [ -z "$(which setfattr 2>/dev/null)" ] &&
6370 skip_env "could not find setfattr" && return
6372 # b10930: get/set/list lustre.lov xattr
6373 echo "get/set/list lustre.lov xattr ..."
6374 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6375 test_mkdir -p $DIR/$tdir
6376 chown $RUNAS_ID $DIR/$tdir
6377 local testfile=$DIR/$tdir/$tfile
6378 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6379 error "setstripe failed"
6380 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6381 error "getstripe failed"
6382 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6383 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6385 local testfile2=${testfile}2
6386 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6387 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6389 $RUNAS $MCREATE $testfile2
6390 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6391 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6392 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6393 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6394 [ $stripe_count -eq $STRIPECOUNT ] ||
6395 error "stripe count $stripe_count != $STRIPECOUNT"
6397 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6399 compare_stripe_info1() {
6400 local stripe_index_all_zero=true
6402 for num in 1 2 3 4; do
6403 for count in $(seq 1 $STRIPE_COUNT); do
6404 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6405 local size=$((STRIPE_SIZE * num))
6406 local file=file"$num-$offset-$count"
6407 stripe_size=$(lfs getstripe -S $PWD/$file)
6408 [[ $stripe_size -ne $size ]] &&
6409 error "$file: size $stripe_size != $size"
6410 stripe_count=$(lfs getstripe -c $PWD/$file)
6411 # allow fewer stripes to be created, ORI-601
6412 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6413 error "$file: count $stripe_count != $count"
6414 stripe_index=$(lfs getstripe -i $PWD/$file)
6415 [[ $stripe_index -ne 0 ]] &&
6416 stripe_index_all_zero=false
6420 $stripe_index_all_zero &&
6421 error "all files are being extracted starting from OST index 0"
6426 [ -n "$(which tar 2>/dev/null)" ] &&
6427 strings $(which tar) | grep -q "lustre" && echo tar
6431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6432 # b10930: tar test for trusted.lov xattr
6433 TAR=$(find_lustre_tar)
6434 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6435 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6437 test_mkdir -p $DIR/d102d
6438 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6440 compare_stripe_info1
6442 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6446 # b10930: tar test for trusted.lov xattr
6447 TAR=$(find_lustre_tar)
6448 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6449 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6451 test_mkdir -p $DIR/d102f
6453 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6455 compare_stripe_info1
6457 run_test 102f "tar copy files, not keep osts ==========="
6460 local xsize=${1:-1024} # in bytes
6461 local file=$DIR/$tfile
6463 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6464 skip "must have user_xattr" && return 0
6465 [ -z "$(which setfattr 2>/dev/null)" ] &&
6466 skip_env "could not find setfattr" && return 0
6467 [ -z "$(which getfattr 2>/dev/null)" ] &&
6468 skip_env "could not find getfattr" && return 0
6472 local value="$(generate_string $xsize)"
6474 local xbig=trusted.big
6475 log "save $xbig on $file"
6476 setfattr -n $xbig -v $value $file ||
6477 error "saving $xbig on $file failed"
6479 local orig=$(get_xattr_value $xbig $file)
6480 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6482 local xsml=trusted.sml
6483 log "save $xsml on $file"
6484 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6486 local new=$(get_xattr_value $xbig $file)
6487 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6489 log "grow $xsml on $file"
6490 setfattr -n $xsml -v "$value" $file ||
6491 error "growing $xsml on $file failed"
6493 new=$(get_xattr_value $xbig $file)
6494 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6495 log "$xbig still valid after growing $xsml"
6500 test_102h() { # bug 15777
6503 run_test 102h "grow xattr from inside inode to external block"
6506 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6507 grow_xattr $(max_xattr_size)
6509 run_test 102ha "grow xattr from inside inode to external inode"
6511 test_102i() { # bug 17038
6512 [ -z "$(which getfattr 2>/dev/null)" ] &&
6513 skip "could not find getfattr" && return
6515 ln -s $DIR/$tfile $DIR/${tfile}link
6516 getfattr -n trusted.lov $DIR/$tfile ||
6517 error "lgetxattr on $DIR/$tfile failed"
6518 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6519 grep -i "no such attr" ||
6520 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6521 rm -f $DIR/$tfile $DIR/${tfile}link
6523 run_test 102i "lgetxattr test on symbolic link ============"
6526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6527 TAR=$(find_lustre_tar)
6528 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6529 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6530 setup_test102 "$RUNAS"
6531 test_mkdir -p $DIR/d102j
6532 chown $RUNAS_ID $DIR/d102j
6533 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6535 compare_stripe_info1 "$RUNAS"
6537 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6540 [ -z "$(which setfattr 2>/dev/null)" ] &&
6541 skip "could not find setfattr" && return
6543 # b22187 just check that does not crash for regular file.
6544 setfattr -n trusted.lov $DIR/$tfile
6545 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6546 local test_kdir=$DIR/d102k
6547 test_mkdir $test_kdir
6548 local default_size=`$GETSTRIPE -S $test_kdir`
6549 local default_count=`$GETSTRIPE -c $test_kdir`
6550 local default_offset=`$GETSTRIPE -i $test_kdir`
6551 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6552 error 'dir setstripe failed'
6553 setfattr -n trusted.lov $test_kdir
6554 local stripe_size=`$GETSTRIPE -S $test_kdir`
6555 local stripe_count=`$GETSTRIPE -c $test_kdir`
6556 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6557 [ $stripe_size -eq $default_size ] ||
6558 error "stripe size $stripe_size != $default_size"
6559 [ $stripe_count -eq $default_count ] ||
6560 error "stripe count $stripe_count != $default_count"
6561 [ $stripe_offset -eq $default_offset ] ||
6562 error "stripe offset $stripe_offset != $default_offset"
6563 rm -rf $DIR/$tfile $test_kdir
6565 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6568 [ -z "$(which getfattr 2>/dev/null)" ] &&
6569 skip "could not find getfattr" && return
6571 # LU-532 trusted. xattr is invisible to non-root
6572 local testfile=$DIR/$tfile
6576 echo "listxattr as user..."
6577 chown $RUNAS_ID $testfile
6578 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6579 grep -q "trusted" &&
6580 error "$testfile trusted xattrs are user visible"
6584 run_test 102l "listxattr size test =================================="
6586 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6587 local path=$DIR/$tfile
6590 listxattr_size_check $path || error "listattr_size_check $path failed"
6592 run_test 102m "Ensure listxattr fails on small bufffer ========"
6596 getxattr() { # getxattr path name
6597 # Return the base64 encoding of the value of xattr name on path.
6601 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6603 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6605 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6607 getfattr --absolute-names --encoding=base64 --name=$name $path |
6608 awk -F= -v name=$name '$1 == name {
6609 print substr($0, index($0, "=") + 1);
6613 test_102n() { # LU-4101 mdt: protect internal xattrs
6614 local file0=$DIR/$tfile.0
6615 local file1=$DIR/$tfile.1
6616 local xattr0=$TMP/$tfile.0
6617 local xattr1=$TMP/$tfile.1
6621 [ -z "$(which setfattr 2>/dev/null)" ] &&
6622 skip "could not find setfattr" && return
6624 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6626 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6630 rm -rf $file0 $file1 $xattr0 $xattr1
6633 # Get 'before' xattrs of $file1.
6634 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6636 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6637 # Try to copy xattr from $file0 to $file1.
6638 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6640 setfattr --name=trusted.$name --value="$value" $file1 ||
6641 error "setxattr 'trusted.$name' failed"
6643 # Try to set a garbage xattr.
6644 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6646 setfattr --name=trusted.$name --value="$value" $file1 ||
6647 error "setxattr 'trusted.$name' failed"
6649 # Try to remove the xattr from $file1. We don't care if this
6650 # appears to succeed or fail, we just don't want there to be
6651 # any changes or crashes.
6652 setfattr --remove=$trusted.$name $file1 2> /dev/null
6655 # Get 'after' xattrs of file1.
6656 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6658 if ! diff $xattr0 $xattr1; then
6659 error "before and after xattrs of '$file1' differ"
6662 rm -rf $file0 $file1 $xattr0 $xattr1
6666 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6668 test_102p() { # LU-4703 setxattr did not check ownership
6669 local testfile=$DIR/$tfile
6671 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6672 skip "MDS needs to be at least 2.5.56" && return
6676 echo "setfacl as user..."
6677 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6678 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6680 echo "setfattr as user..."
6681 setfacl -m "u:$RUNAS_ID:---" $testfile
6682 $RUNAS setfattr -x system.posix_acl_access $testfile
6683 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6685 run_test 102p "check setxattr(2) correctly fails without permission"
6689 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6694 [ "$UID" != 0 ] && skip_env "must run as root" && return
6695 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6696 skip "must have acl enabled" && return
6697 [ -z "$(which setfacl 2>/dev/null)" ] &&
6698 skip_env "could not find setfacl" && return
6699 $GSS && skip "could not run under gss" && return
6701 declare -a identity_old
6703 for num in $(seq $MDSCOUNT); do
6704 switch_identity $num true || identity_old[$num]=$?
6711 echo "performing cp ..."
6712 run_acl_subtest cp || error "run_acl_subtest cp failed"
6713 echo "performing getfacl-noacl..."
6714 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6715 echo "performing misc..."
6716 run_acl_subtest misc || error "misc test failed"
6717 echo "performing permissions..."
6718 run_acl_subtest permissions || error "permissions failed"
6719 echo "performing setfacl..."
6720 run_acl_subtest setfacl || error "setfacl test failed"
6722 # inheritance test got from HP
6723 echo "performing inheritance..."
6724 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6725 chmod +x make-tree || error "chmod +x failed"
6726 run_acl_subtest inheritance || error "inheritance test failed"
6729 echo "LU-974 ignore umask when acl is enabled..."
6730 run_acl_subtest 974 || error "LU-974 umask test failed"
6731 if [ $MDSCOUNT -ge 2 ]; then
6732 run_acl_subtest 974_remote ||
6733 error "LU-974 umask test failed under remote dir"
6736 echo "LU-2561 newly created file is same size as directory..."
6737 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6738 run_acl_subtest 2561 || error "LU-2561 test failed"
6740 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6743 run_acl_subtest 4924 || error "LU-4924 test failed"
6748 for num in $(seq $MDSCOUNT); do
6749 if [ "${identity_old[$num]}" = 1 ]; then
6750 switch_identity $num false || identity_old[$num]=$?
6754 run_test 103 "acl test ========================================="
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6759 lfs df || error "lfs df failed"
6760 lfs df -ih || error "lfs df -ih failed"
6761 lfs df -h $DIR || error "lfs df -h $DIR failed"
6762 lfs df -i $DIR || error "lfs df -i $DIR failed"
6763 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6764 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6766 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6767 lctl --device %$OSC deactivate
6768 lfs df || error "lfs df with deactivated OSC failed"
6769 lctl --device %$OSC activate
6770 # wait the osc back to normal
6771 wait_osc_import_state client ost FULL
6773 lfs df || error "lfs df with reactivated OSC failed"
6776 run_test 104a "lfs df [-ih] [path] test ========================="
6779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6780 [ $RUNAS_ID -eq $UID ] &&
6781 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6783 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6784 grep "Permission denied" | wc -l)))
6785 if [ $denied_cnt -ne 0 ]; then
6786 error "lfs check servers test failed"
6789 run_test 104b "$RUNAS lfs check servers test ===================="
6792 # doesn't work on 2.4 kernels
6794 if $(flock_is_enabled); then
6795 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6797 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6801 run_test 105a "flock when mounted without -o flock test ========"
6805 if $(flock_is_enabled); then
6806 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6808 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6812 run_test 105b "fcntl when mounted without -o flock test ========"
6816 if $(flock_is_enabled); then
6817 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6819 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6823 run_test 105c "lockf when mounted without -o flock test ========"
6825 test_105d() { # bug 15924
6826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6827 test_mkdir -p $DIR/$tdir
6828 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6829 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6830 $LCTL set_param fail_loc=0x80000315
6831 flocks_test 2 $DIR/$tdir
6833 run_test 105d "flock race (should not freeze) ========"
6835 test_105e() { # bug 22660 && 22040
6836 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6838 flocks_test 3 $DIR/$tfile
6840 run_test 105e "Two conflicting flocks from same process ======="
6842 test_106() { #bug 10921
6843 test_mkdir -p $DIR/$tdir
6844 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6845 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6847 run_test 106 "attempt exec of dir followed by chown of that dir"
6850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6857 local save_pattern=$(sysctl -n kernel.core_pattern)
6858 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6859 sysctl -w kernel.core_pattern=$file
6860 sysctl -w kernel.core_uses_pid=0
6868 kill -s 11 $SLEEPPID
6870 if [ -e $file ]; then
6871 size=`stat -c%s $file`
6872 [ $size -eq 0 ] && error "Fail to create core file $file"
6874 error "Fail to create core file $file"
6877 sysctl -w kernel.core_pattern=$save_pattern
6878 sysctl -w kernel.core_uses_pid=$save_uses_pid
6881 run_test 107 "Coredump on SIG"
6884 test_mkdir -p $DIR/$tdir
6885 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6886 error "mkdir with 255 char failed"
6887 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6888 error "mkdir with 256 char should fail, but did not"
6889 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6890 error "create with 255 char failed"
6891 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6892 error "create with 256 char should fail, but did not"
6897 run_test 110 "filename length checking"
6900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6901 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
6902 tail -1 | cut -c11-20)
6903 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
6904 echo "Starting with $OSTIO_pre threads"
6907 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
6908 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
6909 echo "$NUMTEST creates/unlinks"
6910 test_mkdir -p $DIR/$tdir
6911 createmany -o $DIR/$tdir/$tfile $NUMTEST
6912 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6914 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
6915 tail -1 | cut -c11-20)
6917 # don't return an error
6918 [ $OSTIO_post == $OSTIO_pre ] && echo \
6919 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6920 echo "This may be fine, depending on what ran before this test" &&
6921 echo "and how fast this system is." && return
6923 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6925 run_test 115 "verify dynamic thread creation===================="
6928 wait_delete_completed
6929 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6930 echo OST kbytes available: ${AVAIL[@]}
6931 MAXI=0; MAXV=${AVAIL[0]}
6932 MINI=0; MINV=${AVAIL[0]}
6933 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6934 #echo OST $i: ${AVAIL[i]}kb
6935 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
6936 MAXV=${AVAIL[i]}; MAXI=$i
6938 if [[ ${AVAIL[i]} -lt $MINV ]]; then
6939 MINV=${AVAIL[i]}; MINI=$i
6942 echo Min free space: OST $MINI: $MINV
6943 echo Max free space: OST $MAXI: $MAXV
6946 test_116a() { # was previously test_116()
6947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6948 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
6950 echo -n "Free space priority "
6951 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6956 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6957 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
6959 trap simple_cleanup_common EXIT
6962 # Check if we need to generate uneven OSTs
6963 test_mkdir -p $DIR/$tdir/OST${MINI}
6964 local FILL=$(($MINV / 4))
6965 local DIFF=$(($MAXV - $MINV))
6966 local DIFF2=$(($DIFF * 100 / $MINV))
6968 local threshold=$(do_facet $SINGLEMDS \
6969 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6970 threshold=${threshold%%%}
6971 echo -n "Check for uneven OSTs: "
6972 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6974 if [[ $DIFF2 -gt $threshold ]]; then
6976 echo "Don't need to fill OST$MINI"
6978 # generate uneven OSTs. Write 2% over the QOS threshold value
6980 DIFF=$(($threshold - $DIFF2 + 2))
6981 DIFF2=$(( ($MINV * $DIFF)/100 ))
6982 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6983 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6984 error "setstripe failed"
6985 DIFF=$(($DIFF2 / 2048))
6987 while [ $i -lt $DIFF ]; do
6989 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6990 bs=2M count=1 2>/dev/null
6999 DIFF=$(($MAXV - $MINV))
7000 DIFF2=$(($DIFF * 100 / $MINV))
7001 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7002 if [[ $DIFF2 -gt $threshold ]]; then
7005 echo "failed - QOS mode won't be used"
7006 skip "QOS imbalance criteria not met"
7007 simple_cleanup_common
7011 MINI1=$MINI; MINV1=$MINV
7012 MAXI1=$MAXI; MAXV1=$MAXV
7014 # now fill using QOS
7015 $SETSTRIPE -c 1 $DIR/$tdir
7016 FILL=$(($FILL / 200))
7017 if [ $FILL -gt 600 ]; then
7020 echo "writing $FILL files to QOS-assigned OSTs"
7022 while [ $i -lt $FILL ]; do
7024 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7028 echo "wrote $i 200k files"
7032 echo "Note: free space may not be updated, so measurements might be off"
7034 DIFF2=$(($MAXV - $MINV))
7035 echo "free space delta: orig $DIFF final $DIFF2"
7036 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7037 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7038 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7039 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7040 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7041 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7043 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7045 # Figure out which files were written where
7046 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7047 awk '/'$MINI1': / {print $2; exit}')
7049 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7050 echo "$MINC files created on smaller OST $MINI1"
7051 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7052 awk '/'$MAXI1': / {print $2; exit}')
7054 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7055 echo "$MAXC files created on larger OST $MAXI1"
7056 FILL=$(($MAXC * 100 / $MINC - 100))
7057 [[ $MINC -gt 0 ]] &&
7058 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7059 [[ $MAXC -gt $MINC ]] ||
7060 error_ignore LU-9 "stripe QOS didn't balance free space"
7061 simple_cleanup_common
7063 run_test 116a "stripe QOS: free space balance ==================="
7065 test_116b() { # LU-2093
7066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7067 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7068 head -1 2>/dev/null)" ] && skip "no QOS" && return
7069 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7071 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7072 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7073 do_facet $SINGLEMDS lctl set_param \
7074 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7076 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7077 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7078 do_facet $SINGLEMDS lctl set_param fail_loc=0
7080 do_facet $SINGLEMDS lctl set_param \
7081 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7083 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7085 test_117() # bug 10891
7087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7088 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7089 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7090 lctl set_param fail_loc=0x21e
7091 > $DIR/$tfile || error "truncate failed"
7092 lctl set_param fail_loc=0
7093 echo "Truncate succeeded."
7096 run_test 117 "verify osd extend =========="
7098 NO_SLOW_RESENDCOUNT=4
7099 export OLD_RESENDCOUNT=""
7100 set_resend_count () {
7101 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7102 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7103 lctl set_param -n $PROC_RESENDCOUNT $1
7104 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7107 # for reduce test_118* time (b=14842)
7108 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7110 # Reset async IO behavior after error case
7112 FILE=$DIR/reset_async
7114 # Ensure all OSCs are cleared
7115 $SETSTRIPE -c -1 $FILE
7116 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7121 test_118a() #bug 11710
7123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7126 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7127 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7128 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7130 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7131 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7136 run_test 118a "verify O_SYNC works =========="
7140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7141 remote_ost_nodsh && skip "remote OST with nodsh" && return
7145 #define OBD_FAIL_OST_ENOENT 0x217
7146 set_nodes_failloc "$(osts_nodes)" 0x217
7147 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7149 set_nodes_failloc "$(osts_nodes)" 0
7150 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7151 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7154 if [[ $RC -eq 0 ]]; then
7155 error "Must return error due to dropped pages, rc=$RC"
7159 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7160 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7164 echo "Dirty pages not leaked on ENOENT"
7166 # Due to the above error the OSC will issue all RPCs syncronously
7167 # until a subsequent RPC completes successfully without error.
7168 $MULTIOP $DIR/$tfile Ow4096yc
7173 run_test 118b "Reclaim dirty pages on fatal error =========="
7177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7179 # for 118c, restore the original resend count, LU-1940
7180 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7181 set_resend_count $OLD_RESENDCOUNT
7182 remote_ost_nodsh && skip "remote OST with nodsh" && return
7186 #define OBD_FAIL_OST_EROFS 0x216
7187 set_nodes_failloc "$(osts_nodes)" 0x216
7189 # multiop should block due to fsync until pages are written
7190 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7194 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7195 error "Multiop failed to block on fsync, pid=$MULTIPID"
7198 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7200 if [[ $WRITEBACK -eq 0 ]]; then
7201 error "No page in writeback, writeback=$WRITEBACK"
7204 set_nodes_failloc "$(osts_nodes)" 0
7207 if [[ $RC -ne 0 ]]; then
7208 error "Multiop fsync failed, rc=$RC"
7211 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7212 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7214 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7215 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7219 echo "Dirty pages flushed via fsync on EROFS"
7222 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7224 # continue to use small resend count to reduce test_118* time (b=14842)
7225 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7230 remote_ost_nodsh && skip "remote OST with nodsh" && return
7234 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7235 set_nodes_failloc "$(osts_nodes)" 0x214
7236 # multiop should block due to fsync until pages are written
7237 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7241 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7242 error "Multiop failed to block on fsync, pid=$MULTIPID"
7245 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7247 if [[ $WRITEBACK -eq 0 ]]; then
7248 error "No page in writeback, writeback=$WRITEBACK"
7251 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7252 set_nodes_failloc "$(osts_nodes)" 0
7254 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7255 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7257 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7258 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7262 echo "Dirty pages gaurenteed flushed via fsync"
7265 run_test 118d "Fsync validation inject a delay of the bulk =========="
7268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7271 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7272 lctl set_param fail_loc=0x8000040a
7274 # Should simulate EINVAL error which is fatal
7275 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7277 if [[ $RC -eq 0 ]]; then
7278 error "Must return error due to dropped pages, rc=$RC"
7281 lctl set_param fail_loc=0x0
7283 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7284 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7285 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7287 if [[ $LOCKED -ne 0 ]]; then
7288 error "Locked pages remain in cache, locked=$LOCKED"
7291 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7292 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7296 echo "No pages locked after fsync"
7301 run_test 118f "Simulate unrecoverable OSC side error =========="
7304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7307 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7308 lctl set_param fail_loc=0x406
7310 # simulate local -ENOMEM
7311 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7314 lctl set_param fail_loc=0
7315 if [[ $RC -eq 0 ]]; then
7316 error "Must return error due to dropped pages, rc=$RC"
7319 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7320 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7321 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7323 if [[ $LOCKED -ne 0 ]]; then
7324 error "Locked pages remain in cache, locked=$LOCKED"
7327 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7328 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7332 echo "No pages locked after fsync"
7337 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7341 remote_ost_nodsh && skip "remote OST with nodsh" && return
7345 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7346 set_nodes_failloc "$(osts_nodes)" 0x20e
7347 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7348 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7351 set_nodes_failloc "$(osts_nodes)" 0
7352 if [[ $RC -eq 0 ]]; then
7353 error "Must return error due to dropped pages, rc=$RC"
7356 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7357 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7358 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7360 if [[ $LOCKED -ne 0 ]]; then
7361 error "Locked pages remain in cache, locked=$LOCKED"
7364 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7365 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7369 echo "No pages locked after fsync"
7373 run_test 118h "Verify timeout in handling recoverables errors =========="
7375 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7379 remote_ost_nodsh && skip "remote OST with nodsh" && return
7383 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7384 set_nodes_failloc "$(osts_nodes)" 0x20e
7386 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7387 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7390 set_nodes_failloc "$(osts_nodes)" 0
7394 if [[ $RC -ne 0 ]]; then
7395 error "got error, but should be not, rc=$RC"
7398 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7399 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7400 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7401 if [[ $LOCKED -ne 0 ]]; then
7402 error "Locked pages remain in cache, locked=$LOCKED"
7405 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7406 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7410 echo "No pages locked after fsync"
7414 run_test 118i "Fix error before timeout in recoverable error =========="
7416 [ "$SLOW" = "no" ] && set_resend_count 4
7419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7420 remote_ost_nodsh && skip "remote OST with nodsh" && return
7424 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7425 set_nodes_failloc "$(osts_nodes)" 0x220
7427 # return -EIO from OST
7428 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7430 set_nodes_failloc "$(osts_nodes)" 0x0
7431 if [[ $RC -eq 0 ]]; then
7432 error "Must return error due to dropped pages, rc=$RC"
7435 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7436 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7437 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7438 if [[ $LOCKED -ne 0 ]]; then
7439 error "Locked pages remain in cache, locked=$LOCKED"
7442 # in recoverable error on OST we want resend and stay until it finished
7443 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7444 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7448 echo "No pages locked after fsync"
7452 run_test 118j "Simulate unrecoverable OST side error =========="
7456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7457 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7459 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7460 set_nodes_failloc "$(osts_nodes)" 0x20e
7461 test_mkdir -p $DIR/$tdir
7463 for ((i=0;i<10;i++)); do
7464 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7465 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7472 set_nodes_failloc "$(osts_nodes)" 0
7475 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7481 test_mkdir -p $DIR/$tdir
7482 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7485 run_test 118l "fsync dir ========="
7487 test_118m() # LU-3066
7489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7490 test_mkdir -p $DIR/$tdir
7491 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7494 run_test 118m "fdatasync dir ========="
7496 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7498 test_119a() # bug 11737
7500 BSIZE=$((512 * 1024))
7501 directio write $DIR/$tfile 0 1 $BSIZE
7502 # We ask to read two blocks, which is more than a file size.
7503 # directio will indicate an error when requested and actual
7504 # sizes aren't equeal (a normal situation in this case) and
7505 # print actual read amount.
7506 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7507 if [ "$NOB" != "$BSIZE" ]; then
7508 error "read $NOB bytes instead of $BSIZE"
7512 run_test 119a "Short directIO read must return actual read amount"
7514 test_119b() # bug 11737
7516 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7518 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7519 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7521 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7522 error "direct read failed"
7525 run_test 119b "Sparse directIO read must return actual read amount"
7527 test_119c() # bug 13099
7530 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7531 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7534 run_test 119c "Testing for direct read hitting hole"
7536 test_119d() # bug 15950
7538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7539 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7540 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7542 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7543 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7544 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7545 lctl set_param fail_loc=0x40d
7546 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7549 cat $DIR/$tfile > /dev/null &
7550 lctl set_param fail_loc=0
7553 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7555 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7556 error "the read rpcs have not completed in 2s"
7558 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7560 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7564 test_mkdir -p $DIR/$tdir
7565 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7566 skip "no early lock cancel on server" && return 0
7568 lru_resize_disable mdc
7569 lru_resize_disable osc
7570 cancel_lru_locks mdc
7571 # asynchronous object destroy at MDT could cause bl ast to client
7572 cancel_lru_locks osc
7574 stat $DIR/$tdir > /dev/null
7575 can1=$(do_facet $SINGLEMDS \
7576 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7577 awk '/ldlm_cancel/ {print $2}')
7578 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7579 awk '/ldlm_bl_callback/ {print $2}')
7580 test_mkdir -c1 $DIR/$tdir/d1
7581 can2=$(do_facet $SINGLEMDS \
7582 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7583 awk '/ldlm_cancel/ {print $2}')
7584 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7585 awk '/ldlm_bl_callback/ {print $2}')
7586 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7587 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7588 lru_resize_enable mdc
7589 lru_resize_enable osc
7591 run_test 120a "Early Lock Cancel: mkdir test"
7594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7595 test_mkdir $DIR/$tdir
7596 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7597 skip "no early lock cancel on server" && return 0
7598 lru_resize_disable mdc
7599 lru_resize_disable osc
7600 cancel_lru_locks mdc
7601 stat $DIR/$tdir > /dev/null
7602 can1=$(do_facet $SINGLEMDS \
7603 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7604 awk '/ldlm_cancel/ {print $2}')
7605 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7606 awk '/ldlm_bl_callback/ {print $2}')
7608 can2=$(do_facet $SINGLEMDS \
7609 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7610 awk '/ldlm_cancel/ {print $2}')
7611 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7612 awk '/ldlm_bl_callback/ {print $2}')
7613 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7614 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7615 lru_resize_enable mdc
7616 lru_resize_enable osc
7618 run_test 120b "Early Lock Cancel: create test"
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7622 test_mkdir -c1 $DIR/$tdir
7623 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7624 skip "no early lock cancel on server" && return 0
7625 lru_resize_disable mdc
7626 lru_resize_disable osc
7627 test_mkdir -p -c1 $DIR/$tdir/d1
7628 test_mkdir -p -c1 $DIR/$tdir/d2
7629 touch $DIR/$tdir/d1/f1
7630 cancel_lru_locks mdc
7631 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7632 can1=$(do_facet $SINGLEMDS \
7633 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7634 awk '/ldlm_cancel/ {print $2}')
7635 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7636 awk '/ldlm_bl_callback/ {print $2}')
7637 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7638 can2=$(do_facet $SINGLEMDS \
7639 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7640 awk '/ldlm_cancel/ {print $2}')
7641 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7642 awk '/ldlm_bl_callback/ {print $2}')
7643 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7644 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7645 lru_resize_enable mdc
7646 lru_resize_enable osc
7648 run_test 120c "Early Lock Cancel: link test"
7651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7652 test_mkdir -p -c1 $DIR/$tdir
7653 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7654 skip "no early lock cancel on server" && return 0
7655 lru_resize_disable mdc
7656 lru_resize_disable osc
7658 cancel_lru_locks mdc
7659 stat $DIR/$tdir > /dev/null
7660 can1=$(do_facet $SINGLEMDS \
7661 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7662 awk '/ldlm_cancel/ {print $2}')
7663 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7664 awk '/ldlm_bl_callback/ {print $2}')
7665 chmod a+x $DIR/$tdir
7666 can2=$(do_facet $SINGLEMDS \
7667 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7668 awk '/ldlm_cancel/ {print $2}')
7669 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7670 awk '/ldlm_bl_callback/ {print $2}')
7671 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7672 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7673 lru_resize_enable mdc
7674 lru_resize_enable osc
7676 run_test 120d "Early Lock Cancel: setattr test"
7679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7680 test_mkdir -p -c1 $DIR/$tdir
7681 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7682 skip "no early lock cancel on server" && return 0
7683 lru_resize_disable mdc
7684 lru_resize_disable osc
7685 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7686 cancel_lru_locks mdc
7687 cancel_lru_locks osc
7688 dd if=$DIR/$tdir/f1 of=/dev/null
7689 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7690 # XXX client can not do early lock cancel of OST lock
7691 # during unlink (LU-4206), so cancel osc lock now.
7692 cancel_lru_locks osc
7693 can1=$(do_facet $SINGLEMDS \
7694 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7695 awk '/ldlm_cancel/ {print $2}')
7696 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7697 awk '/ldlm_bl_callback/ {print $2}')
7698 unlink $DIR/$tdir/f1
7700 can2=$(do_facet $SINGLEMDS \
7701 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7702 awk '/ldlm_cancel/ {print $2}')
7703 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7704 awk '/ldlm_bl_callback/ {print $2}')
7705 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7706 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7707 lru_resize_enable mdc
7708 lru_resize_enable osc
7710 run_test 120e "Early Lock Cancel: unlink test"
7713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7714 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7715 skip "no early lock cancel on server" && return 0
7716 test_mkdir -p -c1 $DIR/$tdir
7717 lru_resize_disable mdc
7718 lru_resize_disable osc
7719 test_mkdir -p -c1 $DIR/$tdir/d1
7720 test_mkdir -p -c1 $DIR/$tdir/d2
7721 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7722 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7723 cancel_lru_locks mdc
7724 cancel_lru_locks osc
7725 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7726 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7727 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7728 # XXX client can not do early lock cancel of OST lock
7729 # during rename (LU-4206), so cancel osc lock now.
7730 cancel_lru_locks osc
7731 can1=$(do_facet $SINGLEMDS \
7732 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7733 awk '/ldlm_cancel/ {print $2}')
7734 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7735 awk '/ldlm_bl_callback/ {print $2}')
7736 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7738 can2=$(do_facet $SINGLEMDS \
7739 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7740 awk '/ldlm_cancel/ {print $2}')
7741 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7742 awk '/ldlm_bl_callback/ {print $2}')
7743 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7744 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7745 lru_resize_enable mdc
7746 lru_resize_enable osc
7748 run_test 120f "Early Lock Cancel: rename test"
7751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7752 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7753 skip "no early lock cancel on server" && return 0
7754 lru_resize_disable mdc
7755 lru_resize_disable osc
7757 echo create $count files
7758 test_mkdir -p $DIR/$tdir
7759 cancel_lru_locks mdc
7760 cancel_lru_locks osc
7763 can0=$(do_facet $SINGLEMDS \
7764 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7765 awk '/ldlm_cancel/ {print $2}')
7766 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7767 awk '/ldlm_bl_callback/ {print $2}')
7768 createmany -o $DIR/$tdir/f $count
7770 can1=$(do_facet $SINGLEMDS \
7771 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7772 awk '/ldlm_cancel/ {print $2}')
7773 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7774 awk '/ldlm_bl_callback/ {print $2}')
7776 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7777 echo rm $count files
7780 can2=$(do_facet $SINGLEMDS \
7781 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7782 awk '/ldlm_cancel/ {print $2}')
7783 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7784 awk '/ldlm_bl_callback/ {print $2}')
7786 echo total: $count removes in $((t2-t1))
7787 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7789 # wait for commitment of removal
7790 lru_resize_enable mdc
7791 lru_resize_enable osc
7793 run_test 120g "Early Lock Cancel: performance test"
7795 test_121() { #bug #10589
7796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7798 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7799 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7800 lctl set_param fail_loc=0x310
7801 cancel_lru_locks osc > /dev/null
7802 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7803 lctl set_param fail_loc=0
7804 [[ $reads -eq $writes ]] ||
7805 error "read $reads blocks, must be $writes blocks"
7807 run_test 121 "read cancel race ========="
7809 test_123a() { # was test 123, statahead(bug 11401)
7810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7812 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7813 log "testing on UP system. Performance may be not as good as expected."
7818 test_mkdir -p $DIR/$tdir
7819 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7820 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7822 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7823 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7825 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7826 lctl set_param -n llite.*.statahead_max 0
7827 lctl get_param llite.*.statahead_max
7828 cancel_lru_locks mdc
7829 cancel_lru_locks osc
7831 time ls -l $DIR/$tdir | wc -l
7833 delta=$((etime - stime))
7834 log "ls $i files without statahead: $delta sec"
7835 lctl set_param llite.*.statahead_max=$max
7837 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7838 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7839 cancel_lru_locks mdc
7840 cancel_lru_locks osc
7842 time ls -l $DIR/$tdir | wc -l
7844 delta_sa=$((etime - stime))
7845 log "ls $i files with statahead: $delta_sa sec"
7846 lctl get_param -n llite.*.statahead_stats
7847 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7849 [[ $swrong -lt $ewrong ]] &&
7850 log "statahead was stopped, maybe too many locks held!"
7851 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7853 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7854 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7855 lctl set_param -n llite.*.statahead_max 0
7856 lctl get_param llite.*.statahead_max
7857 cancel_lru_locks mdc
7858 cancel_lru_locks osc
7860 time ls -l $DIR/$tdir | wc -l
7862 delta=$((etime - stime))
7863 log "ls $i files again without statahead: $delta sec"
7864 lctl set_param llite.*.statahead_max=$max
7865 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7866 if [ $SLOWOK -eq 0 ]; then
7867 error "ls $i files is slower with statahead!"
7869 log "ls $i files is slower with statahead!"
7875 [ $delta -gt 20 ] && break
7876 [ $delta -gt 8 ] && MULT=$((50 / delta))
7877 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7885 delta=$((etime - stime))
7886 log "rm -r $DIR/$tdir/: $delta seconds"
7888 lctl get_param -n llite.*.statahead_stats
7890 run_test 123a "verify statahead work"
7892 test_123b () { # statahead(bug 15027)
7893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7894 test_mkdir -p $DIR/$tdir
7895 createmany -o $DIR/$tdir/$tfile-%d 1000
7897 cancel_lru_locks mdc
7898 cancel_lru_locks osc
7900 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7901 lctl set_param fail_loc=0x80000803
7902 ls -lR $DIR/$tdir > /dev/null
7904 lctl set_param fail_loc=0x0
7905 lctl get_param -n llite.*.statahead_stats
7910 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7914 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7915 skip "no lru resize on server" && return 0
7917 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7919 log "create $NR files at $DIR/$tdir"
7920 createmany -o $DIR/$tdir/f $NR ||
7921 error "failed to create $NR files in $DIR/$tdir"
7923 cancel_lru_locks mdc
7924 ls -l $DIR/$tdir > /dev/null
7928 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
7929 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7930 LRU_SIZE=$($LCTL get_param -n $PARAM)
7931 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
7932 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7934 log "NS=$(basename $NSDIR)"
7939 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
7940 skip "Not enough cached locks created!"
7947 # We know that lru resize allows one client to hold $LIMIT locks
7948 # for 10h. After that locks begin to be killed by client.
7950 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
7953 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7954 # killing locks. Some time was spent for creating locks. This means
7955 # that up to the moment of sleep finish we must have killed some of
7956 # them (10-100 locks). This depends on how fast ther were created.
7957 # Many of them were touched in almost the same moment and thus will
7958 # be killed in groups.
7959 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7961 # Use $LRU_SIZE_B here to take into account real number of locks
7962 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7963 local LRU_SIZE_B=$LRU_SIZE
7965 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
7966 log "OLD_LVF=$OLD_LVF"
7967 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
7969 # Let's make sure that we really have some margin. Client checks
7970 # cached locks every 10 sec.
7972 log "Sleep ${SLEEP} sec"
7974 while ((SEC<$SLEEP)); do
7978 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
7982 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7983 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
7985 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
7986 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7987 unlinkmany $DIR/$tdir/f $NR
7991 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7992 log "unlink $NR files at $DIR/$tdir"
7993 unlinkmany $DIR/$tdir/f $NR
7995 run_test 124a "lru resize ======================================="
7997 get_max_pool_limit()
7999 local limit=$($LCTL get_param \
8000 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8003 if [[ $l -gt $max ]]; then
8011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8012 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8013 skip "no lru resize on server" && return 0
8015 LIMIT=$(get_max_pool_limit)
8017 NR=$(($(default_lru_size)*20))
8018 if [[ $NR -gt $LIMIT ]]; then
8019 log "Limit lock number by $LIMIT locks"
8022 lru_resize_disable mdc
8023 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8024 error "failed to create $DIR/$tdir/disable_lru_resize"
8026 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8027 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8028 cancel_lru_locks mdc
8031 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8034 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8037 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8041 nolruresize_delta=$((etime-stime))
8042 log "ls -la time: $nolruresize_delta seconds"
8043 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8044 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8046 lru_resize_enable mdc
8047 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8048 error "failed to create $DIR/$tdir/enable_lru_resize"
8050 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8051 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8052 cancel_lru_locks mdc
8055 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8058 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8061 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8065 lruresize_delta=$((etime-stime))
8066 log "ls -la time: $lruresize_delta seconds"
8067 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8069 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8070 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8071 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8072 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8074 log "lru resize performs the same with no lru resize"
8076 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8078 run_test 124b "lru resize (performance test) ======================="
8080 test_125() { # 13358
8081 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8082 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8083 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8084 test_mkdir -p $DIR/d125 || error "mkdir failed"
8085 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8086 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8087 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8089 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8091 test_126() { # bug 12829/13455
8092 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8093 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8094 $GSS && skip "must run as gss disabled" && return
8096 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8097 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8099 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8101 run_test 126 "check that the fsgid provided by the client is taken into account"
8103 test_127a() { # bug 15521
8104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8105 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8106 $LCTL set_param osc.*.stats=0
8107 FSIZE=$((2048 * 1024))
8108 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8109 cancel_lru_locks osc
8110 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8112 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8113 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8114 echo "got $COUNT $NAME"
8115 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8116 eval $NAME=$COUNT || error "Wrong proc format"
8119 read_bytes|write_bytes)
8120 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8121 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8122 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8123 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8124 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8125 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8126 error "sumsquare is too small: $SUMSQ"
8127 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8128 error "sumsquare is too big: $SUMSQ"
8132 done < $DIR/${tfile}.tmp
8134 #check that we actually got some stats
8135 [ "$read_bytes" ] || error "Missing read_bytes stats"
8136 [ "$write_bytes" ] || error "Missing write_bytes stats"
8137 [ "$read_bytes" != 0 ] || error "no read done"
8138 [ "$write_bytes" != 0 ] || error "no write done"
8140 run_test 127a "verify the client stats are sane"
8142 test_127b() { # bug LU-333
8143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8144 $LCTL set_param llite.*.stats=0
8145 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8146 # perform 2 reads and writes so MAX is different from SUM.
8147 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8148 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8149 cancel_lru_locks osc
8150 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8151 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8153 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8154 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8155 echo "got $COUNT $NAME"
8156 eval $NAME=$COUNT || error "Wrong proc format"
8160 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8161 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8162 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8163 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8166 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8167 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8168 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8169 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8173 done < $TMP/${tfile}.tmp
8175 #check that we actually got some stats
8176 [ "$read_bytes" ] || error "Missing read_bytes stats"
8177 [ "$write_bytes" ] || error "Missing write_bytes stats"
8178 [ "$read_bytes" != 0 ] || error "no read done"
8179 [ "$write_bytes" != 0 ] || error "no write done"
8181 run_test 127b "verify the llite client stats are sane"
8183 test_128() { # bug 15212
8185 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8190 result=$(grep error $TMP/$tfile.log)
8192 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8194 run_test 128 "interactive lfs for 2 consecutive find's"
8201 local LDPROC=/proc/fs/ldiskfs
8202 local facets=$(get_facets MDS)
8204 for facet in ${facets//,/ }; do
8205 canondev=$(ldiskfs_canon \
8206 *.$(convert_facet2label $facet).mntdev $facet)
8207 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8208 LDPROC=/sys/fs/ldiskfs
8209 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8215 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8216 skip "Only applicable to ldiskfs-based MDTs"
8219 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8224 test_mkdir -p $DIR/$tdir
8226 # block size of mds1
8227 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8228 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8229 local MAX=$((MDSBLOCKSIZE * 3))
8231 local I=$(stat -c%s "$DIR/$tdir")
8233 local STRIPE_COUNT=1
8234 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8235 MAX=$((MAX*STRIPE_COUNT))
8236 while [[ $I -le $MAX ]]; do
8237 $MULTIOP $DIR/$tdir/$J Oc
8239 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8240 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8241 #and EFBIG for previous versions
8242 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8244 echo "return code $rc received as expected"
8245 multiop $DIR/$tdir/$J Oc ||
8246 error_exit "multiop failed w/o dir size limit"
8248 I=$(stat -c%s "$DIR/$tdir")
8250 if [ $(lustre_version_code $SINGLEMDS) -lt \
8251 $(version_code 2.4.51) ]
8253 [[ $I -eq $MAX ]] && return 0
8255 [[ $I -gt $MAX ]] && return 0
8257 error_exit "current dir size $I, previous limit $MAX"
8258 elif [ $rc -ne 0 ]; then
8260 error_exit "return code $rc received instead of expected " \
8261 "$EFBIG or $ENOSPC, files in dir $I"
8264 I=$(stat -c%s "$DIR/$tdir")
8268 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8270 run_test 129 "test directory size limit ========================"
8279 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8280 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8283 trap cleanup_130 EXIT RETURN
8285 local fm_file=$DIR/$tfile
8286 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8287 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8288 error "dd failed for $fm_file"
8290 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8291 filefrag -ves $fm_file
8293 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8294 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8295 [ $RC != 0 ] && error "filefrag $fm_file failed"
8297 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8298 grep -v "ext:" | grep -v "found")
8299 lun=$($GETSTRIPE -i $fm_file)
8301 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8304 for line in $filefrag_op
8306 frag_lun=`echo $line | cut -d: -f5`
8307 ext_len=`echo $line | cut -d: -f4`
8308 if (( $frag_lun != $lun )); then
8310 error "FIEMAP on 1-stripe file($fm_file) failed"
8313 (( tot_len += ext_len ))
8316 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8318 error "FIEMAP on 1-stripe file($fm_file) failed;"
8324 echo "FIEMAP on single striped file succeeded"
8326 run_test 130a "FIEMAP (1-stripe file)"
8329 [ "$OSTCOUNT" -lt "2" ] &&
8330 skip_env "skipping FIEMAP on 2-stripe file test" && return
8332 [ "$OSTCOUNT" -ge "10" ] &&
8333 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8335 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8336 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8339 trap cleanup_130 EXIT RETURN
8341 local fm_file=$DIR/$tfile
8342 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8343 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8344 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8346 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8347 error "dd failed on $fm_file"
8349 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8350 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8351 grep -v "ext:" | grep -v "found")
8353 last_lun=$(echo $filefrag_op | cut -d: -f5)
8358 for line in $filefrag_op
8360 frag_lun=`echo $line | cut -d: -f5`
8361 ext_len=`echo $line | cut -d: -f4`
8362 if (( $frag_lun != $last_lun )); then
8363 if (( tot_len != 1024 )); then
8365 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8372 (( tot_len += ext_len ))
8375 if (( num_luns != 2 || tot_len != 1024 )); then
8377 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8383 echo "FIEMAP on 2-stripe file succeeded"
8385 run_test 130b "FIEMAP (2-stripe file)"
8388 [ "$OSTCOUNT" -lt "2" ] &&
8389 skip_env "skipping FIEMAP on 2-stripe file" && return
8391 [ "$OSTCOUNT" -ge "10" ] &&
8392 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8394 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8395 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8398 trap cleanup_130 EXIT RETURN
8400 local fm_file=$DIR/$tfile
8401 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8402 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8403 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8405 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8407 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8408 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8410 last_lun=`echo $filefrag_op | cut -d: -f5`
8415 for line in $filefrag_op
8417 frag_lun=`echo $line | cut -d: -f5`
8418 ext_len=`echo $line | cut -d: -f4`
8419 if (( $frag_lun != $last_lun )); then
8420 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8421 if (( logical != 512 )); then
8423 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8426 if (( tot_len != 512 )); then
8428 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8435 (( tot_len += ext_len ))
8438 if (( num_luns != 2 || tot_len != 512 )); then
8440 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8446 echo "FIEMAP on 2-stripe file with hole succeeded"
8448 run_test 130c "FIEMAP (2-stripe file with hole)"
8451 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8453 [ "$OSTCOUNT" -ge "10" ] &&
8454 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8456 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8457 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8459 trap cleanup_130 EXIT RETURN
8461 local fm_file=$DIR/$tfile
8462 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8463 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8464 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8466 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8467 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8468 error "dd failed on $fm_file"
8470 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8471 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8472 grep -v "ext:" | grep -v "found"`
8474 last_lun=`echo $filefrag_op | cut -d: -f5`
8479 for line in $filefrag_op
8481 frag_lun=`echo $line | cut -d: -f5`
8482 ext_len=`echo $line | cut -d: -f4`
8483 if (( $frag_lun != $last_lun )); then
8484 if (( tot_len != 1024 )); then
8486 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8493 (( tot_len += ext_len ))
8496 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8498 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8504 echo "FIEMAP on N-stripe file succeeded"
8506 run_test 130d "FIEMAP (N-stripe file)"
8509 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8511 [ "$OSTCOUNT" -ge "10" ] &&
8512 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8514 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8515 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8517 trap cleanup_130 EXIT RETURN
8519 local fm_file=$DIR/$tfile
8520 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8521 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8522 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8525 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8526 for ((i = 0; i < $NUM_BLKS; i++))
8528 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8531 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8532 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8534 last_lun=`echo $filefrag_op | cut -d: -f5`
8539 for line in $filefrag_op
8541 frag_lun=`echo $line | cut -d: -f5`
8542 ext_len=`echo $line | cut -d: -f4`
8543 if (( $frag_lun != $last_lun )); then
8544 if (( tot_len != $EXPECTED_LEN )); then
8546 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8553 (( tot_len += ext_len ))
8556 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8558 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8564 echo "FIEMAP with continuation calls succeeded"
8566 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8568 # Test for writev/readv
8570 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8571 error "writev test failed"
8572 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8573 error "readv failed"
8576 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8579 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8580 error "append writev test failed"
8581 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8582 error "append writev test failed"
8585 run_test 131b "test append writev"
8588 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8591 run_test 131c "test read/write on file w/o objects"
8594 rwv -f $DIR/$tfile -w -n 1 1572864
8595 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8596 if [ "$NOB" != 1572864 ]; then
8597 error "Short read filed: read $NOB bytes instead of 1572864"
8601 run_test 131d "test short read"
8604 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8605 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8606 error "read hitting hole failed"
8609 run_test 131e "test read hitting hole"
8614 for node in $(osts_nodes); do
8615 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8616 [ x$gl = x"" ] && gl=0
8617 gl_sum=$((gl_sum + gl))
8627 if [ x$som = x"enabled" ]; then
8628 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8629 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8630 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8632 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8633 MOUNTOPT="$MOUNTOPT,som_preview"
8634 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8637 # do remount to make new mount-conf parameters actual
8644 test_132() { #1028, SOM
8645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8647 local num=$(get_mds_dir $DIR)
8648 local mymds=mds${num}
8649 local MOUNTOPT_SAVE=$MOUNTOPT
8651 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8652 cancel_lru_locks osc
8654 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8656 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8657 stat $DIR/$tfile >/dev/null
8658 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8659 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8661 som_mode_switch $som1 $gl1 $gl2
8663 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8664 cancel_lru_locks osc
8666 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8667 if [ $som1 == $som2 ]; then
8668 error "som is still "$som2
8669 if [ x$som2 = x"enabled" ]; then
8676 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8677 stat $DIR/$tfile >/dev/null
8678 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8679 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8680 som_mode_switch $som2 $gl1 $gl2
8681 MOUNTOPT=$MOUNTOPT_SAVE
8683 run_test 132 "som avoids glimpse rpc"
8689 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8691 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8693 *) error "Wrong argument $1" ;;
8696 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8697 # if the argument $3 is zero, it means any stat increment is ok.
8698 if [[ $3 -gt 0 ]]; then
8699 count=$(echo $res | awk '{ print $2 }')
8700 [[ $count -ne $3 ]] &&
8701 error "The $2 counter on $1 is wrong - expected $3"
8706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8707 remote_ost_nodsh && skip "remote OST with nodsh" && return
8708 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8710 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8711 { skip "MDS doesn't support rename stats"; return; }
8712 local testdir=$DIR/${tdir}/stats_testdir
8713 mkdir -p $DIR/${tdir}
8716 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8717 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8719 # verify mdt stats first.
8720 mkdir ${testdir} || error "mkdir failed"
8721 check_stats $SINGLEMDS "mkdir" 1
8722 touch ${testdir}/${tfile} || "touch failed"
8723 check_stats $SINGLEMDS "open" 1
8724 check_stats $SINGLEMDS "close" 1
8725 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8726 check_stats $SINGLEMDS "mknod" 1
8727 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8728 check_stats $SINGLEMDS "unlink" 1
8729 rm -f ${testdir}/${tfile} || error "file remove failed"
8730 check_stats $SINGLEMDS "unlink" 2
8732 # remove working dir and check mdt stats again.
8733 rmdir ${testdir} || error "rmdir failed"
8734 check_stats $SINGLEMDS "rmdir" 1
8736 local testdir1=$DIR/${tdir}/stats_testdir1
8738 mkdir -p ${testdir1}
8739 touch ${testdir1}/test1
8740 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8741 check_stats $SINGLEMDS "crossdir_rename" 1
8743 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8744 check_stats $SINGLEMDS "samedir_rename" 1
8748 run_test 133a "Verifying MDT stats ========================================"
8751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8752 remote_ost_nodsh && skip "remote OST with nodsh" && return
8753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8754 local testdir=$DIR/${tdir}/stats_testdir
8755 mkdir -p ${testdir} || error "mkdir failed"
8756 touch ${testdir}/${tfile} || "touch failed"
8757 cancel_lru_locks mdc
8760 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8761 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8763 # extra mdt stats verification.
8764 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8765 check_stats $SINGLEMDS "setattr" 1
8766 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8767 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8769 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8770 check_stats $SINGLEMDS "getattr" 1
8772 $LFS df || error "lfs failed"
8773 check_stats $SINGLEMDS "statfs" 1
8777 run_test 133b "Verifying extra MDT stats =================================="
8780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8781 remote_ost_nodsh && skip "remote OST with nodsh" && return
8782 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8783 local testdir=$DIR/${tdir}/stats_testdir
8784 test_mkdir -p ${testdir} || error "mkdir failed"
8786 # verify obdfilter stats.
8787 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8789 cancel_lru_locks osc
8790 wait_delete_completed
8793 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8794 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8796 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8798 cancel_lru_locks osc
8799 check_stats ost "write" 1
8801 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8802 check_stats ost "read" 1
8804 > ${testdir}/${tfile} || error "truncate failed"
8805 check_stats ost "punch" 1
8807 rm -f ${testdir}/${tfile} || error "file remove failed"
8808 wait_delete_completed
8809 check_stats ost "destroy" 1
8813 run_test 133c "Verifying OST stats ========================================"
8820 while [ $value -ge 2 ]; do
8825 if [ $orig -gt $order ]; then
8833 local size=('K' 'M' 'G' 'T');
8835 local size_string=$value
8837 while [ $value -ge 1024 ]; do
8838 if [ $i -gt 3 ]; then
8839 #T is the biggest unit we get here, if that is bigger,
8841 size_string=${value}T
8844 value=$((value >> 10))
8845 if [ $value -lt 1024 ]; then
8846 size_string=${value}${size[$i]}
8857 local context=${2:-.}
8858 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8860 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8866 remote_ost_nodsh && skip "remote OST with nodsh" && return
8867 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8868 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8869 { skip "MDS doesn't support rename stats"; return; }
8871 local testdir1=$DIR/${tdir}/stats_testdir1
8872 local testdir2=$DIR/${tdir}/stats_testdir2
8874 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8876 mkdir -p ${testdir1} || error "mkdir failed"
8877 mkdir -p ${testdir2} || error "mkdir failed"
8879 createmany -o $testdir1/test 512 || error "createmany failed"
8881 # check samedir rename size
8882 mv ${testdir1}/test0 ${testdir1}/test_0
8884 local testdir1_size=$(ls -l $DIR/${tdir} |
8885 awk '/stats_testdir1/ {print $5}')
8886 local testdir2_size=$(ls -l $DIR/${tdir} |
8887 awk '/stats_testdir2/ {print $5}')
8889 testdir1_size=$(order_2 $testdir1_size)
8890 testdir2_size=$(order_2 $testdir2_size)
8892 testdir1_size=$(size_in_KMGT $testdir1_size)
8893 testdir2_size=$(size_in_KMGT $testdir2_size)
8895 echo "source rename dir size: ${testdir1_size}"
8896 echo "target rename dir size: ${testdir2_size}"
8898 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8899 eval $cmd || error "$cmd failed"
8900 local samedir=$($cmd | grep 'same_dir')
8901 local same_sample=$(get_rename_size $testdir1_size)
8902 [ -z "$samedir" ] && error "samedir_rename_size count error"
8903 [[ $same_sample -eq 1 ]] ||
8904 error "samedir_rename_size error $same_sample"
8905 echo "Check same dir rename stats success"
8907 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8909 # check crossdir rename size
8910 mv ${testdir1}/test_0 ${testdir2}/test_0
8912 testdir1_size=$(ls -l $DIR/${tdir} |
8913 awk '/stats_testdir1/ {print $5}')
8914 testdir2_size=$(ls -l $DIR/${tdir} |
8915 awk '/stats_testdir2/ {print $5}')
8917 testdir1_size=$(order_2 $testdir1_size)
8918 testdir2_size=$(order_2 $testdir2_size)
8920 testdir1_size=$(size_in_KMGT $testdir1_size)
8921 testdir2_size=$(size_in_KMGT $testdir2_size)
8923 echo "source rename dir size: ${testdir1_size}"
8924 echo "target rename dir size: ${testdir2_size}"
8926 eval $cmd || error "$cmd failed"
8927 local crossdir=$($cmd | grep 'crossdir')
8928 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8929 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8930 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8931 [[ $src_sample -eq 1 ]] ||
8932 error "crossdir_rename_size error $src_sample"
8933 [[ $tgt_sample -eq 1 ]] ||
8934 error "crossdir_rename_size error $tgt_sample"
8935 echo "Check cross dir rename stats success"
8938 run_test 133d "Verifying rename_stats ========================================"
8941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8942 local testdir=$DIR/${tdir}/stats_testdir
8943 local ctr f0 f1 bs=32768 count=42 sum
8945 remote_ost_nodsh && skip "remote OST with nodsh" && return
8946 mkdir -p ${testdir} || error "mkdir failed"
8948 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8950 for ctr in {write,read}_bytes; do
8952 cancel_lru_locks osc
8954 do_facet ost1 $LCTL set_param -n \
8955 "obdfilter.*.exports.clear=clear"
8957 if [ $ctr = write_bytes ]; then
8959 f1=${testdir}/${tfile}
8961 f0=${testdir}/${tfile}
8965 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8968 cancel_lru_locks osc
8970 sum=$(do_facet ost1 $LCTL get_param \
8971 "obdfilter.*.exports.*.stats" |
8972 awk -v ctr=$ctr 'BEGIN { sum = 0 }
8973 $1 == ctr { sum += $7 }
8974 END { printf("%0.0f", sum) }')
8976 if ((sum != bs * count)); then
8977 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8983 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8986 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8989 # First without trusting modes.
8990 find $proc_dirs -exec cat '{}' \; &> /dev/null
8992 # Second verifying readability.
8995 -exec cat '{}' \; &> /dev/null ||
8996 error "proc file read failed"
8998 for facet in $SINGLEMDS ost1; do
8999 do_facet $facet find $proc_dirs \
9000 ! -name req_history \
9001 -exec cat '{}' \\\; &> /dev/null
9003 do_facet $facet find $proc_dirs \
9004 ! -name req_history \
9006 -exec cat '{}' \\\; &> /dev/null ||
9007 error "proc file read failed"
9010 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9013 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9016 # Second verifying readability.
9019 -not -name force_lbug \
9020 -not -name changelog_mask \
9021 -exec badarea_io '{}' \; > /dev/null
9023 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9024 skip "Too old lustre on MDS"
9026 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9027 skip "Too old lustre on ost1"
9029 for facet in $SINGLEMDS ost1; do
9030 do_facet $facet find $proc_dirs \
9032 -not -name force_lbug \
9033 -not -name changelog_mask \
9034 -exec badarea_io '{}' \\\; &> /dev/null
9038 # remount the FS in case writes/reads /proc break the FS
9039 cleanup || error "failed to unmount"
9040 setup || error "failed to setup"
9043 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9045 test_140() { #bug-17379
9046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9047 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9048 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9049 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9051 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9052 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9054 while i=`expr $i + 1`; do
9055 test_mkdir -p $i || error "Creating dir $i"
9056 cd $i || error "Changing to $i"
9057 ln -s ../stat stat || error "Creating stat symlink"
9058 # Read the symlink until ELOOP present,
9059 # not LBUGing the system is considered success,
9060 # we didn't overrun the stack.
9061 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9063 if [ $ret -eq 40 ]; then
9066 error "Open stat symlink"
9072 echo "The symlink depth = $i"
9073 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9074 error "Invalid symlink depth"
9076 # Test recursive symlink
9077 ln -s symlink_self symlink_self
9078 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9079 echo "open symlink_self returns $ret"
9080 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9082 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9086 local TF="$TMP/$tfile"
9088 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9090 cancel_lru_locks osc
9091 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9092 remount_client $MOUNT
9094 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9097 $TRUNCATE $DIR/$tfile 6000
9098 cancel_lru_locks osc
9099 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9102 echo "12345" >>$DIR/$tfile
9103 cancel_lru_locks osc
9104 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9107 echo "12345" >>$DIR/$tfile
9108 cancel_lru_locks osc
9109 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9114 run_test 150 "truncate/append tests"
9116 #LU-2902 roc_hit was not able to read all values from lproc
9117 function roc_hit_init() {
9118 local list=$(comma_list $(osts_nodes))
9119 local dir=$DIR/$tdir-check
9120 local file=$dir/file
9126 #use setstripe to do a write to every ost
9127 for i in $(seq 0 $((OSTCOUNT-1))); do
9128 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9129 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9130 idx=$(printf %04x $i)
9131 BEFORE=$(get_osd_param $list *OST*$idx stats |
9132 awk '$1 == "cache_access" {sum += $2}
9133 END { printf("%0.0f", sum) }')
9135 cancel_lru_locks osc
9136 cat $file >/dev/null
9138 AFTER=$(get_osd_param $list *OST*$idx stats |
9139 awk '$1 == "cache_access" {sum += $2}
9140 END { printf("%0.0f", sum) }')
9142 echo BEFORE:$BEFORE AFTER:$AFTER
9143 if ! let "AFTER - BEFORE == 4"; then
9145 error "roc_hit is not safe to use"
9153 function roc_hit() {
9154 local list=$(comma_list $(osts_nodes))
9155 echo $(get_osd_param $list '' stats |
9156 awk '$1 == "cache_hit" {sum += $2}
9157 END { printf("%0.0f", sum) }')
9160 function set_cache() {
9163 if [ "$2" == "off" ]; then
9166 local list=$(comma_list $(osts_nodes))
9167 set_osd_param $list '' $1_cache_enable $on
9169 cancel_lru_locks osc
9173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9174 remote_ost_nodsh && skip "remote OST with nodsh" && return
9177 local list=$(comma_list $(osts_nodes))
9179 # check whether obdfilter is cache capable at all
9180 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9181 echo "not cache-capable obdfilter"
9185 # check cache is enabled on all obdfilters
9186 if get_osd_param $list '' read_cache_enable | grep 0; then
9187 echo "oss cache is disabled"
9191 set_osd_param $list '' writethrough_cache_enable 1
9193 # check write cache is enabled on all obdfilters
9194 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9195 echo "oss write cache is NOT enabled"
9201 #define OBD_FAIL_OBD_NO_LRU 0x609
9202 do_nodes $list $LCTL set_param fail_loc=0x609
9204 # pages should be in the case right after write
9205 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9208 local BEFORE=$(roc_hit)
9209 cancel_lru_locks osc
9210 cat $DIR/$tfile >/dev/null
9211 local AFTER=$(roc_hit)
9213 do_nodes $list $LCTL set_param fail_loc=0
9215 if ! let "AFTER - BEFORE == CPAGES"; then
9216 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9219 # the following read invalidates the cache
9220 cancel_lru_locks osc
9221 set_osd_param $list '' read_cache_enable 0
9222 cat $DIR/$tfile >/dev/null
9224 # now data shouldn't be found in the cache
9226 cancel_lru_locks osc
9227 cat $DIR/$tfile >/dev/null
9229 if let "AFTER - BEFORE != 0"; then
9230 error "IN CACHE: before: $BEFORE, after: $AFTER"
9233 set_osd_param $list '' read_cache_enable 1
9236 run_test 151 "test cache on oss and controls ==============================="
9239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9240 local TF="$TMP/$tfile"
9242 # simulate ENOMEM during write
9243 #define OBD_FAIL_OST_NOMEM 0x226
9244 lctl set_param fail_loc=0x80000226
9245 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9247 sync || error "sync failed"
9248 lctl set_param fail_loc=0
9250 # discard client's cache
9251 cancel_lru_locks osc
9253 # simulate ENOMEM during read
9254 lctl set_param fail_loc=0x80000226
9255 cmp $TF $DIR/$tfile || error "cmp failed"
9256 lctl set_param fail_loc=0
9260 run_test 152 "test read/write with enomem ============================"
9263 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9265 run_test 153 "test if fdatasync does not crash ======================="
9267 dot_lustre_fid_permission_check() {
9269 local ffid=$MOUNT/.lustre/fid/$fid
9272 echo "stat fid $fid"
9273 stat $ffid > /dev/null || error "stat $ffid failed."
9274 echo "touch fid $fid"
9275 touch $ffid || error "touch $ffid failed."
9276 echo "write to fid $fid"
9277 cat /etc/hosts > $ffid || error "write $ffid failed."
9278 echo "read fid $fid"
9279 diff /etc/hosts $ffid || error "read $ffid failed."
9280 echo "append write to fid $fid"
9281 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9282 echo "rename fid $fid"
9283 mv $ffid $test_dir/$tfile.1 &&
9284 error "rename $ffid to $tfile.1 should fail."
9285 touch $test_dir/$tfile.1
9286 mv $test_dir/$tfile.1 $ffid &&
9287 error "rename $tfile.1 to $ffid should fail."
9288 rm -f $test_dir/$tfile.1
9289 echo "truncate fid $fid"
9290 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9291 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9292 echo "link fid $fid"
9293 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9295 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9296 echo "setfacl fid $fid"
9297 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9298 echo "getfacl fid $fid"
9299 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9301 echo "unlink fid $fid"
9302 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9303 echo "mknod fid $fid"
9304 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9306 fid=[0xf00000400:0x1:0x0]
9307 ffid=$MOUNT/.lustre/fid/$fid
9309 echo "stat non-exist fid $fid"
9310 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9311 echo "write to non-exist fid $fid"
9312 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9313 echo "link new fid $fid"
9314 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9316 mkdir -p $test_dir/$tdir
9317 touch $test_dir/$tdir/$tfile
9318 fid=$($LFS path2fid $test_dir/$tdir)
9321 error "error: could not get fid for $test_dir/$dir/$tfile."
9323 ffid=$MOUNT/.lustre/fid/$fid
9326 ls $ffid > /dev/null || error "ls $ffid failed."
9327 echo "touch $fid/$tfile.1"
9328 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9330 echo "touch $MOUNT/.lustre/fid/$tfile"
9331 touch $MOUNT/.lustre/fid/$tfile && \
9332 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9334 echo "setxattr to $MOUNT/.lustre/fid"
9335 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9337 echo "listxattr for $MOUNT/.lustre/fid"
9338 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9340 echo "delxattr from $MOUNT/.lustre/fid"
9341 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9343 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9344 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9345 error "touch invalid fid should fail."
9347 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9348 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9349 error "touch non-normal fid should fail."
9351 echo "rename $tdir to $MOUNT/.lustre/fid"
9352 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9353 error "rename to $MOUNT/.lustre/fid should fail."
9355 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9357 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9358 local new_obf_mode=777
9360 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9361 chmod $new_obf_mode $DIR/.lustre/fid ||
9362 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9364 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9365 [ $obf_mode -eq $new_obf_mode ] ||
9366 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9368 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9369 chmod $old_obf_mode $DIR/.lustre/fid ||
9370 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9373 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9374 fid=$($LFS path2fid $test_dir/$tfile-2)
9375 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9376 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9377 error "create lov data thru .lustre should fail."
9378 echo "cp /etc/passwd $test_dir/$tfile-2"
9379 cp /etc/passwd $test_dir/$tfile-2 ||
9380 error "copy to $test_dir/$tfile-2 failed."
9381 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9382 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9383 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9385 rm -rf $test_dir/tfile.lnk
9386 rm -rf $test_dir/$tfile-2
9390 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9391 skip "Need MDS version at least 2.4.1" && return
9394 local FID=$($LFS path2fid $DIR/$tfile)
9395 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9397 # check that we get the same pathname back
9398 local FOUND=$($LFS fid2path $MOUNT $FID)
9399 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9400 [ "$FOUND" != "$DIR/$tfile" ] &&
9401 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9405 run_test 154A "lfs path2fid and fid2path basic checks"
9408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9409 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9410 { skip "Need MDS version at least 2.2.51"; return 0; }
9411 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9413 cp /etc/hosts $DIR/$tfile
9415 fid=$($LFS path2fid $DIR/$tfile)
9417 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9419 dot_lustre_fid_permission_check "$fid" $DIR ||
9420 error "dot lustre permission check $fid failed"
9422 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9424 touch $MOUNT/.lustre/file &&
9425 error "creation is not allowed under .lustre"
9427 mkdir $MOUNT/.lustre/dir &&
9428 error "mkdir is not allowed under .lustre"
9432 run_test 154a "Open-by-FID"
9435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9436 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9437 { skip "Need MDS version at least 2.2.51"; return 0; }
9439 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9441 local remote_dir=$DIR/$tdir/remote_dir
9446 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9447 error "create remote directory failed"
9449 cp /etc/hosts $remote_dir/$tfile
9451 fid=$($LFS path2fid $remote_dir/$tfile)
9453 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9455 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9456 error "dot lustre permission check $fid failed"
9459 run_test 154b "Open-by-FID for remote directory"
9462 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9463 skip "Need MDS version at least 2.4.1" && return
9465 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9466 local FID1=$($LFS path2fid $DIR/$tfile.1)
9467 local FID2=$($LFS path2fid $DIR/$tfile.2)
9468 local FID3=$($LFS path2fid $DIR/$tfile.3)
9471 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9472 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9473 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9475 [ "$FID" = "${!want}" ] ||
9476 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9480 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9481 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9482 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9486 run_test 154c "lfs path2fid and fid2path multiple arguments"
9489 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9490 skip "Need MDS version at least 2.5.53" && return
9493 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9497 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9504 fid=$($LFS path2fid $DIR/$tfile)
9507 cmd="exec $fd<$DIR/$tfile"
9509 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9510 echo $fid_list | grep $fid
9513 cmd="exec $fd>/dev/null"
9515 if [ $rc -ne 0 ]; then
9516 error "FID $fid not found in open files list $fid_list"
9519 run_test 154d "Verify open file fid"
9521 test_155_small_load() {
9522 local temp=$TMP/$tfile
9523 local file=$DIR/$tfile
9525 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9526 error "dd of=$temp bs=6096 count=1 failed"
9528 cancel_lru_locks osc
9529 cmp $temp $file || error "$temp $file differ"
9531 $TRUNCATE $temp 6000
9532 $TRUNCATE $file 6000
9533 cmp $temp $file || error "$temp $file differ (truncate1)"
9535 echo "12345" >>$temp
9536 echo "12345" >>$file
9537 cmp $temp $file || error "$temp $file differ (append1)"
9539 echo "12345" >>$temp
9540 echo "12345" >>$file
9541 cmp $temp $file || error "$temp $file differ (append2)"
9547 test_155_big_load() {
9548 remote_ost_nodsh && skip "remote OST with nodsh" && return
9549 local temp=$TMP/$tfile
9550 local file=$DIR/$tfile
9553 local cache_size=$(do_facet ost$((MAXI+1)) \
9554 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9555 local large_file_size=$((cache_size * 2))
9557 echo "OSS cache size: $cache_size KB"
9558 echo "Large file size: $large_file_size KB"
9560 [ $MAXV -le $large_file_size ] && \
9561 skip_env "max available OST size needs > $large_file_size KB" && \
9564 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9566 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9567 error "dd of=$temp bs=$large_file_size count=1k failed"
9570 cancel_lru_locks osc
9571 cmp $temp $file || error "$temp $file differ"
9578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9580 set_cache writethrough on
9583 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9588 set_cache writethrough off
9591 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9596 set_cache writethrough on
9599 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9604 set_cache writethrough off
9607 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9612 set_cache writethrough on
9615 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9620 set_cache writethrough off
9623 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9628 set_cache writethrough on
9631 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9636 set_cache writethrough off
9639 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9646 local file="$DIR/$tfile"
9648 [ "$(facet_fstype ost1)" = "zfs" ] &&
9649 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9654 log "Turn on read and write cache"
9656 set_cache writethrough on
9658 log "Write data and read it back."
9659 log "Read should be satisfied from the cache."
9660 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9662 cancel_lru_locks osc
9663 cat $file >/dev/null
9665 if ! let "AFTER - BEFORE == CPAGES"; then
9666 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9668 log "cache hits:: before: $BEFORE, after: $AFTER"
9671 log "Read again; it should be satisfied from the cache."
9673 cancel_lru_locks osc
9674 cat $file >/dev/null
9676 if ! let "AFTER - BEFORE == CPAGES"; then
9677 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9679 log "cache hits:: before: $BEFORE, after: $AFTER"
9683 log "Turn off the read cache and turn on the write cache"
9685 set_cache writethrough on
9687 log "Read again; it should be satisfied from the cache."
9689 cancel_lru_locks osc
9690 cat $file >/dev/null
9692 if ! let "AFTER - BEFORE == CPAGES"; then
9693 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9695 log "cache hits:: before: $BEFORE, after: $AFTER"
9698 log "Read again; it should not be satisfied from the cache."
9700 cancel_lru_locks osc
9701 cat $file >/dev/null
9703 if ! let "AFTER - BEFORE == 0"; then
9704 error "IN CACHE: before: $BEFORE, after: $AFTER"
9706 log "cache hits:: before: $BEFORE, after: $AFTER"
9709 log "Write data and read it back."
9710 log "Read should be satisfied from the cache."
9711 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9713 cancel_lru_locks osc
9714 cat $file >/dev/null
9716 if ! let "AFTER - BEFORE == CPAGES"; then
9717 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9719 log "cache hits:: before: $BEFORE, after: $AFTER"
9722 log "Read again; it should not be satisfied from the cache."
9724 cancel_lru_locks osc
9725 cat $file >/dev/null
9727 if ! let "AFTER - BEFORE == 0"; then
9728 error "IN CACHE: before: $BEFORE, after: $AFTER"
9730 log "cache hits:: before: $BEFORE, after: $AFTER"
9734 log "Turn off read and write cache"
9736 set_cache writethrough off
9738 log "Write data and read it back"
9739 log "It should not be satisfied from the cache."
9741 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9742 cancel_lru_locks osc
9744 cat $file >/dev/null
9746 if ! let "AFTER - BEFORE == 0"; then
9747 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9749 log "cache hits:: before: $BEFORE, after: $AFTER"
9752 log "Turn on the read cache and turn off the write cache"
9754 set_cache writethrough off
9756 log "Write data and read it back"
9757 log "It should not be satisfied from the cache."
9759 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9761 cancel_lru_locks osc
9762 cat $file >/dev/null
9764 if ! let "AFTER - BEFORE == 0"; then
9765 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9767 log "cache hits:: before: $BEFORE, after: $AFTER"
9770 log "Read again; it should be satisfied from the cache."
9772 cancel_lru_locks osc
9773 cat $file >/dev/null
9775 if ! let "AFTER - BEFORE == CPAGES"; then
9776 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9778 log "cache hits:: before: $BEFORE, after: $AFTER"
9783 run_test 156 "Verification of tunables ============================"
9787 if [[ $MDSCOUNT -gt 1 ]]; then
9788 error_ignore bz17935 $*
9796 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9798 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9800 if [ $MASK -eq 1 ]; then
9801 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9803 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9807 changelog_extract_field() {
9813 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9814 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9820 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9821 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9822 { skip "Need MDS version at least 2.2.0"; return; }
9824 local CL_USERS="mdd.$MDT0.changelog_users"
9825 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9826 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9827 echo "Registered as changelog user $USER"
9828 $GET_CL_USERS | grep -q $USER ||
9829 error "User $USER not found in changelog_users"
9832 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9833 touch $DIR/$tdir/pics/2008/zachy/timestamp
9834 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9835 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9836 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9837 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9838 rm $DIR/$tdir/pics/desktop.jpg
9840 $LFS changelog $MDT0 | tail -5
9842 echo "verifying changelog mask"
9843 changelog_chmask "MKDIR"
9844 changelog_chmask "CLOSE"
9846 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9847 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9849 changelog_chmask "MKDIR"
9850 changelog_chmask "CLOSE"
9852 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9853 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9855 $LFS changelog $MDT0
9856 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9857 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9858 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9859 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9862 echo "verifying target fid"
9863 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9864 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9865 [ "$fidc" == "$fidf" ] ||
9866 err17935 "fid in changelog $fidc != file fid $fidf"
9867 echo "verifying parent fid"
9868 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9869 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9870 [ "$fidc" == "$fidf" ] ||
9871 err17935 "pfid in changelog $fidc != dir fid $fidf"
9873 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9874 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9875 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9876 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9877 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9878 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9880 MIN_REC=$($GET_CL_USERS |
9881 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9882 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9883 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9884 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9885 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9887 # LU-3446 changelog index reset on MDT restart
9888 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9889 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9890 $LFS changelog_clear $MDT0 $USER 0
9891 stop $SINGLEMDS || error "Fail to stop MDT."
9892 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9893 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9894 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9895 [ $CUR_REC1 == $CUR_REC2 ] ||
9896 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9898 echo "verifying user deregister"
9899 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9900 $GET_CL_USERS | grep -q $USER &&
9901 error "User $USER still in changelog_users"
9903 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9904 if [ $USERS -eq 0 ]; then
9905 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9906 touch $DIR/$tdir/chloe
9907 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9908 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9909 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9911 echo "$USERS other changelog users; can't verify off"
9914 run_test 160a "changelog sanity"
9916 test_160b() { # LU-3587
9917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9918 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9919 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9920 { skip "Need MDS version at least 2.2.0"; return; }
9922 local CL_USERS="mdd.$MDT0.changelog_users"
9923 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9924 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9925 echo "Registered as changelog user $USER"
9926 $GET_CL_USERS | grep -q $USER ||
9927 error "User $USER not found in changelog_users"
9929 local LONGNAME1=$(str_repeat a 255)
9930 local LONGNAME2=$(str_repeat b 255)
9933 echo "creating very long named file"
9934 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9935 echo "moving very long named file"
9936 mv $LONGNAME1 $LONGNAME2
9938 $LFS changelog $MDT0 | grep RENME
9940 echo "deregistering $USER"
9941 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9945 run_test 160b "Verify that very long rename doesn't crash in changelog"
9949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9952 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9953 changelog_register -n)
9957 $MCREATE $DIR/$tdir/foo_160c
9958 changelog_chmask "TRUNC"
9959 $TRUNCATE $DIR/$tdir/foo_160c 200
9960 changelog_chmask "TRUNC"
9961 $TRUNCATE $DIR/$tdir/foo_160c 199
9962 $LFS changelog $MDT0
9963 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9964 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9965 $LFS changelog_clear $MDT0 $USER 0
9967 # Deregistration step
9968 echo "deregistering $USER"
9969 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9971 run_test 160c "verify that changelog log catch the truncate event"
9974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9975 test_mkdir -p -c1 $DIR/$tdir
9976 cp /etc/hosts $DIR/$tdir/$tfile
9977 test_mkdir -c1 $DIR/$tdir/foo1
9978 test_mkdir -c1 $DIR/$tdir/foo2
9979 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9980 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9981 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9982 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9983 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9984 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9985 $LFS fid2path $DIR $FID
9986 err17935 "bad link ea"
9989 rm $DIR/$tdir/foo2/zachary
9991 rm $DIR/$tdir/foo2/thor
9993 rm $DIR/$tdir/$tfile
9995 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9996 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9998 $LFS fid2path $DIR $FID
9999 err17935 "bad link rename"
10001 rm $DIR/$tdir/foo2/maggie
10004 local longname=filename_avg_len_is_thirty_two_
10005 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10006 error "failed to hardlink many files"
10007 links=$($LFS fid2path $DIR $FID | wc -l)
10008 echo -n "${links}/1000 links in link EA"
10009 [[ $links -gt 60 ]] ||
10010 err17935 "expected at least 60 links in link EA"
10011 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10012 error "failed to unlink many hardlinks"
10014 run_test 161a "link ea sanity"
10017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10018 [ $MDSCOUNT -lt 2 ] &&
10019 skip "skipping remote directory test" && return
10021 local remote_dir=$DIR/$tdir/remote_dir
10023 mkdir -p $DIR/$tdir
10024 $LFS mkdir -i $MDTIDX $remote_dir ||
10025 error "create remote directory failed"
10027 cp /etc/hosts $remote_dir/$tfile
10028 mkdir -p $remote_dir/foo1
10029 mkdir -p $remote_dir/foo2
10030 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10031 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10032 ln $remote_dir/$tfile $remote_dir/foo1/luna
10033 ln $remote_dir/$tfile $remote_dir/foo2/thor
10035 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10037 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10038 $LFS fid2path $DIR $FID
10039 err17935 "bad link ea"
10042 rm $remote_dir/foo2/zachary
10044 rm $remote_dir/foo2/thor
10046 rm $remote_dir/$tfile
10048 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10049 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10050 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10051 $LFS fid2path $DIR $FID
10052 err17935 "bad link rename"
10054 rm $remote_dir/foo2/maggie
10057 local longname=filename_avg_len_is_thirty_two_
10058 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10059 error "failed to hardlink many files"
10060 links=$($LFS fid2path $DIR $FID | wc -l)
10061 echo -n "${links}/1000 links in link EA"
10062 [[ ${links} -gt 60 ]] ||
10063 err17935 "expected at least 60 links in link EA"
10064 unlinkmany $remote_dir/foo2/$longname 1000 ||
10065 error "failed to unlink many hardlinks"
10067 run_test 161b "link ea sanity under remote directory"
10070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10071 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10072 skip "Need MDS version at least 2.1.5" && return
10074 # define CLF_RENAME_LAST 0x0001
10075 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10076 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10077 changelog_register -n)
10079 mkdir -p $DIR/$tdir
10080 touch $DIR/$tdir/foo_161c
10081 touch $DIR/$tdir/bar_161c
10082 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10083 $LFS changelog $MDT0 | grep RENME
10084 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10086 $LFS changelog_clear $MDT0 $USER 0
10087 if [ x$flags != "x0x1" ]; then
10088 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10090 error "flag $flags is not 0x1"
10092 echo "rename overwrite a target having nlink = 1," \
10093 "changelog record has flags of $flags"
10095 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10096 touch $DIR/$tdir/foo_161c
10097 touch $DIR/$tdir/bar_161c
10098 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10099 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10100 $LFS changelog $MDT0 | grep RENME
10101 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10102 $LFS changelog_clear $MDT0 $USER 0
10103 if [ x$flags != "x0x0" ]; then
10104 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10106 error "flag $flags is not 0x0"
10108 echo "rename overwrite a target having nlink > 1," \
10109 "changelog record has flags of $flags"
10111 # rename doesn't overwrite a target (changelog flag 0x0)
10112 touch $DIR/$tdir/foo_161c
10113 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10114 $LFS changelog $MDT0 | grep RENME
10115 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10116 $LFS changelog_clear $MDT0 $USER 0
10117 if [ x$flags != "x0x0" ]; then
10118 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10120 error "flag $flags is not 0x0"
10122 echo "rename doesn't overwrite a target," \
10123 "changelog record has flags of $flags"
10125 # define CLF_UNLINK_LAST 0x0001
10126 # unlink a file having nlink = 1 (changelog flag 0x1)
10127 rm -f $DIR/$tdir/foo2_161c
10128 $LFS changelog $MDT0 | grep UNLNK
10129 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10130 $LFS changelog_clear $MDT0 $USER 0
10131 if [ x$flags != "x0x1" ]; then
10132 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10134 error "flag $flags is not 0x1"
10136 echo "unlink a file having nlink = 1," \
10137 "changelog record has flags of $flags"
10139 # unlink a file having nlink > 1 (changelog flag 0x0)
10140 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10141 rm -f $DIR/$tdir/foobar_161c
10142 $LFS changelog $MDT0 | grep UNLNK
10143 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10144 $LFS changelog_clear $MDT0 $USER 0
10145 if [ x$flags != "x0x0" ]; then
10146 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10148 error "flag $flags is not 0x0"
10150 echo "unlink a file having nlink > 1," \
10151 "changelog record has flags of $flags"
10152 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10154 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10161 local path=$(${LFS} fid2path $*)
10164 if [ $RC -ne 0 ]; then
10165 err17935 "path looked up of $expected failed. Error $RC"
10167 elif [ "${path}" != "${expected}" ]; then
10168 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10171 echo "fid $fid resolves to path $path (expected $expected)"
10175 # Make changes to filesystem
10176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10177 test_mkdir -p -c1 $DIR/$tdir/d2
10178 touch $DIR/$tdir/d2/$tfile
10179 touch $DIR/$tdir/d2/x1
10180 touch $DIR/$tdir/d2/x2
10181 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10182 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10184 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10185 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10188 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10189 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10190 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10192 # softlink to wrong file
10193 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10194 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10195 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10198 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10199 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10200 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10201 # fid2path dir/fsname should both work
10202 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10203 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10205 # hardlink count: check that there are 2 links
10206 # Doesnt work with CMD yet: 17935
10207 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10208 err17935 "expected 2 links"
10210 # hardlink indexing: remove the first link
10211 rm $DIR/$tdir/d2/p/q/r/hlink
10212 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10216 run_test 162 "path lookup sanity"
10219 # do directio so as not to populate the page cache
10220 log "creating a 10 Mb file"
10221 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10222 log "starting reads"
10223 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10224 log "truncating the file"
10225 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10227 kill %+ || true # reads might have finished
10228 echo "wait until dd is finished"
10230 log "removing the temporary file"
10231 rm -rf $DIR/$tfile || error "tmp file removal failed"
10233 run_test 169 "parallel read and truncate should not deadlock"
10236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10237 $LCTL clear # bug 18514
10238 $LCTL debug_daemon start $TMP/${tfile}_log_good
10240 $LCTL debug_daemon stop
10241 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10242 error "sed failed to read log_good"
10244 $LCTL debug_daemon start $TMP/${tfile}_log_good
10246 $LCTL debug_daemon stop
10248 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10249 error "lctl df log_bad failed"
10251 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10252 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10254 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10255 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10257 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10258 error "bad_line good_line1 good_line2 are empty"
10260 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10261 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10262 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10264 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10265 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10266 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10268 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10269 error "bad_line_new good_line_new are empty"
10271 local expected_good=$((good_line1 + good_line2*2))
10273 rm -f $TMP/${tfile}*
10274 # LU-231, short malformed line may not be counted into bad lines
10275 if [ $bad_line -ne $bad_line_new ] &&
10276 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10277 error "expected $bad_line bad lines, but got $bad_line_new"
10281 if [ $expected_good -ne $good_line_new ]; then
10282 error "expected $expected_good good lines, but got $good_line_new"
10287 run_test 170 "test lctl df to handle corrupted log ====================="
10289 test_171() { # bug20592
10290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10291 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10292 $LCTL set_param fail_loc=0x50e
10293 $LCTL set_param fail_val=3000
10294 multiop_bg_pause $DIR/$tfile O_s || true
10296 kill -USR1 $MULTIPID
10300 if dmesg | grep "recursive fault"; then
10301 error "caught a recursive fault"
10303 $LCTL set_param fail_loc=0
10306 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10308 # it would be good to share it with obdfilter-survey/libecho code
10309 setup_obdecho_osc () {
10312 local obdfilter_name=$2
10313 echo "Creating new osc for $obdfilter_name on $ost_nid"
10314 # make sure we can find loopback nid
10315 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10317 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10318 ${obdfilter_name}_osc_UUID || rc=2; }
10319 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10320 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10324 cleanup_obdecho_osc () {
10325 local obdfilter_name=$1
10326 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10327 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10334 local pages=${3:-64}
10339 local obd_size=$(get_obd_size $node $OBD)
10340 local page_size=$(get_page_size $node)
10341 if [[ -n "$obd_size" ]]; then
10342 local new_count=$((obd_size / (pages * page_size / 1024)))
10343 [[ $new_count -ge $count ]] || count=$new_count
10346 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10347 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10349 if [ $rc -eq 0 ]; then
10350 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10351 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10353 echo "New object id is $id"
10354 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10356 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10357 "test_brw $count w v $pages $id" || rc=4; }
10358 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10360 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10361 "cleanup" || rc=5; }
10362 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10363 "detach" || rc=6; }
10364 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10370 remote_ost_nodsh && skip "remote OST with nodsh" && return
10372 local rmmod_local=0
10374 if ! module_loaded obdecho; then
10375 load_module obdecho/obdecho
10379 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10380 local host=$(lctl get_param -n osc.$osc.import |
10381 awk '/current_connection:/ {print $2}' )
10382 local target=$(lctl get_param -n osc.$osc.import |
10383 awk '/target:/ {print $2}' )
10384 target=${target%_UUID}
10386 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10387 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10388 [[ -n $target ]] && cleanup_obdecho_osc $target
10389 [ $rmmod_local -eq 1 ] && rmmod obdecho
10392 run_test 180a "test obdecho on osc"
10395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10396 remote_ost_nodsh && skip "remote OST with nodsh" && return
10398 local rmmod_remote=0
10400 do_facet ost1 "lsmod | grep -q obdecho || " \
10401 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10402 "modprobe obdecho; }" && rmmod_remote=1
10403 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10404 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10405 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10408 run_test 180b "test obdecho directly on obdfilter"
10410 test_180c() { # LU-2598
10411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10412 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10413 skip "Need MDS version at least 2.4.0" && return
10416 local rmmod_remote=false
10417 local pages=16384 # 64MB bulk I/O RPC size
10420 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10421 rmmod_remote=true || error "failed to load module obdecho"
10423 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10425 if [ -n "$target" ]; then
10426 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10428 echo "there is no obdfilter target on ost1"
10431 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10434 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10436 test_181() { # bug 22177
10437 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10438 # create enough files to index the directory
10439 createmany -o $DIR/$tdir/foobar 4000
10440 # print attributes for debug purpose
10443 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10445 # remove the files & current working dir
10446 unlinkmany $DIR/$tdir/foobar 4000
10448 kill -USR1 $MULTIPID
10450 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10453 run_test 181 "Test open-unlinked dir ========================"
10456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10457 # disable MDC RPC lock wouldn't crash client
10461 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10462 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10463 $LCTL set_param fail_loc=0x804
10465 for (( i=0; i < $tcount; i++ )) ; do
10466 mkdir $DIR/$tdir/$i
10467 createmany -o $DIR/$tdir/$i/f- $fcount &
10471 for (( i=0; i < $tcount; i++ )) ; do
10472 unlinkmany $DIR/$tdir/$i/f- $fcount &
10478 $LCTL set_param fail_loc=0
10480 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10482 test_183() { # LU-2275
10483 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10484 skip "Need MDS version at least 2.3.56" && return
10486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10487 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10488 echo aaa > $DIR/$tdir/$tfile
10490 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10491 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10493 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10494 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10496 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10498 # Flush negative dentry cache
10499 touch $DIR/$tdir/$tfile
10501 # We are not checking for any leaked references here, they'll
10502 # become evident next time we do cleanup with module unload.
10505 run_test 183 "No crash or request leak in case of strange dispositions ========"
10507 # test suite 184 is for LU-2016, LU-2017
10509 check_swap_layouts_support && return 0
10511 dir0=$DIR/$tdir/$testnum
10512 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10517 $SETSTRIPE -c1 $file1
10519 $SETSTRIPE -c2 $file2
10521 gen1=$($GETSTRIPE -g $file1)
10522 gen2=$($GETSTRIPE -g $file2)
10524 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10525 gen=$($GETSTRIPE -g $file1)
10526 [[ $gen1 != $gen ]] ||
10527 "Layout generation on $file1 does not change"
10528 gen=$($GETSTRIPE -g $file2)
10529 [[ $gen2 != $gen ]] ||
10530 "Layout generation on $file2 does not change"
10532 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10533 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10535 run_test 184a "Basic layout swap"
10538 check_swap_layouts_support && return 0
10540 dir0=$DIR/$tdir/$testnum
10541 mkdir -p $dir0 || error "creating dir $dir0"
10548 $SETSTRIPE -c1 $file1
10549 $SETSTRIPE -c2 $file2
10550 $SETSTRIPE -c1 $file3
10551 chown $RUNAS_ID $file3
10552 gen1=$($GETSTRIPE -g $file1)
10553 gen2=$($GETSTRIPE -g $file2)
10555 $LFS swap_layouts $dir1 $dir2 &&
10556 error "swap of directories layouts should fail"
10557 $LFS swap_layouts $dir1 $file1 &&
10558 error "swap of directory and file layouts should fail"
10559 $RUNAS $LFS swap_layouts $file1 $file2 &&
10560 error "swap of file we cannot write should fail"
10561 $LFS swap_layouts $file1 $file3 &&
10562 error "swap of file with different owner should fail"
10563 /bin/true # to clear error code
10565 run_test 184b "Forbidden layout swap (will generate errors)"
10568 check_swap_layouts_support && return 0
10570 local dir0=$DIR/$tdir/$testnum
10571 mkdir -p $dir0 || error "creating dir $dir0"
10573 local ref1=$dir0/ref1
10574 local ref2=$dir0/ref2
10575 local file1=$dir0/file1
10576 local file2=$dir0/file2
10577 # create a file large enough for the concurent test
10578 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10579 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10580 echo "ref file size: ref1($(stat -c %s $ref1))," \
10581 "ref2($(stat -c %s $ref2))"
10584 dd if=$ref1 of=$file1 bs=16k &
10587 # Make sure dd starts to copy file
10588 while [ ! -f $file1 ]; do sleep 0.1; done
10590 $LFS swap_layouts $file1 $file2
10593 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10594 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10596 # how many bytes copied before swapping layout
10597 local copied=$(stat -c %s $file2)
10598 local remaining=$(stat -c %s $ref1)
10599 remaining=$((remaining - copied))
10600 echo "Copied $copied bytes before swapping layout..."
10602 cmp -n $copied $file1 $ref2 | grep differ &&
10603 error "Content mismatch [0, $copied) of ref2 and file1"
10604 cmp -n $copied $file2 $ref1 ||
10605 error "Content mismatch [0, $copied) of ref1 and file2"
10606 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10607 error "Content mismatch [$copied, EOF) of ref1 and file1"
10610 rm -f $ref1 $ref2 $file1 $file2
10612 run_test 184c "Concurrent write and layout swap"
10615 check_swap_layouts_support && return 0
10616 [ -z "$(which getfattr 2>/dev/null)" ] &&
10617 skip "no getfattr command" && return 0
10619 local file1=$DIR/$tdir/$tfile-1
10620 local file2=$DIR/$tdir/$tfile-2
10621 local file3=$DIR/$tdir/$tfile-3
10625 mkdir -p $DIR/$tdir
10626 touch $file1 || error "create $file1 failed"
10627 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10628 error "create $file2 failed"
10629 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10630 error "create $file3 failed"
10631 lovea1=$($LFS getstripe $file1 | sed 1d)
10633 $LFS swap_layouts $file2 $file3 ||
10634 error "swap $file2 $file3 layouts failed"
10635 $LFS swap_layouts $file1 $file2 ||
10636 error "swap $file1 $file2 layouts failed"
10638 lovea2=$($LFS getstripe $file2 | sed 1d)
10639 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10641 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10642 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10644 run_test 184d "allow stripeless layouts swap"
10647 test_185() { # LU-2441
10648 # LU-3553 - no volatile file support in old servers
10649 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10650 { skip "Need MDS version at least 2.3.60"; return 0; }
10652 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10653 touch $DIR/$tdir/spoo
10654 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10655 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10656 error "cannot create/write a volatile file"
10657 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10658 error "FID is still valid after close"
10660 multiop_bg_pause $DIR/$tdir vVw4096_c
10667 # assume that the next FID for this client is sequential, since stdout
10668 # is unfortunately eaten by multiop_bg_pause
10669 local n=$((${fidv[1]} + 1))
10670 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10671 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10672 error "FID is missing before close"
10673 kill -USR1 $multi_pid
10674 # 1 second delay, so if mtime change we will see it
10676 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10677 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10679 run_test 185 "Volatile file support"
10682 local dir0=$DIR/$tdir/$testnum
10683 mkdir -p $dir0 || error "creating dir $dir0"
10685 local file=$dir0/file1
10686 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10687 local dv1=$($LFS data_version $file)
10688 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10689 local dv2=$($LFS data_version $file)
10690 [[ $dv1 != $dv2 ]] ||
10691 error "data version did not change on write $dv1 == $dv2"
10696 run_test 187a "Test data version change"
10699 local dir0=$DIR/$tdir/$testnum
10700 mkdir -p $dir0 || error "creating dir $dir0"
10702 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10703 [[ ${DV[0]} != ${DV[1]} ]] ||
10704 error "data version did not change on write"\
10705 " ${DV[0]} == ${DV[1]}"
10710 run_test 187b "Test data version change on volatile file"
10713 check_file_in_pool()
10718 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10721 for t in $tlist ; do
10722 [ "$i" -eq "$t" ] && continue 2
10725 echo "pool list: $tlist"
10726 echo "striping: $res"
10727 error_noexit "$file not allocated in $pool"
10734 echo "Creating new pool"
10737 create_pool $FSNAME.$pool ||
10738 { error_noexit "No pool created, result code $?"; return 1; }
10739 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10740 { error_noexit "$pool not in lfs pool_list"; return 2; }
10743 pool_add_targets() {
10744 echo "Adding targets to pool"
10750 local list=$(seq $first $step $last)
10752 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10753 do_facet mgs $LCTL pool_add \
10754 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10755 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10756 | sort -u | tr '\n' ' ' " "$t" || {
10757 error_noexit "Add to pool failed"
10760 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10761 local addcount=$(((last - first) / step + 1))
10762 [ $lfscount -eq $addcount ] || {
10763 error_noexit "lfs pool_list bad ost count" \
10764 "$lfscount != $addcount"
10772 echo "Setting pool on directory $tdir"
10774 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10776 error_noexit "Cannot set pool $pool to $tdir"
10783 echo "Checking pool on directory $tdir"
10785 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10786 [ "$res" = "$pool" ] && return 0
10788 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10792 pool_dir_rel_path() {
10793 echo "Testing relative path works well"
10798 mkdir -p $root/$tdir/$tdir
10800 pool_set_dir $pool $tdir || return 1
10801 pool_set_dir $pool ./$tdir || return 2
10802 pool_set_dir $pool ../$tdir || return 3
10803 pool_set_dir $pool ../$tdir/$tdir || return 4
10804 rm -rf $tdir; cd - > /dev/null
10807 pool_alloc_files() {
10808 echo "Checking files allocation from directory pool"
10815 for i in $(seq -w 1 $count)
10817 local file=$tdir/file-$i
10819 check_file_in_pool $file $pool "$tlist" || \
10820 failed=$((failed + 1))
10822 [ "$failed" = 0 ] && return 0
10824 error_noexit "$failed files not allocated in $pool"
10828 pool_create_files() {
10829 echo "Creating files in pool"
10837 for i in $(seq -w 1 $count)
10839 local file=$tdir/spoo-$i
10840 $SETSTRIPE -p $pool $file
10841 check_file_in_pool $file $pool "$tlist" || \
10842 failed=$((failed + 1))
10844 [ "$failed" = 0 ] && return 0
10846 error_noexit "$failed files not allocated in $pool"
10851 echo "Checking 'lfs df' output"
10854 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10856 local res=$($LFS df --pool $FSNAME.$pool |
10858 grep "$FSNAME-OST" |
10860 [ "$res" = "$t" ] && return 0
10862 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10866 pool_file_rel_path() {
10867 echo "Creating files in a pool with relative pathname"
10872 { error_noexit "unable to create $tdir"; return 1 ; }
10873 local file="/..$tdir/$tfile-1"
10874 $SETSTRIPE -p $pool $file ||
10875 { error_noexit "unable to create $file" ; return 2 ; }
10878 $SETSTRIPE -p $pool $tfile-2 || {
10879 error_noexit "unable to create $tfile-2 in $tdir"
10884 pool_remove_first_target() {
10885 echo "Removing first target from a pool"
10888 local pname="lov.$FSNAME-*.pools.$pool"
10889 local t=$($LCTL get_param -n $pname | head -n1)
10890 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10891 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10892 error_noexit "$t not removed from $FSNAME.$pool"
10897 pool_remove_all_targets() {
10898 echo "Removing all targets from pool"
10901 local pname="lov.$FSNAME-*.pools.$pool"
10902 for t in $($LCTL get_param -n $pname | sort -u)
10904 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10906 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10907 error_noexit "Pool $FSNAME.$pool cannot be drained"
10910 # striping on an empty/nonexistant pool should fall back
10911 # to "pool of everything"
10913 error_noexit "failed to use fallback striping for empty pool"
10916 # setstripe on an empty pool should fail
10917 $SETSTRIPE -p $pool $file 2>/dev/null && {
10918 error_noexit "expected failure when creating file" \
10926 echo "Destroying pool"
10930 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10933 # striping on an empty/nonexistant pool should fall back
10934 # to "pool of everything"
10936 error_noexit "failed to use fallback striping for missing pool"
10939 # setstripe on an empty pool should fail
10940 $SETSTRIPE -p $pool $file 2>/dev/null && {
10941 error_noexit "expected failure when creating file" \
10942 "with missing pool"
10946 # get param should return err once pool is gone
10947 if wait_update $HOSTNAME "lctl get_param -n \
10948 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10950 remove_pool_from_list $FSNAME.$pool
10953 error_noexit "Pool $FSNAME.$pool is not destroyed"
10958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10959 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10961 local POOL=${POOL:-cea1}
10962 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10963 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10966 local last_ost=$(($OSTCOUNT - 1))
10968 local ost_list=$(seq $first_ost $ost_step $last_ost)
10969 local ost_range="$first_ost $last_ost $ost_step"
10970 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10971 local file_dir=$POOL_ROOT/file_tst
10975 # former test_200a test_200b
10976 pool_add $POOL || { rc=$? ; break; }
10977 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10978 # former test_200c test_200d
10979 mkdir -p $test_path
10980 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10981 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10982 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10983 || { rc=$? ; break; }
10984 # former test_200e test_200f
10985 local files=$((OSTCOUNT*3))
10986 pool_alloc_files $POOL $test_path $files "$ost_list" \
10987 || { rc=$? ; break; }
10988 pool_create_files $POOL $file_dir $files "$ost_list" \
10989 || { rc=$? ; break; }
10990 # former test_200g test_200h
10991 pool_lfs_df $POOL || { rc=$? ; break; }
10992 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10994 # former test_201a test_201b test_201c
10995 pool_remove_first_target $POOL || { rc=$? ; break; }
10997 local f=$test_path/$tfile
10998 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10999 pool_remove $POOL $f || { rc=$? ; break; }
11006 run_test 200 "OST pools"
11008 # usage: default_attr <count | size | offset>
11010 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11013 # usage: check_default_stripe_attr
11014 check_default_stripe_attr() {
11015 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11017 --stripe-count|--count)
11018 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11019 --stripe-size|--size)
11020 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11021 --stripe-index|--index)
11024 error "unknown getstripe attr '$1'"
11027 [ $ACTUAL != $EXPECTED ] &&
11028 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11032 test_mkdir -p $DIR/$tdir
11033 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11035 check_default_stripe_attr --stripe-count
11036 check_default_stripe_attr --stripe-size
11037 check_default_stripe_attr --stripe-index
11041 run_test 204a "Print default stripe attributes ================="
11044 test_mkdir -p $DIR/$tdir
11045 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11047 check_default_stripe_attr --stripe-size
11048 check_default_stripe_attr --stripe-index
11052 run_test 204b "Print default stripe size and offset ==========="
11055 test_mkdir -p $DIR/$tdir
11056 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11058 check_default_stripe_attr --stripe-count
11059 check_default_stripe_attr --stripe-index
11063 run_test 204c "Print default stripe count and offset ==========="
11066 test_mkdir -p $DIR/$tdir
11067 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11069 check_default_stripe_attr --stripe-count
11070 check_default_stripe_attr --stripe-size
11074 run_test 204d "Print default stripe count and size ============="
11077 test_mkdir -p $DIR/$tdir
11078 $SETSTRIPE -d $DIR/$tdir
11080 check_default_stripe_attr --stripe-count --raw
11081 check_default_stripe_attr --stripe-size --raw
11082 check_default_stripe_attr --stripe-index --raw
11086 run_test 204e "Print raw stripe attributes ================="
11089 test_mkdir -p $DIR/$tdir
11090 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11092 check_default_stripe_attr --stripe-size --raw
11093 check_default_stripe_attr --stripe-index --raw
11097 run_test 204f "Print raw stripe size and offset ==========="
11100 test_mkdir -p $DIR/$tdir
11101 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11103 check_default_stripe_attr --stripe-count --raw
11104 check_default_stripe_attr --stripe-index --raw
11108 run_test 204g "Print raw stripe count and offset ==========="
11111 test_mkdir -p $DIR/$tdir
11112 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11114 check_default_stripe_attr --stripe-count --raw
11115 check_default_stripe_attr --stripe-size --raw
11119 run_test 204h "Print raw stripe count and size ============="
11121 # Figure out which job scheduler is being used, if any,
11122 # or use a fake one
11123 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11124 JOBENV=SLURM_JOB_ID
11125 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11127 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11129 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11130 JOBENV=LOADL_STEP_ID
11131 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11137 verify_jobstats() {
11141 # clear old jobstats
11142 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11143 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11145 # use a new JobID for this test, or we might see an old one
11146 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11150 log "Using JobID environment variable $JOBENV=$JOBVAL"
11152 if [ $JOBENV = "FAKE_JOBID" ]; then
11153 FAKE_JOBID=$JOBVAL $cmd
11158 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11159 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11160 do_facet $FACET lctl get_param mdt.*.job_stats |
11161 grep $JOBVAL || error "No job stats found on MDT $FACET"
11163 if [ "$target" = "ost" -o "$target" = "both" ]; then
11165 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11166 grep $JOBVAL || error "No job stats found on OST $FACET"
11172 NEW_JOBENV=${1:-$OLD_JOBENV}
11173 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11174 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11177 test_205() { # Job stats
11178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11179 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11180 skip "Server doesn't support jobstats" && return 0
11181 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11184 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11185 if [ $OLD_JOBENV != $JOBENV ]; then
11186 jobstats_set $JOBENV
11187 trap jobstats_set EXIT
11191 cmd="mkdir $DIR/$tfile"
11192 verify_jobstats "$cmd" "mdt"
11194 cmd="rm -fr $DIR/$tfile"
11195 verify_jobstats "$cmd" "mdt"
11197 cmd="mknod $DIR/$tfile c 1 3"
11198 verify_jobstats "$cmd" "mdt"
11200 cmd="rm -f $DIR/$tfile"
11201 verify_jobstats "$cmd" "mdt"
11203 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11204 verify_jobstats "$cmd" "mdt"
11206 cmd="touch $DIR/$tfile"
11207 verify_jobstats "$cmd" "both"
11209 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11210 verify_jobstats "$cmd" "ost"
11212 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11213 verify_jobstats "$cmd" "ost"
11215 cmd="$TRUNCATE $DIR/$tfile 0"
11216 verify_jobstats "$cmd" "both"
11218 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11219 verify_jobstats "$cmd" "mdt"
11222 rm -f $DIR/jobstats_test_rename
11224 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11226 run_test 205 "Verify job stats"
11228 # LU-1480, LU-1773 and LU-1657
11230 mkdir -p $DIR/$tdir
11231 $SETSTRIPE -c -1 $DIR/$tdir
11232 #define OBD_FAIL_LOV_INIT 0x1403
11233 $LCTL set_param fail_loc=0xa0001403
11234 $LCTL set_param fail_val=1
11235 touch $DIR/$tdir/$tfile || true
11237 run_test 206 "fail lov_init_raid0() doesn't lbug"
11240 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11241 local fsz=`stat -c %s $DIR/$tfile`
11242 cancel_lru_locks mdc
11244 # do not return layout in getattr intent
11245 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11246 $LCTL set_param fail_loc=0x170
11247 local sz=`stat -c %s $DIR/$tfile`
11249 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11253 run_test 207a "can refresh layout at glimpse"
11256 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11257 local cksum=`md5sum $DIR/$tfile`
11258 local fsz=`stat -c %s $DIR/$tfile`
11259 cancel_lru_locks mdc
11260 cancel_lru_locks osc
11262 # do not return layout in getattr intent
11263 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11264 $LCTL set_param fail_loc=0x171
11266 # it will refresh layout after the file is opened but before read issues
11267 echo checksum is "$cksum"
11268 echo "$cksum" |md5sum -c --quiet || error "file differs"
11272 run_test 207b "can refresh layout at open"
11275 # FIXME: in this test suite, only RD lease is used. This is okay
11276 # for now as only exclusive open is supported. After generic lease
11277 # is done, this test suite should be revised. - Jinshan
11279 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11280 { skip "Need MDS version at least 2.4.52"; return 0; }
11282 echo "==== test 1: verify get lease work"
11283 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11285 echo "==== test 2: verify lease can be broken by upcoming open"
11286 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11290 $MULTIOP $DIR/$tfile oO_RDONLY:c
11291 kill -USR1 $PID && wait $PID || error "break lease error"
11293 echo "==== test 3: verify lease can't be granted if an open already exists"
11294 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11298 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11299 kill -USR1 $PID && wait $PID || error "open file error"
11301 echo "==== test 4: lease can sustain over recovery"
11302 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11308 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11310 echo "==== test 5: lease broken can't be regained by replay"
11311 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11315 # open file to break lease and then recovery
11316 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11319 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11323 run_test 208 "Exclusive open"
11326 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11327 skip_env "must have disp_stripe" && return
11330 sync; sleep 5; sync;
11332 echo 3 > /proc/sys/vm/drop_caches
11333 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11335 # open/close 500 times
11336 for i in $(seq 500); do
11340 echo 3 > /proc/sys/vm/drop_caches
11341 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11343 echo "before: $req_before, after: $req_after"
11344 [ $((req_after - req_before)) -ge 300 ] &&
11345 error "open/close requests are not freed"
11348 run_test 209 "read-only open/close requests should be freed promptly"
11352 size=$((size % 8192 + 1))
11353 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11354 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11355 rm -f $DIR/f212 $DIR/f212.xyz
11357 run_test 212 "Sendfile test ============================================"
11360 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11361 cancel_lru_locks osc
11362 lctl set_param fail_loc=0x8000040f
11363 # generate a read lock
11364 cat $DIR/$tfile > /dev/null
11365 # write to the file, it will try to cancel the above read lock.
11366 cat /etc/hosts >> $DIR/$tfile
11368 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11370 test_214() { # for bug 20133
11371 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11372 for (( i=0; i < 340; i++ )) ; do
11373 touch $DIR/$tdir/d214c/a$i
11376 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11377 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11378 ls $DIR/d214c || error "ls $DIR/d214c failed"
11379 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11380 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11382 run_test 214 "hash-indexed directory test - bug 20133"
11384 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11385 create_lnet_proc_files() {
11386 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11387 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11389 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11390 rm -f "$TMP/lnet_$1.sys_tmp"
11393 # counterpart of create_lnet_proc_files
11394 remove_lnet_proc_files() {
11395 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11398 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11399 # 3rd arg as regexp for body
11400 check_lnet_proc_stats() {
11401 local l=$(cat "$TMP/lnet_$1" |wc -l)
11402 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11404 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11407 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11408 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11409 # optional and can be regexp for 2nd line (lnet.routes case)
11410 check_lnet_proc_entry() {
11411 local blp=2 # blp stands for 'position of 1st line of body'
11412 [ -z "$5" ] || blp=3 # lnet.routes case
11414 local l=$(cat "$TMP/lnet_$1" |wc -l)
11415 # subtracting one from $blp because the body can be empty
11416 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11418 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11419 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11421 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11422 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11424 # bail out if any unexpected line happened
11425 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11426 [ "$?" != 0 ] || error "$2 misformatted"
11429 test_215() { # for bugs 18102, 21079, 21517
11430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11431 local N='(0|[1-9][0-9]*)' # non-negative numeric
11432 local P='[1-9][0-9]*' # positive numeric
11433 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11434 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11435 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11436 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11438 local L1 # regexp for 1st line
11439 local L2 # regexp for 2nd line (optional)
11440 local BR # regexp for the rest (body)
11442 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11443 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11444 create_lnet_proc_files "stats"
11445 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11446 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11447 remove_lnet_proc_files "stats"
11449 # /proc/sys/lnet/routes should look like this:
11450 # Routing disabled/enabled
11451 # net hops priority state router
11452 # where net is a string like tcp0, hops > 0, priority >= 0,
11453 # state is up/down,
11454 # router is a string like 192.168.1.1@tcp2
11455 L1="^Routing (disabled|enabled)$"
11456 L2="^net +hops +priority +state +router$"
11457 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11458 create_lnet_proc_files "routes"
11459 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11460 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11461 remove_lnet_proc_files "routes"
11463 # /proc/sys/lnet/routers should look like this:
11464 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11465 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11466 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11467 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11468 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11469 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11470 create_lnet_proc_files "routers"
11471 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11472 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11473 remove_lnet_proc_files "routers"
11475 # /proc/sys/lnet/peers should look like this:
11476 # nid refs state last max rtr min tx min queue
11477 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11478 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11479 # numeric (0 or >0 or <0), queue >= 0.
11480 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11481 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11482 create_lnet_proc_files "peers"
11483 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11484 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11485 remove_lnet_proc_files "peers"
11487 # /proc/sys/lnet/buffers should look like this:
11488 # pages count credits min
11489 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11490 L1="^pages +count +credits +min$"
11491 BR="^ +$N +$N +$I +$I$"
11492 create_lnet_proc_files "buffers"
11493 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11494 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11495 remove_lnet_proc_files "buffers"
11497 # /proc/sys/lnet/nis should look like this:
11498 # nid status alive refs peer rtr max tx min
11499 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11500 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11501 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11502 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11503 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11504 create_lnet_proc_files "nis"
11505 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11506 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11507 remove_lnet_proc_files "nis"
11509 # can we successfully write to /proc/sys/lnet/stats?
11510 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11511 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11513 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11515 test_216() { # bug 20317
11516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11517 remote_ost_nodsh && skip "remote OST with nodsh" && return
11520 local facets=$(get_facets OST)
11521 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11523 save_lustre_params client "osc.*.contention_seconds" > $p
11524 save_lustre_params $facets \
11525 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11526 save_lustre_params $facets \
11527 "ldlm.namespaces.filter-*.contended_locks" >> $p
11528 save_lustre_params $facets \
11529 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11532 # agressive lockless i/o settings
11533 for node in $(osts_nodes); do
11534 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'
11536 lctl set_param -n osc.*.contention_seconds 60
11538 $DIRECTIO write $DIR/$tfile 0 10 4096
11539 $CHECKSTAT -s 40960 $DIR/$tfile
11541 # disable lockless i/o
11542 for node in $(osts_nodes); do
11543 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'
11545 lctl set_param -n osc.*.contention_seconds 0
11548 dd if=/dev/zero of=$DIR/$tfile count=0
11549 $CHECKSTAT -s 0 $DIR/$tfile
11551 restore_lustre_params <$p
11555 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11557 test_217() { # bug 22430
11558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11562 for node in $(nodes_list); do
11563 nid=$(host_nids_address $node $NETTYPE)
11564 if [[ $nid = *-* ]] ; then
11565 echo "lctl ping $nid@$NETTYPE"
11566 lctl ping $nid@$NETTYPE
11568 echo "skipping $node (no hyphen detected)"
11572 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11575 # do directio so as not to populate the page cache
11576 log "creating a 10 Mb file"
11577 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11578 log "starting reads"
11579 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11580 log "truncating the file"
11581 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11583 kill %+ || true # reads might have finished
11584 echo "wait until dd is finished"
11586 log "removing the temporary file"
11587 rm -rf $DIR/$tfile || error "tmp file removal failed"
11589 run_test 218 "parallel read and truncate should not deadlock ======================="
11592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11593 # write one partial page
11594 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11595 # set no grant so vvp_io_commit_write will do sync write
11596 $LCTL set_param fail_loc=0x411
11597 # write a full page at the end of file
11598 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11600 $LCTL set_param fail_loc=0
11601 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11602 $LCTL set_param fail_loc=0x411
11603 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11606 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11607 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11609 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11611 test_220() { #LU-325
11612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11613 remote_ost_nodsh && skip "remote OST with nodsh" && return
11616 test_mkdir -p $DIR/$tdir
11617 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11618 awk '{print $2}' | sed -e 's/_UUID$//')
11621 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11622 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11623 osc.$mdtosc_proc1.prealloc_last_id)
11624 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11625 osc.$mdtosc_proc1.prealloc_next_id)
11629 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11630 #define OBD_FAIL_OST_ENOINO 0x229
11631 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11632 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11633 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11635 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11637 MDSOBJS=$((last_id - next_id))
11638 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11640 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11641 echo "OST still has $count kbytes free"
11643 echo "create $MDSOBJS files @next_id..."
11644 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11646 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11647 osc.$mdtosc_proc1.prealloc_last_id)
11648 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11649 osc.$mdtosc_proc1.prealloc_next_id)
11651 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11656 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11657 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11659 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11660 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11661 echo "unlink $MDSOBJS files @$next_id..."
11662 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11664 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11668 dd if=`which date` of=$MOUNT/date oflag=sync
11669 chmod +x $MOUNT/date
11671 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11672 $LCTL set_param fail_loc=0x80001401
11674 $MOUNT/date > /dev/null
11677 run_test 221 "make sure fault and truncate race to not cause OOM"
11680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11682 test_mkdir -p $DIR/$tdir
11683 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11684 createmany -o $DIR/$tdir/$tfile 10
11685 cancel_lru_locks mdc
11686 cancel_lru_locks osc
11687 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11688 $LCTL set_param fail_loc=0x31a
11689 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11690 $LCTL set_param fail_loc=0
11693 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11698 test_mkdir -p $DIR/$tdir
11699 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11700 createmany -o $DIR/$tdir/$tfile 10
11701 cancel_lru_locks mdc
11702 cancel_lru_locks osc
11703 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11704 $LCTL set_param fail_loc=0x31a
11705 rm -r $DIR/$tdir || "AGL for rmdir failed"
11706 $LCTL set_param fail_loc=0
11708 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11713 test_mkdir -p $DIR/$tdir
11714 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11715 createmany -o $DIR/$tdir/$tfile 10
11716 cancel_lru_locks mdc
11717 cancel_lru_locks osc
11718 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11719 $LCTL set_param fail_loc=0x31b
11720 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11721 $LCTL set_param fail_loc=0
11724 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11726 test_224a() { # LU-1039, MRP-303
11727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11728 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11729 $LCTL set_param fail_loc=0x508
11730 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11731 $LCTL set_param fail_loc=0
11734 run_test 224a "Don't panic on bulk IO failure"
11736 test_224b() { # LU-1039, MRP-303
11737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11738 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11739 cancel_lru_locks osc
11740 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11741 $LCTL set_param fail_loc=0x515
11742 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11743 $LCTL set_param fail_loc=0
11746 run_test 224b "Don't panic on bulk IO failure"
11748 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11751 if [ -z ${MDSSURVEY} ]; then
11752 skip_env "mds-survey not found" && return
11755 [ $MDSCOUNT -ge 2 ] &&
11756 skip "skipping now for more than one MDT" && return
11758 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11759 { skip "Need MDS version at least 2.2.51"; return; }
11761 local mds=$(facet_host $SINGLEMDS)
11762 local target=$(do_nodes $mds 'lctl dl' | \
11763 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11765 local cmd1="file_count=1000 thrhi=4"
11766 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11767 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11768 local cmd="$cmd1 $cmd2 $cmd3"
11770 rm -f ${TMP}/mds_survey*
11772 eval $cmd || error "mds-survey with zero-stripe failed"
11773 cat ${TMP}/mds_survey*
11774 rm -f ${TMP}/mds_survey*
11776 run_test 225a "Metadata survey sanity with zero-stripe"
11779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11781 if [ -z ${MDSSURVEY} ]; then
11782 skip_env "mds-survey not found" && return
11784 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11785 { skip "Need MDS version at least 2.2.51"; return; }
11787 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11788 skip_env "Need to mount OST to test" && return
11791 [ $MDSCOUNT -ge 2 ] &&
11792 skip "skipping now for more than one MDT" && return
11793 local mds=$(facet_host $SINGLEMDS)
11794 local target=$(do_nodes $mds 'lctl dl' | \
11795 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11797 local cmd1="file_count=1000 thrhi=4"
11798 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11799 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11800 local cmd="$cmd1 $cmd2 $cmd3"
11802 rm -f ${TMP}/mds_survey*
11804 eval $cmd || error "mds-survey with stripe_count failed"
11805 cat ${TMP}/mds_survey*
11806 rm -f ${TMP}/mds_survey*
11808 run_test 225b "Metadata survey sanity with stripe_count = 1"
11810 mcreate_path2fid () {
11816 local path=$DIR/$tdir/$name
11821 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11822 error "cannot create $desc"
11824 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11826 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11828 fid_path=$($LFS fid2path $MOUNT $fid)
11830 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11832 [ "$path" == "$fid_path" ] ||
11833 error "fid2path returned $fid_path, expected $path"
11835 echo "pass with $path and $fid"
11840 mkdir -p $DIR/$tdir
11842 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11843 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11844 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11845 mcreate_path2fid 0040666 0 0 dir "directory"
11846 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11847 mcreate_path2fid 0100666 0 0 file "regular file"
11848 mcreate_path2fid 0120666 0 0 link "symbolic link"
11849 mcreate_path2fid 0140666 0 0 sock "socket"
11851 run_test 226a "call path2fid and fid2path on files of all type"
11854 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11858 mkdir -p $DIR/$tdir
11859 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11860 error "create remote directory failed"
11861 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11862 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11863 "character special file (null)"
11864 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11865 "character special file (no device)"
11866 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11867 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11868 "block special file (loop)"
11869 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11870 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11871 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11873 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11875 # LU-1299 Executing or running ldd on a truncated executable does not
11876 # cause an out-of-memory condition.
11878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11879 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11880 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11881 chmod +x $MOUNT/date
11883 $MOUNT/date > /dev/null
11884 ldd $MOUNT/date > /dev/null
11887 run_test 227 "running truncated executable does not cause OOM"
11889 # LU-1512 try to reuse idle OI blocks
11891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11892 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11893 skip "non-ldiskfs backend" && return
11895 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11896 local myDIR=$DIR/$tdir
11899 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11900 $LCTL set_param fail_loc=0x80001002
11901 createmany -o $myDIR/t- 10000
11902 $LCTL set_param fail_loc=0
11903 # The guard is current the largest FID holder
11905 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11907 local IDX=$(($SEQ % 64))
11909 do_facet $SINGLEMDS sync
11910 # Make sure journal flushed.
11912 local blk1=$(do_facet $SINGLEMDS \
11913 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11914 grep Blockcount | awk '{print $4}')
11916 # Remove old files, some OI blocks will become idle.
11917 unlinkmany $myDIR/t- 10000
11918 # Create new files, idle OI blocks should be reused.
11919 createmany -o $myDIR/t- 2000
11920 do_facet $SINGLEMDS sync
11921 # Make sure journal flushed.
11923 local blk2=$(do_facet $SINGLEMDS \
11924 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11925 grep Blockcount | awk '{print $4}')
11927 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11929 run_test 228a "try to reuse idle OI blocks"
11932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11933 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11934 skip "non-ldiskfs backend" && return
11936 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11937 local myDIR=$DIR/$tdir
11940 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11941 $LCTL set_param fail_loc=0x80001002
11942 createmany -o $myDIR/t- 10000
11943 $LCTL set_param fail_loc=0
11944 # The guard is current the largest FID holder
11946 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11948 local IDX=$(($SEQ % 64))
11950 do_facet $SINGLEMDS sync
11951 # Make sure journal flushed.
11953 local blk1=$(do_facet $SINGLEMDS \
11954 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11955 grep Blockcount | awk '{print $4}')
11957 # Remove old files, some OI blocks will become idle.
11958 unlinkmany $myDIR/t- 10000
11961 stop $SINGLEMDS || error "Fail to stop MDT."
11963 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11965 df $MOUNT || error "Fail to df."
11966 # Create new files, idle OI blocks should be reused.
11967 createmany -o $myDIR/t- 2000
11968 do_facet $SINGLEMDS sync
11969 # Make sure journal flushed.
11971 local blk2=$(do_facet $SINGLEMDS \
11972 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11973 grep Blockcount | awk '{print $4}')
11975 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11977 run_test 228b "idle OI blocks can be reused after MDT restart"
11981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11982 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11983 skip "non-ldiskfs backend" && return
11985 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11986 local myDIR=$DIR/$tdir
11989 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11990 $LCTL set_param fail_loc=0x80001002
11991 # 20000 files can guarantee there are index nodes in the OI file
11992 createmany -o $myDIR/t- 20000
11993 $LCTL set_param fail_loc=0
11994 # The guard is current the largest FID holder
11996 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11998 local IDX=$(($SEQ % 64))
12000 do_facet $SINGLEMDS sync
12001 # Make sure journal flushed.
12003 local blk1=$(do_facet $SINGLEMDS \
12004 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12005 grep Blockcount | awk '{print $4}')
12007 # Remove old files, some OI blocks will become idle.
12008 unlinkmany $myDIR/t- 20000
12010 # The OI file should become empty now
12012 # Create new files, idle OI blocks should be reused.
12013 createmany -o $myDIR/t- 2000
12014 do_facet $SINGLEMDS sync
12015 # Make sure journal flushed.
12017 local blk2=$(do_facet $SINGLEMDS \
12018 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12019 grep Blockcount | awk '{print $4}')
12021 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12023 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12025 test_229() { # LU-2482, LU-3448
12026 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12027 skip "No HSM support on MDS of $(get_lustre_version)," \
12028 "need 2.4.53 at least" && return
12029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12030 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12034 # Create a file with a released layout and stripe count 2.
12035 $MULTIOP $DIR/$tfile H2c ||
12036 error "failed to create file with released layout"
12038 $GETSTRIPE -v $DIR/$tfile
12040 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12041 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12043 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12044 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12045 stat $DIR/$tfile || error "failed to stat released file"
12047 chown $RUNAS_ID $DIR/$tfile ||
12048 error "chown $RUNAS_ID $DIR/$tfile failed"
12050 chgrp $RUNAS_ID $DIR/$tfile ||
12051 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12053 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12054 rm $DIR/$tfile || error "failed to remove released file"
12056 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12060 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12063 mkdir -p $DIR/$tdir/test_230_local
12064 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12065 [ $mdt_idx -ne 0 ] &&
12066 error "create local directory on wrong MDT $mdt_idx"
12068 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12069 error "create remote directory failed"
12070 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12071 [ $mdt_idx -ne $MDTIDX ] &&
12072 error "create remote directory on wrong MDT $mdt_idx"
12074 createmany -o $DIR/$tdir/test_230/t- 10 ||
12075 error "create files on remote directory failed"
12076 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12077 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12078 rm -r $DIR/$tdir || error "unlink remote directory failed"
12080 run_test 230a "Create remote directory and files under the remote directory"
12083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12091 local migrate_dir=$DIR/$tdir/migrate_dir
12092 local other_dir=$DIR/$tdir/other_dir
12094 mkdir -p $migrate_dir
12095 mkdir -p $other_dir
12096 for ((i=0; i<10; i++)); do
12097 mkdir -p $migrate_dir/dir_${i}
12098 createmany -o $migrate_dir/dir_${i}/f 10 ||
12099 error "create files under remote dir failed $i"
12102 cp /etc/passwd $migrate_dir/$tfile
12103 cp /etc/passwd $other_dir/$tfile
12104 chattr +SAD $migrate_dir
12105 chattr +SAD $migrate_dir/$tfile
12107 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12108 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12109 local old_dir_mode=$(stat -c%f $migrate_dir)
12110 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12112 mkdir -p $migrate_dir/dir_default_stripe2
12113 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12114 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12116 mkdir -p $other_dir
12117 ln $migrate_dir/$tfile $other_dir/luna
12118 ln $migrate_dir/$tfile $migrate_dir/sofia
12119 ln $other_dir/$tfile $migrate_dir/david
12120 ln -s $migrate_dir/$tfile $other_dir/zachary
12121 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12122 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12124 $LFS mv -v -M $MDTIDX $migrate_dir ||
12125 error "migrate remote dir error"
12127 echo "migratate to MDT1, then checking.."
12128 for ((i=0; i<10; i++)); do
12129 for file in $(find $migrate_dir/dir_${i}); do
12130 mdt_index=$($LFS getstripe -M $file)
12131 [ $mdt_index == $MDTIDX ] ||
12132 error "$file is not on MDT${MDTIDX}"
12136 # the multiple link file should still in MDT0
12137 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12138 [ $mdt_index == 0 ] ||
12139 error "$file is not on MDT${MDTIDX}"
12141 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12142 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12143 error " expect $old_dir_flag get $new_dir_flag"
12145 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12146 [ "$old_file_flag" = "$new_file_flag" ] ||
12147 error " expect $old_file_flag get $new_file_flag"
12149 local new_dir_mode=$(stat -c%f $migrate_dir)
12150 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12151 error "expect mode $old_dir_mode get $new_dir_mode"
12153 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12154 [ "$old_file_mode" = "$new_file_mode" ] ||
12155 error "expect mode $old_file_mode get $new_file_mode"
12157 diff /etc/passwd $migrate_dir/$tfile ||
12158 error "$tfile different after migration"
12160 diff /etc/passwd $other_dir/luna ||
12161 error "luna different after migration"
12163 diff /etc/passwd $migrate_dir/sofia ||
12164 error "sofia different after migration"
12166 diff /etc/passwd $migrate_dir/david ||
12167 error "david different after migration"
12169 diff /etc/passwd $other_dir/zachary ||
12170 error "zachary different after migration"
12172 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12173 error "${tfile}_ln different after migration"
12175 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12176 error "${tfile}_ln_other different after migration"
12178 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12179 [ $stripe_count = 2 ] ||
12180 error "dir strpe_count $d != 2 after migration."
12182 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12183 [ $stripe_count = 2 ] ||
12184 error "file strpe_count $d != 2 after migration."
12186 #migrate back to MDT0
12188 $LFS mv -v -M $MDTIDX $migrate_dir ||
12189 error "migrate remote dir error"
12191 echo "migrate back to MDT0, checking.."
12192 for file in $(find $migrate_dir); do
12193 mdt_index=$($LFS getstripe -M $file)
12194 [ $mdt_index == $MDTIDX ] ||
12195 error "$file is not on MDT${MDTIDX}"
12198 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12199 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12200 error " expect $old_dir_flag get $new_dir_flag"
12202 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12203 [ "$old_file_flag" = "$new_file_flag" ] ||
12204 error " expect $old_file_flag get $new_file_flag"
12206 local new_dir_mode=$(stat -c%f $migrate_dir)
12207 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12208 error "expect mode $old_dir_mode get $new_dir_mode"
12210 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12211 [ "$old_file_mode" = "$new_file_mode" ] ||
12212 error "expect mode $old_file_mode get $new_file_mode"
12214 diff /etc/passwd ${migrate_dir}/$tfile ||
12215 error "$tfile different after migration"
12217 diff /etc/passwd ${other_dir}/luna ||
12218 error "luna different after migration"
12220 diff /etc/passwd ${migrate_dir}/sofia ||
12221 error "sofia different after migration"
12223 diff /etc/passwd ${other_dir}/zachary ||
12224 error "zachary different after migration"
12226 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12227 error "${tfile}_ln different after migration"
12229 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12230 error "${tfile}_ln_other different after migration"
12232 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12233 [ $stripe_count = 2 ] ||
12234 error "dir strpe_count $d != 2 after migration."
12236 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12237 [ $stripe_count = 2 ] ||
12238 error "file strpe_count $d != 2 after migration."
12240 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12242 run_test 230b "migrate directory"
12245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12251 #If migrating directory fails in the middle, all entries of
12252 #the directory is still accessiable.
12253 mkdir -p $DIR/$tdir
12255 createmany -o $DIR/$tdir/f 10 ||
12256 error "create files under ${tdir} failed"
12258 #failed after migrating 5 entries
12259 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12260 do_facet mds1 lctl set_param fail_loc=0x20001801
12261 do_facet mds1 lctl set_param fail_val=5
12262 local t=`ls $DIR/$tdir | wc -l`
12263 $LFS mv -M $MDTIDX $DIR/$tdir &&
12264 error "migrate should failed after 5 entries"
12265 local u=`ls $DIR/$tdir | wc -l`
12266 [ "$u" == "$t" ] || error "$u != $t during migration"
12268 for file in $(find $DIR/$tdir); do
12269 stat $file || error "stat $file failed"
12272 do_facet mds1 lctl set_param fail_loc=0
12273 do_facet mds1 lctl set_param fail_val=0
12275 $LFS mv -M $MDTIDX $DIR/$tdir ||
12276 error "migrate open files should failed with open files"
12278 echo "Finish migration, then checking.."
12279 for file in $(find $DIR/$tdir); do
12280 mdt_index=$($LFS getstripe -M $file)
12281 [ $mdt_index == $MDTIDX ] ||
12282 error "$file is not on MDT${MDTIDX}"
12285 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12287 run_test 230c "check directory accessiblity if migration is failed"
12290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12291 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12297 mkdir -p $DIR/$tdir
12299 for ((i=0; i<100; i++)); do
12300 mkdir -p $DIR/$tdir/dir_${i}
12301 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12302 error "create files under remote dir failed $i"
12305 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12307 echo "Finish migration, then checking.."
12308 for file in $(find $DIR/$tdir); do
12309 mdt_index=$($LFS getstripe -M $file)
12310 [ $mdt_index == $MDTIDX ] ||
12311 error "$file is not on MDT${MDTIDX}"
12314 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12316 run_test 230d "check migrate big directory"
12320 # For simplicity this test assumes that max_pages_per_rpc
12321 # is the same across all OSCs
12322 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12323 local bulk_size=$((max_pages * 4096))
12325 mkdir -p $DIR/$tdir
12327 # clear the OSC stats
12328 $LCTL set_param osc.*.stats=0 &>/dev/null
12330 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12331 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12332 oflag=direct &>/dev/null || error "dd failed"
12334 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12335 if [ x$nrpcs != "x1" ]; then
12336 error "found $nrpc ost_write RPCs, not 1 as expected"
12339 # Drop the OSC cache, otherwise we will read from it
12340 cancel_lru_locks osc
12342 # clear the OSC stats
12343 $LCTL set_param osc.*.stats=0 &>/dev/null
12345 # Client reads $bulk_size.
12346 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12347 iflag=direct &>/dev/null || error "dd failed"
12349 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12350 if [ x$nrpcs != "x1" ]; then
12351 error "found $nrpc ost_read RPCs, not 1 as expected"
12354 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12357 mkdir -p $DIR/$tdir
12359 for i in {0..1023}; do
12360 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12361 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12362 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12366 run_test 231b "must not assert on fully utilized OST request buffer"
12369 mkdir -p $DIR/$tdir
12370 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12371 $LCTL set_param fail_loc=0x31c
12373 # ignore dd failure
12374 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12376 $LCTL set_param fail_loc=0
12377 umount_client $MOUNT || error "umount failed"
12378 mount_client $MOUNT || error "mount failed"
12380 run_test 232 "failed lock should not block umount"
12383 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12384 { skip "Need MDS version at least 2.3.64"; return; }
12386 local fid=$($LFS path2fid $MOUNT)
12387 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12388 error "cannot access $MOUNT using its FID '$fid'"
12390 run_test 233a "checking that OBF of the FS root succeeds"
12393 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12394 { skip "Need MDS version at least 2.5.90"; return; }
12396 local fid=$($LFS path2fid $MOUNT/.lustre)
12397 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12398 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12400 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12401 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12402 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12404 run_test 233b "checking that OBF of the FS .lustre succeeds"
12407 local p="$TMP/sanityN-$TESTNAME.parameters"
12408 save_lustre_params client "llite.*.xattr_cache" > $p
12409 lctl set_param llite.*.xattr_cache 1 ||
12410 { skip "xattr cache is not supported"; return 0; }
12412 mkdir -p $DIR/$tdir || error "mkdir failed"
12413 touch $DIR/$tdir/$tfile || error "touch failed"
12414 # OBD_FAIL_LLITE_XATTR_ENOMEM
12415 $LCTL set_param fail_loc=0x1405
12416 if [ ! -f /etc/SuSE-release ]; then
12417 # attr pre-2.4.44-7 had a bug with rc
12418 # LU-3703 - SLES clients have older attr
12419 getfattr -n user.attr $DIR/$tdir/$tfile &&
12420 error "getfattr should have failed with ENOMEM"
12422 $LCTL set_param fail_loc=0x0
12425 restore_lustre_params < $p
12428 run_test 234 "xattr cache should not crash on ENOMEM"
12431 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12432 skip "Need MDS version at least 2.4.52" && return
12433 flock_deadlock $DIR/$tfile
12438 124) error "process hangs on a deadlock"
12440 *) error "error executing flock_deadlock $DIR/$tfile"
12444 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12448 check_swap_layouts_support && return 0
12449 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12451 local ref1=/etc/passwd
12452 local ref2=/etc/group
12453 local file1=$DIR/$tdir/f1
12454 local file2=$DIR/$tdir/f2
12456 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12457 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12458 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12459 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12460 local fd=$(free_fd)
12461 local cmd="exec $fd<>$file2"
12464 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12465 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12468 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12473 run_test 236 "Layout swap on open unlinked file"
12475 # test to verify file handle related system calls
12476 # (name_to_handle_at/open_by_handle_at)
12477 # The new system calls are supported in glibc >= 2.14.
12480 echo "Test file_handle syscalls" > $DIR/$tfile
12481 check_fhandle_syscalls $DIR/$tfile ||
12482 error "check_fhandle_syscalls failed"
12484 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12486 # LU-4659 linkea consistency
12489 ln $DIR/$tfile $DIR/$tfile.lnk
12490 touch $DIR/$tfile.new
12491 mv $DIR/$tfile.new $DIR/$tfile
12492 local fid1=$(lfs path2fid $DIR/$tfile)
12493 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12494 local path1=$(lfs fid2path $FSNAME $fid1)
12495 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12496 local path2=$(lfs fid2path $FSNAME $fid2)
12497 [ $tfile.lnk == $path2 ] ||
12498 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12501 run_test 238 "Verify linkea consistency"
12503 test_striped_dir() {
12508 mkdir -p $DIR/$tdir
12509 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12510 error "set striped dir error"
12512 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12513 if [ "$stripe_count" != "2" ]; then
12514 error "stripe_count is $stripe_count, expect 2"
12517 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12518 if [ "$stripe_index" != "$mdt_index" ]; then
12519 error "stripe_index is $stripe_index, expect $mdt_index"
12522 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12523 error "nlink error after create striped dir"
12525 mkdir $DIR/$tdir/striped_dir/a
12526 mkdir $DIR/$tdir/striped_dir/b
12528 stat $DIR/$tdir/striped_dir/a ||
12529 error "create dir under striped dir failed"
12530 stat $DIR/$tdir/striped_dir/b ||
12531 error "create dir under striped dir failed"
12533 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12534 error "nlink error after mkdir"
12536 rmdir $DIR/$tdir/striped_dir/a
12537 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12538 error "nlink error after rmdir"
12540 rmdir $DIR/$tdir/striped_dir/b
12541 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12542 error "nlink error after rmdir"
12544 rmdir $DIR/$tdir/striped_dir ||
12545 error "rmdir striped dir error"
12550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12551 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12553 test_striped_dir 0 || error "failed on striped dir on MDT0"
12554 test_striped_dir 1 || error "failed on striped dir on MDT0"
12556 run_test 300a "basic striped dir sanity test"
12559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12560 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12566 test_mkdir $DIR/$tdir || error "mkdir fail"
12567 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12568 error "set striped dir error"
12569 for ((i=0; i<10; i++)); do
12570 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12572 touch $DIR/$tdir/striped_dir/file_$i ||
12573 error "touch error $i"
12574 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12575 [ $mtime1 -eq $mtime2 ] &&
12576 error "mtime not change after create"
12578 rm -f $DIR/$tdir/striped_dir/file_$i ||
12579 error "unlink error $i"
12580 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12581 [ $mtime2 -eq $mtime3 ] &&
12582 error "mtime did not change after unlink"
12586 run_test 300b "check ctime/mtime for striped dir"
12589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12593 mkdir -p $DIR/$tdir
12594 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12595 error "set striped dir error"
12597 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12598 error "chown striped dir failed"
12600 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12601 error "create 5k files failed"
12603 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12605 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12609 run_test 300c "chown && check ls under striped directory"
12612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12613 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12617 mkdir -p $DIR/$tdir
12618 $SETSTRIPE -c 2 $DIR/$tdir
12620 #local striped directory
12621 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12622 error "set striped dir error"
12623 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12624 error "create 10 files failed"
12626 #remote striped directory
12627 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12628 error "set striped dir error"
12629 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12630 error "create 10 files failed"
12632 for file in $(find $DIR/$tdir); do
12633 stripe_count=$($GETSTRIPE -c $file)
12634 [ $stripe_count -eq 2 ] ||
12635 error "wrong stripe $stripe_count for $file"
12640 run_test 300d "check default stripe under striped directory"
12643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12644 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12648 mkdir -p $DIR/$tdir
12650 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12651 error "set striped dir error"
12653 touch $DIR/$tdir/striped_dir/a
12654 touch $DIR/$tdir/striped_dir/b
12655 touch $DIR/$tdir/striped_dir/c
12657 mkdir $DIR/$tdir/striped_dir/dir_a
12658 mkdir $DIR/$tdir/striped_dir/dir_b
12659 mkdir $DIR/$tdir/striped_dir/dir_c
12661 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12662 error "set striped dir under striped dir error"
12664 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12665 error "set striped dir under striped dir error"
12667 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12668 error "set striped dir under striped dir error"
12670 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12671 error "rename file under striped dir should fail"
12673 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12674 error "rename dir under striped dir should fail"
12676 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12677 error "rename dir under different stripes should fail"
12679 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12680 error "rename file under striped dir should succeed"
12682 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12683 error "rename dir under striped dir should succeed"
12687 run_test 300e "check rename under striped directory"
12690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12691 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12696 mkdir -p $DIR/$tdir
12698 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12699 error "set striped dir error"
12701 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12702 error "set striped dir error"
12704 touch $DIR/$tdir/striped_dir/a
12705 mkdir $DIR/$tdir/striped_dir/dir_a
12706 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12707 error "create striped dir under striped dir fails"
12709 touch $DIR/$tdir/striped_dir1/b
12710 mkdir $DIR/$tdir/striped_dir1/dir_b
12711 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12712 error "create striped dir under striped dir fails"
12714 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12715 error "rename file under different striped dir should fail"
12717 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12718 error "rename dir under different striped dir should fail"
12720 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12721 error "rename striped dir under diff striped dir should fail"
12723 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12724 error "rename file under diff striped dirs fails"
12726 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12727 error "rename dir under diff striped dirs fails"
12731 run_test 300f "check rename cross striped directory"
12734 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12739 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12740 $DIR/$tdir/striped_dir ||
12741 error "set striped dir error"
12743 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12744 error "set default stripe on striped dir error"
12746 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12748 for dir in $(find $DIR/$tdir/striped_dir/*); do
12749 stripe_count=$($LFS getdirstripe -c $dir)
12750 [ $stripe_count -eq $MDSCOUNT ] ||
12751 error "expect $MDSCOUNT get $stripe_count for $dir"
12754 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12755 #change default stripe count to 2
12756 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12757 error "set default stripe on striped dir error"
12759 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12761 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12763 #change default stripe count to 1
12764 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12765 error "set default stripe on striped dir error"
12767 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12768 for dir in $(find $DIR/$tdir/striped_dir/*); do
12769 stripe_count=$($LFS getdirstripe -c $dir)
12770 [ $stripe_count -eq 1 ] ||
12771 error "expect 1 get $stripe_count for $dir"
12773 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12775 run_test 300g "check default striped directory for striped directory"
12777 test_400a() { # LU-1606, was conf-sanity test_74
12778 local extra_flags=''
12779 local out=$TMP/$tfile
12780 local prefix=/usr/include/lustre
12783 if ! which $CC > /dev/null 2>&1; then
12784 skip_env "$CC is not installed"
12788 if ! [[ -d $prefix ]]; then
12789 # Assume we're running in tree and fixup the include path.
12790 extra_flags+=" -I$LUSTRE/../libcfs/include"
12791 extra_flags+=" -I$LUSTRE/include"
12792 extra_flags+=" -L$LUSTRE/utils"
12795 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
12796 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
12797 error "client api broken"
12800 run_test 400a "Lustre client api program can compile and link"
12802 test_400b() { # LU-1606, LU-5011
12804 local out=$TMP/$tfile
12805 local prefix=/usr/include/lustre
12807 # We use a hard coded prefix so that this test will not fail
12808 # when run in tree. There are headers in lustre/include/lustre/
12809 # that are not packaged (like lustre_idl.h) and have more
12810 # complicated include dependencies (like config.h and lnet/types.h).
12811 # Since this test about correct packaging we just skip them when
12812 # they don't exist (see below) rather than try to fixup cppflags.
12814 if ! which $CC > /dev/null 2>&1; then
12815 skip_env "$CC is not installed"
12819 for header in $prefix/*.h; do
12820 if ! [[ -f "$header" ]]; then
12824 if [[ "$(basename $header)" == liblustreapi.h ]]; then
12825 continue # liblustreapi.h is deprecated.
12828 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
12829 error "cannot compile '$header'"
12832 run_test 400b "packaged headers can be compiled"
12835 # tests that do cleanup/setup should be run at the end
12839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12841 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12842 $LCTL set_param fail_loc=0x903
12843 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12844 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12847 FAIL_ON_ERROR=true cleanup
12848 FAIL_ON_ERROR=true setup
12850 run_test 900 "umount should not race with any mgc requeue thread"
12853 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12854 check_and_cleanup_lustre
12855 if [ "$I_MOUNTED" != "yes" ]; then
12856 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true