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
41 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
42 CREATETEST=${CREATETEST:-createtest}
44 LFIND=${LFIND:-"$LFS find"}
45 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
47 MCREATE=${MCREATE:-mcreate}
48 OPENFILE=${OPENFILE:-openfile}
49 OPENUNLINK=${OPENUNLINK:-openunlink}
50 export MULTIOP=${MULTIOP:-multiop}
51 READS=${READS:-"reads"}
52 MUNLINK=${MUNLINK:-munlink}
53 SOCKETSERVER=${SOCKETSERVER:-socketserver}
54 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
55 MEMHOG=${MEMHOG:-memhog}
56 DIRECTIO=${DIRECTIO:-directio}
57 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
58 UMOUNT=${UMOUNT:-"umount -d"}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 . $LUSTRE/tests/test-framework.sh
74 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
77 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
79 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
80 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
81 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
87 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
88 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
97 check_kernel_version() {
99 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
101 patchless|patchless_client) return 0;;
102 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
104 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
108 check_swap_layouts_support()
110 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
111 { skip "Does not support layout lock."; return 0; }
115 if [ "$ONLY" == "cleanup" ]; then
120 check_and_setup_lustre
125 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
126 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
127 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
128 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
129 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
130 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
131 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
132 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
134 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
135 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
136 rm -rf $DIR/[Rdfs][0-9]*
138 # $RUNAS_ID may get set incorrectly somewhere else
139 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
141 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
145 if [ "${ONLY}" = "MOUNT" ] ; then
146 echo "Lustre is up, please go on"
150 echo "preparing for tests involving mounts"
151 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
153 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
154 echo # add a newline after mke2fs.
158 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
159 lctl set_param debug=-1 2> /dev/null || true
162 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
164 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
166 run_test 0a "touch; rm ====================="
169 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
170 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
172 run_test 0b "chmod 0755 $DIR ============================="
175 $LCTL get_param mdc.*.import | grep "state: FULL" ||
176 error "import not FULL"
177 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
180 run_test 0c "check import proc ============================="
183 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
184 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
185 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
186 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
191 run_test 1 "mkdir; remkdir; rmdir =============================="
194 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
195 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
198 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
200 run_test 2 "mkdir; touch; rmdir; check file ===================="
203 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
204 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
205 touch $DIR/$tdir/$tfile
206 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
208 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
210 run_test 3 "mkdir; touch; rmdir; check dir ====================="
212 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
215 local remote_dir=remote_dir
217 test_mkdir $DIR/$remote_dir ||
218 error "Create remote directory failed"
220 touch $DIR/$remote_dir/$tfile ||
221 error "Create file under remote directory failed"
223 rmdir $DIR/$remote_dir &&
224 error "Expect error removing in-use dir $DIR/$remote_dir"
226 test -d $DIR/$remote_dir || error "Remote directory disappeared"
228 rm -rf $DIR/$remote_dir || error "remove remote dir error"
230 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
233 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
234 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
235 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
236 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
237 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
239 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
242 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
243 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
245 error "$tfile does not have perm 0666 or UID $UID"
246 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
247 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
248 error "$tfile should be 0666 and owned by UID $UID"
250 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
253 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
255 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
256 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
257 error "$tfile should be owned by UID $RUNAS_ID"
258 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
260 error "$tfile should be owned by UID $RUNAS_ID"
262 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
265 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
267 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
268 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
269 error "$tfile should be owned by GID $UID"
270 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
272 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
274 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
278 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
279 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
280 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
281 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
282 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
283 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
284 error "$tdir/d/subdir should be GID $RUNAS_GID"
286 run_test 6g "Is new dir in sgid dir inheriting group?"
288 test_6h() { # bug 7331
289 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
290 touch $DIR/$tfile || error "touch failed"
291 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
292 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
293 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
294 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
295 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
297 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
300 test_mkdir $DIR/$tdir
301 $MCREATE $DIR/$tdir/$tfile
302 chmod 0666 $DIR/$tdir/$tfile
303 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
304 error "$tdir/$tfile should be mode 0666"
306 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
309 if [ ! -d $DIR/$tdir ]; then
312 $MCREATE $DIR/$tdir/$tfile
313 echo -n foo > $DIR/$tdir/$tfile
314 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
315 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
317 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
320 test_mkdir $DIR/$tdir
321 touch $DIR/$tdir/$tfile
322 chmod 0666 $DIR/$tdir/$tfile
323 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
324 error "$tfile mode not 0666"
326 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 test_mkdir $DIR/$tdir/d2/d3
332 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
334 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
337 test_mkdir $DIR/$tdir
338 test_mkdir $DIR/$tdir/d2
339 touch $DIR/$tdir/d2/$tfile
340 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
341 error "$tdir/d2/$tfile not a file"
343 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
346 test_mkdir $DIR/$tdir
347 test_mkdir $DIR/$tdir/d2
348 chmod 0666 $DIR/$tdir/d2
349 chmod 0705 $DIR/$tdir/d2
350 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
351 error "$tdir/d2 mode not 0705"
353 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
358 chmod 0666 $DIR/$tdir/$tfile
359 chmod 0654 $DIR/$tdir/$tfile
360 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
361 error "$tdir/d2 mode not 0654"
363 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
366 test_mkdir $DIR/$tdir
367 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
369 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
370 error "$tdir/$tfile size not 0 after truncate"
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
383 test_mkdir $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
386 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
387 error "$tdir/${tfile_2} not a file after rename"
389 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 rm -rf $DIR/$tdir/$tfile
395 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
397 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
400 test_mkdir -p $DIR/$tdir
401 touch $DIR/$tdir/$tfile
402 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
404 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not a symlink"
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
407 error "$tdir/l-exist not referencing a file"
408 rm -f $DIR/$tdir/l-exist
409 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
411 run_test 17a "symlinks: create, remove (real) =================="
414 test_mkdir -p $DIR/$tdir
415 ln -s no-such-file $DIR/$tdir/l-dangle
417 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing no-such-file"
419 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
420 error "$tdir/l-dangle not referencing non-existent file"
421 rm -f $DIR/$tdir/l-dangle
422 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
424 run_test 17b "symlinks: create, remove (dangling) =============="
426 test_17c() { # bug 3440 - don't save failed open RPC for replay
427 test_mkdir -p $DIR/$tdir
428 ln -s foo $DIR/$tdir/$tfile
429 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
431 run_test 17c "symlinks: open dangling (should return error) ===="
434 test_mkdir -p $DIR/$tdir
435 ln -s foo $DIR/$tdir/$tfile
436 touch $DIR/$tdir/$tfile || error "creating to new symlink"
438 run_test 17d "symlinks: create dangling ========================"
441 test_mkdir -p $DIR/$tdir
442 local foo=$DIR/$tdir/$tfile
443 ln -s $foo $foo || error "create symlink failed"
444 ls -l $foo || error "ls -l failed"
445 ls $foo && error "ls not failed" || true
447 run_test 17e "symlinks: create recursive symlink (should return error) ===="
450 test_mkdir -p $DIR/d17f
451 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
456 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
459 run_test 17f "symlinks: long and very long symlink name ========================"
461 # str_repeat(S, N) generate a string that is string S repeated N times
466 while [ $((n -= 1)) -ge 0 ]; do
472 # Long symlinks and LU-2241
474 test_mkdir -p $DIR/$tdir
475 local TESTS="59 60 61 4094 4095"
477 # Fix for inode size boundary in 2.1.4
478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
481 # Patch not applied to 2.2 or 2.3 branches
482 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
483 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
486 # skip long symlink name for rhel6.5.
487 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
488 grep -q '6.5' /etc/redhat-release &>/dev/null &&
489 TESTS="59 60 61 4062 4063"
492 local SYMNAME=$(str_repeat 'x' $i)
493 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
494 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
497 run_test 17g "symlinks: really long symlink name and inode boundaries"
499 test_17h() { #bug 17378
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
503 test_mkdir -p $DIR/$tdir
504 if [[ $MDSCOUNT -gt 1 ]]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 $SETSTRIPE -c -1 $DIR/$tdir
510 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
512 touch $DIR/$tdir/$tfile || true
514 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
516 test_17i() { #bug 20018
517 remote_mds_nodsh && skip "remote MDS with nodsh" && return
518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
519 test_mkdir -c1 $DIR/$tdir
520 local foo=$DIR/$tdir/$tfile
522 if [[ $MDSCOUNT -gt 1 ]]; then
523 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
527 ln -s $foo $foo || error "create symlink failed"
528 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
529 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
530 ls -l $foo && error "error not detected"
533 run_test 17i "don't panic on short symlink"
535 test_17k() { #bug 22301
536 [[ -z "$(which rsync 2>/dev/null)" ]] &&
537 skip "no rsync command" && return 0
538 rsync --help | grep -q xattr ||
539 skip_env "$(rsync --version | head -n1) does not support xattrs"
540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
541 test_mkdir -p $DIR/$tdir
542 test_mkdir -p $DIR/$tdir.new
543 touch $DIR/$tdir/$tfile
544 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
545 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
546 error "rsync failed with xattrs enabled"
548 run_test 17k "symlinks: rsync with xattrs enabled ========================="
550 test_17l() { # LU-279
551 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
552 skip "no getfattr command" && return 0
554 touch $DIR/$tdir/$tfile
555 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
556 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
557 # -h to not follow symlinks. -m '' to list all the xattrs.
558 # grep to remove first line: '# file: $path'.
559 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
561 lgetxattr_size_check $path $xattr ||
562 error "lgetxattr_size_check $path $xattr failed"
566 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
570 local short_sym="0123456789"
571 local WDIR=$DIR/${tdir}m
578 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
579 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
580 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
582 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
583 skip "only for ldiskfs MDT" && return 0
585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
589 # create a long symlink file
590 for ((i = 0; i < 4; ++i)); do
591 long_sym=${long_sym}${long_sym}
594 echo "create 512 short and long symlink files under $WDIR"
595 for ((i = 0; i < 256; ++i)); do
596 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
597 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
603 wait_delete_completed
605 echo "recreate the 512 symlink files with a shorter string"
606 for ((i = 0; i < 512; ++i)); do
607 # rewrite the symlink file with a shorter string
608 ln -sf ${long_sym} $WDIR/long-$i
609 ln -sf ${short_sym} $WDIR/short-$i
612 mds_index=$($LFS getstripe -M $WDIR)
613 mds_index=$((mds_index+1))
614 devname=$(mdsdevname $mds_index)
615 cmd="$E2FSCK -fnvd $devname"
617 echo "stop and checking mds${mds_index}: $cmd"
618 # e2fsck should not return error
620 do_facet mds${mds_index} $cmd || rc=$?
622 start mds${mds_index} $devname $MDS_MOUNT_OPTS
623 df $MOUNT > /dev/null 2>&1
624 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
625 "short/long symlink MDT: rc=$rc"
628 run_test 17m "run e2fsck against MDT which contains short/long symlink"
630 check_fs_consistency_17n() {
636 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
637 # so it only check MDT1/MDT2 instead of all of MDTs.
638 for mdt_index in $(seq 1 2); do
639 devname=$(mdsdevname $mdt_index)
640 cmd="$E2FSCK -fnvd $devname"
642 echo "stop and checking mds${mdt_index}: $cmd"
643 # e2fsck should not return error
645 do_facet mds${mdt_index} $cmd || rc=$?
647 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
648 df $MOUNT > /dev/null 2>&1
649 [ $rc -ne 0 ] && break
657 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
658 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
659 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
661 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
662 skip "only for ldiskfs MDT" && return 0
664 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
669 for ((i=0; i<10; i++)); do
670 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
671 error "create remote dir error $i"
672 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
673 error "create files under remote dir failed $i"
676 check_fs_consistency_17n ||
677 error "e2fsck report error after create files under remote dir"
679 for ((i=0;i<10;i++)); do
680 rm -rf $DIR/$tdir/remote_dir_${i} ||
681 error "destroy remote dir error $i"
684 check_fs_consistency_17n ||
685 error "e2fsck report error after unlink files under remote dir"
687 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
688 skip "lustre < 2.4.50 does not support migrate mv " && return
690 for ((i=0; i<10; i++)); do
691 mkdir -p $DIR/$tdir/remote_dir_${i}
692 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
693 error "create files under remote dir failed $i"
694 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
695 error "migrate remote dir error $i"
697 check_fs_consistency_17n || error "e2fsck report error after migration"
699 for ((i=0;i<10;i++)); do
700 rm -rf $DIR/$tdir/remote_dir_${i} ||
701 error "destroy remote dir error $i"
704 check_fs_consistency_17n || error "e2fsck report error after unlink"
706 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
709 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
710 skip "Need MDS version at least 2.3.64" && return
712 local WDIR=$DIR/${tdir}o
718 mdt_index=$($LFS getstripe -M $WDIR)
719 mdt_index=$((mdt_index+1))
720 mdtdevname=$(mdsdevname $mdt_index)
724 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
726 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
727 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
728 ls -l $WDIR/$tfile && rc=1
729 do_facet mds${mdt_index} lctl set_param fail_loc=0
730 [[ $rc -ne 0 ]] && error "stat file should fail"
733 run_test 17o "stat file with incompat LMA feature"
736 touch $DIR/f || error "Failed to touch $DIR/f: $?"
737 ls $DIR || error "Failed to ls $DIR: $?"
739 run_test 18 "touch .../f ; ls ... =============================="
745 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
747 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
750 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
752 run_test 19b "ls -l .../f19 (should return error) =============="
755 [ $RUNAS_ID -eq $UID ] &&
756 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
757 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
759 run_test 19c "$RUNAS touch .../f19 (should return error) =="
762 cat $DIR/f19 && error || true
764 run_test 19d "cat .../f19 (should return error) =============="
776 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
778 run_test 20 "touch .../f ; ls -l ... ==========================="
781 test_mkdir -p $DIR/$tdir
782 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
783 ln -s dangle $DIR/$tdir/link
784 echo foo >> $DIR/$tdir/link
785 cat $DIR/$tdir/dangle
786 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
787 $CHECKSTAT -f -t file $DIR/$tdir/link ||
788 error "$tdir/link not linked to a file"
790 run_test 21 "write to dangling link ============================"
794 test_mkdir -p $DIR/$tdir
795 chown $RUNAS_ID:$RUNAS_GID $WDIR
796 (cd $WDIR || error "cd $WDIR failed";
797 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
799 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
800 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
801 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
803 run_test 22 "unpack tar archive as non-root user ==============="
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
810 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
811 openfile -f O_CREAT:O_EXCL $file &&
812 error "$file recreate succeeded" || true
814 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
816 test_23b() { # bug 18988
817 test_mkdir -p $DIR/$tdir
818 local file=$DIR/$tdir/$tfile
821 echo foo > $file || error "write filed"
822 echo bar >> $file || error "append filed"
823 $CHECKSTAT -s 8 $file || error "wrong size"
826 run_test 23b "O_APPEND check =========================="
830 echo '-- same directory rename'
831 test_mkdir $DIR/$tdir
832 touch $DIR/$tdir/$tfile.1
833 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
834 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
836 run_test 24a "rename file to non-existent target"
839 test_mkdir $DIR/$tdir
840 touch $DIR/$tdir/$tfile.{1,2}
841 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
842 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
843 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
845 run_test 24b "rename file to existing target"
848 test_mkdir $DIR/$tdir
849 test_mkdir $DIR/$tdir/d$testnum.1
850 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
851 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
852 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
854 run_test 24c "rename directory to non-existent target"
857 test_mkdir -c1 $DIR/$tdir
858 test_mkdir -c1 $DIR/$tdir/d$testnum.1
859 test_mkdir -c1 $DIR/$tdir/d$testnum.2
860 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
861 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
862 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
864 run_test 24d "rename directory to existing target"
867 echo '-- cross directory renames --'
871 mv $DIR/R5a/f $DIR/R5b/g
872 $CHECKSTAT -a $DIR/R5a/f || error
873 $CHECKSTAT -t file $DIR/R5b/g || error
875 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
880 touch $DIR/R6a/f $DIR/R6b/g
881 mv $DIR/R6a/f $DIR/R6b/g
882 $CHECKSTAT -a $DIR/R6a/f || error
883 $CHECKSTAT -t file $DIR/R6b/g || error
885 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
890 test_mkdir $DIR/R7a/d
891 mv $DIR/R7a/d $DIR/R7b/e
892 $CHECKSTAT -a $DIR/R7a/d || error
893 $CHECKSTAT -t dir $DIR/R7b/e || error
895 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
898 test_mkdir -c1 $DIR/R8a
899 test_mkdir -c1 $DIR/R8b
900 test_mkdir -c1 $DIR/R8a/d
901 test_mkdir -c1 $DIR/R8b/e
902 mrename $DIR/R8a/d $DIR/R8b/e
903 $CHECKSTAT -a $DIR/R8a/d || error
904 $CHECKSTAT -t dir $DIR/R8b/e || error
906 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
909 echo "-- rename error cases"
913 mrename $DIR/R9/f $DIR/R9/a
914 $CHECKSTAT -t file $DIR/R9/f || error
915 $CHECKSTAT -t dir $DIR/R9/a || error
916 $CHECKSTAT -a $DIR/R9/a/f || error
918 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
922 mrename $DIR/R10/f $DIR/R10/g
923 $CHECKSTAT -t dir $DIR/R10 || error
924 $CHECKSTAT -a $DIR/R10/f || error
925 $CHECKSTAT -a $DIR/R10/g || error
927 run_test 24j "source does not exist ============================"
931 test_mkdir $DIR/R11a/d
933 mv $DIR/R11a/f $DIR/R11a/d
934 $CHECKSTAT -a $DIR/R11a/f || error
935 $CHECKSTAT -t file $DIR/R11a/d/f || error
937 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
939 # bug 2429 - rename foo foo foo creates invalid file
942 $MULTIOP $f OcNs || error
944 run_test 24l "Renaming a file to itself ========================"
948 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
949 # on ext3 this does not remove either the source or target files
950 # though the "expected" operation would be to remove the source
951 $CHECKSTAT -t file ${f} || error "${f} missing"
952 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
954 run_test 24m "Renaming a file to a hard link to itself ========="
958 # this stats the old file after it was renamed, so it should fail
962 $CHECKSTAT ${f}.rename
965 run_test 24n "Statting the old file after renaming (Posix rename 2)"
968 check_kernel_version 37 || return 0
969 test_mkdir -p $DIR/d24o
970 rename_many -s random -v -n 10 $DIR/d24o
972 run_test 24o "rename of files during htree split ==============="
977 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
978 mrename $DIR/R12a $DIR/R12b
979 $CHECKSTAT -a $DIR/R12a || error
980 $CHECKSTAT -t dir $DIR/R12b || error
981 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
982 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
984 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
986 cleanup_multiop_pause() {
992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
995 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
996 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
999 trap cleanup_multiop_pause EXIT
1000 mrename $DIR/R13a $DIR/R13b
1001 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1002 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1003 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1004 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1005 cleanup_multiop_pause
1006 wait $MULTIPID || error "multiop close failed"
1008 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1010 test_24r() { #bug 3789
1011 test_mkdir $DIR/R14a
1012 test_mkdir $DIR/R14a/b
1013 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1015 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1017 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1020 test_mkdir $DIR/R15a
1021 test_mkdir $DIR/R15a/b
1022 test_mkdir $DIR/R15a/b/c
1023 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1024 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1025 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1027 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1029 test_mkdir $DIR/R16a
1030 test_mkdir $DIR/R16a/b
1031 test_mkdir $DIR/R16a/b/c
1032 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1033 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1034 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1036 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1038 test_24u() { # bug12192
1040 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1041 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1043 run_test 24u "create stripe file"
1049 simple_cleanup_common() {
1052 wait_delete_completed
1055 max_pages_per_rpc() {
1056 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1060 local NRFILES=100000
1061 local FREE_INODES=$(mdt_free_inodes 0)
1062 [[ $FREE_INODES -lt $NRFILES ]] &&
1063 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1067 trap simple_cleanup_common EXIT
1069 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1070 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1073 createmany -m $DIR/$tdir/$tfile $NRFILES
1075 cancel_lru_locks mdc
1076 lctl set_param mdc.*.stats clear
1078 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1080 # LU-5 large readdir
1081 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1082 # 8 bytes for name(filename is mostly 5 in this test) +
1083 # 8 bytes for luda_type
1084 # take into account of overhead in lu_dirpage header and end mark in
1085 # each page, plus one in RPC_NUM calculation.
1087 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1088 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1089 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1090 awk '/^mds_readpage/ {print $2}')
1091 [[ $mds_readpage -gt $RPC_NUM ]] &&
1092 error "large readdir doesn't take effect"
1094 simple_cleanup_common
1096 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1098 test_24w() { # bug21506
1100 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1101 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1102 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1103 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1104 [ "$SZ1" = "$SZ2" ] || \
1105 error "Error reading at the end of the file $tfile"
1107 run_test 24w "Reading a file larger than 4Gb"
1110 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1113 local remote_dir=$DIR/$tdir/remote_dir
1116 $LFS mkdir -i $MDTIDX $remote_dir ||
1117 error "create remote directory failed"
1119 mkdir -p $DIR/$tdir/src_dir
1120 touch $DIR/$tdir/src_file
1121 mkdir -p $remote_dir/tgt_dir
1122 touch $remote_dir/tgt_file
1124 mrename $remote_dir $DIR/ &&
1125 error "rename dir cross MDT works!"
1127 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1128 error "rename dir cross MDT works!"
1130 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1131 error "rename file cross MDT works!"
1133 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1134 error "ln file cross MDT should not work!"
1136 rm -rf $DIR/$tdir || error "Can not delete directories"
1138 run_test 24x "cross rename/link should be failed"
1141 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1144 local remote_dir=$DIR/$tdir/remote_dir
1147 $LFS mkdir -i $MDTIDX $remote_dir ||
1148 error "create remote directory failed"
1150 mkdir -p $remote_dir/src_dir
1151 touch $remote_dir/src_file
1152 mkdir -p $remote_dir/tgt_dir
1153 touch $remote_dir/tgt_file
1155 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1156 error "rename subdir in the same remote dir failed!"
1158 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1159 error "rename files in the same remote dir failed!"
1161 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1162 error "link files in the same remote dir failed!"
1164 rm -rf $DIR/$tdir || error "Can not delete directories"
1166 run_test 24y "rename/link on the same dir should succeed"
1169 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1172 local remote_src=$DIR/$tdir/remote_dir
1173 local remote_tgt=$DIR/$tdir/remote_tgt
1176 $LFS mkdir -i $MDTIDX $remote_src ||
1177 error "create remote directory failed"
1179 $LFS mkdir -i $MDTIDX $remote_tgt ||
1180 error "create remote directory failed"
1182 mrename $remote_src $remote_tgt &&
1183 error "rename remote dirs should not work!"
1185 # If target dir does not exists, it should succeed
1187 mrename $remote_src $remote_tgt ||
1188 error "rename remote dirs(tgt dir does not exists) failed!"
1190 rm -rf $DIR/$tdir || error "Can not delete directories"
1192 run_test 24z "rename one remote dir to another remote dir should fail"
1194 test_24A() { # LU-3182
1199 createmany -m $DIR/$tdir/$tfile $NFILES
1200 local t=`ls $DIR/$tdir | wc -l`
1201 local u=`ls $DIR/$tdir | sort -u | wc -l`
1202 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1203 error "Expected $NFILES files, got $t ($u unique)"
1206 rm -rf $DIR/$tdir || error "Can not delete directories"
1208 run_test 24A "readdir() returns correct number of entries."
1211 echo '== symlink sanity ============================================='
1215 touch $DIR/s25/foo || error
1217 run_test 25a "create file in symlinked directory ==============="
1220 [ ! -d $DIR/d25 ] && test_25a
1221 $CHECKSTAT -t file $DIR/s25/foo || error
1223 run_test 25b "lookup file in symlinked directory ==============="
1227 test_mkdir $DIR/d26/d26-2
1228 ln -s d26/d26-2 $DIR/s26
1229 touch $DIR/s26/foo || error
1231 run_test 26a "multiple component symlink ======================="
1234 test_mkdir -p $DIR/d26b/d26-2
1235 ln -s d26b/d26-2/foo $DIR/s26-2
1236 touch $DIR/s26-2 || error
1238 run_test 26b "multiple component symlink at end of lookup ======"
1241 test_mkdir $DIR/d26.2
1242 touch $DIR/d26.2/foo
1243 ln -s d26.2 $DIR/s26.2-1
1244 ln -s s26.2-1 $DIR/s26.2-2
1245 ln -s s26.2-2 $DIR/s26.2-3
1246 chmod 0666 $DIR/s26.2-3/foo
1248 run_test 26c "chain of symlinks ================================"
1250 # recursive symlinks (bug 439)
1252 ln -s d26-3/foo $DIR/d26-3
1254 run_test 26d "create multiple component recursive symlink ======"
1257 [ ! -h $DIR/d26-3 ] && test_26d
1260 run_test 26e "unlink multiple component recursive symlink ======"
1262 # recursive symlinks (bug 7022)
1264 test_mkdir -p $DIR/$tdir
1265 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1266 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1267 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1268 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1269 cd $tfile || error "cd $tfile failed"
1270 ln -s .. dotdot || error "ln dotdot failed"
1271 ln -s dotdot/lndir lndir || error "ln lndir failed"
1272 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1273 output=`ls $tfile/$tfile/lndir/bar1`
1274 [ "$output" = bar1 ] && error "unexpected output"
1275 rm -r $tfile || error "rm $tfile failed"
1276 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1278 run_test 26f "rm -r of a directory which has recursive symlink ="
1281 echo '== stripe sanity =============================================='
1282 test_mkdir -p $DIR/d27 || error "mkdir failed"
1284 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1285 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1286 log "== test_27a: write to one stripe file ========================="
1287 cp /etc/hosts $DIR/d27/f0 || error
1289 run_test 27a "one stripe file =================================="
1292 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1293 test_mkdir -p $DIR/d27
1294 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1295 $GETSTRIPE -c $DIR/d27/f01
1296 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1297 error "two-stripe file doesn't have two stripes"
1299 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1301 run_test 27b "create and write to two stripe file"
1304 test_mkdir -p $DIR/d27
1305 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1306 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1307 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1309 run_test 27d "create file with default settings ================"
1312 test_mkdir -p $DIR/d27
1313 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1314 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1315 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1317 run_test 27e "setstripe existing file (should return error) ======"
1320 test_mkdir -p $DIR/d27
1321 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1322 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1323 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1325 run_test 27f "setstripe with bad stripe size (should return error)"
1328 test_mkdir -p $DIR/d27
1329 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1330 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1331 error "$DIR/d27/fnone has object"
1333 run_test 27g "$GETSTRIPE with no objects"
1336 touch $DIR/d27/fsome || error "touch failed"
1337 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1339 run_test 27i "$GETSTRIPE with some objects"
1342 test_mkdir -p $DIR/d27
1343 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1345 run_test 27j "setstripe with bad stripe offset (should return error)"
1347 test_27k() { # bug 2844
1348 test_mkdir -p $DIR/d27
1350 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1351 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1352 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1353 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1354 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1355 dd if=/dev/zero of=$FILE bs=4k count=1
1356 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1357 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1359 run_test 27k "limit i_blksize for broken user apps ============="
1362 test_mkdir -p $DIR/d27
1363 mcreate $DIR/f27l || error "creating file"
1364 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1365 error "setstripe should have failed" || true
1367 run_test 27l "check setstripe permissions (should return error)"
1370 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1372 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1373 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1376 trap simple_cleanup_common EXIT
1377 test_mkdir -p $DIR/$tdir
1378 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1379 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1380 error "dd should fill OST0"
1382 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1384 [ $i -gt 256 ] && break
1387 touch $DIR/$tdir/f27m_$i
1388 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1389 error "OST0 was full but new created file still use it"
1391 touch $DIR/$tdir/f27m_$i
1392 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1393 error "OST0 was full but new created file still use it"
1394 simple_cleanup_common
1396 run_test 27m "create file while OST0 was full =================="
1399 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1403 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1404 # if the OST isn't full anymore.
1406 local OSTIDX=${1:-""}
1408 local list=$(comma_list $(osts_nodes))
1409 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1411 do_nodes $list lctl set_param fail_loc=0
1412 sync # initiate all OST_DESTROYs from MDS to OST
1416 exhaust_precreations() {
1419 local FAILIDX=${3:-$OSTIDX}
1421 test_mkdir -p $DIR/$tdir
1422 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1423 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1425 local OST=$(ostname_from_index $OSTIDX)
1426 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1427 sed -e 's/_UUID$//;s/^.*-//')
1430 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1431 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1432 osc.$mdtosc_proc1.prealloc_last_id)
1433 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1434 osc.$mdtosc_proc1.prealloc_next_id)
1436 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1437 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1439 test_mkdir -p $DIR/$tdir/${OST}
1440 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1441 #define OBD_FAIL_OST_ENOSPC 0x215
1442 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1443 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1444 echo "Creating to objid $last_id on ost $OST..."
1445 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1446 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1447 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1451 exhaust_all_precreations() {
1453 for (( i=0; i < OSTCOUNT; i++ )) ; do
1454 exhaust_precreations $i $1 -1
1459 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1461 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1462 remote_ost_nodsh && skip "remote OST with nodsh" && return
1465 rm -f $DIR/$tdir/$tfile
1466 exhaust_precreations 0 0x80000215
1467 $SETSTRIPE -c -1 $DIR/$tdir
1468 touch $DIR/$tdir/$tfile || error
1469 $GETSTRIPE $DIR/$tdir/$tfile
1472 run_test 27n "create file with some full OSTs =================="
1475 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1478 remote_ost_nodsh && skip "remote OST with nodsh" && return
1481 rm -f $DIR/$tdir/$tfile
1482 exhaust_all_precreations 0x215
1484 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1489 run_test 27o "create file with all full OSTs (should error) ===="
1492 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1495 remote_ost_nodsh && skip "remote OST with nodsh" && return
1498 rm -f $DIR/$tdir/$tfile
1499 test_mkdir -p $DIR/$tdir
1501 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1502 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1503 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1505 exhaust_precreations 0 0x80000215
1506 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1507 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1508 $GETSTRIPE $DIR/$tdir/$tfile
1512 run_test 27p "append to a truncated file with some full OSTs ==="
1515 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1517 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1518 remote_ost_nodsh && skip "remote OST with nodsh" && return
1521 rm -f $DIR/$tdir/$tfile
1523 test_mkdir -p $DIR/$tdir
1524 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1525 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1526 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1528 exhaust_all_precreations 0x215
1530 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1531 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1535 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1538 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1541 remote_ost_nodsh && skip "remote OST with nodsh" && return
1544 rm -f $DIR/$tdir/$tfile
1545 exhaust_precreations 0 0x80000215
1547 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1551 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1553 test_27s() { # bug 10725
1554 test_mkdir -p $DIR/$tdir
1555 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1556 local stripe_count=0
1557 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1558 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1559 error "stripe width >= 2^32 succeeded" || true
1562 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1564 test_27t() { # bug 10864
1569 $WLFS getstripe $tfile
1572 run_test 27t "check that utils parse path correctly"
1574 test_27u() { # bug 4900
1575 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1576 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 local list=$(comma_list $(mdts_nodes))
1580 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1581 do_nodes $list $LCTL set_param fail_loc=0x139
1582 test_mkdir -p $DIR/$tdir
1584 createmany -o $DIR/$tdir/t- 1000
1585 do_nodes $list $LCTL set_param fail_loc=0
1587 TLOG=$DIR/$tfile.getstripe
1588 $GETSTRIPE $DIR/$tdir > $TLOG
1589 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1590 unlinkmany $DIR/$tdir/t- 1000
1591 [[ $OBJS -gt 0 ]] &&
1592 error "$OBJS objects created on OST-0. See $TLOG" || pass
1594 run_test 27u "skip object creation on OSC w/o objects =========="
1596 test_27v() { # bug 4900
1597 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1599 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1600 remote_ost_nodsh && skip "remote OST with nodsh" && return
1602 exhaust_all_precreations 0x215
1605 test_mkdir -p $DIR/$tdir
1606 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1608 touch $DIR/$tdir/$tfile
1609 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1611 for (( i=1; i < OSTCOUNT; i++ )); do
1612 do_facet ost$i lctl set_param fail_loc=0x705
1614 local START=`date +%s`
1615 createmany -o $DIR/$tdir/$tfile 32
1617 local FINISH=`date +%s`
1618 local TIMEOUT=`lctl get_param -n timeout`
1619 local PROCESS=$((FINISH - START))
1620 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1621 error "$FINISH - $START >= $TIMEOUT / 2"
1622 sleep $((TIMEOUT / 2 - PROCESS))
1625 run_test 27v "skip object creation on slow OST ================="
1627 test_27w() { # bug 10997
1628 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1629 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1630 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1631 error "stripe size $size != 65536" || true
1632 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1633 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1635 run_test 27w "check $SETSTRIPE -S option"
1638 [[ $OSTCOUNT -lt 2 ]] &&
1639 skip_env "skipping multiple stripe count/offset test" && return
1641 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1642 for i in $(seq 1 $OSTCOUNT); do
1644 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1645 error "setstripe -c $i -i $offset failed"
1646 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1647 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1648 [ $count -ne $i ] && error "stripe count $count != $i" || true
1649 [ $index -ne $offset ] &&
1650 error "stripe offset $index != $offset" || true
1653 run_test 27wa "check $SETSTRIPE -c -i options"
1656 remote_ost_nodsh && skip "remote OST with nodsh" && return
1657 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1659 OFFSET=$(($OSTCOUNT - 1))
1661 local OST=$(ostname_from_index $OSTIDX)
1663 test_mkdir -p $DIR/$tdir
1664 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1665 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1667 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1668 for i in `seq 0 $OFFSET`; do
1669 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1670 error "OST0 was degraded but new created file still use it"
1672 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1674 run_test 27x "create files while OST0 is degraded"
1677 [[ $OSTCOUNT -lt 2 ]] &&
1678 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1679 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1680 remote_ost_nodsh && skip "remote OST with nodsh" && return
1681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1683 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1684 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1685 osc.$mdtosc.prealloc_last_id)
1686 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1687 osc.$mdtosc.prealloc_next_id)
1688 local fcount=$((last_id - next_id))
1689 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1690 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1692 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1693 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1694 local OST_DEACTIVE_IDX=-1
1699 for OSC in $MDS_OSCS; do
1700 OST=$(osc_to_ost $OSC)
1701 OSTIDX=$(index_from_ostuuid $OST)
1702 if [ $OST_DEACTIVE_IDX == -1 ]; then
1703 OST_DEACTIVE_IDX=$OSTIDX
1705 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1706 echo $OSC "is Deactivated:"
1707 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1711 OSTIDX=$(index_from_ostuuid $OST)
1713 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1715 for OSC in $MDS_OSCS; do
1716 OST=$(osc_to_ost $OSC)
1717 OSTIDX=$(index_from_ostuuid $OST)
1718 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1719 echo $OST "is degraded:"
1720 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1721 obdfilter.$OST.degraded=1
1726 createmany -o $DIR/$tdir/$tfile $fcount
1728 for OSC in $MDS_OSCS; do
1729 OST=$(osc_to_ost $OSC)
1730 OSTIDX=$(index_from_ostuuid $OST)
1731 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1732 echo $OST "is recovered from degraded:"
1733 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1734 obdfilter.$OST.degraded=0
1736 do_facet $SINGLEMDS lctl --device %$OSC activate
1740 # all osp devices get activated, hence -1 stripe count restored
1743 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1744 # devices get activated.
1746 $SETSTRIPE -c -1 $DIR/$tfile
1747 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1749 [ $stripecnt -ne $OSTCOUNT ] &&
1750 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1753 run_test 27y "create files while OST0 is degraded and the rest inactive"
1759 lmm_count=$($GETSTRIPE -c $1)
1760 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1761 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1763 local old_ifs="$IFS"
1765 fid=($($LFS path2fid $1))
1768 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1769 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1771 # compare lmm_seq and lu_fid->f_seq
1772 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1773 # compare lmm_object_id and lu_fid->oid
1774 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1776 # check the trusted.fid attribute of the OST objects of the file
1777 local have_obdidx=false
1779 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1780 # skip lines up to and including "obdidx"
1781 [ -z "$obdidx" ] && break
1782 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1783 $have_obdidx || continue
1785 local ost=$((obdidx + 1))
1786 local dev=$(ostdevname $ost)
1789 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1791 seq=$(echo $seq | sed -e "s/^0x//g")
1792 if [ $seq == 0 ]; then
1793 oid_hex=$(echo $oid)
1795 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1797 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1801 # Don't unmount/remount the OSTs if we don't need to do that.
1802 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1803 # update too, until that use mount/ll_decode_filter_fid/mount.
1804 # Re-enable when debugfs will understand new filter_fid.
1806 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1807 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1808 $dev 2>/dev/null" | grep "parent=")
1811 mount_fstype ost$ost
1812 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1813 $(facet_mntpt ost$ost)/$obj_file)
1814 unmount_fstype ost$ost
1815 start ost$ost $dev $OST_MOUNT_OPTS
1818 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1820 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1822 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1823 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1824 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1825 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1826 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1828 if echo $ff_parent | grep -q 'stripe='; then
1829 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1832 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1833 # into f_ver in this case. See the comment on
1836 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1840 # compare lmm_seq and filter_fid->ff_parent.f_seq
1841 [ $ff_pseq = $lmm_seq ] ||
1842 error "FF parent SEQ $ff_pseq != $lmm_seq"
1843 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1844 [ $ff_poid = $lmm_oid ] ||
1845 error "FF parent OID $ff_poid != $lmm_oid"
1846 (($ff_pstripe == $stripe_nr)) ||
1847 error "FF stripe $ff_pstripe != $stripe_nr"
1849 stripe_nr=$((stripe_nr + 1))
1854 remote_ost_nodsh && skip "remote OST with nodsh" && return
1855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1856 test_mkdir -p $DIR/$tdir
1858 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1859 { error "setstripe -c -1 failed"; return 1; }
1860 # We need to send a write to every object to get parent FID info set.
1861 # This _should_ also work for setattr, but does not currently.
1862 # touch $DIR/$tdir/$tfile-1 ||
1863 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1864 { error "dd $tfile-1 failed"; return 2; }
1865 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1866 { error "setstripe -c -1 failed"; return 3; }
1867 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1868 { error "dd $tfile-2 failed"; return 4; }
1870 # make sure write RPCs have been sent to OSTs
1873 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1874 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1876 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1878 test_27A() { # b=19102
1879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1880 local restore_size=$($GETSTRIPE -S $MOUNT)
1881 local restore_count=$($GETSTRIPE -c $MOUNT)
1882 local restore_offset=$($GETSTRIPE -i $MOUNT)
1883 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1884 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1885 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1886 local default_size=$($GETSTRIPE -S $MOUNT)
1887 local default_offset=$($GETSTRIPE -i $MOUNT)
1888 local dsize=$((1024 * 1024))
1889 [ $default_size -eq $dsize ] ||
1890 error "stripe size $default_size != $dsize"
1891 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1892 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1894 run_test 27A "check filesystem-wide default LOV EA values"
1896 test_27B() { # LU-2523
1897 test_mkdir -p $DIR/$tdir
1898 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1900 # open f1 with O_LOV_DELAY_CREATE
1902 # call setstripe ioctl on open file descriptor for f1
1904 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1908 # open f1 with O_LOV_DELAY_CREATE
1910 # call setstripe ioctl on open file descriptor for f1
1912 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1914 # Allow multiop to fail in imitation of NFS's busted semantics.
1917 run_test 27B "call setstripe on open unlinked file/rename victim"
1919 test_27C() { #LU-2871
1920 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1928 test_mkdir -p $DIR/$tdir
1930 for i in $(seq 0 $((OSTCOUNT - 1))); do
1931 # set stripe across all OSTs starting from OST$i
1932 $SETSTRIPE -i $i -c -1 $tfile$i
1933 # get striping information
1934 ost_idx=($($GETSTRIPE $tfile$i |
1935 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1939 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1940 error "${#ost_idx[@]} != $OSTCOUNT"
1942 for index in $(seq 0 $((OSTCOUNT - 1))); do
1944 for j in $(echo ${ost_idx[@]}); do
1945 if [ $index -eq $j ]; then
1951 error "Can not find $index in ${ost_idx[@]}"
1955 run_test 27C "check full striping across all OSTs"
1957 # createtest also checks that device nodes are created and
1958 # then visible correctly (#2091)
1959 test_28() { # bug 2091
1961 $CREATETEST $DIR/d28/ct || error
1963 run_test 28 "create/mknod/mkdir with bad file types ============"
1966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1967 cancel_lru_locks mdc
1973 declare -i LOCKCOUNTORIG=0
1974 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1975 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1977 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1979 declare -i LOCKUNUSEDCOUNTORIG=0
1980 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1981 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1988 declare -i LOCKCOUNTCURRENT=0
1989 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1990 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1993 declare -i LOCKUNUSEDCOUNTCURRENT=0
1994 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1995 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1998 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
1999 $LCTL set_param -n ldlm.dump_namespaces ""
2000 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2001 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2002 log "dumped log to $TMP/test_29.dk (bug 5793)"
2005 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2006 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2007 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2008 log "dumped log to $TMP/test_29.dk (bug 5793)"
2012 run_test 29 "IT_GETATTR regression ============================"
2014 test_30a() { # was test_30
2015 cp $(which ls) $DIR || cp /bin/ls $DIR
2019 run_test 30a "execute binary from Lustre (execve) =============="
2022 cp `which ls` $DIR || cp /bin/ls $DIR
2024 $RUNAS $DIR/ls / || error
2027 run_test 30b "execute binary from Lustre as non-root ==========="
2029 test_30c() { # b=22376
2030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2031 cp `which ls` $DIR || cp /bin/ls $DIR
2033 cancel_lru_locks mdc
2034 cancel_lru_locks osc
2035 $RUNAS $DIR/ls / || error
2038 run_test 30c "execute binary from Lustre without read perms ===="
2041 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2042 $CHECKSTAT -a $DIR/f31 || error
2044 run_test 31a "open-unlink file =================================="
2047 touch $DIR/f31 || error
2048 ln $DIR/f31 $DIR/f31b || error
2049 $MULTIOP $DIR/f31b Ouc || error
2050 $CHECKSTAT -t file $DIR/f31 || error
2052 run_test 31b "unlink file with multiple links while open ======="
2055 touch $DIR/f31 || error
2056 ln $DIR/f31 $DIR/f31c || error
2057 multiop_bg_pause $DIR/f31 O_uc || return 1
2059 $MULTIOP $DIR/f31c Ouc
2060 kill -USR1 $MULTIPID
2063 run_test 31c "open-unlink file with multiple links ============="
2066 opendirunlink $DIR/d31d $DIR/d31d || error
2067 $CHECKSTAT -a $DIR/d31d || error
2069 run_test 31d "remove of open directory ========================="
2071 test_31e() { # bug 2904
2072 check_kernel_version 34 || return 0
2073 openfilleddirunlink $DIR/d31e || error
2075 run_test 31e "remove of open non-empty directory ==============="
2077 test_31f() { # bug 4554
2078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2080 test_mkdir $DIR/d31f
2081 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2082 cp /etc/hosts $DIR/d31f
2084 $GETSTRIPE $DIR/d31f/hosts
2085 multiop_bg_pause $DIR/d31f D_c || return 1
2088 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2089 test_mkdir $DIR/d31f
2090 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2091 cp /etc/hosts $DIR/d31f
2093 $GETSTRIPE $DIR/d31f/hosts
2094 multiop_bg_pause $DIR/d31f D_c || return 1
2097 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2098 wait $MULTIPID || error "first opendir $MULTIPID failed"
2102 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2103 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2106 run_test 31f "remove of open directory with open-unlink file ==="
2109 echo "-- cross directory link --"
2110 test_mkdir -c1 $DIR/${tdir}ga
2111 test_mkdir -c1 $DIR/${tdir}gb
2112 touch $DIR/${tdir}ga/f
2113 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2114 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2115 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2116 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2117 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2119 run_test 31g "cross directory link==============="
2122 echo "-- cross directory link --"
2123 test_mkdir -c1 $DIR/${tdir}
2124 test_mkdir -c1 $DIR/${tdir}/dir
2125 touch $DIR/${tdir}/f
2126 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2127 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2128 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2129 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2130 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2132 run_test 31h "cross directory link under child==============="
2135 echo "-- cross directory link --"
2136 test_mkdir -c1 $DIR/$tdir
2137 test_mkdir -c1 $DIR/$tdir/dir
2138 touch $DIR/$tdir/dir/f
2139 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2140 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2141 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2142 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2143 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2145 run_test 31i "cross directory link under parent==============="
2148 test_mkdir -c1 -p $DIR/$tdir
2149 test_mkdir -c1 -p $DIR/$tdir/dir1
2150 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2151 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2152 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2153 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2156 run_test 31j "link for directory==============="
2159 test_mkdir -c1 -p $DIR/$tdir
2161 touch $DIR/$tdir/exist
2162 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2163 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2164 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2165 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2166 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2167 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2168 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2171 run_test 31k "link to file: the same, non-existing, dir==============="
2177 touch $DIR/d31m2/exist
2178 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2179 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2180 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2181 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2182 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2183 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2186 run_test 31m "link to file: the same, non-existing, dir==============="
2189 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2190 nlink=$(stat --format=%h $DIR/$tfile)
2191 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2193 local cmd="exec $fd<$DIR/$tfile"
2196 trap "eval $cmd" EXIT
2197 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2198 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2199 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2200 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2201 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2204 run_test 31n "check link count of unlinked file"
2207 local TEMPNAME=$(mktemp $1_XXXXXX)
2208 mlink $TEMPNAME $1 2> /dev/null &&
2209 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2213 test_31o() { # LU-2901
2215 for LOOP in $(seq 100); do
2216 rm -f $DIR/$tdir/$tfile*
2217 for THREAD in $(seq 8); do
2218 link_one $DIR/$tdir/$tfile.$LOOP &
2221 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2222 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2223 error "$LINKS duplicate links to $tfile.$LOOP" &&
2227 run_test 31o "duplicate hard links with same filename"
2230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2233 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2234 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2236 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2237 error "open unlink test1 failed"
2238 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2239 error "open unlink test2 failed"
2241 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2242 error "test1 still exists"
2243 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2244 error "test2 still exists"
2246 run_test 31p "remove of open striped directory"
2248 cleanup_test32_mount() {
2250 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2255 echo "== more mountpoints and symlinks ================="
2256 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2257 trap cleanup_test32_mount EXIT
2258 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2259 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2260 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2261 cleanup_test32_mount
2263 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2267 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2268 trap cleanup_test32_mount EXIT
2269 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2270 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2271 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2272 cleanup_test32_mount
2274 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2278 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2279 trap cleanup_test32_mount EXIT
2280 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2281 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2282 test_mkdir -p $DIR/$tdir/d2/test_dir
2283 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2284 cleanup_test32_mount
2286 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2290 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2291 trap cleanup_test32_mount EXIT
2292 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2293 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2294 test_mkdir -p $DIR/$tdir/d2/test_dir
2295 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2296 cleanup_test32_mount
2298 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2301 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2302 test_mkdir -p $DIR/d32e/tmp
2303 TMP_DIR=$DIR/d32e/tmp
2304 ln -s $DIR/d32e $TMP_DIR/symlink11
2305 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2306 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2307 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2309 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2312 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2313 test_mkdir -p $DIR/d32f/tmp
2314 TMP_DIR=$DIR/d32f/tmp
2315 ln -s $DIR/d32f $TMP_DIR/symlink11
2316 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2317 ls $DIR/d32f/tmp/symlink11 || error
2318 ls $DIR/d32f/symlink01 || error
2320 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2323 TMP_DIR=$DIR/$tdir/tmp
2324 test_mkdir -p $DIR/$tdir/tmp
2325 test_mkdir $DIR/${tdir}2
2326 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2327 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2328 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2329 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2330 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2331 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2333 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2336 rm -fr $DIR/$tdir $DIR/${tdir}2
2337 TMP_DIR=$DIR/$tdir/tmp
2338 test_mkdir -p $DIR/$tdir/tmp
2339 test_mkdir $DIR/${tdir}2
2340 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2341 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2342 ls $TMP_DIR/symlink12 || error
2343 ls $DIR/$tdir/symlink02 || error
2345 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2349 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2350 trap cleanup_test32_mount EXIT
2351 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2352 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2353 touch $DIR/$tdir/test_file
2354 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2355 cleanup_test32_mount
2357 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2361 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2362 trap cleanup_test32_mount EXIT
2363 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2364 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2365 touch $DIR/$tdir/test_file
2366 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2367 cleanup_test32_mount
2369 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2374 trap cleanup_test32_mount EXIT
2375 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2376 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2377 test_mkdir -p $DIR/$tdir/d2
2378 touch $DIR/$tdir/d2/test_file || error
2379 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2380 cleanup_test32_mount
2382 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2387 trap cleanup_test32_mount EXIT
2388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2390 test_mkdir -p $DIR/$tdir/d2
2391 touch $DIR/$tdir/d2/test_file
2392 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2393 cleanup_test32_mount
2395 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2399 test_mkdir -p $DIR/d32m/tmp
2400 TMP_DIR=$DIR/d32m/tmp
2401 ln -s $DIR $TMP_DIR/symlink11
2402 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2403 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2404 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2406 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2410 test_mkdir -p $DIR/d32n/tmp
2411 TMP_DIR=$DIR/d32n/tmp
2412 ln -s $DIR $TMP_DIR/symlink11
2413 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2414 ls -l $DIR/d32n/tmp/symlink11 || error
2415 ls -l $DIR/d32n/symlink01 || error
2417 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2420 rm -fr $DIR/d32o $DIR/$tfile
2422 test_mkdir -p $DIR/d32o/tmp
2423 TMP_DIR=$DIR/d32o/tmp
2424 ln -s $DIR/$tfile $TMP_DIR/symlink12
2425 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2426 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2427 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2428 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2429 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2431 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2441 test_mkdir -p $DIR/d32p/tmp
2443 TMP_DIR=$DIR/d32p/tmp
2445 ln -s $DIR/$tfile $TMP_DIR/symlink12
2447 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2449 cat $DIR/d32p/tmp/symlink12 || error
2451 cat $DIR/d32p/symlink02 || error
2454 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2456 cleanup_testdir_mount() {
2458 $UMOUNT -d $DIR/$tdir
2462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2463 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2464 trap cleanup_testdir_mount EXIT
2465 test_mkdir -p $DIR/$tdir
2466 touch $DIR/$tdir/under_the_mount
2467 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2468 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2469 cleanup_testdir_mount
2471 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2476 trap cleanup_testdir_mount EXIT
2477 test_mkdir -p $DIR/$tdir
2478 touch $DIR/$tdir/under_the_mount
2479 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2480 ls $DIR/$tdir | grep -q under_the_mount && error || true
2481 cleanup_testdir_mount
2483 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2488 chmod 444 $DIR/$tfile
2489 chown $RUNAS_ID $DIR/$tfile
2491 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2494 run_test 33aa "write file with mode 444 (should return error) ===="
2498 test_mkdir -p $DIR/d33
2499 chown $RUNAS_ID $DIR/d33
2500 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2501 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2502 error "open RDWR" || true
2504 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2508 test_mkdir -p $DIR/d33
2509 chown $RUNAS_ID $DIR/d33
2510 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2512 run_test 33b "test open file with malformed flags (No panic and return error)"
2515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2521 remote_ost_nodsh && skip "remote OST with nodsh" && return
2524 test_mkdir -p $DIR/d33
2525 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2528 for ostnum in $(seq $OSTCOUNT); do
2529 # test-framework's OST numbering is one-based, while Lustre's
2531 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2532 # Parsing llobdstat's output sucks; we could grep the /proc
2533 # path, but that's likely to not be as portable as using the
2534 # llobdstat utility. So we parse lctl output instead.
2535 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2536 obdfilter/$ostname/stats |
2537 awk '/^write_bytes/ {print $7}' )
2538 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2539 if (( ${write_bytes:-0} > 0 ))
2546 $all_zeros || return 0
2549 echo foo > $DIR/d33/bar
2553 # Total up write_bytes after writing. We'd better find non-zeros.
2554 for ostnum in $(seq $OSTCOUNT); do
2555 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2556 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2557 obdfilter/$ostname/stats |
2558 awk '/^write_bytes/ {print $7}' )
2559 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2560 if (( ${write_bytes:-0} > 0 ))
2569 for ostnum in $(seq $OSTCOUNT); do
2570 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2571 echo "Check that write_bytes is present in obdfilter/*/stats:"
2572 do_facet ost$ostnum lctl get_param -n \
2573 obdfilter/$ostname/stats
2575 error "OST not keeping write_bytes stats (b22312)"
2578 run_test 33c "test llobdstat and write_bytes"
2581 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 local remote_dir=$DIR/$tdir/remote_dir
2587 $LFS mkdir -i $MDTIDX $remote_dir ||
2588 error "create remote directory failed"
2590 touch $remote_dir/$tfile
2591 chmod 444 $remote_dir/$tfile
2592 chown $RUNAS_ID $remote_dir/$tfile
2594 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2596 chown $RUNAS_ID $remote_dir
2597 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2598 error "create" || true
2599 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2600 error "open RDWR" || true
2601 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2602 error "create" || true
2604 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2606 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2609 $MCREATE $DIR/f34 || error
2610 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2611 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2612 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2613 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2615 run_test 34a "truncate file that has not been opened ==========="
2618 [ ! -f $DIR/f34 ] && test_34a
2619 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2620 $OPENFILE -f O_RDONLY $DIR/f34
2621 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2622 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2624 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2627 [ ! -f $DIR/f34 ] && test_34a
2628 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2629 $OPENFILE -f O_RDWR $DIR/f34
2630 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2631 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2633 run_test 34c "O_RDWR opening file-with-size works =============="
2636 [ ! -f $DIR/f34 ] && test_34a
2637 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2638 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2641 run_test 34d "write to sparse file ============================="
2645 $MCREATE $DIR/f34e || error
2646 $TRUNCATE $DIR/f34e 1000 || error
2647 $CHECKSTAT -s 1000 $DIR/f34e || error
2648 $OPENFILE -f O_RDWR $DIR/f34e
2649 $CHECKSTAT -s 1000 $DIR/f34e || error
2651 run_test 34e "create objects, some with size and some without =="
2653 test_34f() { # bug 6242, 6243
2654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2657 $MCREATE $DIR/f34f || error
2658 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2659 dd if=$DIR/f34f of=$TMP/f34f
2660 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2661 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2662 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2663 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2664 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2666 run_test 34f "read from a file with no objects until EOF ======="
2669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2670 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2671 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2672 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2673 cancel_lru_locks osc
2674 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2675 error "wrong size after lock cancel"
2677 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2678 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2679 error "expanding truncate failed"
2680 cancel_lru_locks osc
2681 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2682 error "wrong expanded size after lock cancel"
2684 run_test 34g "truncate long file ==============================="
2687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2691 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2692 sync # Flush the cache so that multiop below does not block on cache
2693 # flush when getting the group lock
2694 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2697 # Since just timed wait is not good enough, let's do a sync write
2698 # that way we are sure enough time for a roundtrip + processing
2699 # passed + 2 seconds of extra margin.
2700 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2704 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2705 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2709 local nsz=`stat -c %s $DIR/$tfile`
2710 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2712 run_test 34h "ftruncate file under grouplock should not block"
2715 cp /bin/sh $DIR/f35a
2717 chown $RUNAS_ID $DIR/f35a
2718 $RUNAS $DIR/f35a && error || true
2721 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2725 utime $DIR/f36 || error
2727 run_test 36a "MDS utime check (mknod, utime) ==================="
2731 utime $DIR/f36 || error
2733 run_test 36b "OST utime check (open, utime) ===================="
2738 chown $RUNAS_ID $DIR/d36
2739 $RUNAS utime $DIR/d36/f36 || error
2741 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2744 [ ! -d $DIR/d36 ] && test_36c
2745 echo "" > $DIR/d36/f36
2746 $RUNAS utime $DIR/d36/f36 || error
2748 run_test 36d "non-root OST utime check (open, utime) ==========="
2751 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2752 test_mkdir -p $DIR/$tdir
2753 touch $DIR/$tdir/$tfile
2754 $RUNAS utime $DIR/$tdir/$tfile && \
2755 error "utime worked, expected failure" || true
2757 run_test 36e "utime on non-owned file (should return error) ===="
2761 local LANG_SAVE=$LANG
2762 local LC_LANG_SAVE=$LC_LANG
2763 export LANG=C LC_LANG=C # for date language
2765 DATESTR="Dec 20 2000"
2766 test_mkdir -p $DIR/$tdir
2767 lctl set_param fail_loc=$fl
2769 cp /etc/hosts $DIR/$tdir/$tfile
2770 sync & # write RPC generated with "current" inode timestamp, but delayed
2772 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2773 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2774 cancel_lru_locks osc
2775 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2777 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2778 echo "BEFORE: $LS_BEFORE" && \
2779 echo "AFTER : $LS_AFTER" && \
2780 echo "WANT : $DATESTR" && \
2781 error "$DIR/$tdir/$tfile timestamps changed" || true
2783 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2788 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2789 subr_36fh "0x80000214"
2791 run_test 36f "utime on file racing with OST BRW write =========="
2794 remote_ost_nodsh && skip "remote OST with nodsh" && return
2795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2800 test_mkdir -p $DIR/$tdir
2801 fmd_max_age=$(do_facet ost1 \
2802 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2805 fmd_before=$(do_facet ost1 \
2806 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2807 touch $DIR/$tdir/$tfile
2808 sleep $((fmd_max_age + 12))
2809 fmd_after=$(do_facet ost1 \
2810 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2812 echo "fmd_before: $fmd_before"
2813 echo "fmd_after: $fmd_after"
2814 [[ $fmd_after -gt $fmd_before ]] &&
2815 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2816 error "fmd didn't expire after ping" || true
2818 run_test 36g "filter mod data cache expiry ====================="
2821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2822 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2823 subr_36fh "0x80000227"
2825 run_test 36h "utime on file racing with OST BRW write =========="
2828 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2831 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2833 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2834 local new_mtime=$((mtime + 200))
2836 #change Modify time of striped dir
2837 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2838 error "change mtime failed"
2840 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2842 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2844 run_test 36i "change mtime on striped directory"
2846 # test_37 - duplicate with tests 32q 32r
2849 local file=$DIR/$tfile
2851 openfile -f O_DIRECTORY $file
2854 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2855 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2857 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2861 touch $DIR/${tfile}2
2862 # ls -l $DIR/$tfile $DIR/${tfile}2
2863 # ls -lu $DIR/$tfile $DIR/${tfile}2
2864 # ls -lc $DIR/$tfile $DIR/${tfile}2
2866 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2867 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2869 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2871 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2873 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2874 error "O_TRUNC didn't change timestamps"
2877 run_test 39 "mtime changed on create ==========================="
2880 test_mkdir -p -c1 $DIR/$tdir
2881 cp -p /etc/passwd $DIR/$tdir/fopen
2882 cp -p /etc/passwd $DIR/$tdir/flink
2883 cp -p /etc/passwd $DIR/$tdir/funlink
2884 cp -p /etc/passwd $DIR/$tdir/frename
2885 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2888 echo "aaaaaa" >> $DIR/$tdir/fopen
2889 echo "aaaaaa" >> $DIR/$tdir/flink
2890 echo "aaaaaa" >> $DIR/$tdir/funlink
2891 echo "aaaaaa" >> $DIR/$tdir/frename
2893 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2894 local link_new=`stat -c %Y $DIR/$tdir/flink`
2895 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2896 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2898 cat $DIR/$tdir/fopen > /dev/null
2899 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2900 rm -f $DIR/$tdir/funlink2
2901 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2903 for (( i=0; i < 2; i++ )) ; do
2904 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2905 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2906 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2907 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2909 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2910 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2911 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2912 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2914 cancel_lru_locks osc
2915 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2918 run_test 39b "mtime change on open, link, unlink, rename ======"
2920 # this should be set to past
2921 TEST_39_MTIME=`date -d "1 year ago" +%s`
2927 local mtime0=`stat -c %Y $DIR1/$tfile`
2929 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2930 local mtime1=`stat -c %Y $DIR1/$tfile`
2931 [ "$mtime1" = $TEST_39_MTIME ] || \
2932 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2935 echo hello >> $DIR1/$tfile
2937 local mtime2=`stat -c %Y $DIR1/$tfile`
2938 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2939 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2941 mv $DIR1/$tfile $DIR1/$tfile-1
2943 for (( i=0; i < 2; i++ )) ; do
2944 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2945 [ "$mtime2" = "$mtime3" ] || \
2946 error "mtime ($mtime2) changed (to $mtime3) on rename"
2948 cancel_lru_locks osc
2949 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2952 run_test 39c "mtime change on rename ==========================="
2956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2959 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2961 for (( i=0; i < 2; i++ )) ; do
2962 local mtime=`stat -c %Y $DIR1/$tfile`
2963 [ $mtime = $TEST_39_MTIME ] || \
2964 error "mtime($mtime) is not set to $TEST_39_MTIME"
2966 cancel_lru_locks osc
2967 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2970 run_test 39d "create, utime, stat =============================="
2974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2976 local mtime1=`stat -c %Y $DIR1/$tfile`
2978 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2980 for (( i=0; i < 2; i++ )) ; do
2981 local mtime2=`stat -c %Y $DIR1/$tfile`
2982 [ $mtime2 = $TEST_39_MTIME ] || \
2983 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2985 cancel_lru_locks osc
2986 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2989 run_test 39e "create, stat, utime, stat ========================"
2993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2995 mtime1=`stat -c %Y $DIR1/$tfile`
2998 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3000 for (( i=0; i < 2; i++ )) ; do
3001 local mtime2=`stat -c %Y $DIR1/$tfile`
3002 [ $mtime2 = $TEST_39_MTIME ] || \
3003 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3005 cancel_lru_locks osc
3006 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3009 run_test 39f "create, stat, sleep, utime, stat ================="
3013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3014 echo hello >> $DIR1/$tfile
3015 local mtime1=`stat -c %Y $DIR1/$tfile`
3018 chmod o+r $DIR1/$tfile
3020 for (( i=0; i < 2; i++ )) ; do
3021 local mtime2=`stat -c %Y $DIR1/$tfile`
3022 [ "$mtime1" = "$mtime2" ] || \
3023 error "lost mtime: $mtime2, should be $mtime1"
3025 cancel_lru_locks osc
3026 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3029 run_test 39g "write, chmod, stat ==============================="
3033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3038 echo hello >> $DIR1/$tfile
3039 local mtime1=`stat -c %Y $DIR1/$tfile`
3041 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3043 if [ "$d1" != "$d2" ]; then
3044 echo "write and touch not within one second"
3046 for (( i=0; i < 2; i++ )) ; do
3047 local mtime2=`stat -c %Y $DIR1/$tfile`
3048 [ "$mtime2" = $TEST_39_MTIME ] || \
3049 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3051 cancel_lru_locks osc
3052 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3056 run_test 39h "write, utime within one second, stat ============="
3059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3063 echo hello >> $DIR1/$tfile
3064 local mtime1=`stat -c %Y $DIR1/$tfile`
3066 mv $DIR1/$tfile $DIR1/$tfile-1
3068 for (( i=0; i < 2; i++ )) ; do
3069 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3071 [ "$mtime1" = "$mtime2" ] || \
3072 error "lost mtime: $mtime2, should be $mtime1"
3074 cancel_lru_locks osc
3075 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3078 run_test 39i "write, rename, stat =============================="
3081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3082 start_full_debug_logging
3086 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3087 lctl set_param fail_loc=0x80000412
3088 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3089 error "multiop failed"
3091 local mtime1=`stat -c %Y $DIR1/$tfile`
3093 mv $DIR1/$tfile $DIR1/$tfile-1
3095 kill -USR1 $multipid
3096 wait $multipid || error "multiop close failed"
3098 for (( i=0; i < 2; i++ )) ; do
3099 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3100 [ "$mtime1" = "$mtime2" ] ||
3101 error "mtime is lost on close: $mtime2, " \
3104 cancel_lru_locks osc
3105 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3107 lctl set_param fail_loc=0
3108 stop_full_debug_logging
3110 run_test 39j "write, rename, close, stat ======================="
3113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3117 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3119 local mtime1=`stat -c %Y $DIR1/$tfile`
3121 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3123 kill -USR1 $multipid
3124 wait $multipid || error "multiop close failed"
3126 for (( i=0; i < 2; i++ )) ; do
3127 local mtime2=`stat -c %Y $DIR1/$tfile`
3129 [ "$mtime2" = $TEST_39_MTIME ] || \
3130 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3132 cancel_lru_locks osc
3133 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3136 run_test 39k "write, utime, close, stat ========================"
3138 # this should be set to future
3139 TEST_39_ATIME=`date -d "1 year" +%s`
3142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3143 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3144 local atime_diff=$(do_facet $SINGLEMDS \
3145 lctl get_param -n mdd.*MDT0000*.atime_diff)
3149 # test setting directory atime to future
3150 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3151 local atime=$(stat -c %X $DIR/$tdir)
3152 [ "$atime" = $TEST_39_ATIME ] || \
3153 error "atime is not set to future: $atime, $TEST_39_ATIME"
3155 # test setting directory atime from future to now
3156 local d1=$(date +%s)
3158 local d2=$(date +%s)
3160 cancel_lru_locks mdc
3161 atime=$(stat -c %X $DIR/$tdir)
3162 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3163 error "atime is not updated from future: $atime, $d1<atime<$d2"
3165 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3168 # test setting directory atime when now > dir atime + atime_diff
3172 cancel_lru_locks mdc
3173 atime=$(stat -c %X $DIR/$tdir)
3174 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3175 error "atime is not updated : $atime, should be $d2"
3177 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3180 # test not setting directory atime when now < dir atime + atime_diff
3182 cancel_lru_locks mdc
3183 atime=$(stat -c %X $DIR/$tdir)
3184 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3185 error "atime is updated to $atime, should remain $d1<atime<$d2"
3187 do_facet $SINGLEMDS \
3188 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3190 run_test 39l "directory atime update ==========================="
3193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3196 local far_past_mtime=$(date -d "May 29 1953" +%s)
3197 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3199 touch -m -d @$far_past_mtime $DIR1/$tfile
3200 touch -a -d @$far_past_atime $DIR1/$tfile
3202 for (( i=0; i < 2; i++ )) ; do
3203 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3204 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3205 error "atime or mtime set incorrectly"
3207 cancel_lru_locks osc
3208 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3211 run_test 39m "test atime and mtime before 1970"
3213 test_39n() { # LU-3832
3214 local atime_diff=$(do_facet $SINGLEMDS \
3215 lctl get_param -n mdd.*MDT0000*.atime_diff)
3220 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3223 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3224 atime0=$(stat -c %X $DIR/$tfile)
3227 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3228 atime1=$(stat -c %X $DIR/$tfile)
3231 cancel_lru_locks mdc
3232 cancel_lru_locks osc
3233 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3234 atime2=$(stat -c %X $DIR/$tfile)
3236 do_facet $SINGLEMDS \
3237 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3239 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3240 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3242 run_test 39n "check that O_NOATIME is honored"
3245 TESTDIR=$DIR/$tdir/$tfile
3246 [ -e $TESTDIR ] && rm -rf $TESTDIR
3247 test_mkdir -p $TESTDIR
3253 links2=$(stat -c %h .)
3254 [ $(($links1 + 2)) != $links2 ] &&
3255 error "wrong links count $(($links1 + 2)) != $links2"
3257 links3=$(stat -c %h .)
3258 [ $(($links1 + 1)) != $links3 ] &&
3259 error "wrong links count $links1 != $links3"
3262 run_test 39o "directory cached attributes updated after create ========"
3265 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3267 TESTDIR=$DIR/$tdir/$tfile
3268 [ -e $TESTDIR ] && rm -rf $TESTDIR
3273 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3274 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3276 links2=$(stat -c %h .)
3277 [ $(($links1 + 2)) != $links2 ] &&
3278 error "wrong links count $(($links1 + 2)) != $links2"
3280 links3=$(stat -c %h .)
3281 [ $(($links1 + 1)) != $links3 ] &&
3282 error "wrong links count $links1 != $links3"
3285 run_test 39p "remote directory cached attributes updated after create ========"
3289 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3290 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3291 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3292 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3293 error "$tfile is not 4096 bytes in size"
3295 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3299 small_write $DIR/f41 18
3301 run_test 41 "test small file write + fstat ====================="
3303 count_ost_writes() {
3304 lctl get_param -n osc.*.stats |
3305 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3306 END { printf("%0.0f", writes) }'
3313 BG_DIRTY_RATIO_SAVE=10
3314 MAX_BG_DIRTY_RATIO=25
3318 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3319 # dirty_ratio, dirty_background_ratio
3320 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3321 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3322 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3323 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3325 # if file not here, we are a 2.4 kernel
3326 kill -CONT `pidof kupdated`
3331 # setup the trap first, so someone cannot exit the test at the
3332 # exact wrong time and mess up a machine
3333 trap start_writeback EXIT
3334 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3335 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3336 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3337 sysctl -w vm.dirty_writeback_centisecs=0
3338 sysctl -w vm.dirty_writeback_centisecs=0
3339 # save and increase /proc/sys/vm/dirty_ratio
3340 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3341 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3342 # save and increase /proc/sys/vm/dirty_background_ratio
3343 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3344 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3346 # if file not here, we are a 2.4 kernel
3347 kill -STOP `pidof kupdated`
3351 # ensure that all stripes have some grant before we test client-side cache
3353 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3354 dd if=/dev/zero of=$i bs=4k count=1
3359 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3360 # file truncation, and file removal.
3362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3364 cancel_lru_locks osc
3366 sync; sleep 1; sync # just to be safe
3367 BEFOREWRITES=`count_ost_writes`
3368 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3369 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3370 AFTERWRITES=`count_ost_writes`
3371 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3372 error "$BEFOREWRITES < $AFTERWRITES"
3375 run_test 42a "ensure that we don't flush on close =============="
3378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3380 cancel_lru_locks osc
3383 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3384 BEFOREWRITES=$(count_ost_writes)
3385 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3386 AFTERWRITES=$(count_ost_writes)
3387 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3388 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3390 BEFOREWRITES=$(count_ost_writes)
3391 sync || error "sync: $?"
3392 AFTERWRITES=$(count_ost_writes)
3393 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3394 error "$BEFOREWRITES < $AFTERWRITES on sync"
3396 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3400 run_test 42b "test destroy of file with cached dirty data ======"
3402 # if these tests just want to test the effect of truncation,
3403 # they have to be very careful. consider:
3404 # - the first open gets a {0,EOF}PR lock
3405 # - the first write conflicts and gets a {0, count-1}PW
3406 # - the rest of the writes are under {count,EOF}PW
3407 # - the open for truncate tries to match a {0,EOF}PR
3408 # for the filesize and cancels the PWs.
3409 # any number of fixes (don't get {0,EOF} on open, match
3410 # composite locks, do smarter file size management) fix
3411 # this, but for now we want these tests to verify that
3412 # the cancellation with truncate intent works, so we
3413 # start the file with a full-file pw lock to match against
3414 # until the truncate.
3419 cancel_lru_locks osc
3421 # prime the file with 0,EOF PW to match
3425 # now the real test..
3426 dd if=/dev/zero of=$file bs=1024 count=100
3427 BEFOREWRITES=`count_ost_writes`
3428 $TRUNCATE $file $offset
3429 cancel_lru_locks osc
3430 AFTERWRITES=`count_ost_writes`
3435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3437 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3438 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3441 run_test 42c "test partial truncate of file with cached dirty data"
3444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3446 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3447 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3450 run_test 42d "test complete truncate of file with cached dirty data"
3452 test_42e() { # bug22074
3453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3454 local TDIR=$DIR/${tdir}e
3455 local pagesz=$(page_size)
3456 local pages=16 # hardcoded 16 pages, don't change it.
3457 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3458 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3462 test_mkdir -p $DIR/${tdir}e
3463 $SETSTRIPE -c 1 $TDIR
3464 createmany -o $TDIR/f $files
3466 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3468 # we assume that with $OSTCOUNT files, at least one of them will
3469 # be allocated on OST0.
3470 warmup_files=$((OSTCOUNT * max_dirty_mb))
3471 createmany -o $TDIR/w $warmup_files
3473 # write a large amount of data into one file and sync, to get good
3474 # avail_grant number from OST.
3475 for ((i=0; i<$warmup_files; i++)); do
3476 idx=$($GETSTRIPE -i $TDIR/w$i)
3477 [ $idx -ne 0 ] && continue
3478 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3481 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3483 $LCTL get_param $proc_osc0/cur_dirty_bytes
3484 $LCTL get_param $proc_osc0/cur_grant_bytes
3486 # create as much dirty pages as we can while not to trigger the actual
3487 # RPCs directly. but depends on the env, VFS may trigger flush during this
3488 # period, hopefully we are good.
3489 for ((i=0; i<$warmup_files; i++)); do
3490 idx=$($GETSTRIPE -i $TDIR/w$i)
3491 [ $idx -ne 0 ] && continue
3492 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3494 $LCTL get_param $proc_osc0/cur_dirty_bytes
3495 $LCTL get_param $proc_osc0/cur_grant_bytes
3497 # perform the real test
3498 $LCTL set_param $proc_osc0/rpc_stats 0
3499 for ((;i<$files; i++)); do
3500 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3501 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3504 $LCTL get_param $proc_osc0/rpc_stats
3507 local have_ppr=false
3508 $LCTL get_param $proc_osc0/rpc_stats |
3509 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3510 # skip lines until we are at the RPC histogram data
3511 [ "$PPR" == "pages" ] && have_ppr=true && continue
3512 $have_ppr || continue
3514 # we only want the percent stat for < 16 pages
3515 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3517 percent=$((percent + WPCT))
3518 if [[ $percent -gt 15 ]]; then
3519 error "less than 16-pages write RPCs" \
3526 run_test 42e "verify sub-RPC writes are not done synchronously"
3529 test_mkdir -p $DIR/$tdir
3530 cp -p /bin/ls $DIR/$tdir/$tfile
3531 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3533 # give multiop a chance to open
3536 $DIR/$tdir/$tfile && error || true
3539 run_test 43 "execution of file opened for write should return -ETXTBSY"
3542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3543 test_mkdir -p $DIR/$tdir
3544 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3545 cp -p multiop $DIR/$tdir/multiop
3546 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3549 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3550 kill -USR1 $MULTIOP_PID || return 2
3551 wait $MULTIOP_PID || return 3
3552 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3554 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3558 test_mkdir -p $DIR/$tdir
3559 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3560 cp -p multiop $DIR/$tdir/multiop
3561 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3564 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3565 kill -USR1 $MULTIOP_PID || return 2
3566 wait $MULTIOP_PID || return 3
3567 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3569 run_test 43b "truncate of file being executed should return -ETXTBSY"
3572 local testdir="$DIR/$tdir"
3573 test_mkdir -p $DIR/$tdir
3575 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3576 ( cd $testdir && md5sum -c)
3578 run_test 43c "md5sum of copy into lustre========================"
3581 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3582 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3583 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3585 run_test 44 "zero length read from a sparse stripe ============="
3588 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3590 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3591 [[ $nstripe -gt $OSTCOUNT ]] &&
3592 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3594 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3596 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3597 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3601 OFFSETS="0 $((stride/2)) $((stride-1))"
3602 for offset in $OFFSETS; do
3603 for i in $(seq 0 $((nstripe-1))); do
3604 local GLOBALOFFSETS=""
3606 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3607 local myfn=$DIR/d44a-$size
3608 echo "--------writing $myfn at $size"
3609 ll_sparseness_write $myfn $size ||
3610 error "ll_sparseness_write"
3611 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3612 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3613 error "ll_sparseness_verify $GLOBALOFFSETS"
3615 for j in $(seq 0 $((nstripe-1))); do
3617 size=$((((j + $nstripe )*$stride + $offset)))
3618 ll_sparseness_write $myfn $size ||
3619 error "ll_sparseness_write"
3620 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3622 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3623 error "ll_sparseness_verify $GLOBALOFFSETS"
3628 run_test 44a "test sparse pwrite ==============================="
3632 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3638 before=`dirty_osc_total`
3639 echo executing "\"$*\""
3641 after=`dirty_osc_total`
3642 echo before $before, after $after
3645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3647 # Obtain grants from OST if it supports it
3648 echo blah > ${f}_grant
3651 do_dirty_record "echo blah > $f"
3652 [[ $before -eq $after ]] && error "write wasn't cached"
3653 do_dirty_record "> $f"
3654 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3655 do_dirty_record "echo blah > $f"
3656 [[ $before -eq $after ]] && error "write wasn't cached"
3657 do_dirty_record "sync"
3658 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3659 do_dirty_record "echo blah > $f"
3660 [[ $before -eq $after ]] && error "write wasn't cached"
3661 do_dirty_record "cancel_lru_locks osc"
3662 [[ $before -gt $after ]] ||
3663 error "lock cancellation didn't lower dirty count"
3666 run_test 45 "osc io page accounting ============================"
3668 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3669 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3670 # objects offset and an assert hit when an rpc was built with 1023's mapped
3671 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3677 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3679 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3680 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3684 run_test 46 "dirtying a previously written page ================"
3686 # test_47 is removed "Device nodes check" is moved to test_28
3688 test_48a() { # bug 2399
3689 check_kernel_version 34 || return 0
3690 test_mkdir -p $DIR/$tdir
3692 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3693 test_mkdir $DIR/$tdir || error "recreate directory failed"
3694 touch foo || error "'touch foo' failed after recreating cwd"
3695 test_mkdir $DIR/$tdir/bar ||
3696 error "'mkdir foo' failed after recreating cwd"
3697 if check_kernel_version 44; then
3698 touch .foo || error "'touch .foo' failed after recreating cwd"
3699 test_mkdir $DIR/$tdir/.bar ||
3700 error "'mkdir .foo' failed after recreating cwd"
3702 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3703 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3704 cd . || error "'cd .' failed after recreating cwd"
3705 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3706 rmdir . && error "'rmdir .' worked after recreating cwd"
3707 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3708 cd .. || error "'cd ..' failed after recreating cwd"
3710 run_test 48a "Access renamed working dir (should return errors)="
3712 test_48b() { # bug 2399
3713 check_kernel_version 34 || return 0
3715 test_mkdir -p $DIR/$tdir
3717 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3718 touch foo && error "'touch foo' worked after removing cwd"
3719 test_mkdir $DIR/$tdir/foo &&
3720 error "'mkdir foo' worked after removing cwd"
3721 if check_kernel_version 44; then
3722 touch .foo && error "'touch .foo' worked after removing cwd"
3723 test_mkdir $DIR/$tdir/.foo &&
3724 error "'mkdir .foo' worked after removing cwd"
3726 ls . > /dev/null && error "'ls .' worked after removing cwd"
3727 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3728 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3729 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3730 rmdir . && error "'rmdir .' worked after removing cwd"
3731 ln -s . foo && error "'ln -s .' worked after removing cwd"
3732 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3734 run_test 48b "Access removed working dir (should return errors)="
3736 test_48c() { # bug 2350
3737 check_kernel_version 36 || return 0
3738 #lctl set_param debug=-1
3741 test_mkdir -p $DIR/$tdir/dir
3743 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3744 $TRACE touch foo && error "touch foo worked after removing cwd"
3745 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3746 if check_kernel_version 44; then
3747 touch .foo && error "touch .foo worked after removing cwd"
3748 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3750 $TRACE ls . && error "'ls .' worked after removing cwd"
3751 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3752 is_patchless || ( $TRACE cd . &&
3753 error "'cd .' worked after removing cwd" )
3754 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3755 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3756 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3757 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3759 run_test 48c "Access removed working subdir (should return errors)"
3761 test_48d() { # bug 2350
3762 check_kernel_version 36 || return 0
3763 #lctl set_param debug=-1
3766 test_mkdir -p $DIR/$tdir/dir
3768 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3769 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3770 $TRACE touch foo && error "'touch foo' worked after removing parent"
3771 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3772 if check_kernel_version 44; then
3773 touch .foo && error "'touch .foo' worked after removing parent"
3775 error "mkdir .foo worked after removing parent"
3777 $TRACE ls . && error "'ls .' worked after removing parent"
3778 $TRACE ls .. && error "'ls ..' worked after removing parent"
3779 is_patchless || ( $TRACE cd . &&
3780 error "'cd .' worked after recreate parent" )
3781 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3782 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3783 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3784 is_patchless || ( $TRACE cd .. &&
3785 error "'cd ..' worked after removing parent" || true )
3787 run_test 48d "Access removed parent subdir (should return errors)"
3789 test_48e() { # bug 4134
3790 check_kernel_version 41 || return 0
3791 #lctl set_param debug=-1
3794 test_mkdir -p $DIR/$tdir/dir
3796 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3797 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3798 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3799 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3800 # On a buggy kernel addition of "touch foo" after cd .. will
3801 # produce kernel oops in lookup_hash_it
3802 touch ../foo && error "'cd ..' worked after recreate parent"
3804 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3806 run_test 48e "Access to recreated parent subdir (should return errors)"
3808 test_49() { # LU-1030
3809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3810 # get ost1 size - lustre-OST0000
3811 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3813 # write 800M at maximum
3814 [[ $ost1_size -lt 2 ]] && ost1_size=2
3815 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3817 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3818 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3821 # change max_pages_per_rpc while writing the file
3822 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3823 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3824 # loop until dd process exits
3825 while ps ax -opid | grep -wq $dd_pid; do
3826 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3827 sleep $((RANDOM % 5 + 1))
3829 # restore original max_pages_per_rpc
3830 $LCTL set_param $osc1_mppc=$orig_mppc
3831 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3833 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3837 test_mkdir $DIR/$tdir
3839 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3841 run_test 50 "special situations: /proc symlinks ==============="
3843 test_51a() { # was test_51
3844 # bug 1516 - create an empty entry right after ".." then split dir
3845 test_mkdir -c1 $DIR/$tdir
3846 touch $DIR/$tdir/foo
3847 $MCREATE $DIR/$tdir/bar
3849 createmany -m $DIR/$tdir/longfile 201
3851 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3852 $MCREATE $DIR/$tdir/longfile$FNUM
3857 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3859 run_test 51a "special situations: split htree with empty entry =="
3861 export NUMTEST=70000
3863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3864 local BASE=$DIR/d${base}.${TESTSUITE}
3866 # cleanup the directory
3869 test_mkdir -p -c1 $BASE
3871 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3872 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3873 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3876 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3877 echo "reduced count to $NUMTEST due to inodes"
3879 # need to check free space for the directories as well
3880 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3881 numfree=$((blkfree / 4))
3882 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3883 echo "reduced count to $NUMTEST due to blocks"
3885 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3886 echo "failed" > $BASE/fnum
3888 run_test 51b "exceed 64k subdirectory nlink limit"
3890 test_51ba() { # LU-993
3891 local BASE=$DIR/d${base}.${TESTSUITE}
3892 # unlink all but 100 subdirectories, then check it still works
3894 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3896 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3897 local DELETE=$((NUMTEST - LEFT))
3899 # continue on to run this test even if 51b didn't finish,
3900 # just to delete the many subdirectories created.
3901 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3903 # for ldiskfs the nlink count should be 1, but this is OSD specific
3904 # and so this is listed for informational purposes only
3905 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3906 unlinkmany -d $BASE/d $DELETE
3909 if [ $RC -ne 0 ]; then
3910 if [ "$NUMPREV" == "failed" ]; then
3911 skip "previous setup failed"
3914 error "unlink of first $DELETE subdirs failed"
3919 echo "nlink between: $(stat -c %h $BASE)"
3920 # trim the first line of ls output
3921 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3922 [ $FOUND -ne $LEFT ] &&
3923 error "can't find subdirs: found only $FOUND/$LEFT"
3925 unlinkmany -d $BASE/d $DELETE $LEFT ||
3926 error "unlink of second $LEFT subdirs failed"
3927 # regardless of whether the backing filesystem tracks nlink accurately
3928 # or not, the nlink count shouldn't be more than "." and ".." here
3929 local AFTER=$(stat -c %h $BASE)
3930 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
3931 echo "nlink after: $AFTER"
3933 run_test 51ba "verify nlink for many subdirectory cleanup"
3936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3937 [[ $OSTCOUNT -lt 3 ]] &&
3938 skip_env "skipping test with few OSTs" && return
3939 test_mkdir -p $DIR/$tdir
3940 createmany -o $DIR/$tdir/t- 1000
3941 $GETSTRIPE $DIR/$tdir > $TMP/files
3942 for N in $(seq 0 $((OSTCOUNT - 1))); do
3943 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
3944 END { printf("%0.0f", objs) }' $TMP/files)
3945 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
3946 '($1 == '$N') { objs += 1 } \
3947 END { printf("%0.0f", objs) }')
3948 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3950 unlinkmany $DIR/$tdir/t- 1000
3953 for N in $(seq 1 $((OSTCOUNT - 1))); do
3954 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
3955 error "OST $N has less objects vs OST $NLAST" \
3956 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3957 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
3958 error "OST $N has less objects vs OST $NLAST" \
3959 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3961 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
3962 error "OST $N has less #0 objects vs OST $NLAST" \
3963 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3964 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
3965 error "OST $N has less #0 objects vs OST $NLAST" \
3966 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3970 run_test 51d "check object distribution ===================="
3973 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3974 test_mkdir -p $DIR/$tdir
3975 touch $DIR/$tdir/foo
3976 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3977 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3978 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3979 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3980 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3982 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3983 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3984 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3986 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3987 cp -r $DIR/$tdir /tmp/
3988 rm -fr $DIR/$tdir || error "cleanup rm failed"
3990 run_test 52a "append-only flag test (should return errors) ====="
3993 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3994 test_mkdir -p $DIR/$tdir
3995 touch $DIR/$tdir/foo
3996 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3997 cat test > $DIR/$tdir/foo && error "cat test worked"
3998 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3999 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4000 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4002 echo foo >> $DIR/$tdir/foo && error "echo worked"
4003 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4004 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4005 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4006 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4008 chattr -i $DIR/$tdir/foo || error "chattr failed"
4010 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4012 run_test 52b "immutable flag test (should return errors) ======="
4015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4016 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4017 remote_ost_nodsh && skip "remote OST with nodsh" && return
4030 local support_last_seq=true
4032 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4033 support_last_seq=false
4036 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4038 for value in $(do_facet $SINGLEMDS \
4039 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4040 param=$(echo ${value[0]} | cut -d "=" -f1)
4041 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4043 if $support_last_seq; then
4044 param_seq=$(echo $param |
4045 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4046 mds_last_seq=$(do_facet $SINGLEMDS \
4047 $LCTL get_param -n $param_seq)
4049 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4051 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4052 node=$(facet_active_host ost$((ostnum+1)))
4053 param="obdfilter.$ostname.last_id"
4054 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4055 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4056 ost_last_id=$ost_last
4058 if $support_last_seq; then
4059 ost_last_id=$(echo $ost_last |
4060 awk -F':' '{print $2}' |
4062 ost_last_seq=$(echo $ost_last |
4063 awk -F':' '{print $1}')
4064 [[ $ost_last_seq = $mds_last_seq ]] || continue
4067 if [[ $ost_last_id != $mds_last ]]; then
4068 error "$ost_last_id != $mds_last"
4075 $found || error "can not match last_seq/last_id for $mdtosc"
4078 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4081 $SOCKETSERVER $DIR/socket ||
4082 error "$SOCKETSERVER $DIR/socket failed: $?"
4083 $SOCKETCLIENT $DIR/socket ||
4084 error "$SOCKETCLIENT $DIR/socket failed: $?"
4085 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4087 run_test 54a "unix domain socket test =========================="
4093 dd if=/dev/zero of=$f bs=$(page_size) count=1
4095 run_test 54b "char device works in lustre ======================"
4098 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4099 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4100 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4102 for i in $(seq 3 7); do
4103 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4111 loopdev="$DIR/loop54c"
4114 $UMOUNT -d $tdir || rc=$?
4115 losetup -d $loopdev || true
4121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4124 loopdev="$DIR/loop54c"
4127 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4128 mknod $loopdev b 7 $LOOPNUM
4129 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4130 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4131 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4132 trap cleanup_54c EXIT
4133 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4135 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4136 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4138 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4141 run_test 54c "block device works in lustre ====================="
4147 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4149 run_test 54d "fifo device works in lustre ======================"
4152 check_kernel_version 46 || return 0
4155 cp -aL /dev/console $f
4156 echo $string > $f || error "echo $string to $f failed"
4158 run_test 54e "console/tty device works in lustre ======================"
4160 #The test_55 used to be iopen test and it was removed by bz#24037.
4161 #run_test 55 "check iopen_connect_dentry() ======================"
4163 test_56a() { # was test_56
4166 test_mkdir -p $DIR/$tdir/dir
4168 NUMFILESx2=$(($NUMFILES * 2))
4169 for i in $(seq 1 $NUMFILES); do
4170 touch $DIR/$tdir/file$i
4171 touch $DIR/$tdir/dir/file$i
4174 # test lfs getstripe with --recursive
4175 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4176 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4177 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4178 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4179 [[ $FILENUM -eq $NUMFILES ]] ||
4180 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4181 echo "$GETSTRIPE --recursive passed."
4183 # test lfs getstripe with file instead of dir
4184 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4185 [[ $FILENUM -eq 1 ]] ||
4186 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4187 echo "$GETSTRIPE file1 passed."
4189 #test lfs getstripe with --verbose
4190 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4191 grep -c lmm_magic) -eq $NUMFILES ]] ||
4192 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4193 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4194 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4195 echo "$GETSTRIPE --verbose passed."
4197 #test lfs getstripe with --obd
4198 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4199 grep -q "unknown obduuid" ||
4200 error "$GETSTRIPE --obd wrong_uuid should return error message"
4202 [[ $OSTCOUNT -lt 2 ]] &&
4203 skip_env "skipping other $GETSTRIPE --obd test" && return
4206 OBDUUID=$(ostuuid_from_index $OSTIDX)
4207 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4208 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4209 [[ $FOUND -eq $FILENUM ]] ||
4210 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4211 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4212 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4213 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4214 error "$GETSTRIPE --obd: should not show file on other obd"
4215 echo "$GETSTRIPE --obd passed"
4217 run_test 56a "check $GETSTRIPE"
4222 local LOCAL_NUMFILES="$1"
4223 local LOCAL_NUMDIRS="$2"
4224 local MKDIR_PARAMS="$3"
4225 local DIR_STRIPE_PARAMS="$4"
4227 if [ ! -d "$TDIR" ] ; then
4228 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4229 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4230 for i in `seq 1 $LOCAL_NUMFILES` ; do
4233 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4234 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4235 for j in `seq 1 $LOCAL_NUMFILES` ; do
4236 touch $TDIR/dir$i/file$j
4242 setup_56_special() {
4246 if [ ! -e "$TDIR/loop1b" ] ; then
4247 for i in `seq 1 $LOCAL_NUMFILES` ; do
4248 mknod $TDIR/loop${i}b b 7 $i
4249 mknod $TDIR/null${i}c c 1 3
4250 ln -s $TDIR/file1 $TDIR/link${i}l
4252 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4253 mknod $TDIR/dir$i/loop${i}b b 7 $i
4254 mknod $TDIR/dir$i/null${i}c c 1 3
4255 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4264 setup_56 $NUMFILES $NUMDIRS
4266 EXPECTED=$(($NUMDIRS + 2))
4267 # test lfs find with -name
4268 for i in $(seq 1 $NUMFILES) ; do
4269 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4270 [ $NUMS -eq $EXPECTED ] ||
4271 error "lfs find -name \"*$i\" $TDIR wrong: "\
4272 "found $NUMS, expected $EXPECTED"
4275 run_test 56g "check lfs find -name ============================="
4281 setup_56 $NUMFILES $NUMDIRS
4283 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4284 # test lfs find with ! -name
4285 for i in $(seq 1 $NUMFILES) ; do
4286 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4287 [ $NUMS -eq $EXPECTED ] ||
4288 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4289 "found $NUMS, expected $EXPECTED"
4292 run_test 56h "check lfs find ! -name ============================="
4296 test_mkdir -p $DIR/$tdir
4297 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4298 CMD="$LFIND -ost $UUID $DIR/$tdir"
4300 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4302 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4306 setup_56_special $NUMFILES $NUMDIRS
4308 EXPECTED=$((NUMDIRS + 1))
4309 CMD="$LFIND -type d $TDIR"
4310 NUMS=$($CMD | wc -l)
4311 [ $NUMS -eq $EXPECTED ] ||
4312 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4314 run_test 56j "check lfs find -type d ============================="
4318 setup_56_special $NUMFILES $NUMDIRS
4320 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4321 CMD="$LFIND -type f $TDIR"
4322 NUMS=$($CMD | wc -l)
4323 [ $NUMS -eq $EXPECTED ] ||
4324 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4326 run_test 56k "check lfs find -type f ============================="
4330 setup_56_special $NUMFILES $NUMDIRS
4332 EXPECTED=$((NUMDIRS + NUMFILES))
4333 CMD="$LFIND -type b $TDIR"
4334 NUMS=$($CMD | wc -l)
4335 [ $NUMS -eq $EXPECTED ] ||
4336 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4338 run_test 56l "check lfs find -type b ============================="
4342 setup_56_special $NUMFILES $NUMDIRS
4344 EXPECTED=$((NUMDIRS + NUMFILES))
4345 CMD="$LFIND -type c $TDIR"
4346 NUMS=$($CMD | wc -l)
4347 [ $NUMS -eq $EXPECTED ] ||
4348 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4350 run_test 56m "check lfs find -type c ============================="
4354 setup_56_special $NUMFILES $NUMDIRS
4356 EXPECTED=$((NUMDIRS + NUMFILES))
4357 CMD="$LFIND -type l $TDIR"
4358 NUMS=$($CMD | wc -l)
4359 [ $NUMS -eq $EXPECTED ] ||
4360 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4362 run_test 56n "check lfs find -type l ============================="
4366 setup_56 $NUMFILES $NUMDIRS
4367 utime $TDIR/file1 > /dev/null || error "utime (1)"
4368 utime $TDIR/file2 > /dev/null || error "utime (2)"
4369 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4370 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4371 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4372 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4375 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4376 [ $NUMS -eq $EXPECTED ] || \
4377 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4380 CMD="$LFIND -mtime 0 $TDIR"
4381 NUMS=$($CMD | wc -l)
4382 [ $NUMS -eq $EXPECTED ] ||
4383 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4385 run_test 56o "check lfs find -mtime for old files =========================="
4388 [ $RUNAS_ID -eq $UID ] &&
4389 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4392 setup_56 $NUMFILES $NUMDIRS
4394 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4396 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4397 NUMS=$($CMD | wc -l)
4398 [ $NUMS -eq $EXPECTED ] || \
4399 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4401 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4402 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4403 NUMS=$($CMD | wc -l)
4404 [ $NUMS -eq $EXPECTED ] || \
4405 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4407 run_test 56p "check lfs find -uid and ! -uid ==============================="
4410 [ $RUNAS_ID -eq $UID ] &&
4411 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4414 setup_56 $NUMFILES $NUMDIRS
4416 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4419 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4420 NUMS=$($CMD | wc -l)
4421 [ $NUMS -eq $EXPECTED ] ||
4422 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4424 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4425 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4426 NUMS=$($CMD | wc -l)
4427 [ $NUMS -eq $EXPECTED ] ||
4428 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4430 run_test 56q "check lfs find -gid and ! -gid ==============================="
4434 setup_56 $NUMFILES $NUMDIRS
4437 CMD="$LFIND -size 0 -type f $TDIR"
4438 NUMS=$($CMD | wc -l)
4439 [ $NUMS -eq $EXPECTED ] ||
4440 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4442 CMD="$LFIND ! -size 0 -type f $TDIR"
4443 NUMS=$($CMD | wc -l)
4444 [ $NUMS -eq $EXPECTED ] ||
4445 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4446 echo "test" > $TDIR/$tfile
4447 echo "test2" > $TDIR/$tfile.2 && sync
4449 CMD="$LFIND -size 5 -type f $TDIR"
4450 NUMS=$($CMD | wc -l)
4451 [ $NUMS -eq $EXPECTED ] ||
4452 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4454 CMD="$LFIND -size +5 -type f $TDIR"
4455 NUMS=$($CMD | wc -l)
4456 [ $NUMS -eq $EXPECTED ] ||
4457 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4459 CMD="$LFIND -size +0 -type f $TDIR"
4460 NUMS=$($CMD | wc -l)
4461 [ $NUMS -eq $EXPECTED ] ||
4462 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4464 CMD="$LFIND ! -size -5 -type f $TDIR"
4465 NUMS=$($CMD | wc -l)
4466 [ $NUMS -eq $EXPECTED ] ||
4467 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4469 CMD="$LFIND -size -5 -type f $TDIR"
4470 NUMS=$($CMD | wc -l)
4471 [ $NUMS -eq $EXPECTED ] ||
4472 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4474 run_test 56r "check lfs find -size works =========================="
4476 test_56s() { # LU-611
4478 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4480 if [[ $OSTCOUNT -gt 1 ]]; then
4481 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4485 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4489 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4490 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4491 NUMS=$($CMD | wc -l)
4492 [ $NUMS -eq $EXPECTED ] ||
4493 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4495 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4496 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4497 NUMS=$($CMD | wc -l)
4498 [ $NUMS -eq $EXPECTED ] ||
4499 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4502 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4503 NUMS=$($CMD | wc -l)
4504 [ $NUMS -eq $EXPECTED ] ||
4505 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4507 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4508 NUMS=$($CMD | wc -l)
4509 [ $NUMS -eq $EXPECTED ] ||
4510 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4513 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4514 NUMS=$($CMD | wc -l)
4515 [ $NUMS -eq $EXPECTED ] ||
4516 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4518 run_test 56s "check lfs find -stripe-count works"
4520 test_56t() { # LU-611
4522 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4524 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4526 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4527 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4528 NUMS=$($CMD | wc -l)
4529 [ $NUMS -eq $EXPECTED ] ||
4530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4532 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4533 NUMS=$($CMD | wc -l)
4534 [ $NUMS -eq $EXPECTED ] ||
4535 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4537 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4538 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4539 NUMS=$($CMD | wc -l)
4540 [ $NUMS -eq $EXPECTED ] ||
4541 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4543 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4544 NUMS=$($CMD | wc -l)
4545 [ $NUMS -eq $EXPECTED ] ||
4546 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4550 NUMS=$($CMD | wc -l)
4551 [ $NUMS -eq $EXPECTED ] ||
4552 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4554 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4555 NUMS=$($CMD | wc -l)
4556 [ $NUMS -eq $EXPECTED ] ||
4557 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4560 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4561 NUMS=$($CMD | wc -l)
4562 [ $NUMS -eq $EXPECTED ] ||
4563 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4565 run_test 56t "check lfs find -stripe-size works"
4567 test_56u() { # LU-611
4569 setup_56 $NUMFILES $NUMDIRS "-i 0"
4571 if [[ $OSTCOUNT -gt 1 ]]; then
4572 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4578 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4579 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4580 NUMS=$($CMD | wc -l)
4581 [ $NUMS -eq $EXPECTED ] ||
4582 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4585 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4586 NUMS=$($CMD | wc -l)
4587 [ $NUMS -eq $EXPECTED ] ||
4588 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4590 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4591 NUMS=$($CMD | wc -l)
4592 [ $NUMS -eq $EXPECTED ] ||
4593 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4596 # This should produce an error and not return any files
4597 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4598 NUMS=$($CMD 2>/dev/null | wc -l)
4599 [ $NUMS -eq $EXPECTED ] ||
4600 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4602 if [[ $OSTCOUNT -gt 1 ]]; then
4603 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4604 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4605 NUMS=$($CMD | wc -l)
4606 [ $NUMS -eq $EXPECTED ] ||
4607 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4610 run_test 56u "check lfs find -stripe-index works"
4617 setup_56 $NUMFILES $NUMDIRS
4619 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4620 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4622 for file in $($LFIND -mdt $UUID $TDIR); do
4623 file_mdt_idx=$($GETSTRIPE -M $file)
4624 [ $file_mdt_idx -eq $MDT_IDX ] ||
4625 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4628 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4630 # Get and check the actual stripe count of one file.
4631 # Usage: check_stripe_count <file> <expected_stripe_count>
4632 check_stripe_count() {
4637 [[ -z "$file" || -z "$expected" ]] &&
4638 error "check_stripe_count: invalid argument!"
4640 local cmd="$GETSTRIPE -c $file"
4641 actual=$($cmd) || error "$cmd failed"
4642 actual=${actual%% *}
4644 if [[ $actual -ne $expected ]]; then
4645 [[ $expected -eq -1 ]] ||
4646 error "$cmd wrong: found $actual, expected $expected"
4647 [[ $actual -eq $OSTCOUNT ]] ||
4648 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4656 rm -rf $TDIR || error "remove $TDIR failed"
4657 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4660 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4661 error "$GETSTRIPE -S -d $TDIR failed"
4662 stripe_size=${stripe_size%% *}
4664 local file_size=$((stripe_size * OSTCOUNT))
4665 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4666 local required_space=$((file_num * file_size))
4667 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4668 [[ $free_space -le $((required_space / 1024)) ]] &&
4669 skip_env "need at least $required_space bytes free space," \
4670 "have $free_space kbytes" && return
4673 local dd_count=$((file_size / dd_bs))
4675 # write data into the files
4679 for i in $(seq 1 $NUMFILES); do
4681 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4682 error "write data into $file failed"
4684 for i in $(seq 1 $NUMDIRS); do
4685 for j in $(seq 1 $NUMFILES); do
4686 file=$TDIR/dir$i/file$j
4687 yes | dd bs=$dd_bs count=$dd_count of=$file \
4689 error "write data into $file failed"
4694 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4697 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4699 eval $cmd || error "$cmd failed"
4701 check_stripe_count $TDIR/file1 $expected
4704 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4706 eval $cmd || error "$cmd failed"
4708 for j in $(seq 1 $NUMFILES); do
4709 check_stripe_count $TDIR/dir1/file$j $expected
4712 # lfs_migrate works with lfs find
4713 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4714 $LFS_MIGRATE -y -c $expected"
4716 eval $cmd || error "$cmd failed"
4718 for i in $(seq 2 $NUMFILES); do
4719 check_stripe_count $TDIR/file$i $expected
4721 for i in $(seq 2 $NUMDIRS); do
4722 for j in $(seq 1 $NUMFILES); do
4723 check_stripe_count $TDIR/dir$i/file$j $expected
4727 run_test 56w "check lfs_migrate -c stripe_count works"
4730 check_swap_layouts_support && return 0
4731 [[ $OSTCOUNT -lt 2 ]] &&
4732 skip_env "need 2 OST, skipping test" && return
4734 local dir0=$DIR/$tdir/$testnum
4735 mkdir -p $dir0 || error "creating dir $dir0"
4737 local ref1=/etc/passwd
4738 local file1=$dir0/file1
4740 $SETSTRIPE -c 2 $file1
4742 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4743 stripe=$($GETSTRIPE -c $file1)
4744 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4745 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4750 run_test 56x "lfs migration support"
4753 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4754 skip "No HSM support on MDS of $(get_lustre_version)," \
4755 "need 2.4.53 at least" && return
4758 local dir0=$DIR/$tdir/$testnum
4759 mkdir -p $dir0 || error "creating dir $dir0"
4760 local f1=$dir0/file1
4761 local f2=$dir0/file2
4763 touch $f1 || error "creating std file $f1"
4764 $MULTIOP $f2 H2c || error "creating released file $f2"
4766 # a directory can be raid0, so ask only for files
4767 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4768 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4770 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4771 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4773 # only files can be released, so no need to force file search
4774 res=$($LFIND $dir0 -L released)
4775 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4777 res=$($LFIND $dir0 \! -L released)
4778 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4781 run_test 56y "lfs find -L raid0|released"
4784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4785 # note test will not do anything if MDS is not local
4786 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4787 skip "Only applicable to ldiskfs-based MDTs"
4791 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4792 local MNTDEV="osd*.*MDT*.mntdev"
4793 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4794 [ -z "$DEV" ] && error "can't access $MNTDEV"
4795 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4796 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4797 error "can't access $DEV"
4798 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4799 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4803 run_test 57a "verify MDS filesystem created with large inodes =="
4806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4807 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4808 skip "Only applicable to ldiskfs-based MDTs"
4812 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4817 local FILEN=$dir/f$FILECOUNT
4819 rm -rf $dir || error "removing $dir"
4820 test_mkdir -p $dir || error "creating $dir"
4821 local num=$(get_mds_dir $dir)
4824 echo "mcreating $FILECOUNT files"
4825 createmany -m $dir/f 1 $FILECOUNT || \
4826 error "creating files in $dir"
4828 # verify that files do not have EAs yet
4829 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4830 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4834 df $dir #make sure we get new statfs data
4835 local MDSFREE=$(do_facet $mymds \
4836 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4837 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4838 echo "opening files to create objects/EAs"
4840 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4841 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4844 # verify that files have EAs now
4845 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4846 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4848 sleep 1 #make sure we get new statfs data
4850 local MDSFREE2=$(do_facet $mymds \
4851 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4852 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4853 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4854 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4855 error "MDC before $MDCFREE != after $MDCFREE2"
4857 echo "MDC before $MDCFREE != after $MDCFREE2"
4858 echo "unable to confirm if MDS has large inodes"
4863 run_test 57b "default LOV EAs are stored inside large inodes ==="
4866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4867 [ -z "$(which wiretest 2>/dev/null)" ] &&
4868 skip_env "could not find wiretest" && return
4871 run_test 58 "verify cross-platform wire constants =============="
4874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4875 echo "touch 130 files"
4876 createmany -o $DIR/f59- 130
4878 unlinkmany $DIR/f59- 130
4880 # wait for commitment of removal
4881 wait_delete_completed
4883 run_test 59 "verify cancellation of llog records async ========="
4885 TEST60_HEAD="test_60 run $RANDOM"
4887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4888 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4889 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4890 skip_env "missing subtest run-llog.sh" && return
4891 log "$TEST60_HEAD - from kernel mode"
4892 do_facet mgs sh run-llog.sh
4894 run_test 60a "llog sanity tests run from kernel module =========="
4896 test_60b() { # bug 6411
4897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4899 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4911 [[ $LLOG_COUNT -gt 50 ]] &&
4912 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
4914 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4918 echo "create 5000 files"
4919 createmany -o $DIR/f60c- 5000
4920 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4921 lctl set_param fail_loc=0x80000137
4922 unlinkmany $DIR/f60c- 5000
4923 lctl set_param fail_loc=0
4925 run_test 60c "unlink file when mds full"
4928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4929 SAVEPRINTK=$(lctl get_param -n printk)
4931 # verify "lctl mark" is even working"
4932 MESSAGE="test message ID $RANDOM $$"
4933 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4934 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4936 lctl set_param printk=0 || error "set lnet.printk failed"
4937 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4938 MESSAGE="new test message ID $RANDOM $$"
4939 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4940 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4941 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4943 lctl set_param -n printk="$SAVEPRINTK"
4945 run_test 60d "test printk console message masking"
4948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4950 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4951 cancel_lru_locks osc
4952 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4955 run_test 61 "mmap() writes don't make sync hang ================"
4957 # bug 2330 - insufficient obd_match error checking causes LBUG
4959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4962 cancel_lru_locks osc
4963 lctl set_param fail_loc=0x405
4964 cat $f && error "cat succeeded, expect -EIO"
4965 lctl set_param fail_loc=0
4967 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4968 # match every page all of the time.
4969 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4971 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4972 # Though this test is irrelevant anymore, it helped to reveal some
4973 # other grant bugs (LU-4482), let's keep it.
4974 test_63a() { # was test_63
4975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4976 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4977 for i in `seq 10` ; do
4978 dd if=/dev/zero of=$DIR/f63 bs=8k &
4984 rm -f $DIR/f63 || true
4986 run_test 63a "Verify oig_wait interruption does not crash ======="
4988 # bug 2248 - async write errors didn't return to application on sync
4989 # bug 3677 - async write errors left page locked
4991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4993 lctl set_param debug=-1
4995 # ensure we have a grant to do async writes
4996 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4999 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5000 lctl set_param fail_loc=0x80000406
5001 $MULTIOP $DIR/$tfile Owy && \
5002 error "sync didn't return ENOMEM"
5003 sync; sleep 2; sync # do a real sync this time to flush page
5004 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5005 error "locked page left in cache after async error" || true
5008 run_test 63b "async write errors should be returned to fsync ==="
5011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5013 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5015 run_test 64a "verify filter grant calculations (in kernel) ====="
5018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5019 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5021 run_test 64b "check out-of-space detection on client ==========="
5024 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5026 run_test 64c "verify grant shrink ========================------"
5028 # bug 1414 - set/get directories' stripe info
5030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5031 test_mkdir -p $DIR/$tdir
5033 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5035 run_test 65a "directory with no stripe info ===================="
5038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5039 test_mkdir -p $DIR/$tdir
5040 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5043 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5045 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5049 if [[ $OSTCOUNT -gt 1 ]]; then
5050 test_mkdir -p $DIR/$tdir
5051 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5052 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5054 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5057 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5061 test_mkdir -p $DIR/$tdir
5062 if [[ $STRIPECOUNT -le 0 ]]; then
5064 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5065 #LOV_MAX_STRIPE_COUNT is 2000
5066 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5068 sc=$(($STRIPECOUNT - 1))
5070 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5071 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5072 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5073 error "lverify failed"
5075 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5079 test_mkdir -p $DIR/$tdir
5081 $SETSTRIPE $DIR/$tdir || error "setstripe"
5082 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5083 error "no stripe info failed"
5085 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5087 run_test 65e "directory setstripe defaults ======================="
5090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5091 test_mkdir -p $DIR/${tdir}f
5092 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5094 run_test 65f "dir setstripe permission (should return error) ==="
5097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5098 test_mkdir -p $DIR/$tdir
5099 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5101 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5102 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5103 error "delete default stripe failed"
5105 run_test 65g "directory setstripe -d ==========================="
5108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5109 test_mkdir -p $DIR/$tdir
5110 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5112 test_mkdir -p $DIR/$tdir/dd1
5113 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5114 error "stripe info inherit failed"
5116 run_test 65h "directory stripe info inherit ===================="
5118 test_65i() { # bug6367
5119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5120 $SETSTRIPE -S 65536 -c -1 $MOUNT
5122 run_test 65i "set non-default striping on root directory (bug 6367)="
5124 test_65ia() { # bug12836
5125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5126 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5128 run_test 65ia "getstripe on -1 default directory striping"
5130 test_65ib() { # bug12836
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5134 run_test 65ib "getstripe -v on -1 default directory striping"
5136 test_65ic() { # bug12836
5137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5138 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5140 run_test 65ic "new find on -1 default directory striping"
5142 test_65j() { # bug6367
5143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5145 # if we aren't already remounting for each test, do so for this test
5146 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5147 cleanup || error "failed to unmount"
5150 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5152 run_test 65j "set default striping on root directory (bug 6367)="
5154 test_65k() { # bug11679
5155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5156 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5157 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5159 echo "Check OST status: "
5160 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5161 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5163 for OSC in $MDS_OSCS; do
5164 echo $OSC "is activate"
5165 do_facet $SINGLEMDS lctl --device %$OSC activate
5169 for INACTIVE_OSC in $MDS_OSCS; do
5170 echo "Deactivate: " $INACTIVE_OSC
5171 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5172 for STRIPE_OSC in $MDS_OSCS; do
5173 OST=`osc_to_ost $STRIPE_OSC`
5174 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5175 awk -F: /$OST/'{ print $1 }' | head -n 1`
5177 [ -f $DIR/$tdir/$IDX ] && continue
5178 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5179 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5181 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5184 echo $INACTIVE_OSC "is Activate."
5185 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5188 run_test 65k "validate manual striping works properly with deactivated OSCs"
5190 test_65l() { # bug 12836
5191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5192 test_mkdir -p $DIR/$tdir/test_dir
5193 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5194 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5196 run_test 65l "lfs find on -1 stripe dir ========================"
5198 # bug 2543 - update blocks count on client
5200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5202 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5203 sync; sync_all_data; sync; sync_all_data
5204 cancel_lru_locks osc
5205 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5206 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5208 run_test 66 "update inode blocks count on client ==============="
5213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5215 if [ ! -z "$LLOOP" ]; then
5216 if swapon -s | grep -q $LLOOP; then
5217 swapoff $LLOOP || error "swapoff failed"
5220 $LCTL blockdev_detach $LLOOP || error "detach failed"
5224 if [ ! -z "$LLITELOOPLOAD" ]; then
5232 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5236 swapon -s | awk '($1 == "'$1'") { print $4 }'
5239 # test case for lloop driver, basic function
5241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5242 [ "$UID" != 0 ] && skip_env "must run as root" && return
5243 llite_lloop_enabled || \
5244 { skip_env "llite_lloop module disabled" && return; }
5246 trap cleanup_68 EXIT
5248 if ! module_loaded llite_lloop; then
5249 if load_module llite/llite_lloop; then
5252 skip_env "can't find module llite_lloop"
5257 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5258 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5259 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5261 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5262 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5266 run_test 68a "lloop driver - basic test ========================"
5268 # excercise swapping to lustre by adding a high priority swapfile entry
5269 # and then consuming memory until it is used.
5270 test_68b() { # was test_68
5271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5272 [ "$UID" != 0 ] && skip_env "must run as root" && return
5273 lctl get_param -n devices | grep -q obdfilter && \
5274 skip "local OST" && return
5276 grep -q llite_lloop /proc/modules
5277 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5279 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5280 skip "can't reliably test swap with TCP" && return
5282 MEMTOTAL=`meminfo MemTotal`
5283 NR_BLOCKS=$((MEMTOTAL>>8))
5284 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5286 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5287 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5290 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5292 trap cleanup_68 EXIT
5294 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5296 echo "before: `swapon -s | grep $LLOOP`"
5297 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5298 echo "after: `swapon -s | grep $LLOOP`"
5299 SWAPUSED=`swap_used $LLOOP`
5303 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5305 run_test 68b "support swapping to Lustre ========================"
5307 # bug5265, obdfilter oa2dentry return -ENOENT
5308 # #define OBD_FAIL_OST_ENOENT 0x217
5310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5311 remote_ost_nodsh && skip "remote OST with nodsh" && return
5314 $SETSTRIPE -c 1 -i 0 $f
5316 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5318 do_facet ost1 lctl set_param fail_loc=0x217
5319 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5320 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5322 do_facet ost1 lctl set_param fail_loc=0
5323 $DIRECTIO write $f 0 2 || error "write error"
5325 cancel_lru_locks osc
5326 $DIRECTIO read $f 0 1 || error "read error"
5328 do_facet ost1 lctl set_param fail_loc=0x217
5329 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5331 do_facet ost1 lctl set_param fail_loc=0
5334 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5337 test_mkdir -p $DIR/$tdir
5338 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5340 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5342 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5344 [ "$RUNAS_ID" = "$UID" ] &&
5345 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5347 # Check that testing environment is properly set up. Skip if not
5348 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5349 skip_env "User $RUNAS_ID does not exist - skipping"
5352 # We had better clear the $DIR to get enough space for dd
5355 chmod 777 $DIR/$tfile
5356 chmod ug+s $DIR/$tfile
5357 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5358 error "$RUNAS dd $DIR/$tfile failed"
5359 # See if we are still setuid/sgid
5360 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5361 error "S/gid is not dropped on write"
5362 # Now test that MDS is updated too
5363 cancel_lru_locks mdc
5364 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5365 error "S/gid is not dropped on MDS"
5368 run_test 72a "Test that remove suid works properly (bug5695) ===="
5370 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5373 [ "$RUNAS_ID" = "$UID" ] && \
5374 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5375 [ "$RUNAS_ID" -eq 0 ] && \
5376 skip_env "RUNAS_ID = 0 -- skipping" && return
5378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5379 # Check that testing environment is properly set up. Skip if not
5380 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5381 skip_env "User $RUNAS_ID does not exist - skipping"
5384 touch $DIR/${tfile}-f{g,u}
5385 test_mkdir $DIR/${tfile}-dg
5386 test_mkdir $DIR/${tfile}-du
5387 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5388 chmod g+s $DIR/${tfile}-{f,d}g
5389 chmod u+s $DIR/${tfile}-{f,d}u
5390 for perm in 777 2777 4777; do
5391 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5392 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5393 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5394 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5398 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5400 # bug 3462 - multiple simultaneous MDC requests
5402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5403 test_mkdir $DIR/d73-1
5404 test_mkdir $DIR/d73-2
5405 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5408 lctl set_param fail_loc=0x80000129
5409 $MULTIOP $DIR/d73-1/f73-2 Oc &
5411 lctl set_param fail_loc=0
5413 $MULTIOP $DIR/d73-2/f73-3 Oc &
5417 wait $pid1 || return 1
5421 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5422 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5423 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5427 run_test 73 "multiple MDC requests (should not deadlock)"
5429 test_74a() { # bug 6149, 6184
5430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5431 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5433 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5434 # will spin in a tight reconnection loop
5436 $LCTL set_param fail_loc=0x8000030e
5437 # get any lock that won't be difficult - lookup works.
5439 $LCTL set_param fail_loc=0
5443 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5445 test_74b() { # bug 13310
5446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5447 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5449 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5450 # will spin in a tight reconnection loop
5451 $LCTL set_param fail_loc=0x8000030e
5452 # get a "difficult" lock
5454 $LCTL set_param fail_loc=0
5458 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5462 #define OBD_FAIL_LDLM_NEW_LOCK
5463 $LCTL set_param fail_loc=0x319
5464 touch $DIR/$tfile && error "touch successful"
5465 $LCTL set_param fail_loc=0
5468 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5471 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5474 get_inode_slab_tunables() {
5475 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5478 set_inode_slab_tunables() {
5479 echo "lustre_inode_cache $1" > /proc/slabinfo
5482 test_76() { # Now for bug 20433, added originally in bug 1443
5483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5484 local SLAB_SETTINGS=`get_inode_slab_tunables`
5485 local CPUS=`getconf _NPROCESSORS_ONLN`
5486 # we cannot set limit below 1 which means 1 inode in each
5487 # per-cpu cache is still allowed
5488 set_inode_slab_tunables "1 1 0"
5489 cancel_lru_locks osc
5490 BEFORE_INODES=$(num_inodes)
5491 echo "before inodes: $BEFORE_INODES"
5493 [ "$SLOW" = "no" ] && COUNT=100
5494 for i in $(seq $COUNT); do
5498 cancel_lru_locks osc
5499 AFTER_INODES=$(num_inodes)
5500 echo "after inodes: $AFTER_INODES"
5502 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5504 AFTER_INODES=$(num_inodes)
5506 echo "wait $wait seconds inodes: $AFTER_INODES"
5507 if [ $wait -gt 30 ]; then
5508 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5511 set_inode_slab_tunables "$SLAB_SETTINGS"
5513 run_test 76 "confirm clients recycle inodes properly ===="
5519 # Note: in sptlrpc modes which enable its own bulk checksum, the
5520 # original crc32_le bulk checksum will be automatically disabled,
5521 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5522 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5523 # In this case set_checksums() will not be no-op, because sptlrpc
5524 # bulk checksum will be enabled all through the test.
5526 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5527 lctl set_param -n osc.*.checksums $1
5531 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5532 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5533 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5534 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5537 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5538 log "set checksum type to $1"
5541 F77_TMP=$TMP/f77-temp
5544 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5545 error "error writing to $F77_TMP"
5548 test_77a() { # bug 10889
5549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5550 $GSS && skip "could not run with gss" && return
5551 [ ! -f $F77_TMP ] && setup_f77
5553 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5557 run_test 77a "normal checksum read/write operation"
5559 test_77b() { # bug 10889
5560 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5561 $GSS && skip "could not run with gss" && return
5562 [ ! -f $F77_TMP ] && setup_f77
5563 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5564 $LCTL set_param fail_loc=0x80000409
5567 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5568 error "dd error: $?"
5569 $LCTL set_param fail_loc=0
5571 for algo in $CKSUM_TYPES; do
5572 cancel_lru_locks osc
5573 set_checksum_type $algo
5574 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5575 $LCTL set_param fail_loc=0x80000408
5576 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5577 $LCTL set_param fail_loc=0
5580 set_checksum_type $ORIG_CSUM_TYPE
5583 run_test 77b "checksum error on client write, read"
5585 test_77d() { # bug 10889
5586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5587 $GSS && skip "could not run with gss" && return
5588 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5589 $LCTL set_param fail_loc=0x80000409
5591 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5592 error "direct write: rc=$?"
5593 $LCTL set_param fail_loc=0
5596 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5597 $LCTL set_param fail_loc=0x80000408
5599 cancel_lru_locks osc
5600 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5601 error "direct read: rc=$?"
5602 $LCTL set_param fail_loc=0
5605 run_test 77d "checksum error on OST direct write, read"
5607 test_77f() { # bug 10889
5608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5609 $GSS && skip "could not run with gss" && return
5611 for algo in $CKSUM_TYPES; do
5612 cancel_lru_locks osc
5613 set_checksum_type $algo
5614 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5615 $LCTL set_param fail_loc=0x409
5616 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5617 error "direct write succeeded"
5618 $LCTL set_param fail_loc=0
5620 set_checksum_type $ORIG_CSUM_TYPE
5623 run_test 77f "repeat checksum error on write (expect error)"
5625 test_77g() { # bug 10889
5626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5627 $GSS && skip "could not run with gss" && return
5628 remote_ost_nodsh && skip "remote OST with nodsh" && return
5630 [ ! -f $F77_TMP ] && setup_f77
5632 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5633 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5634 do_facet ost1 lctl set_param fail_loc=0x8000021a
5636 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5637 error "write error: rc=$?"
5638 do_facet ost1 lctl set_param fail_loc=0
5641 cancel_lru_locks osc
5642 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5643 do_facet ost1 lctl set_param fail_loc=0x8000021b
5645 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5646 do_facet ost1 lctl set_param fail_loc=0
5649 run_test 77g "checksum error on OST write, read"
5651 test_77i() { # bug 13805
5652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5653 $GSS && skip "could not run with gss" && return
5654 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5655 lctl set_param fail_loc=0x40b
5656 remount_client $MOUNT
5657 lctl set_param fail_loc=0
5658 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5659 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5660 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5661 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5663 remount_client $MOUNT
5665 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5667 test_77j() { # bug 13805
5668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5669 $GSS && skip "could not run with gss" && return
5670 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5671 lctl set_param fail_loc=0x40c
5672 remount_client $MOUNT
5673 lctl set_param fail_loc=0
5674 sleep 2 # wait async osc connect to finish
5675 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5676 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5677 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5678 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5680 remount_client $MOUNT
5682 run_test 77j "client only supporting ADLER32"
5684 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5688 test_78() { # bug 10901
5689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5690 remote_ost || { skip_env "local OST" && return; }
5693 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5694 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5695 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5696 echo "MemTotal: $MEMTOTAL"
5698 # reserve 256MB of memory for the kernel and other running processes,
5699 # and then take 1/2 of the remaining memory for the read/write buffers.
5700 if [ $MEMTOTAL -gt 512 ] ;then
5701 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5703 # for those poor memory-starved high-end clusters...
5704 MEMTOTAL=$((MEMTOTAL / 2))
5706 echo "Mem to use for directio: $MEMTOTAL"
5708 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5709 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5710 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5711 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5713 echo "Smallest OST: $SMALLESTOST"
5714 [[ $SMALLESTOST -lt 10240 ]] &&
5715 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5717 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5718 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5720 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5721 echo "File size: $F78SIZE"
5722 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5723 for i in $(seq 1 $NSEQ); do
5724 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5725 echo directIO rdwr round $i of $NSEQ
5726 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5731 run_test 78 "handle large O_DIRECT writes correctly ============"
5733 test_79() { # bug 12743
5734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5735 wait_delete_completed
5737 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5738 BKFREE=$(calc_osc_kbytes kbytesfree)
5739 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5741 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5742 DFTOTAL=`echo $STRING | cut -d, -f1`
5743 DFUSED=`echo $STRING | cut -d, -f2`
5744 DFAVAIL=`echo $STRING | cut -d, -f3`
5745 DFFREE=$(($DFTOTAL - $DFUSED))
5747 ALLOWANCE=$((64 * $OSTCOUNT))
5749 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5750 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5751 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5753 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5754 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5755 error "df free($DFFREE) mismatch OST free($BKFREE)"
5757 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5758 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5759 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5762 run_test 79 "df report consistency check ======================="
5764 test_80() { # bug 10718
5765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5766 # relax strong synchronous semantics for slow backends like ZFS
5767 local soc="obdfilter.*.sync_on_lock_cancel"
5768 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5770 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5771 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5772 facet_active_host $host; done | sort -u)
5773 do_nodes $hosts lctl set_param $soc=never
5776 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5778 local BEFORE=`date +%s`
5779 cancel_lru_locks osc
5780 local AFTER=`date +%s`
5781 local DIFF=$((AFTER-BEFORE))
5782 if [ $DIFF -gt 1 ] ; then
5783 error "elapsed for 1M@1T = $DIFF"
5786 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5790 run_test 80 "Page eviction is equally fast at high offsets too ===="
5792 test_81a() { # LU-456
5793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5794 remote_ost_nodsh && skip "remote OST with nodsh" && return
5795 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5796 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5797 do_facet ost1 lctl set_param fail_loc=0x80000228
5799 # write should trigger a retry and success
5800 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5801 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5803 if [ $RC -ne 0 ] ; then
5804 error "write should success, but failed for $RC"
5807 run_test 81a "OST should retry write when get -ENOSPC ==============="
5809 test_81b() { # LU-456
5810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5811 remote_ost_nodsh && skip "remote OST with nodsh" && return
5812 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5813 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5814 do_facet ost1 lctl set_param fail_loc=0x228
5816 # write should retry several times and return -ENOSPC finally
5817 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5818 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5821 if [ $RC -ne $ENOSPC ] ; then
5822 error "dd should fail for -ENOSPC, but succeed."
5825 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5827 test_82() { # LU-1031
5828 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5832 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5834 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5836 kill -USR1 $MULTIPID2
5838 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5839 error "First grouplock does not block second one"
5841 echo "Second grouplock blocks first one"
5843 kill -USR1 $MULTIPID1
5847 run_test 82 "Basic grouplock test ==============================="
5850 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5852 test_mkdir -p $DIR/d99cvsroot
5853 chown $RUNAS_ID $DIR/d99cvsroot
5854 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5857 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5860 run_test 99a "cvs init ========================================="
5863 [ -z "$(which cvs 2>/dev/null)" ] &&
5864 skip_env "could not find cvs" && return
5865 [ ! -d $DIR/d99cvsroot ] && test_99a
5867 # some versions of cvs import exit(1) when asked to import links or
5868 # files they can't read. ignore those files.
5869 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5870 ! -perm +4 -printf '-I %f\n')
5871 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5872 d99reposname vtag rtag
5874 run_test 99b "cvs import ======================================="
5877 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5878 [ ! -d $DIR/d99cvsroot ] && test_99b
5880 test_mkdir -p $DIR/d99reposname
5881 chown $RUNAS_ID $DIR/d99reposname
5882 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5884 run_test 99c "cvs checkout ====================================="
5887 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5888 [ ! -d $DIR/d99cvsroot ] && test_99c
5889 cd $DIR/d99reposname
5891 $RUNAS cvs add -m 'addmsg' foo99
5893 run_test 99d "cvs add =========================================="
5896 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5897 [ ! -d $DIR/d99cvsroot ] && test_99c
5898 cd $DIR/d99reposname
5901 run_test 99e "cvs update ======================================="
5904 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5905 [ ! -d $DIR/d99cvsroot ] && test_99d
5906 cd $DIR/d99reposname
5907 $RUNAS cvs commit -m 'nomsg' foo99
5908 rm -fr $DIR/d99cvsroot
5910 run_test 99f "cvs commit ======================================="
5913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5914 [ "$NETTYPE" = tcp ] || \
5915 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5918 remote_ost_nodsh && skip "remote OST with nodsh" && return
5919 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5921 { skip "useless for local single node setup" && return; }
5923 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5924 [ "$PROT" != "tcp" ] && continue
5925 RPORT=$(echo $REMOTE | cut -d: -f2)
5926 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5929 LPORT=`echo $LOCAL | cut -d: -f2`
5930 if [ $LPORT -ge 1024 ]; then
5931 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5933 error_exit "local: $LPORT > 1024, remote: $RPORT"
5936 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5938 run_test 100 "check local port using privileged port ==========="
5940 function get_named_value()
5949 echo $line | sed "s/^$tag[ ]*//"
5956 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5957 awk '/^max_cached_mb/ { print $2 }')
5960 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5966 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5970 local cache_limit=32
5972 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5973 trap cleanup_101a EXIT
5974 $LCTL set_param -n llite.*.read_ahead_stats 0
5975 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5978 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5980 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5981 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5984 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
5985 get_named_value 'read but discarded' | cut -d" " -f1); do
5986 discard=$(($discard + $s))
5990 if [[ $(($discard * 10)) -gt $nreads ]]; then
5991 $LCTL get_param osc.*-osc*.rpc_stats
5992 $LCTL get_param llite.*.read_ahead_stats
5993 error "too many ($discard) discarded pages"
5995 rm -f $DIR/$tfile || true
5997 run_test 101a "check read-ahead for random reads ================"
6000 test_mkdir -p $DIR/$tdir
6001 local STRIPE_SIZE=$1
6002 local FILE_LENGTH=$2
6005 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6007 local list=$(comma_list $(osts_nodes))
6008 set_osd_param $list '' read_cache_enable 0
6009 set_osd_param $list '' writethrough_cache_enable 0
6011 trap cleanup_test101bc EXIT
6012 # prepare the read-ahead file
6013 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6015 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6016 count=$FILE_SIZE_MB 2> /dev/null
6020 cleanup_test101bc() {
6025 local list=$(comma_list $(osts_nodes))
6026 set_osd_param $list '' read_cache_enable 1
6027 set_osd_param $list '' writethrough_cache_enable 1
6031 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6036 local STRIPE_SIZE=$2
6037 local FILE_LENGTH=$3
6038 local RA_INC=1048576
6039 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6040 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6041 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6042 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6043 get_named_value 'read but discarded' |
6044 cut -d" " -f1 | calc_total)
6045 if [[ $DISCARD -gt $discard_limit ]]; then
6046 $LCTL get_param llite.*.read_ahead_stats
6047 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6049 echo "Read-ahead success for size ${READ_SIZE}"
6054 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6055 [[ $OSTCOUNT -lt 2 ]] &&
6056 skip_env "skipping stride IO stride-ahead test" && return
6057 local STRIPE_SIZE=1048576
6058 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6059 if [ $SLOW == "yes" ]; then
6060 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6062 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6065 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6067 # prepare the read-ahead file
6068 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6069 cancel_lru_locks osc
6070 for BIDX in 2 4 8 16 32 64 128 256
6072 local BSIZE=$((BIDX*4096))
6073 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6074 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6075 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6076 $LCTL set_param -n llite.*.read_ahead_stats 0
6077 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6078 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6079 cancel_lru_locks osc
6080 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6085 run_test 101b "check stride-io mode read-ahead ================="
6088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6089 local STRIPE_SIZE=1048576
6090 local FILE_LENGTH=$((STRIPE_SIZE*100))
6094 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6096 cancel_lru_locks osc
6097 $LCTL set_param osc.*.rpc_stats 0
6098 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6099 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6100 local stats=$($LCTL get_param -n $osc_rpc_stats)
6101 local lines=$(echo "$stats" | awk 'END {print NR;}')
6104 if [ $lines -le 20 ]; then
6107 for size in 1 2 4 8; do
6108 local rpc=$(echo "$stats" |
6109 awk '($1 == "'$size':") {print $2; exit; }')
6111 error "Small $((size*4))k read IO $rpc !"
6113 echo "$osc_rpc_stats check passed!"
6118 run_test 101c "check stripe_size aligned read-ahead ================="
6121 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6122 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6127 local file=$DIR/$tfile
6128 local sz_MB=${FILESIZE_101d:-500}
6129 local ra_MB=${READAHEAD_MB:-40}
6131 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6132 [ $free_MB -lt $sz_MB ] &&
6133 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6135 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6136 $SETSTRIPE -c -1 $file || error "setstripe failed"
6138 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6139 echo Cancel LRU locks on lustre client to flush the client cache
6140 cancel_lru_locks osc
6142 echo Disable read-ahead
6143 local old_READAHEAD=$(set_read_ahead 0)
6145 echo Reading the test file $file with read-ahead disabled
6146 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6148 echo Cancel LRU locks on lustre client to flush the client cache
6149 cancel_lru_locks osc
6150 echo Enable read-ahead with ${ra_MB}MB
6151 set_read_ahead $ra_MB
6153 echo Reading the test file $file with read-ahead enabled
6154 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6156 echo "read-ahead disabled time read $raOFF"
6157 echo "read-ahead enabled time read $raON"
6159 set_read_ahead $old_READAHEAD
6161 wait_delete_completed
6163 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6164 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6166 run_test 101d "file read with and without read-ahead enabled"
6169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6170 local file=$DIR/$tfile
6171 local size_KB=500 #KB
6175 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6176 local need_KB=$((count * size_KB))
6177 [[ $free_KB -le $need_KB ]] &&
6178 skip_env "Need free space $need_KB, have $free_KB" && return
6180 echo "Creating $count ${size_KB}K test files"
6181 for ((i = 0; i < $count; i++)); do
6182 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6185 echo "Cancel LRU locks on lustre client to flush the client cache"
6186 cancel_lru_locks osc
6188 echo "Reset readahead stats"
6189 $LCTL set_param -n llite.*.read_ahead_stats 0
6191 for ((i = 0; i < $count; i++)); do
6192 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6195 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6196 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6198 for ((i = 0; i < $count; i++)); do
6199 rm -rf $file.$i 2>/dev/null
6202 #10000 means 20% reads are missing in readahead
6203 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6205 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6207 cleanup_test101f() {
6209 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6210 rm -rf $DIR/$tfile 2>/dev/null
6214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6215 local file=$DIR/$tfile
6218 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6219 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6220 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6221 trap cleanup_test101f EXIT
6223 echo Cancel LRU locks on lustre client to flush the client cache
6224 cancel_lru_locks osc
6226 echo Reset readahead stats
6227 $LCTL set_param -n llite.*.read_ahead_stats 0
6228 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6229 # readahead should read in 2M file on second read, so only miss
6231 echo Random 4K reads on 2M file for 1000 times
6232 $READS -f $file -s 2097152 -b 4096 -n $nreads
6234 echo checking missing pages
6235 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6236 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6238 [ $miss -lt 3 ] || error "misses too much pages!"
6241 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6244 test_mkdir -p $DIR/$tdir
6245 chown $RUNAS_ID $DIR/$tdir
6248 STRIPE_COUNT=$OSTCOUNT
6249 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6251 trap cleanup_test102 EXIT
6253 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6255 for num in 1 2 3 4; do
6256 for count in $(seq 1 $STRIPE_COUNT); do
6257 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6258 local size=`expr $STRIPE_SIZE \* $num`
6259 local file=file"$num-$idx-$count"
6260 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6266 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6272 rm -rf $DIR/d0.sanity/d102
6276 local testfile=$DIR/xattr_testfile
6280 [ "$UID" != 0 ] && skip_env "must run as root" && return
6281 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6282 skip_env "must have user_xattr" && return
6284 [ -z "$(which setfattr 2>/dev/null)" ] &&
6285 skip_env "could not find setfattr" && return
6287 echo "set/get xattr..."
6288 setfattr -n trusted.name1 -v value1 $testfile ||
6289 error "setfattr -n trusted.name1=value1 $testfile failed"
6290 getfattr -n trusted.name1 $testfile 2> /dev/null |
6291 grep "trusted.name1=.value1" ||
6292 error "$testfile missing trusted.name1=value1"
6294 setfattr -n user.author1 -v author1 $testfile ||
6295 error "setfattr -n user.author1=author1 $testfile failed"
6296 getfattr -n user.author1 $testfile 2> /dev/null |
6297 grep "user.author1=.author1" ||
6298 error "$testfile missing trusted.author1=author1"
6301 setfattr -n trusted.name2 -v value2 $testfile ||
6302 error "$testfile unable to set trusted.name2"
6303 setfattr -n trusted.name3 -v value3 $testfile ||
6304 error "$testfile unable to set trusted.name3"
6305 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6306 grep "trusted.name" | wc -l) -eq 3 ] ||
6307 error "$testfile missing 3 trusted.name xattrs"
6309 setfattr -n user.author2 -v author2 $testfile ||
6310 error "$testfile unable to set user.author2"
6311 setfattr -n user.author3 -v author3 $testfile ||
6312 error "$testfile unable to set user.author3"
6313 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6314 grep "user.author" | wc -l) -eq 3 ] ||
6315 error "$testfile missing 3 user.author xattrs"
6317 echo "remove xattr..."
6318 setfattr -x trusted.name1 $testfile ||
6319 error "$testfile error deleting trusted.name1"
6320 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6321 error "$testfile did not delete trusted.name1 xattr"
6323 setfattr -x user.author1 $testfile ||
6324 error "$testfile error deleting user.author1"
6325 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6326 error "$testfile did not delete trusted.name1 xattr"
6328 # b10667: setting lustre special xattr be silently discarded
6329 echo "set lustre special xattr ..."
6330 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6331 error "$testfile allowed setting trusted.lov"
6333 run_test 102a "user xattr test =================================="
6336 [ -z "$(which setfattr 2>/dev/null)" ] &&
6337 skip_env "could not find setfattr" && return
6339 # b10930: get/set/list trusted.lov xattr
6340 echo "get/set/list trusted.lov xattr ..."
6341 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6342 local testfile=$DIR/$tfile
6343 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6344 error "setstripe failed"
6345 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6346 error "getstripe failed"
6347 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6348 error "can't get trusted.lov from $testfile"
6350 local testfile2=${testfile}2
6351 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6352 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6355 setfattr -n trusted.lov -v $value $testfile2
6356 local stripe_size=$($GETSTRIPE -S $testfile2)
6357 local stripe_count=$($GETSTRIPE -c $testfile2)
6358 [[ $stripe_size -eq 65536 ]] ||
6359 error "stripe size $stripe_size != 65536"
6360 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6361 error "stripe count $stripe_count != $STRIPECOUNT"
6364 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6367 [ -z "$(which setfattr 2>/dev/null)" ] &&
6368 skip_env "could not find setfattr" && return
6370 # b10930: get/set/list lustre.lov xattr
6371 echo "get/set/list lustre.lov xattr ..."
6372 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6373 test_mkdir -p $DIR/$tdir
6374 chown $RUNAS_ID $DIR/$tdir
6375 local testfile=$DIR/$tdir/$tfile
6376 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6377 error "setstripe failed"
6378 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6379 error "getstripe failed"
6380 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6381 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6383 local testfile2=${testfile}2
6384 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6385 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6387 $RUNAS $MCREATE $testfile2
6388 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6389 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6390 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6391 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6392 [ $stripe_count -eq $STRIPECOUNT ] ||
6393 error "stripe count $stripe_count != $STRIPECOUNT"
6395 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6397 compare_stripe_info1() {
6398 local stripe_index_all_zero=true
6400 for num in 1 2 3 4; do
6401 for count in $(seq 1 $STRIPE_COUNT); do
6402 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6403 local size=$((STRIPE_SIZE * num))
6404 local file=file"$num-$offset-$count"
6405 stripe_size=$(lfs getstripe -S $PWD/$file)
6406 [[ $stripe_size -ne $size ]] &&
6407 error "$file: size $stripe_size != $size"
6408 stripe_count=$(lfs getstripe -c $PWD/$file)
6409 # allow fewer stripes to be created, ORI-601
6410 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6411 error "$file: count $stripe_count != $count"
6412 stripe_index=$(lfs getstripe -i $PWD/$file)
6413 [[ $stripe_index -ne 0 ]] &&
6414 stripe_index_all_zero=false
6418 $stripe_index_all_zero &&
6419 error "all files are being extracted starting from OST index 0"
6424 [ -n "$(which tar 2>/dev/null)" ] &&
6425 strings $(which tar) | grep -q "lustre" && echo tar
6429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6430 # b10930: tar test for trusted.lov xattr
6431 TAR=$(find_lustre_tar)
6432 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6433 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6435 test_mkdir -p $DIR/d102d
6436 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6438 compare_stripe_info1
6440 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6444 # b10930: tar test for trusted.lov xattr
6445 TAR=$(find_lustre_tar)
6446 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6447 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6449 test_mkdir -p $DIR/d102f
6451 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6453 compare_stripe_info1
6455 run_test 102f "tar copy files, not keep osts ==========="
6458 local xsize=${1:-1024} # in bytes
6459 local file=$DIR/$tfile
6461 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6462 skip "must have user_xattr" && return 0
6463 [ -z "$(which setfattr 2>/dev/null)" ] &&
6464 skip_env "could not find setfattr" && return 0
6465 [ -z "$(which getfattr 2>/dev/null)" ] &&
6466 skip_env "could not find getfattr" && return 0
6470 local value="$(generate_string $xsize)"
6472 local xbig=trusted.big
6473 log "save $xbig on $file"
6474 setfattr -n $xbig -v $value $file ||
6475 error "saving $xbig on $file failed"
6477 local orig=$(get_xattr_value $xbig $file)
6478 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6480 local xsml=trusted.sml
6481 log "save $xsml on $file"
6482 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6484 local new=$(get_xattr_value $xbig $file)
6485 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6487 log "grow $xsml on $file"
6488 setfattr -n $xsml -v "$value" $file ||
6489 error "growing $xsml on $file failed"
6491 new=$(get_xattr_value $xbig $file)
6492 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6493 log "$xbig still valid after growing $xsml"
6498 test_102h() { # bug 15777
6501 run_test 102h "grow xattr from inside inode to external block"
6504 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6505 grow_xattr $(max_xattr_size)
6507 run_test 102ha "grow xattr from inside inode to external inode"
6509 test_102i() { # bug 17038
6510 [ -z "$(which getfattr 2>/dev/null)" ] &&
6511 skip "could not find getfattr" && return
6513 ln -s $DIR/$tfile $DIR/${tfile}link
6514 getfattr -n trusted.lov $DIR/$tfile ||
6515 error "lgetxattr on $DIR/$tfile failed"
6516 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6517 grep -i "no such attr" ||
6518 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6519 rm -f $DIR/$tfile $DIR/${tfile}link
6521 run_test 102i "lgetxattr test on symbolic link ============"
6524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6525 TAR=$(find_lustre_tar)
6526 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6527 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6528 setup_test102 "$RUNAS"
6529 test_mkdir -p $DIR/d102j
6530 chown $RUNAS_ID $DIR/d102j
6531 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6533 compare_stripe_info1 "$RUNAS"
6535 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6538 [ -z "$(which setfattr 2>/dev/null)" ] &&
6539 skip "could not find setfattr" && return
6541 # b22187 just check that does not crash for regular file.
6542 setfattr -n trusted.lov $DIR/$tfile
6543 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6544 local test_kdir=$DIR/d102k
6545 test_mkdir $test_kdir
6546 local default_size=`$GETSTRIPE -S $test_kdir`
6547 local default_count=`$GETSTRIPE -c $test_kdir`
6548 local default_offset=`$GETSTRIPE -i $test_kdir`
6549 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6550 error 'dir setstripe failed'
6551 setfattr -n trusted.lov $test_kdir
6552 local stripe_size=`$GETSTRIPE -S $test_kdir`
6553 local stripe_count=`$GETSTRIPE -c $test_kdir`
6554 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6555 [ $stripe_size -eq $default_size ] ||
6556 error "stripe size $stripe_size != $default_size"
6557 [ $stripe_count -eq $default_count ] ||
6558 error "stripe count $stripe_count != $default_count"
6559 [ $stripe_offset -eq $default_offset ] ||
6560 error "stripe offset $stripe_offset != $default_offset"
6561 rm -rf $DIR/$tfile $test_kdir
6563 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6566 [ -z "$(which getfattr 2>/dev/null)" ] &&
6567 skip "could not find getfattr" && return
6569 # LU-532 trusted. xattr is invisible to non-root
6570 local testfile=$DIR/$tfile
6574 echo "listxattr as user..."
6575 chown $RUNAS_ID $testfile
6576 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6577 grep -q "trusted" &&
6578 error "$testfile trusted xattrs are user visible"
6582 run_test 102l "listxattr size test =================================="
6584 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6585 local path=$DIR/$tfile
6588 listxattr_size_check $path || error "listattr_size_check $path failed"
6590 run_test 102m "Ensure listxattr fails on small bufffer ========"
6594 getxattr() { # getxattr path name
6595 # Return the base64 encoding of the value of xattr name on path.
6599 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6601 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6603 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6605 getfattr --absolute-names --encoding=base64 --name=$name $path |
6606 awk -F= -v name=$name '$1 == name {
6607 print substr($0, index($0, "=") + 1);
6611 test_102n() { # LU-4101 mdt: protect internal xattrs
6612 local file0=$DIR/$tfile.0
6613 local file1=$DIR/$tfile.1
6614 local xattr0=$TMP/$tfile.0
6615 local xattr1=$TMP/$tfile.1
6619 [ -z "$(which setfattr 2>/dev/null)" ] &&
6620 skip "could not find setfattr" && return
6622 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6624 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6628 rm -rf $file0 $file1 $xattr0 $xattr1
6631 # Get 'before' xattrs of $file1.
6632 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6634 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6635 # Try to copy xattr from $file0 to $file1.
6636 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6638 setfattr --name=trusted.$name --value="$value" $file1 ||
6639 error "setxattr 'trusted.$name' failed"
6641 # Try to set a garbage xattr.
6642 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6644 setfattr --name=trusted.$name --value="$value" $file1 ||
6645 error "setxattr 'trusted.$name' failed"
6647 # Try to remove the xattr from $file1. We don't care if this
6648 # appears to succeed or fail, we just don't want there to be
6649 # any changes or crashes.
6650 setfattr --remove=$trusted.$name $file1 2> /dev/null
6653 # Get 'after' xattrs of file1.
6654 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6656 if ! diff $xattr0 $xattr1; then
6657 error "before and after xattrs of '$file1' differ"
6660 rm -rf $file0 $file1 $xattr0 $xattr1
6664 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6666 test_102p() { # LU-4703 setxattr did not check ownership
6667 local testfile=$DIR/$tfile
6669 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6670 skip "MDS needs to be at least 2.5.56" && return
6674 echo "setfacl as user..."
6675 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6676 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6678 echo "setfattr as user..."
6679 setfacl -m "u:$RUNAS_ID:---" $testfile
6680 $RUNAS setfattr -x system.posix_acl_access $testfile
6681 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6683 run_test 102p "check setxattr(2) correctly fails without permission"
6687 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6692 [ "$UID" != 0 ] && skip_env "must run as root" && return
6693 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6694 skip "must have acl enabled" && return
6695 [ -z "$(which setfacl 2>/dev/null)" ] &&
6696 skip_env "could not find setfacl" && return
6697 $GSS && skip "could not run under gss" && return
6699 declare -a identity_old
6701 for num in $(seq $MDSCOUNT); do
6702 switch_identity $num true || identity_old[$num]=$?
6709 echo "performing cp ..."
6710 run_acl_subtest cp || error "run_acl_subtest cp failed"
6711 echo "performing getfacl-noacl..."
6712 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6713 echo "performing misc..."
6714 run_acl_subtest misc || error "misc test failed"
6715 echo "performing permissions..."
6716 run_acl_subtest permissions || error "permissions failed"
6717 echo "performing setfacl..."
6718 run_acl_subtest setfacl || error "setfacl test failed"
6720 # inheritance test got from HP
6721 echo "performing inheritance..."
6722 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6723 chmod +x make-tree || error "chmod +x failed"
6724 run_acl_subtest inheritance || error "inheritance test failed"
6727 echo "LU-974 ignore umask when acl is enabled..."
6728 run_acl_subtest 974 || error "LU-974 umask test failed"
6729 if [ $MDSCOUNT -ge 2 ]; then
6730 run_acl_subtest 974_remote ||
6731 error "LU-974 umask test failed under remote dir"
6734 echo "LU-2561 newly created file is same size as directory..."
6735 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6736 run_acl_subtest 2561 || error "LU-2561 test failed"
6738 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6744 for num in $(seq $MDSCOUNT); do
6745 if [ "${identity_old[$num]}" = 1 ]; then
6746 switch_identity $num false || identity_old[$num]=$?
6750 run_test 103 "acl test ========================================="
6753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6755 lfs df || error "lfs df failed"
6756 lfs df -ih || error "lfs df -ih failed"
6757 lfs df -h $DIR || error "lfs df -h $DIR failed"
6758 lfs df -i $DIR || error "lfs df -i $DIR failed"
6759 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6760 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6762 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6763 lctl --device %$OSC deactivate
6764 lfs df || error "lfs df with deactivated OSC failed"
6765 lctl --device %$OSC activate
6766 # wait the osc back to normal
6767 wait_osc_import_state client ost FULL
6769 lfs df || error "lfs df with reactivated OSC failed"
6772 run_test 104a "lfs df [-ih] [path] test ========================="
6775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6776 [ $RUNAS_ID -eq $UID ] &&
6777 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6779 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6780 grep "Permission denied" | wc -l)))
6781 if [ $denied_cnt -ne 0 ]; then
6782 error "lfs check servers test failed"
6785 run_test 104b "$RUNAS lfs check servers test ===================="
6788 # doesn't work on 2.4 kernels
6790 if $(flock_is_enabled); then
6791 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6793 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6797 run_test 105a "flock when mounted without -o flock test ========"
6801 if $(flock_is_enabled); then
6802 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6804 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6808 run_test 105b "fcntl when mounted without -o flock test ========"
6812 if $(flock_is_enabled); then
6813 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6815 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6819 run_test 105c "lockf when mounted without -o flock test ========"
6821 test_105d() { # bug 15924
6822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6823 test_mkdir -p $DIR/$tdir
6824 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6825 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6826 $LCTL set_param fail_loc=0x80000315
6827 flocks_test 2 $DIR/$tdir
6829 run_test 105d "flock race (should not freeze) ========"
6831 test_105e() { # bug 22660 && 22040
6832 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6834 flocks_test 3 $DIR/$tfile
6836 run_test 105e "Two conflicting flocks from same process ======="
6838 test_106() { #bug 10921
6839 test_mkdir -p $DIR/$tdir
6840 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6841 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6843 run_test 106 "attempt exec of dir followed by chown of that dir"
6846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6853 local save_pattern=$(sysctl -n kernel.core_pattern)
6854 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6855 sysctl -w kernel.core_pattern=$file
6856 sysctl -w kernel.core_uses_pid=0
6864 kill -s 11 $SLEEPPID
6866 if [ -e $file ]; then
6867 size=`stat -c%s $file`
6868 [ $size -eq 0 ] && error "Fail to create core file $file"
6870 error "Fail to create core file $file"
6873 sysctl -w kernel.core_pattern=$save_pattern
6874 sysctl -w kernel.core_uses_pid=$save_uses_pid
6877 run_test 107 "Coredump on SIG"
6880 test_mkdir -p $DIR/$tdir
6881 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6882 error "mkdir with 255 char failed"
6883 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6884 error "mkdir with 256 char should fail, but did not"
6885 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6886 error "create with 255 char failed"
6887 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6888 error "create with 256 char should fail, but did not"
6893 run_test 110 "filename length checking"
6896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6897 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
6898 tail -1 | cut -c11-20)
6899 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
6900 echo "Starting with $OSTIO_pre threads"
6903 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
6904 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
6905 echo "$NUMTEST creates/unlinks"
6906 test_mkdir -p $DIR/$tdir
6907 createmany -o $DIR/$tdir/$tfile $NUMTEST
6908 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6910 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
6911 tail -1 | cut -c11-20)
6913 # don't return an error
6914 [ $OSTIO_post == $OSTIO_pre ] && echo \
6915 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6916 echo "This may be fine, depending on what ran before this test" &&
6917 echo "and how fast this system is." && return
6919 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6921 run_test 115 "verify dynamic thread creation===================="
6924 wait_delete_completed
6925 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6926 echo OST kbytes available: ${AVAIL[@]}
6927 MAXI=0; MAXV=${AVAIL[0]}
6928 MINI=0; MINV=${AVAIL[0]}
6929 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6930 #echo OST $i: ${AVAIL[i]}kb
6931 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
6932 MAXV=${AVAIL[i]}; MAXI=$i
6934 if [[ ${AVAIL[i]} -lt $MINV ]]; then
6935 MINV=${AVAIL[i]}; MINI=$i
6938 echo Min free space: OST $MINI: $MINV
6939 echo Max free space: OST $MAXI: $MAXV
6942 test_116a() { # was previously test_116()
6943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6944 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
6946 echo -n "Free space priority "
6947 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6952 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6953 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
6955 trap simple_cleanup_common EXIT
6958 # Check if we need to generate uneven OSTs
6959 test_mkdir -p $DIR/$tdir/OST${MINI}
6960 local FILL=$(($MINV / 4))
6961 local DIFF=$(($MAXV - $MINV))
6962 local DIFF2=$(($DIFF * 100 / $MINV))
6964 local threshold=$(do_facet $SINGLEMDS \
6965 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6966 threshold=${threshold%%%}
6967 echo -n "Check for uneven OSTs: "
6968 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6970 if [[ $DIFF2 -gt $threshold ]]; then
6972 echo "Don't need to fill OST$MINI"
6974 # generate uneven OSTs. Write 2% over the QOS threshold value
6976 DIFF=$(($threshold - $DIFF2 + 2))
6977 DIFF2=$(( ($MINV * $DIFF)/100 ))
6978 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6979 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6980 error "setstripe failed"
6981 DIFF=$(($DIFF2 / 2048))
6983 while [ $i -lt $DIFF ]; do
6985 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6986 bs=2M count=1 2>/dev/null
6995 DIFF=$(($MAXV - $MINV))
6996 DIFF2=$(($DIFF * 100 / $MINV))
6997 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6998 if [[ $DIFF2 -gt $threshold ]]; then
7001 echo "failed - QOS mode won't be used"
7002 skip "QOS imbalance criteria not met"
7003 simple_cleanup_common
7007 MINI1=$MINI; MINV1=$MINV
7008 MAXI1=$MAXI; MAXV1=$MAXV
7010 # now fill using QOS
7011 $SETSTRIPE -c 1 $DIR/$tdir
7012 FILL=$(($FILL / 200))
7013 if [ $FILL -gt 600 ]; then
7016 echo "writing $FILL files to QOS-assigned OSTs"
7018 while [ $i -lt $FILL ]; do
7020 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7024 echo "wrote $i 200k files"
7028 echo "Note: free space may not be updated, so measurements might be off"
7030 DIFF2=$(($MAXV - $MINV))
7031 echo "free space delta: orig $DIFF final $DIFF2"
7032 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7033 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7034 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7035 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7036 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7037 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7039 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7041 # Figure out which files were written where
7042 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7043 awk '/'$MINI1': / {print $2; exit}')
7045 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7046 echo "$MINC files created on smaller OST $MINI1"
7047 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7048 awk '/'$MAXI1': / {print $2; exit}')
7050 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7051 echo "$MAXC files created on larger OST $MAXI1"
7052 FILL=$(($MAXC * 100 / $MINC - 100))
7053 [[ $MINC -gt 0 ]] &&
7054 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7055 [[ $MAXC -gt $MINC ]] ||
7056 error_ignore LU-9 "stripe QOS didn't balance free space"
7057 simple_cleanup_common
7059 run_test 116a "stripe QOS: free space balance ==================="
7061 test_116b() { # LU-2093
7062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7063 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7064 head -1 2>/dev/null)" ] && skip "no QOS" && return
7065 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7067 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7068 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7069 do_facet $SINGLEMDS lctl set_param \
7070 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7072 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7073 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7074 do_facet $SINGLEMDS lctl set_param fail_loc=0
7076 do_facet $SINGLEMDS lctl set_param \
7077 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7079 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7081 test_117() # bug 10891
7083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7084 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7085 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7086 lctl set_param fail_loc=0x21e
7087 > $DIR/$tfile || error "truncate failed"
7088 lctl set_param fail_loc=0
7089 echo "Truncate succeeded."
7092 run_test 117 "verify osd extend =========="
7094 NO_SLOW_RESENDCOUNT=4
7095 export OLD_RESENDCOUNT=""
7096 set_resend_count () {
7097 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7098 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7099 lctl set_param -n $PROC_RESENDCOUNT $1
7100 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7103 # for reduce test_118* time (b=14842)
7104 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7106 # Reset async IO behavior after error case
7108 FILE=$DIR/reset_async
7110 # Ensure all OSCs are cleared
7111 $SETSTRIPE -c -1 $FILE
7112 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7117 test_118a() #bug 11710
7119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7122 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7123 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7124 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7126 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7127 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7132 run_test 118a "verify O_SYNC works =========="
7136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7137 remote_ost_nodsh && skip "remote OST with nodsh" && return
7141 #define OBD_FAIL_OST_ENOENT 0x217
7142 set_nodes_failloc "$(osts_nodes)" 0x217
7143 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7145 set_nodes_failloc "$(osts_nodes)" 0
7146 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7147 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7150 if [[ $RC -eq 0 ]]; then
7151 error "Must return error due to dropped pages, rc=$RC"
7155 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7156 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7160 echo "Dirty pages not leaked on ENOENT"
7162 # Due to the above error the OSC will issue all RPCs syncronously
7163 # until a subsequent RPC completes successfully without error.
7164 $MULTIOP $DIR/$tfile Ow4096yc
7169 run_test 118b "Reclaim dirty pages on fatal error =========="
7173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7175 # for 118c, restore the original resend count, LU-1940
7176 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7177 set_resend_count $OLD_RESENDCOUNT
7178 remote_ost_nodsh && skip "remote OST with nodsh" && return
7182 #define OBD_FAIL_OST_EROFS 0x216
7183 set_nodes_failloc "$(osts_nodes)" 0x216
7185 # multiop should block due to fsync until pages are written
7186 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7190 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7191 error "Multiop failed to block on fsync, pid=$MULTIPID"
7194 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7196 if [[ $WRITEBACK -eq 0 ]]; then
7197 error "No page in writeback, writeback=$WRITEBACK"
7200 set_nodes_failloc "$(osts_nodes)" 0
7203 if [[ $RC -ne 0 ]]; then
7204 error "Multiop fsync failed, rc=$RC"
7207 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7208 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7210 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7211 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7215 echo "Dirty pages flushed via fsync on EROFS"
7218 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7220 # continue to use small resend count to reduce test_118* time (b=14842)
7221 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7226 remote_ost_nodsh && skip "remote OST with nodsh" && return
7230 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7231 set_nodes_failloc "$(osts_nodes)" 0x214
7232 # multiop should block due to fsync until pages are written
7233 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7237 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7238 error "Multiop failed to block on fsync, pid=$MULTIPID"
7241 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7243 if [[ $WRITEBACK -eq 0 ]]; then
7244 error "No page in writeback, writeback=$WRITEBACK"
7247 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7248 set_nodes_failloc "$(osts_nodes)" 0
7250 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7251 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7253 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7254 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7258 echo "Dirty pages gaurenteed flushed via fsync"
7261 run_test 118d "Fsync validation inject a delay of the bulk =========="
7264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7267 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7268 lctl set_param fail_loc=0x8000040a
7270 # Should simulate EINVAL error which is fatal
7271 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7273 if [[ $RC -eq 0 ]]; then
7274 error "Must return error due to dropped pages, rc=$RC"
7277 lctl set_param fail_loc=0x0
7279 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7280 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7281 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7283 if [[ $LOCKED -ne 0 ]]; then
7284 error "Locked pages remain in cache, locked=$LOCKED"
7287 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7288 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7292 echo "No pages locked after fsync"
7297 run_test 118f "Simulate unrecoverable OSC side error =========="
7300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7303 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7304 lctl set_param fail_loc=0x406
7306 # simulate local -ENOMEM
7307 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7310 lctl set_param fail_loc=0
7311 if [[ $RC -eq 0 ]]; then
7312 error "Must return error due to dropped pages, rc=$RC"
7315 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7316 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7317 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7319 if [[ $LOCKED -ne 0 ]]; then
7320 error "Locked pages remain in cache, locked=$LOCKED"
7323 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7324 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7328 echo "No pages locked after fsync"
7333 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7337 remote_ost_nodsh && skip "remote OST with nodsh" && return
7341 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7342 set_nodes_failloc "$(osts_nodes)" 0x20e
7343 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7344 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7347 set_nodes_failloc "$(osts_nodes)" 0
7348 if [[ $RC -eq 0 ]]; then
7349 error "Must return error due to dropped pages, rc=$RC"
7352 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7353 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7354 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7356 if [[ $LOCKED -ne 0 ]]; then
7357 error "Locked pages remain in cache, locked=$LOCKED"
7360 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7361 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7365 echo "No pages locked after fsync"
7369 run_test 118h "Verify timeout in handling recoverables errors =========="
7371 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7375 remote_ost_nodsh && skip "remote OST with nodsh" && return
7379 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7380 set_nodes_failloc "$(osts_nodes)" 0x20e
7382 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7383 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7386 set_nodes_failloc "$(osts_nodes)" 0
7390 if [[ $RC -ne 0 ]]; then
7391 error "got error, but should be not, rc=$RC"
7394 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7395 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7396 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7397 if [[ $LOCKED -ne 0 ]]; then
7398 error "Locked pages remain in cache, locked=$LOCKED"
7401 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7402 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7406 echo "No pages locked after fsync"
7410 run_test 118i "Fix error before timeout in recoverable error =========="
7412 [ "$SLOW" = "no" ] && set_resend_count 4
7415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7416 remote_ost_nodsh && skip "remote OST with nodsh" && return
7420 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7421 set_nodes_failloc "$(osts_nodes)" 0x220
7423 # return -EIO from OST
7424 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7426 set_nodes_failloc "$(osts_nodes)" 0x0
7427 if [[ $RC -eq 0 ]]; then
7428 error "Must return error due to dropped pages, rc=$RC"
7431 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7432 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7433 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7434 if [[ $LOCKED -ne 0 ]]; then
7435 error "Locked pages remain in cache, locked=$LOCKED"
7438 # in recoverable error on OST we want resend and stay until it finished
7439 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7440 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7444 echo "No pages locked after fsync"
7448 run_test 118j "Simulate unrecoverable OST side error =========="
7452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7453 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7455 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7456 set_nodes_failloc "$(osts_nodes)" 0x20e
7457 test_mkdir -p $DIR/$tdir
7459 for ((i=0;i<10;i++)); do
7460 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7461 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7468 set_nodes_failloc "$(osts_nodes)" 0
7471 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7477 test_mkdir -p $DIR/$tdir
7478 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7481 run_test 118l "fsync dir ========="
7483 test_118m() # LU-3066
7485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7486 test_mkdir -p $DIR/$tdir
7487 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7490 run_test 118m "fdatasync dir ========="
7492 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7494 test_119a() # bug 11737
7496 BSIZE=$((512 * 1024))
7497 directio write $DIR/$tfile 0 1 $BSIZE
7498 # We ask to read two blocks, which is more than a file size.
7499 # directio will indicate an error when requested and actual
7500 # sizes aren't equeal (a normal situation in this case) and
7501 # print actual read amount.
7502 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7503 if [ "$NOB" != "$BSIZE" ]; then
7504 error "read $NOB bytes instead of $BSIZE"
7508 run_test 119a "Short directIO read must return actual read amount"
7510 test_119b() # bug 11737
7512 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7514 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7515 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7517 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7518 error "direct read failed"
7521 run_test 119b "Sparse directIO read must return actual read amount"
7523 test_119c() # bug 13099
7526 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7527 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7530 run_test 119c "Testing for direct read hitting hole"
7532 test_119d() # bug 15950
7534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7535 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7536 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7538 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7539 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7540 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7541 lctl set_param fail_loc=0x40d
7542 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7545 cat $DIR/$tfile > /dev/null &
7546 lctl set_param fail_loc=0
7549 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7551 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7552 error "the read rpcs have not completed in 2s"
7554 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7556 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7560 test_mkdir -p $DIR/$tdir
7561 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7562 skip "no early lock cancel on server" && return 0
7564 lru_resize_disable mdc
7565 lru_resize_disable osc
7566 cancel_lru_locks mdc
7567 # asynchronous object destroy at MDT could cause bl ast to client
7568 cancel_lru_locks osc
7570 stat $DIR/$tdir > /dev/null
7571 can1=$(do_facet $SINGLEMDS \
7572 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7573 awk '/ldlm_cancel/ {print $2}')
7574 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7575 awk '/ldlm_bl_callback/ {print $2}')
7576 test_mkdir -c1 $DIR/$tdir/d1
7577 can2=$(do_facet $SINGLEMDS \
7578 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7579 awk '/ldlm_cancel/ {print $2}')
7580 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7581 awk '/ldlm_bl_callback/ {print $2}')
7582 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7583 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7584 lru_resize_enable mdc
7585 lru_resize_enable osc
7587 run_test 120a "Early Lock Cancel: mkdir test"
7590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7591 test_mkdir $DIR/$tdir
7592 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7593 skip "no early lock cancel on server" && return 0
7594 lru_resize_disable mdc
7595 lru_resize_disable osc
7596 cancel_lru_locks mdc
7597 stat $DIR/$tdir > /dev/null
7598 can1=$(do_facet $SINGLEMDS \
7599 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7600 awk '/ldlm_cancel/ {print $2}')
7601 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7602 awk '/ldlm_bl_callback/ {print $2}')
7604 can2=$(do_facet $SINGLEMDS \
7605 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7606 awk '/ldlm_cancel/ {print $2}')
7607 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7608 awk '/ldlm_bl_callback/ {print $2}')
7609 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7610 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7611 lru_resize_enable mdc
7612 lru_resize_enable osc
7614 run_test 120b "Early Lock Cancel: create test"
7617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7618 test_mkdir -c1 $DIR/$tdir
7619 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7620 skip "no early lock cancel on server" && return 0
7621 lru_resize_disable mdc
7622 lru_resize_disable osc
7623 test_mkdir -p -c1 $DIR/$tdir/d1
7624 test_mkdir -p -c1 $DIR/$tdir/d2
7625 touch $DIR/$tdir/d1/f1
7626 cancel_lru_locks mdc
7627 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7628 can1=$(do_facet $SINGLEMDS \
7629 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7630 awk '/ldlm_cancel/ {print $2}')
7631 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7632 awk '/ldlm_bl_callback/ {print $2}')
7633 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7634 can2=$(do_facet $SINGLEMDS \
7635 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7636 awk '/ldlm_cancel/ {print $2}')
7637 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7638 awk '/ldlm_bl_callback/ {print $2}')
7639 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7640 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7641 lru_resize_enable mdc
7642 lru_resize_enable osc
7644 run_test 120c "Early Lock Cancel: link test"
7647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7648 test_mkdir -p -c1 $DIR/$tdir
7649 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7650 skip "no early lock cancel on server" && return 0
7651 lru_resize_disable mdc
7652 lru_resize_disable osc
7654 cancel_lru_locks mdc
7655 stat $DIR/$tdir > /dev/null
7656 can1=$(do_facet $SINGLEMDS \
7657 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7658 awk '/ldlm_cancel/ {print $2}')
7659 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7660 awk '/ldlm_bl_callback/ {print $2}')
7661 chmod a+x $DIR/$tdir
7662 can2=$(do_facet $SINGLEMDS \
7663 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7664 awk '/ldlm_cancel/ {print $2}')
7665 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7666 awk '/ldlm_bl_callback/ {print $2}')
7667 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7668 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7669 lru_resize_enable mdc
7670 lru_resize_enable osc
7672 run_test 120d "Early Lock Cancel: setattr test"
7675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7676 test_mkdir -p -c1 $DIR/$tdir
7677 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7678 skip "no early lock cancel on server" && return 0
7679 lru_resize_disable mdc
7680 lru_resize_disable osc
7681 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7682 cancel_lru_locks mdc
7683 cancel_lru_locks osc
7684 dd if=$DIR/$tdir/f1 of=/dev/null
7685 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7686 # XXX client can not do early lock cancel of OST lock
7687 # during unlink (LU-4206), so cancel osc lock now.
7688 cancel_lru_locks osc
7689 can1=$(do_facet $SINGLEMDS \
7690 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7691 awk '/ldlm_cancel/ {print $2}')
7692 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7693 awk '/ldlm_bl_callback/ {print $2}')
7694 unlink $DIR/$tdir/f1
7696 can2=$(do_facet $SINGLEMDS \
7697 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7698 awk '/ldlm_cancel/ {print $2}')
7699 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7700 awk '/ldlm_bl_callback/ {print $2}')
7701 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7702 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7703 lru_resize_enable mdc
7704 lru_resize_enable osc
7706 run_test 120e "Early Lock Cancel: unlink test"
7709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7710 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7711 skip "no early lock cancel on server" && return 0
7712 test_mkdir -p -c1 $DIR/$tdir
7713 lru_resize_disable mdc
7714 lru_resize_disable osc
7715 test_mkdir -p -c1 $DIR/$tdir/d1
7716 test_mkdir -p -c1 $DIR/$tdir/d2
7717 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7718 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7719 cancel_lru_locks mdc
7720 cancel_lru_locks osc
7721 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7722 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7723 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7724 # XXX client can not do early lock cancel of OST lock
7725 # during rename (LU-4206), so cancel osc lock now.
7726 cancel_lru_locks osc
7727 can1=$(do_facet $SINGLEMDS \
7728 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7729 awk '/ldlm_cancel/ {print $2}')
7730 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7731 awk '/ldlm_bl_callback/ {print $2}')
7732 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7734 can2=$(do_facet $SINGLEMDS \
7735 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7736 awk '/ldlm_cancel/ {print $2}')
7737 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7738 awk '/ldlm_bl_callback/ {print $2}')
7739 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7740 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7741 lru_resize_enable mdc
7742 lru_resize_enable osc
7744 run_test 120f "Early Lock Cancel: rename test"
7747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7748 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7749 skip "no early lock cancel on server" && return 0
7750 lru_resize_disable mdc
7751 lru_resize_disable osc
7753 echo create $count files
7754 test_mkdir -p $DIR/$tdir
7755 cancel_lru_locks mdc
7756 cancel_lru_locks osc
7759 can0=$(do_facet $SINGLEMDS \
7760 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7761 awk '/ldlm_cancel/ {print $2}')
7762 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7763 awk '/ldlm_bl_callback/ {print $2}')
7764 createmany -o $DIR/$tdir/f $count
7766 can1=$(do_facet $SINGLEMDS \
7767 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7768 awk '/ldlm_cancel/ {print $2}')
7769 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7770 awk '/ldlm_bl_callback/ {print $2}')
7772 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7773 echo rm $count files
7776 can2=$(do_facet $SINGLEMDS \
7777 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7778 awk '/ldlm_cancel/ {print $2}')
7779 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7780 awk '/ldlm_bl_callback/ {print $2}')
7782 echo total: $count removes in $((t2-t1))
7783 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7785 # wait for commitment of removal
7786 lru_resize_enable mdc
7787 lru_resize_enable osc
7789 run_test 120g "Early Lock Cancel: performance test"
7791 test_121() { #bug #10589
7792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7794 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7795 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7796 lctl set_param fail_loc=0x310
7797 cancel_lru_locks osc > /dev/null
7798 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7799 lctl set_param fail_loc=0
7800 [[ $reads -eq $writes ]] ||
7801 error "read $reads blocks, must be $writes blocks"
7803 run_test 121 "read cancel race ========="
7805 test_123a() { # was test 123, statahead(bug 11401)
7806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7808 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7809 log "testing on UP system. Performance may be not as good as expected."
7814 test_mkdir -p $DIR/$tdir
7815 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7816 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7818 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7819 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7821 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7822 lctl set_param -n llite.*.statahead_max 0
7823 lctl get_param llite.*.statahead_max
7824 cancel_lru_locks mdc
7825 cancel_lru_locks osc
7827 time ls -l $DIR/$tdir | wc -l
7829 delta=$((etime - stime))
7830 log "ls $i files without statahead: $delta sec"
7831 lctl set_param llite.*.statahead_max=$max
7833 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7834 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7835 cancel_lru_locks mdc
7836 cancel_lru_locks osc
7838 time ls -l $DIR/$tdir | wc -l
7840 delta_sa=$((etime - stime))
7841 log "ls $i files with statahead: $delta_sa sec"
7842 lctl get_param -n llite.*.statahead_stats
7843 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7845 [[ $swrong -lt $ewrong ]] &&
7846 log "statahead was stopped, maybe too many locks held!"
7847 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7849 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7850 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7851 lctl set_param -n llite.*.statahead_max 0
7852 lctl get_param llite.*.statahead_max
7853 cancel_lru_locks mdc
7854 cancel_lru_locks osc
7856 time ls -l $DIR/$tdir | wc -l
7858 delta=$((etime - stime))
7859 log "ls $i files again without statahead: $delta sec"
7860 lctl set_param llite.*.statahead_max=$max
7861 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7862 if [ $SLOWOK -eq 0 ]; then
7863 error "ls $i files is slower with statahead!"
7865 log "ls $i files is slower with statahead!"
7871 [ $delta -gt 20 ] && break
7872 [ $delta -gt 8 ] && MULT=$((50 / delta))
7873 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7881 delta=$((etime - stime))
7882 log "rm -r $DIR/$tdir/: $delta seconds"
7884 lctl get_param -n llite.*.statahead_stats
7886 run_test 123a "verify statahead work"
7888 test_123b () { # statahead(bug 15027)
7889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7890 test_mkdir -p $DIR/$tdir
7891 createmany -o $DIR/$tdir/$tfile-%d 1000
7893 cancel_lru_locks mdc
7894 cancel_lru_locks osc
7896 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7897 lctl set_param fail_loc=0x80000803
7898 ls -lR $DIR/$tdir > /dev/null
7900 lctl set_param fail_loc=0x0
7901 lctl get_param -n llite.*.statahead_stats
7906 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7910 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7911 skip "no lru resize on server" && return 0
7913 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7915 log "create $NR files at $DIR/$tdir"
7916 createmany -o $DIR/$tdir/f $NR ||
7917 error "failed to create $NR files in $DIR/$tdir"
7919 cancel_lru_locks mdc
7920 ls -l $DIR/$tdir > /dev/null
7924 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
7925 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7926 LRU_SIZE=$($LCTL get_param -n $PARAM)
7927 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
7928 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7930 log "NS=$(basename $NSDIR)"
7935 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
7936 skip "Not enough cached locks created!"
7943 # We know that lru resize allows one client to hold $LIMIT locks
7944 # for 10h. After that locks begin to be killed by client.
7946 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
7949 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7950 # killing locks. Some time was spent for creating locks. This means
7951 # that up to the moment of sleep finish we must have killed some of
7952 # them (10-100 locks). This depends on how fast ther were created.
7953 # Many of them were touched in almost the same moment and thus will
7954 # be killed in groups.
7955 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7957 # Use $LRU_SIZE_B here to take into account real number of locks
7958 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7959 local LRU_SIZE_B=$LRU_SIZE
7961 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
7962 log "OLD_LVF=$OLD_LVF"
7963 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
7965 # Let's make sure that we really have some margin. Client checks
7966 # cached locks every 10 sec.
7968 log "Sleep ${SLEEP} sec"
7970 while ((SEC<$SLEEP)); do
7974 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
7978 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7979 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
7981 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
7982 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7983 unlinkmany $DIR/$tdir/f $NR
7987 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7988 log "unlink $NR files at $DIR/$tdir"
7989 unlinkmany $DIR/$tdir/f $NR
7991 run_test 124a "lru resize ======================================="
7993 get_max_pool_limit()
7995 local limit=$($LCTL get_param \
7996 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
7999 if [[ $l -gt $max ]]; then
8007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8008 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8009 skip "no lru resize on server" && return 0
8011 LIMIT=$(get_max_pool_limit)
8013 NR=$(($(default_lru_size)*20))
8014 if [[ $NR -gt $LIMIT ]]; then
8015 log "Limit lock number by $LIMIT locks"
8018 lru_resize_disable mdc
8019 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8020 error "failed to create $DIR/$tdir/disable_lru_resize"
8022 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8023 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8024 cancel_lru_locks mdc
8027 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8030 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8033 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8037 nolruresize_delta=$((etime-stime))
8038 log "ls -la time: $nolruresize_delta seconds"
8039 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8040 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8042 lru_resize_enable mdc
8043 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8044 error "failed to create $DIR/$tdir/enable_lru_resize"
8046 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8047 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8048 cancel_lru_locks mdc
8051 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8054 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8057 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8061 lruresize_delta=$((etime-stime))
8062 log "ls -la time: $lruresize_delta seconds"
8063 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8065 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8066 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8067 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8068 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8070 log "lru resize performs the same with no lru resize"
8072 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8074 run_test 124b "lru resize (performance test) ======================="
8076 test_125() { # 13358
8077 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8078 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8079 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8080 test_mkdir -p $DIR/d125 || error "mkdir failed"
8081 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8082 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8083 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8085 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8087 test_126() { # bug 12829/13455
8088 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8089 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8090 $GSS && skip "must run as gss disabled" && return
8092 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8093 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8095 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8097 run_test 126 "check that the fsgid provided by the client is taken into account"
8099 test_127a() { # bug 15521
8100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8101 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8102 $LCTL set_param osc.*.stats=0
8103 FSIZE=$((2048 * 1024))
8104 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8105 cancel_lru_locks osc
8106 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8108 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8109 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8110 echo "got $COUNT $NAME"
8111 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8112 eval $NAME=$COUNT || error "Wrong proc format"
8115 read_bytes|write_bytes)
8116 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8117 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8118 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8119 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8120 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8121 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8122 error "sumsquare is too small: $SUMSQ"
8123 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8124 error "sumsquare is too big: $SUMSQ"
8128 done < $DIR/${tfile}.tmp
8130 #check that we actually got some stats
8131 [ "$read_bytes" ] || error "Missing read_bytes stats"
8132 [ "$write_bytes" ] || error "Missing write_bytes stats"
8133 [ "$read_bytes" != 0 ] || error "no read done"
8134 [ "$write_bytes" != 0 ] || error "no write done"
8136 run_test 127a "verify the client stats are sane"
8138 test_127b() { # bug LU-333
8139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8140 $LCTL set_param llite.*.stats=0
8141 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8142 # perform 2 reads and writes so MAX is different from SUM.
8143 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8144 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8145 cancel_lru_locks osc
8146 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8147 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8149 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8150 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8151 echo "got $COUNT $NAME"
8152 eval $NAME=$COUNT || error "Wrong proc format"
8156 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8157 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8158 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8159 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8162 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8163 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8164 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8165 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8169 done < $TMP/${tfile}.tmp
8171 #check that we actually got some stats
8172 [ "$read_bytes" ] || error "Missing read_bytes stats"
8173 [ "$write_bytes" ] || error "Missing write_bytes stats"
8174 [ "$read_bytes" != 0 ] || error "no read done"
8175 [ "$write_bytes" != 0 ] || error "no write done"
8177 run_test 127b "verify the llite client stats are sane"
8179 test_128() { # bug 15212
8181 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8186 result=$(grep error $TMP/$tfile.log)
8188 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8190 run_test 128 "interactive lfs for 2 consecutive find's"
8197 local LDPROC=/proc/fs/ldiskfs
8198 local facets=$(get_facets MDS)
8200 for facet in ${facets//,/ }; do
8201 canondev=$(ldiskfs_canon \
8202 *.$(convert_facet2label $facet).mntdev $facet)
8203 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8204 LDPROC=/sys/fs/ldiskfs
8205 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8211 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8212 skip "Only applicable to ldiskfs-based MDTs"
8215 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8220 test_mkdir -p $DIR/$tdir
8222 # block size of mds1
8223 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8224 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8225 local MAX=$((MDSBLOCKSIZE * 3))
8227 local I=$(stat -c%s "$DIR/$tdir")
8229 local STRIPE_COUNT=1
8230 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8231 MAX=$((MAX*STRIPE_COUNT))
8232 while [[ $I -le $MAX ]]; do
8233 $MULTIOP $DIR/$tdir/$J Oc
8235 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8236 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8237 #and EFBIG for previous versions
8238 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8240 echo "return code $rc received as expected"
8241 multiop $DIR/$tdir/$J Oc ||
8242 error_exit "multiop failed w/o dir size limit"
8244 I=$(stat -c%s "$DIR/$tdir")
8246 if [ $(lustre_version_code $SINGLEMDS) -lt \
8247 $(version_code 2.4.51) ]
8249 [[ $I -eq $MAX ]] && return 0
8251 [[ $I -gt $MAX ]] && return 0
8253 error_exit "current dir size $I, previous limit $MAX"
8254 elif [ $rc -ne 0 ]; then
8256 error_exit "return code $rc received instead of expected " \
8257 "$EFBIG or $ENOSPC, files in dir $I"
8260 I=$(stat -c%s "$DIR/$tdir")
8264 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8266 run_test 129 "test directory size limit ========================"
8275 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8276 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8279 trap cleanup_130 EXIT RETURN
8281 local fm_file=$DIR/$tfile
8282 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8283 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8284 error "dd failed for $fm_file"
8286 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8287 filefrag -ves $fm_file
8289 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8290 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8291 [ $RC != 0 ] && error "filefrag $fm_file failed"
8293 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8294 grep -v "ext:" | grep -v "found")
8295 lun=$($GETSTRIPE -i $fm_file)
8297 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8300 for line in $filefrag_op
8302 frag_lun=`echo $line | cut -d: -f5`
8303 ext_len=`echo $line | cut -d: -f4`
8304 if (( $frag_lun != $lun )); then
8306 error "FIEMAP on 1-stripe file($fm_file) failed"
8309 (( tot_len += ext_len ))
8312 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8314 error "FIEMAP on 1-stripe file($fm_file) failed;"
8320 echo "FIEMAP on single striped file succeeded"
8322 run_test 130a "FIEMAP (1-stripe file)"
8325 [ "$OSTCOUNT" -lt "2" ] &&
8326 skip_env "skipping FIEMAP on 2-stripe file test" && return
8328 [ "$OSTCOUNT" -ge "10" ] &&
8329 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8331 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8332 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8335 trap cleanup_130 EXIT RETURN
8337 local fm_file=$DIR/$tfile
8338 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8339 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8340 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8342 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8343 error "dd failed on $fm_file"
8345 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8346 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8347 grep -v "ext:" | grep -v "found")
8349 last_lun=$(echo $filefrag_op | cut -d: -f5)
8354 for line in $filefrag_op
8356 frag_lun=`echo $line | cut -d: -f5`
8357 ext_len=`echo $line | cut -d: -f4`
8358 if (( $frag_lun != $last_lun )); then
8359 if (( tot_len != 1024 )); then
8361 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8368 (( tot_len += ext_len ))
8371 if (( num_luns != 2 || tot_len != 1024 )); then
8373 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8379 echo "FIEMAP on 2-stripe file succeeded"
8381 run_test 130b "FIEMAP (2-stripe file)"
8384 [ "$OSTCOUNT" -lt "2" ] &&
8385 skip_env "skipping FIEMAP on 2-stripe file" && return
8387 [ "$OSTCOUNT" -ge "10" ] &&
8388 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8390 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8391 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8394 trap cleanup_130 EXIT RETURN
8396 local fm_file=$DIR/$tfile
8397 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8398 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8399 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8401 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8403 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8404 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8406 last_lun=`echo $filefrag_op | cut -d: -f5`
8411 for line in $filefrag_op
8413 frag_lun=`echo $line | cut -d: -f5`
8414 ext_len=`echo $line | cut -d: -f4`
8415 if (( $frag_lun != $last_lun )); then
8416 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8417 if (( logical != 512 )); then
8419 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8422 if (( tot_len != 512 )); then
8424 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8431 (( tot_len += ext_len ))
8434 if (( num_luns != 2 || tot_len != 512 )); then
8436 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8442 echo "FIEMAP on 2-stripe file with hole succeeded"
8444 run_test 130c "FIEMAP (2-stripe file with hole)"
8447 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8449 [ "$OSTCOUNT" -ge "10" ] &&
8450 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8452 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8453 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8455 trap cleanup_130 EXIT RETURN
8457 local fm_file=$DIR/$tfile
8458 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8459 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8460 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8462 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8463 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8464 error "dd failed on $fm_file"
8466 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8467 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8468 grep -v "ext:" | grep -v "found"`
8470 last_lun=`echo $filefrag_op | cut -d: -f5`
8475 for line in $filefrag_op
8477 frag_lun=`echo $line | cut -d: -f5`
8478 ext_len=`echo $line | cut -d: -f4`
8479 if (( $frag_lun != $last_lun )); then
8480 if (( tot_len != 1024 )); then
8482 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8489 (( tot_len += ext_len ))
8492 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8494 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8500 echo "FIEMAP on N-stripe file succeeded"
8502 run_test 130d "FIEMAP (N-stripe file)"
8505 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8507 [ "$OSTCOUNT" -ge "10" ] &&
8508 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8510 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8511 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8513 trap cleanup_130 EXIT RETURN
8515 local fm_file=$DIR/$tfile
8516 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8517 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8518 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8521 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8522 for ((i = 0; i < $NUM_BLKS; i++))
8524 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8527 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8528 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8530 last_lun=`echo $filefrag_op | cut -d: -f5`
8535 for line in $filefrag_op
8537 frag_lun=`echo $line | cut -d: -f5`
8538 ext_len=`echo $line | cut -d: -f4`
8539 if (( $frag_lun != $last_lun )); then
8540 if (( tot_len != $EXPECTED_LEN )); then
8542 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8549 (( tot_len += ext_len ))
8552 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8554 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8560 echo "FIEMAP with continuation calls succeeded"
8562 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8564 # Test for writev/readv
8566 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8567 error "writev test failed"
8568 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8569 error "readv failed"
8572 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8575 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8576 error "append writev test failed"
8577 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8578 error "append writev test failed"
8581 run_test 131b "test append writev"
8584 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8587 run_test 131c "test read/write on file w/o objects"
8590 rwv -f $DIR/$tfile -w -n 1 1572864
8591 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8592 if [ "$NOB" != 1572864 ]; then
8593 error "Short read filed: read $NOB bytes instead of 1572864"
8597 run_test 131d "test short read"
8600 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8601 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8602 error "read hitting hole failed"
8605 run_test 131e "test read hitting hole"
8610 for node in $(osts_nodes); do
8611 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8612 [ x$gl = x"" ] && gl=0
8613 gl_sum=$((gl_sum + gl))
8623 if [ x$som = x"enabled" ]; then
8624 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8625 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8626 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8628 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8629 MOUNTOPT="$MOUNTOPT,som_preview"
8630 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8633 # do remount to make new mount-conf parameters actual
8640 test_132() { #1028, SOM
8641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8642 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8643 local num=$(get_mds_dir $DIR)
8644 local mymds=mds${num}
8645 local MOUNTOPT_SAVE=$MOUNTOPT
8647 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8648 cancel_lru_locks osc
8650 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8652 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8653 stat $DIR/$tfile >/dev/null
8654 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8655 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8657 som_mode_switch $som1 $gl1 $gl2
8659 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8660 cancel_lru_locks osc
8662 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8663 if [ $som1 == $som2 ]; then
8664 error "som is still "$som2
8665 if [ x$som2 = x"enabled" ]; then
8672 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8673 stat $DIR/$tfile >/dev/null
8674 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8675 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8676 som_mode_switch $som2 $gl1 $gl2
8677 MOUNTOPT=$MOUNTOPT_SAVE
8679 run_test 132 "som avoids glimpse rpc"
8685 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8687 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8689 *) error "Wrong argument $1" ;;
8692 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8693 # if the argument $3 is zero, it means any stat increment is ok.
8694 if [[ $3 -gt 0 ]]; then
8695 count=$(echo $res | awk '{ print $2 }')
8696 [[ $count -ne $3 ]] &&
8697 error "The $2 counter on $1 is wrong - expected $3"
8702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8703 remote_ost_nodsh && skip "remote OST with nodsh" && return
8704 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8706 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8707 { skip "MDS doesn't support rename stats"; return; }
8708 local testdir=$DIR/${tdir}/stats_testdir
8709 mkdir -p $DIR/${tdir}
8712 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8713 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8715 # verify mdt stats first.
8716 mkdir ${testdir} || error "mkdir failed"
8717 check_stats $SINGLEMDS "mkdir" 1
8718 touch ${testdir}/${tfile} || "touch failed"
8719 check_stats $SINGLEMDS "open" 1
8720 check_stats $SINGLEMDS "close" 1
8721 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8722 check_stats $SINGLEMDS "mknod" 1
8723 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8724 check_stats $SINGLEMDS "unlink" 1
8725 rm -f ${testdir}/${tfile} || error "file remove failed"
8726 check_stats $SINGLEMDS "unlink" 2
8728 # remove working dir and check mdt stats again.
8729 rmdir ${testdir} || error "rmdir failed"
8730 check_stats $SINGLEMDS "rmdir" 1
8732 local testdir1=$DIR/${tdir}/stats_testdir1
8734 mkdir -p ${testdir1}
8735 touch ${testdir1}/test1
8736 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8737 check_stats $SINGLEMDS "crossdir_rename" 1
8739 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8740 check_stats $SINGLEMDS "samedir_rename" 1
8744 run_test 133a "Verifying MDT stats ========================================"
8747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8748 remote_ost_nodsh && skip "remote OST with nodsh" && return
8749 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8750 local testdir=$DIR/${tdir}/stats_testdir
8751 mkdir -p ${testdir} || error "mkdir failed"
8752 touch ${testdir}/${tfile} || "touch failed"
8753 cancel_lru_locks mdc
8756 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8757 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8759 # extra mdt stats verification.
8760 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8761 check_stats $SINGLEMDS "setattr" 1
8762 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8763 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8765 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8766 check_stats $SINGLEMDS "getattr" 1
8768 $LFS df || error "lfs failed"
8769 check_stats $SINGLEMDS "statfs" 1
8773 run_test 133b "Verifying extra MDT stats =================================="
8776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8777 remote_ost_nodsh && skip "remote OST with nodsh" && return
8778 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8779 local testdir=$DIR/${tdir}/stats_testdir
8780 test_mkdir -p ${testdir} || error "mkdir failed"
8782 # verify obdfilter stats.
8783 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8785 cancel_lru_locks osc
8786 wait_delete_completed
8789 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8790 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8792 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8794 cancel_lru_locks osc
8795 check_stats ost "write" 1
8797 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8798 check_stats ost "read" 1
8800 > ${testdir}/${tfile} || error "truncate failed"
8801 check_stats ost "punch" 1
8803 rm -f ${testdir}/${tfile} || error "file remove failed"
8804 wait_delete_completed
8805 check_stats ost "destroy" 1
8809 run_test 133c "Verifying OST stats ========================================"
8816 while [ $value -ge 2 ]; do
8821 if [ $orig -gt $order ]; then
8829 local size=('K' 'M' 'G' 'T');
8831 local size_string=$value
8833 while [ $value -ge 1024 ]; do
8834 if [ $i -gt 3 ]; then
8835 #T is the biggest unit we get here, if that is bigger,
8837 size_string=${value}T
8840 value=$((value >> 10))
8841 if [ $value -lt 1024 ]; then
8842 size_string=${value}${size[$i]}
8853 local context=${2:-.}
8854 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8856 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8862 remote_ost_nodsh && skip "remote OST with nodsh" && return
8863 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8864 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8865 { skip "MDS doesn't support rename stats"; return; }
8867 local testdir1=$DIR/${tdir}/stats_testdir1
8868 local testdir2=$DIR/${tdir}/stats_testdir2
8870 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8872 mkdir -p ${testdir1} || error "mkdir failed"
8873 mkdir -p ${testdir2} || error "mkdir failed"
8875 createmany -o $testdir1/test 512 || error "createmany failed"
8877 # check samedir rename size
8878 mv ${testdir1}/test0 ${testdir1}/test_0
8880 local testdir1_size=$(ls -l $DIR/${tdir} |
8881 awk '/stats_testdir1/ {print $5}')
8882 local testdir2_size=$(ls -l $DIR/${tdir} |
8883 awk '/stats_testdir2/ {print $5}')
8885 testdir1_size=$(order_2 $testdir1_size)
8886 testdir2_size=$(order_2 $testdir2_size)
8888 testdir1_size=$(size_in_KMGT $testdir1_size)
8889 testdir2_size=$(size_in_KMGT $testdir2_size)
8891 echo "source rename dir size: ${testdir1_size}"
8892 echo "target rename dir size: ${testdir2_size}"
8894 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8895 eval $cmd || error "$cmd failed"
8896 local samedir=$($cmd | grep 'same_dir')
8897 local same_sample=$(get_rename_size $testdir1_size)
8898 [ -z "$samedir" ] && error "samedir_rename_size count error"
8899 [[ $same_sample -eq 1 ]] ||
8900 error "samedir_rename_size error $same_sample"
8901 echo "Check same dir rename stats success"
8903 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8905 # check crossdir rename size
8906 mv ${testdir1}/test_0 ${testdir2}/test_0
8908 testdir1_size=$(ls -l $DIR/${tdir} |
8909 awk '/stats_testdir1/ {print $5}')
8910 testdir2_size=$(ls -l $DIR/${tdir} |
8911 awk '/stats_testdir2/ {print $5}')
8913 testdir1_size=$(order_2 $testdir1_size)
8914 testdir2_size=$(order_2 $testdir2_size)
8916 testdir1_size=$(size_in_KMGT $testdir1_size)
8917 testdir2_size=$(size_in_KMGT $testdir2_size)
8919 echo "source rename dir size: ${testdir1_size}"
8920 echo "target rename dir size: ${testdir2_size}"
8922 eval $cmd || error "$cmd failed"
8923 local crossdir=$($cmd | grep 'crossdir')
8924 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8925 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8926 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8927 [[ $src_sample -eq 1 ]] ||
8928 error "crossdir_rename_size error $src_sample"
8929 [[ $tgt_sample -eq 1 ]] ||
8930 error "crossdir_rename_size error $tgt_sample"
8931 echo "Check cross dir rename stats success"
8934 run_test 133d "Verifying rename_stats ========================================"
8937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8938 local testdir=$DIR/${tdir}/stats_testdir
8939 local ctr f0 f1 bs=32768 count=42 sum
8941 remote_ost_nodsh && skip "remote OST with nodsh" && return
8942 mkdir -p ${testdir} || error "mkdir failed"
8944 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8946 for ctr in {write,read}_bytes; do
8948 cancel_lru_locks osc
8950 do_facet ost1 $LCTL set_param -n \
8951 "obdfilter.*.exports.clear=clear"
8953 if [ $ctr = write_bytes ]; then
8955 f1=${testdir}/${tfile}
8957 f0=${testdir}/${tfile}
8961 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8964 cancel_lru_locks osc
8966 sum=$(do_facet ost1 $LCTL get_param \
8967 "obdfilter.*.exports.*.stats" |
8968 awk -v ctr=$ctr 'BEGIN { sum = 0 }
8969 $1 == ctr { sum += $7 }
8970 END { printf("%0.0f", sum) }')
8972 if ((sum != bs * count)); then
8973 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8979 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8982 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8985 # First without trusting modes.
8986 find $proc_dirs -exec cat '{}' \; &> /dev/null
8988 # Second verifying readability.
8991 -exec cat '{}' \; &> /dev/null ||
8992 error "proc file read failed"
8994 for facet in $SINGLEMDS ost1; do
8995 do_facet $facet find $proc_dirs \
8996 ! -name req_history \
8997 -exec cat '{}' \\\; &> /dev/null
8999 do_facet $facet find $proc_dirs \
9000 ! -name req_history \
9002 -exec cat '{}' \\\; &> /dev/null ||
9003 error "proc file read failed"
9006 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9009 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9012 # Second verifying readability.
9015 -not -name force_lbug \
9016 -not -name changelog_mask \
9017 -exec badarea_io '{}' \; > /dev/null
9019 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9020 skip "Too old lustre on MDS"
9022 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9023 skip "Too old lustre on ost1"
9025 for facet in $SINGLEMDS ost1; do
9026 do_facet $facet find $proc_dirs \
9028 -not -name force_lbug \
9029 -not -name changelog_mask \
9030 -exec badarea_io '{}' \\\; &> /dev/null
9034 # remount the FS in case writes/reads /proc break the FS
9035 cleanup || error "failed to unmount"
9036 setup || error "failed to setup"
9039 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9041 test_140() { #bug-17379
9042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9043 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9044 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9045 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9047 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9048 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9050 while i=`expr $i + 1`; do
9051 test_mkdir -p $i || error "Creating dir $i"
9052 cd $i || error "Changing to $i"
9053 ln -s ../stat stat || error "Creating stat symlink"
9054 # Read the symlink until ELOOP present,
9055 # not LBUGing the system is considered success,
9056 # we didn't overrun the stack.
9057 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9059 if [ $ret -eq 40 ]; then
9062 error "Open stat symlink"
9068 echo "The symlink depth = $i"
9069 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9070 error "Invalid symlink depth"
9072 # Test recursive symlink
9073 ln -s symlink_self symlink_self
9074 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9075 echo "open symlink_self returns $ret"
9076 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9078 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9082 local TF="$TMP/$tfile"
9084 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9086 cancel_lru_locks osc
9087 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9088 remount_client $MOUNT
9090 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9093 $TRUNCATE $DIR/$tfile 6000
9094 cancel_lru_locks osc
9095 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9098 echo "12345" >>$DIR/$tfile
9099 cancel_lru_locks osc
9100 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9103 echo "12345" >>$DIR/$tfile
9104 cancel_lru_locks osc
9105 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9110 run_test 150 "truncate/append tests"
9112 #LU-2902 roc_hit was not able to read all values from lproc
9113 function roc_hit_init() {
9114 local list=$(comma_list $(osts_nodes))
9115 local dir=$DIR/$tdir-check
9116 local file=$dir/file
9122 #use setstripe to do a write to every ost
9123 for i in $(seq 0 $((OSTCOUNT-1))); do
9124 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9125 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9126 idx=$(printf %04x $i)
9127 BEFORE=$(get_osd_param $list *OST*$idx stats |
9128 awk '$1 == "cache_access" {sum += $2}
9129 END { printf("%0.0f", sum) }')
9131 cancel_lru_locks osc
9132 cat $file >/dev/null
9134 AFTER=$(get_osd_param $list *OST*$idx stats |
9135 awk '$1 == "cache_access" {sum += $2}
9136 END { printf("%0.0f", sum) }')
9138 echo BEFORE:$BEFORE AFTER:$AFTER
9139 if ! let "AFTER - BEFORE == 4"; then
9141 error "roc_hit is not safe to use"
9149 function roc_hit() {
9150 local list=$(comma_list $(osts_nodes))
9151 echo $(get_osd_param $list '' stats |
9152 awk '$1 == "cache_hit" {sum += $2}
9153 END { printf("%0.0f", sum) }')
9156 function set_cache() {
9159 if [ "$2" == "off" ]; then
9162 local list=$(comma_list $(osts_nodes))
9163 set_osd_param $list '' $1_cache_enable $on
9165 cancel_lru_locks osc
9169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9170 remote_ost_nodsh && skip "remote OST with nodsh" && return
9173 local list=$(comma_list $(osts_nodes))
9175 # check whether obdfilter is cache capable at all
9176 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9177 echo "not cache-capable obdfilter"
9181 # check cache is enabled on all obdfilters
9182 if get_osd_param $list '' read_cache_enable | grep 0; then
9183 echo "oss cache is disabled"
9187 set_osd_param $list '' writethrough_cache_enable 1
9189 # check write cache is enabled on all obdfilters
9190 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9191 echo "oss write cache is NOT enabled"
9197 #define OBD_FAIL_OBD_NO_LRU 0x609
9198 do_nodes $list $LCTL set_param fail_loc=0x609
9200 # pages should be in the case right after write
9201 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9204 local BEFORE=$(roc_hit)
9205 cancel_lru_locks osc
9206 cat $DIR/$tfile >/dev/null
9207 local AFTER=$(roc_hit)
9209 do_nodes $list $LCTL set_param fail_loc=0
9211 if ! let "AFTER - BEFORE == CPAGES"; then
9212 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9215 # the following read invalidates the cache
9216 cancel_lru_locks osc
9217 set_osd_param $list '' read_cache_enable 0
9218 cat $DIR/$tfile >/dev/null
9220 # now data shouldn't be found in the cache
9222 cancel_lru_locks osc
9223 cat $DIR/$tfile >/dev/null
9225 if let "AFTER - BEFORE != 0"; then
9226 error "IN CACHE: before: $BEFORE, after: $AFTER"
9229 set_osd_param $list '' read_cache_enable 1
9232 run_test 151 "test cache on oss and controls ==============================="
9235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9236 local TF="$TMP/$tfile"
9238 # simulate ENOMEM during write
9239 #define OBD_FAIL_OST_NOMEM 0x226
9240 lctl set_param fail_loc=0x80000226
9241 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9243 sync || error "sync failed"
9244 lctl set_param fail_loc=0
9246 # discard client's cache
9247 cancel_lru_locks osc
9249 # simulate ENOMEM during read
9250 lctl set_param fail_loc=0x80000226
9251 cmp $TF $DIR/$tfile || error "cmp failed"
9252 lctl set_param fail_loc=0
9256 run_test 152 "test read/write with enomem ============================"
9259 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9261 run_test 153 "test if fdatasync does not crash ======================="
9263 dot_lustre_fid_permission_check() {
9265 local ffid=$MOUNT/.lustre/fid/$fid
9268 echo "stat fid $fid"
9269 stat $ffid > /dev/null || error "stat $ffid failed."
9270 echo "touch fid $fid"
9271 touch $ffid || error "touch $ffid failed."
9272 echo "write to fid $fid"
9273 cat /etc/hosts > $ffid || error "write $ffid failed."
9274 echo "read fid $fid"
9275 diff /etc/hosts $ffid || error "read $ffid failed."
9276 echo "append write to fid $fid"
9277 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9278 echo "rename fid $fid"
9279 mv $ffid $test_dir/$tfile.1 &&
9280 error "rename $ffid to $tfile.1 should fail."
9281 touch $test_dir/$tfile.1
9282 mv $test_dir/$tfile.1 $ffid &&
9283 error "rename $tfile.1 to $ffid should fail."
9284 rm -f $test_dir/$tfile.1
9285 echo "truncate fid $fid"
9286 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9287 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9288 echo "link fid $fid"
9289 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9291 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9292 echo "setfacl fid $fid"
9293 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9294 echo "getfacl fid $fid"
9295 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9297 echo "unlink fid $fid"
9298 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9299 echo "mknod fid $fid"
9300 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9302 fid=[0xf00000400:0x1:0x0]
9303 ffid=$MOUNT/.lustre/fid/$fid
9305 echo "stat non-exist fid $fid"
9306 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9307 echo "write to non-exist fid $fid"
9308 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9309 echo "link new fid $fid"
9310 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9312 mkdir -p $test_dir/$tdir
9313 touch $test_dir/$tdir/$tfile
9314 fid=$($LFS path2fid $test_dir/$tdir)
9317 error "error: could not get fid for $test_dir/$dir/$tfile."
9319 ffid=$MOUNT/.lustre/fid/$fid
9322 ls $ffid > /dev/null || error "ls $ffid failed."
9323 echo "touch $fid/$tfile.1"
9324 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9326 echo "touch $MOUNT/.lustre/fid/$tfile"
9327 touch $MOUNT/.lustre/fid/$tfile && \
9328 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9330 echo "setxattr to $MOUNT/.lustre/fid"
9331 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9333 echo "listxattr for $MOUNT/.lustre/fid"
9334 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9336 echo "delxattr from $MOUNT/.lustre/fid"
9337 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9339 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9340 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9341 error "touch invalid fid should fail."
9343 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9344 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9345 error "touch non-normal fid should fail."
9347 echo "rename $tdir to $MOUNT/.lustre/fid"
9348 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9349 error "rename to $MOUNT/.lustre/fid should fail."
9351 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9353 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9354 local new_obf_mode=777
9356 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9357 chmod $new_obf_mode $DIR/.lustre/fid ||
9358 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9360 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9361 [ $obf_mode -eq $new_obf_mode ] ||
9362 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9364 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9365 chmod $old_obf_mode $DIR/.lustre/fid ||
9366 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9369 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9370 fid=$($LFS path2fid $test_dir/$tfile-2)
9371 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9372 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9373 error "create lov data thru .lustre should fail."
9374 echo "cp /etc/passwd $test_dir/$tfile-2"
9375 cp /etc/passwd $test_dir/$tfile-2 ||
9376 error "copy to $test_dir/$tfile-2 failed."
9377 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9378 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9379 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9381 rm -rf $test_dir/tfile.lnk
9382 rm -rf $test_dir/$tfile-2
9386 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9387 skip "Need MDS version at least 2.4.1" && return
9390 local FID=$($LFS path2fid $DIR/$tfile)
9391 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9393 # check that we get the same pathname back
9394 local FOUND=$($LFS fid2path $MOUNT $FID)
9395 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9396 [ "$FOUND" != "$DIR/$tfile" ] &&
9397 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9401 run_test 154A "lfs path2fid and fid2path basic checks"
9404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9405 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9406 { skip "Need MDS version at least 2.2.51"; return 0; }
9407 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9409 cp /etc/hosts $DIR/$tfile
9411 fid=$($LFS path2fid $DIR/$tfile)
9413 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9415 dot_lustre_fid_permission_check "$fid" $DIR ||
9416 error "dot lustre permission check $fid failed"
9418 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9420 touch $MOUNT/.lustre/file &&
9421 error "creation is not allowed under .lustre"
9423 mkdir $MOUNT/.lustre/dir &&
9424 error "mkdir is not allowed under .lustre"
9428 run_test 154a "Open-by-FID"
9431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9432 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9433 { skip "Need MDS version at least 2.2.51"; return 0; }
9435 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9437 local remote_dir=$DIR/$tdir/remote_dir
9442 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9443 error "create remote directory failed"
9445 cp /etc/hosts $remote_dir/$tfile
9447 fid=$($LFS path2fid $remote_dir/$tfile)
9449 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9451 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9452 error "dot lustre permission check $fid failed"
9455 run_test 154b "Open-by-FID for remote directory"
9458 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9459 skip "Need MDS version at least 2.4.1" && return
9461 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9462 local FID1=$($LFS path2fid $DIR/$tfile.1)
9463 local FID2=$($LFS path2fid $DIR/$tfile.2)
9464 local FID3=$($LFS path2fid $DIR/$tfile.3)
9467 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9468 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9469 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9471 [ "$FID" = "${!want}" ] ||
9472 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9476 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9477 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9478 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9482 run_test 154c "lfs path2fid and fid2path multiple arguments"
9485 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9486 skip "Need MDS version at least 2.5.53" && return
9489 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9493 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9500 fid=$($LFS path2fid $DIR/$tfile)
9503 cmd="exec $fd<$DIR/$tfile"
9505 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9506 echo $fid_list | grep $fid
9509 cmd="exec $fd>/dev/null"
9511 if [ $rc -ne 0 ]; then
9512 error "FID $fid not found in open files list $fid_list"
9515 run_test 154d "Verify open file fid"
9517 test_155_small_load() {
9518 local temp=$TMP/$tfile
9519 local file=$DIR/$tfile
9521 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9522 error "dd of=$temp bs=6096 count=1 failed"
9524 cancel_lru_locks osc
9525 cmp $temp $file || error "$temp $file differ"
9527 $TRUNCATE $temp 6000
9528 $TRUNCATE $file 6000
9529 cmp $temp $file || error "$temp $file differ (truncate1)"
9531 echo "12345" >>$temp
9532 echo "12345" >>$file
9533 cmp $temp $file || error "$temp $file differ (append1)"
9535 echo "12345" >>$temp
9536 echo "12345" >>$file
9537 cmp $temp $file || error "$temp $file differ (append2)"
9543 test_155_big_load() {
9544 remote_ost_nodsh && skip "remote OST with nodsh" && return
9545 local temp=$TMP/$tfile
9546 local file=$DIR/$tfile
9549 local cache_size=$(do_facet ost$((MAXI+1)) \
9550 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9551 local large_file_size=$((cache_size * 2))
9553 echo "OSS cache size: $cache_size KB"
9554 echo "Large file size: $large_file_size KB"
9556 [ $MAXV -le $large_file_size ] && \
9557 skip_env "max available OST size needs > $large_file_size KB" && \
9560 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9562 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9563 error "dd of=$temp bs=$large_file_size count=1k failed"
9566 cancel_lru_locks osc
9567 cmp $temp $file || error "$temp $file differ"
9574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9576 set_cache writethrough on
9579 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9584 set_cache writethrough off
9587 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9592 set_cache writethrough on
9595 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9600 set_cache writethrough off
9603 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9608 set_cache writethrough on
9611 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9616 set_cache writethrough off
9619 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9624 set_cache writethrough on
9627 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9632 set_cache writethrough off
9635 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9642 local file="$DIR/$tfile"
9644 [ "$(facet_fstype ost1)" = "zfs" ] &&
9645 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9650 log "Turn on read and write cache"
9652 set_cache writethrough on
9654 log "Write data and read it back."
9655 log "Read should be satisfied from the cache."
9656 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9658 cancel_lru_locks osc
9659 cat $file >/dev/null
9661 if ! let "AFTER - BEFORE == CPAGES"; then
9662 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9664 log "cache hits:: before: $BEFORE, after: $AFTER"
9667 log "Read again; it should be satisfied from the cache."
9669 cancel_lru_locks osc
9670 cat $file >/dev/null
9672 if ! let "AFTER - BEFORE == CPAGES"; then
9673 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9675 log "cache hits:: before: $BEFORE, after: $AFTER"
9679 log "Turn off the read cache and turn on the write cache"
9681 set_cache writethrough on
9683 log "Read again; it should be satisfied from the cache."
9685 cancel_lru_locks osc
9686 cat $file >/dev/null
9688 if ! let "AFTER - BEFORE == CPAGES"; then
9689 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9691 log "cache hits:: before: $BEFORE, after: $AFTER"
9694 log "Read again; it should not be satisfied from the cache."
9696 cancel_lru_locks osc
9697 cat $file >/dev/null
9699 if ! let "AFTER - BEFORE == 0"; then
9700 error "IN CACHE: before: $BEFORE, after: $AFTER"
9702 log "cache hits:: before: $BEFORE, after: $AFTER"
9705 log "Write data and read it back."
9706 log "Read should be satisfied from the cache."
9707 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9709 cancel_lru_locks osc
9710 cat $file >/dev/null
9712 if ! let "AFTER - BEFORE == CPAGES"; then
9713 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9715 log "cache hits:: before: $BEFORE, after: $AFTER"
9718 log "Read again; it should not be satisfied from the cache."
9720 cancel_lru_locks osc
9721 cat $file >/dev/null
9723 if ! let "AFTER - BEFORE == 0"; then
9724 error "IN CACHE: before: $BEFORE, after: $AFTER"
9726 log "cache hits:: before: $BEFORE, after: $AFTER"
9730 log "Turn off read and write cache"
9732 set_cache writethrough off
9734 log "Write data and read it back"
9735 log "It should not be satisfied from the cache."
9737 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9738 cancel_lru_locks osc
9740 cat $file >/dev/null
9742 if ! let "AFTER - BEFORE == 0"; then
9743 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9745 log "cache hits:: before: $BEFORE, after: $AFTER"
9748 log "Turn on the read cache and turn off the write cache"
9750 set_cache writethrough off
9752 log "Write data and read it back"
9753 log "It should not be satisfied from the cache."
9755 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9757 cancel_lru_locks osc
9758 cat $file >/dev/null
9760 if ! let "AFTER - BEFORE == 0"; then
9761 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9763 log "cache hits:: before: $BEFORE, after: $AFTER"
9766 log "Read again; it should be satisfied from the cache."
9768 cancel_lru_locks osc
9769 cat $file >/dev/null
9771 if ! let "AFTER - BEFORE == CPAGES"; then
9772 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9774 log "cache hits:: before: $BEFORE, after: $AFTER"
9779 run_test 156 "Verification of tunables ============================"
9783 if [[ $MDSCOUNT -gt 1 ]]; then
9784 error_ignore bz17935 $*
9792 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9794 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9796 if [ $MASK -eq 1 ]; then
9797 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9799 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9803 changelog_extract_field() {
9809 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9810 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9816 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9817 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9818 { skip "Need MDS version at least 2.2.0"; return; }
9820 local CL_USERS="mdd.$MDT0.changelog_users"
9821 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9822 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9823 echo "Registered as changelog user $USER"
9824 $GET_CL_USERS | grep -q $USER ||
9825 error "User $USER not found in changelog_users"
9828 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9829 touch $DIR/$tdir/pics/2008/zachy/timestamp
9830 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9831 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9832 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9833 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9834 rm $DIR/$tdir/pics/desktop.jpg
9836 $LFS changelog $MDT0 | tail -5
9838 echo "verifying changelog mask"
9839 changelog_chmask "MKDIR"
9840 changelog_chmask "CLOSE"
9842 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9843 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9845 changelog_chmask "MKDIR"
9846 changelog_chmask "CLOSE"
9848 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9849 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9851 $LFS changelog $MDT0
9852 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9853 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9854 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9855 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9858 echo "verifying target fid"
9859 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9860 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9861 [ "$fidc" == "$fidf" ] ||
9862 err17935 "fid in changelog $fidc != file fid $fidf"
9863 echo "verifying parent fid"
9864 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9865 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9866 [ "$fidc" == "$fidf" ] ||
9867 err17935 "pfid in changelog $fidc != dir fid $fidf"
9869 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9870 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9871 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9872 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9873 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9874 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9876 MIN_REC=$($GET_CL_USERS |
9877 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9878 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9879 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9880 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9881 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9883 # LU-3446 changelog index reset on MDT restart
9884 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9885 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9886 $LFS changelog_clear $MDT0 $USER 0
9887 stop $SINGLEMDS || error "Fail to stop MDT."
9888 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9889 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9890 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9891 [ $CUR_REC1 == $CUR_REC2 ] ||
9892 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9894 echo "verifying user deregister"
9895 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9896 $GET_CL_USERS | grep -q $USER &&
9897 error "User $USER still in changelog_users"
9899 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9900 if [ $USERS -eq 0 ]; then
9901 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9902 touch $DIR/$tdir/chloe
9903 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9904 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9905 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9907 echo "$USERS other changelog users; can't verify off"
9910 run_test 160a "changelog sanity"
9912 test_160b() { # LU-3587
9913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9914 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9915 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9916 { skip "Need MDS version at least 2.2.0"; return; }
9918 local CL_USERS="mdd.$MDT0.changelog_users"
9919 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9920 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9921 echo "Registered as changelog user $USER"
9922 $GET_CL_USERS | grep -q $USER ||
9923 error "User $USER not found in changelog_users"
9925 local LONGNAME1=$(str_repeat a 255)
9926 local LONGNAME2=$(str_repeat b 255)
9929 echo "creating very long named file"
9930 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9931 echo "moving very long named file"
9932 mv $LONGNAME1 $LONGNAME2
9934 $LFS changelog $MDT0 | grep RENME
9936 echo "deregistering $USER"
9937 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9941 run_test 160b "Verify that very long rename doesn't crash in changelog"
9945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9948 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9949 changelog_register -n)
9953 $MCREATE $DIR/$tdir/foo_160c
9954 changelog_chmask "TRUNC"
9955 $TRUNCATE $DIR/$tdir/foo_160c 200
9956 changelog_chmask "TRUNC"
9957 $TRUNCATE $DIR/$tdir/foo_160c 199
9958 $LFS changelog $MDT0
9959 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9960 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9961 $LFS changelog_clear $MDT0 $USER 0
9963 # Deregistration step
9964 echo "deregistering $USER"
9965 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9967 run_test 160c "verify that changelog log catch the truncate event"
9970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9971 test_mkdir -p -c1 $DIR/$tdir
9972 cp /etc/hosts $DIR/$tdir/$tfile
9973 test_mkdir -c1 $DIR/$tdir/foo1
9974 test_mkdir -c1 $DIR/$tdir/foo2
9975 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9976 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9977 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9978 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9979 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9980 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9981 $LFS fid2path $DIR $FID
9982 err17935 "bad link ea"
9985 rm $DIR/$tdir/foo2/zachary
9987 rm $DIR/$tdir/foo2/thor
9989 rm $DIR/$tdir/$tfile
9991 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9992 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9994 $LFS fid2path $DIR $FID
9995 err17935 "bad link rename"
9997 rm $DIR/$tdir/foo2/maggie
10000 local longname=filename_avg_len_is_thirty_two_
10001 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10002 error "failed to hardlink many files"
10003 links=$($LFS fid2path $DIR $FID | wc -l)
10004 echo -n "${links}/1000 links in link EA"
10005 [[ $links -gt 60 ]] ||
10006 err17935 "expected at least 60 links in link EA"
10007 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10008 error "failed to unlink many hardlinks"
10010 run_test 161a "link ea sanity"
10013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10014 [ $MDSCOUNT -lt 2 ] &&
10015 skip "skipping remote directory test" && return
10017 local remote_dir=$DIR/$tdir/remote_dir
10019 mkdir -p $DIR/$tdir
10020 $LFS mkdir -i $MDTIDX $remote_dir ||
10021 error "create remote directory failed"
10023 cp /etc/hosts $remote_dir/$tfile
10024 mkdir -p $remote_dir/foo1
10025 mkdir -p $remote_dir/foo2
10026 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10027 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10028 ln $remote_dir/$tfile $remote_dir/foo1/luna
10029 ln $remote_dir/$tfile $remote_dir/foo2/thor
10031 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10033 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10034 $LFS fid2path $DIR $FID
10035 err17935 "bad link ea"
10038 rm $remote_dir/foo2/zachary
10040 rm $remote_dir/foo2/thor
10042 rm $remote_dir/$tfile
10044 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10045 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10046 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10047 $LFS fid2path $DIR $FID
10048 err17935 "bad link rename"
10050 rm $remote_dir/foo2/maggie
10053 local longname=filename_avg_len_is_thirty_two_
10054 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10055 error "failed to hardlink many files"
10056 links=$($LFS fid2path $DIR $FID | wc -l)
10057 echo -n "${links}/1000 links in link EA"
10058 [[ ${links} -gt 60 ]] ||
10059 err17935 "expected at least 60 links in link EA"
10060 unlinkmany $remote_dir/foo2/$longname 1000 ||
10061 error "failed to unlink many hardlinks"
10063 run_test 161b "link ea sanity under remote directory"
10066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10067 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10068 skip "Need MDS version at least 2.1.5" && return
10070 # define CLF_RENAME_LAST 0x0001
10071 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10072 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10073 changelog_register -n)
10075 mkdir -p $DIR/$tdir
10076 touch $DIR/$tdir/foo_161c
10077 touch $DIR/$tdir/bar_161c
10078 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10079 $LFS changelog $MDT0 | grep RENME
10080 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10082 $LFS changelog_clear $MDT0 $USER 0
10083 if [ x$flags != "x0x1" ]; then
10084 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10086 error "flag $flags is not 0x1"
10088 echo "rename overwrite a target having nlink = 1," \
10089 "changelog record has flags of $flags"
10091 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10092 touch $DIR/$tdir/foo_161c
10093 touch $DIR/$tdir/bar_161c
10094 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10095 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10096 $LFS changelog $MDT0 | grep RENME
10097 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10098 $LFS changelog_clear $MDT0 $USER 0
10099 if [ x$flags != "x0x0" ]; then
10100 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10102 error "flag $flags is not 0x0"
10104 echo "rename overwrite a target having nlink > 1," \
10105 "changelog record has flags of $flags"
10107 # rename doesn't overwrite a target (changelog flag 0x0)
10108 touch $DIR/$tdir/foo_161c
10109 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10110 $LFS changelog $MDT0 | grep RENME
10111 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10112 $LFS changelog_clear $MDT0 $USER 0
10113 if [ x$flags != "x0x0" ]; then
10114 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10116 error "flag $flags is not 0x0"
10118 echo "rename doesn't overwrite a target," \
10119 "changelog record has flags of $flags"
10121 # define CLF_UNLINK_LAST 0x0001
10122 # unlink a file having nlink = 1 (changelog flag 0x1)
10123 rm -f $DIR/$tdir/foo2_161c
10124 $LFS changelog $MDT0 | grep UNLNK
10125 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10126 $LFS changelog_clear $MDT0 $USER 0
10127 if [ x$flags != "x0x1" ]; then
10128 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10130 error "flag $flags is not 0x1"
10132 echo "unlink a file having nlink = 1," \
10133 "changelog record has flags of $flags"
10135 # unlink a file having nlink > 1 (changelog flag 0x0)
10136 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10137 rm -f $DIR/$tdir/foobar_161c
10138 $LFS changelog $MDT0 | grep UNLNK
10139 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10140 $LFS changelog_clear $MDT0 $USER 0
10141 if [ x$flags != "x0x0" ]; then
10142 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10144 error "flag $flags is not 0x0"
10146 echo "unlink a file having nlink > 1," \
10147 "changelog record has flags of $flags"
10148 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10150 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10157 local path=$(${LFS} fid2path $*)
10160 if [ $RC -ne 0 ]; then
10161 err17935 "path looked up of $expected failed. Error $RC"
10163 elif [ "${path}" != "${expected}" ]; then
10164 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10167 echo "fid $fid resolves to path $path (expected $expected)"
10171 # Make changes to filesystem
10172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10173 test_mkdir -p -c1 $DIR/$tdir/d2
10174 touch $DIR/$tdir/d2/$tfile
10175 touch $DIR/$tdir/d2/x1
10176 touch $DIR/$tdir/d2/x2
10177 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10178 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10180 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10181 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10184 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10185 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10186 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10188 # softlink to wrong file
10189 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10190 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10191 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10194 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10195 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10196 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10197 # fid2path dir/fsname should both work
10198 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10199 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10201 # hardlink count: check that there are 2 links
10202 # Doesnt work with CMD yet: 17935
10203 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10204 err17935 "expected 2 links"
10206 # hardlink indexing: remove the first link
10207 rm $DIR/$tdir/d2/p/q/r/hlink
10208 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10212 run_test 162 "path lookup sanity"
10215 # do directio so as not to populate the page cache
10216 log "creating a 10 Mb file"
10217 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10218 log "starting reads"
10219 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10220 log "truncating the file"
10221 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10223 kill %+ || true # reads might have finished
10224 echo "wait until dd is finished"
10226 log "removing the temporary file"
10227 rm -rf $DIR/$tfile || error "tmp file removal failed"
10229 run_test 169 "parallel read and truncate should not deadlock"
10232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10233 $LCTL clear # bug 18514
10234 $LCTL debug_daemon start $TMP/${tfile}_log_good
10236 $LCTL debug_daemon stop
10237 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10238 error "sed failed to read log_good"
10240 $LCTL debug_daemon start $TMP/${tfile}_log_good
10242 $LCTL debug_daemon stop
10244 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10245 error "lctl df log_bad failed"
10247 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10248 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10250 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10251 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10253 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10254 error "bad_line good_line1 good_line2 are empty"
10256 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10257 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10258 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10260 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10261 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10262 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10264 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10265 error "bad_line_new good_line_new are empty"
10267 local expected_good=$((good_line1 + good_line2*2))
10269 rm -f $TMP/${tfile}*
10270 # LU-231, short malformed line may not be counted into bad lines
10271 if [ $bad_line -ne $bad_line_new ] &&
10272 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10273 error "expected $bad_line bad lines, but got $bad_line_new"
10277 if [ $expected_good -ne $good_line_new ]; then
10278 error "expected $expected_good good lines, but got $good_line_new"
10283 run_test 170 "test lctl df to handle corrupted log ====================="
10285 test_171() { # bug20592
10286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10287 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10288 $LCTL set_param fail_loc=0x50e
10289 $LCTL set_param fail_val=3000
10290 multiop_bg_pause $DIR/$tfile O_s || true
10292 kill -USR1 $MULTIPID
10296 if dmesg | grep "recursive fault"; then
10297 error "caught a recursive fault"
10299 $LCTL set_param fail_loc=0
10302 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10304 # it would be good to share it with obdfilter-survey/libecho code
10305 setup_obdecho_osc () {
10308 local obdfilter_name=$2
10309 echo "Creating new osc for $obdfilter_name on $ost_nid"
10310 # make sure we can find loopback nid
10311 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10313 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10314 ${obdfilter_name}_osc_UUID || rc=2; }
10315 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10316 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10320 cleanup_obdecho_osc () {
10321 local obdfilter_name=$1
10322 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10323 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10330 local pages=${3:-64}
10335 local obd_size=$(get_obd_size $node $OBD)
10336 local page_size=$(get_page_size $node)
10337 if [[ -n "$obd_size" ]]; then
10338 local new_count=$((obd_size / (pages * page_size / 1024)))
10339 [[ $new_count -ge $count ]] || count=$new_count
10342 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10343 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10345 if [ $rc -eq 0 ]; then
10346 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10347 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10349 echo "New object id is $id"
10350 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10352 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10353 "test_brw $count w v $pages $id" || rc=4; }
10354 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10356 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10357 "cleanup" || rc=5; }
10358 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10359 "detach" || rc=6; }
10360 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10366 remote_ost_nodsh && skip "remote OST with nodsh" && return
10368 local rmmod_local=0
10370 if ! module_loaded obdecho; then
10371 load_module obdecho/obdecho
10375 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10376 local host=$(lctl get_param -n osc.$osc.import |
10377 awk '/current_connection:/ {print $2}' )
10378 local target=$(lctl get_param -n osc.$osc.import |
10379 awk '/target:/ {print $2}' )
10380 target=${target%_UUID}
10382 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10383 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10384 [[ -n $target ]] && cleanup_obdecho_osc $target
10385 [ $rmmod_local -eq 1 ] && rmmod obdecho
10388 run_test 180a "test obdecho on osc"
10391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10392 remote_ost_nodsh && skip "remote OST with nodsh" && return
10394 local rmmod_remote=0
10396 do_facet ost1 "lsmod | grep -q obdecho || " \
10397 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10398 "modprobe obdecho; }" && rmmod_remote=1
10399 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10400 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10401 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10404 run_test 180b "test obdecho directly on obdfilter"
10406 test_180c() { # LU-2598
10407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10408 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10409 skip "Need MDS version at least 2.4.0" && return
10412 local rmmod_remote=false
10413 local pages=16384 # 64MB bulk I/O RPC size
10416 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10417 rmmod_remote=true || error "failed to load module obdecho"
10419 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10421 if [ -n "$target" ]; then
10422 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10424 echo "there is no obdfilter target on ost1"
10427 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10430 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10432 test_181() { # bug 22177
10433 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10434 # create enough files to index the directory
10435 createmany -o $DIR/$tdir/foobar 4000
10436 # print attributes for debug purpose
10439 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10441 # remove the files & current working dir
10442 unlinkmany $DIR/$tdir/foobar 4000
10444 kill -USR1 $MULTIPID
10446 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10449 run_test 181 "Test open-unlinked dir ========================"
10452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10453 # disable MDC RPC lock wouldn't crash client
10457 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10458 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10459 $LCTL set_param fail_loc=0x804
10461 for (( i=0; i < $tcount; i++ )) ; do
10462 mkdir $DIR/$tdir/$i
10463 createmany -o $DIR/$tdir/$i/f- $fcount &
10467 for (( i=0; i < $tcount; i++ )) ; do
10468 unlinkmany $DIR/$tdir/$i/f- $fcount &
10474 $LCTL set_param fail_loc=0
10476 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10478 test_183() { # LU-2275
10479 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10480 skip "Need MDS version at least 2.3.56" && return
10482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10483 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10484 echo aaa > $DIR/$tdir/$tfile
10486 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10487 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10489 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10490 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10492 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10494 # Flush negative dentry cache
10495 touch $DIR/$tdir/$tfile
10497 # We are not checking for any leaked references here, they'll
10498 # become evident next time we do cleanup with module unload.
10501 run_test 183 "No crash or request leak in case of strange dispositions ========"
10503 # test suite 184 is for LU-2016, LU-2017
10505 check_swap_layouts_support && return 0
10507 dir0=$DIR/$tdir/$testnum
10508 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10513 $SETSTRIPE -c1 $file1
10515 $SETSTRIPE -c2 $file2
10517 gen1=$($GETSTRIPE -g $file1)
10518 gen2=$($GETSTRIPE -g $file2)
10520 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10521 gen=$($GETSTRIPE -g $file1)
10522 [[ $gen1 != $gen ]] ||
10523 "Layout generation on $file1 does not change"
10524 gen=$($GETSTRIPE -g $file2)
10525 [[ $gen2 != $gen ]] ||
10526 "Layout generation on $file2 does not change"
10528 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10529 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10531 run_test 184a "Basic layout swap"
10534 check_swap_layouts_support && return 0
10536 dir0=$DIR/$tdir/$testnum
10537 mkdir -p $dir0 || error "creating dir $dir0"
10544 $SETSTRIPE -c1 $file1
10545 $SETSTRIPE -c2 $file2
10546 $SETSTRIPE -c1 $file3
10547 chown $RUNAS_ID $file3
10548 gen1=$($GETSTRIPE -g $file1)
10549 gen2=$($GETSTRIPE -g $file2)
10551 $LFS swap_layouts $dir1 $dir2 &&
10552 error "swap of directories layouts should fail"
10553 $LFS swap_layouts $dir1 $file1 &&
10554 error "swap of directory and file layouts should fail"
10555 $RUNAS $LFS swap_layouts $file1 $file2 &&
10556 error "swap of file we cannot write should fail"
10557 $LFS swap_layouts $file1 $file3 &&
10558 error "swap of file with different owner should fail"
10559 /bin/true # to clear error code
10561 run_test 184b "Forbidden layout swap (will generate errors)"
10564 check_swap_layouts_support && return 0
10566 local dir0=$DIR/$tdir/$testnum
10567 mkdir -p $dir0 || error "creating dir $dir0"
10569 local ref1=$dir0/ref1
10570 local ref2=$dir0/ref2
10571 local file1=$dir0/file1
10572 local file2=$dir0/file2
10573 # create a file large enough for the concurent test
10574 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10575 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10576 echo "ref file size: ref1($(stat -c %s $ref1))," \
10577 "ref2($(stat -c %s $ref2))"
10580 dd if=$ref1 of=$file1 bs=16k &
10583 # Make sure dd starts to copy file
10584 while [ ! -f $file1 ]; do sleep 0.1; done
10586 $LFS swap_layouts $file1 $file2
10589 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10590 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10592 # how many bytes copied before swapping layout
10593 local copied=$(stat -c %s $file2)
10594 local remaining=$(stat -c %s $ref1)
10595 remaining=$((remaining - copied))
10596 echo "Copied $copied bytes before swapping layout..."
10598 cmp -n $copied $file1 $ref2 | grep differ &&
10599 error "Content mismatch [0, $copied) of ref2 and file1"
10600 cmp -n $copied $file2 $ref1 ||
10601 error "Content mismatch [0, $copied) of ref1 and file2"
10602 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10603 error "Content mismatch [$copied, EOF) of ref1 and file1"
10606 rm -f $ref1 $ref2 $file1 $file2
10608 run_test 184c "Concurrent write and layout swap"
10611 check_swap_layouts_support && return 0
10612 [ -z "$(which getfattr 2>/dev/null)" ] &&
10613 skip "no getfattr command" && return 0
10615 local file1=$DIR/$tdir/$tfile-1
10616 local file2=$DIR/$tdir/$tfile-2
10617 local file3=$DIR/$tdir/$tfile-3
10621 mkdir -p $DIR/$tdir
10622 touch $file1 || error "create $file1 failed"
10623 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10624 error "create $file2 failed"
10625 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10626 error "create $file3 failed"
10627 lovea1=$($LFS getstripe $file1 | sed 1d)
10629 $LFS swap_layouts $file2 $file3 ||
10630 error "swap $file2 $file3 layouts failed"
10631 $LFS swap_layouts $file1 $file2 ||
10632 error "swap $file1 $file2 layouts failed"
10634 lovea2=$($LFS getstripe $file2 | sed 1d)
10635 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10637 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10638 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10640 run_test 184d "allow stripeless layouts swap"
10643 test_185() { # LU-2441
10644 # LU-3553 - no volatile file support in old servers
10645 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10646 { skip "Need MDS version at least 2.3.60"; return 0; }
10648 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10649 touch $DIR/$tdir/spoo
10650 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10651 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10652 error "cannot create/write a volatile file"
10653 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10654 error "FID is still valid after close"
10656 multiop_bg_pause $DIR/$tdir vVw4096_c
10663 # assume that the next FID for this client is sequential, since stdout
10664 # is unfortunately eaten by multiop_bg_pause
10665 local n=$((${fidv[1]} + 1))
10666 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10667 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10668 error "FID is missing before close"
10669 kill -USR1 $multi_pid
10670 # 1 second delay, so if mtime change we will see it
10672 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10673 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10675 run_test 185 "Volatile file support"
10678 local dir0=$DIR/$tdir/$testnum
10679 mkdir -p $dir0 || error "creating dir $dir0"
10681 local file=$dir0/file1
10682 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10683 local dv1=$($LFS data_version $file)
10684 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10685 local dv2=$($LFS data_version $file)
10686 [[ $dv1 != $dv2 ]] ||
10687 error "data version did not change on write $dv1 == $dv2"
10692 run_test 187a "Test data version change"
10695 local dir0=$DIR/$tdir/$testnum
10696 mkdir -p $dir0 || error "creating dir $dir0"
10698 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10699 [[ ${DV[0]} != ${DV[1]} ]] ||
10700 error "data version did not change on write"\
10701 " ${DV[0]} == ${DV[1]}"
10706 run_test 187b "Test data version change on volatile file"
10709 check_file_in_pool()
10714 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10717 for t in $tlist ; do
10718 [ "$i" -eq "$t" ] && continue 2
10721 echo "pool list: $tlist"
10722 echo "striping: $res"
10723 error_noexit "$file not allocated in $pool"
10730 echo "Creating new pool"
10733 create_pool $FSNAME.$pool ||
10734 { error_noexit "No pool created, result code $?"; return 1; }
10735 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10736 { error_noexit "$pool not in lfs pool_list"; return 2; }
10739 pool_add_targets() {
10740 echo "Adding targets to pool"
10746 local list=$(seq $first $step $last)
10748 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10749 do_facet mgs $LCTL pool_add \
10750 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10751 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10752 | sort -u | tr '\n' ' ' " "$t" || {
10753 error_noexit "Add to pool failed"
10756 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10757 local addcount=$(((last - first) / step + 1))
10758 [ $lfscount -eq $addcount ] || {
10759 error_noexit "lfs pool_list bad ost count" \
10760 "$lfscount != $addcount"
10768 echo "Setting pool on directory $tdir"
10770 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10772 error_noexit "Cannot set pool $pool to $tdir"
10779 echo "Checking pool on directory $tdir"
10781 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10782 [ "$res" = "$pool" ] && return 0
10784 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10788 pool_dir_rel_path() {
10789 echo "Testing relative path works well"
10794 mkdir -p $root/$tdir/$tdir
10796 pool_set_dir $pool $tdir || return 1
10797 pool_set_dir $pool ./$tdir || return 2
10798 pool_set_dir $pool ../$tdir || return 3
10799 pool_set_dir $pool ../$tdir/$tdir || return 4
10800 rm -rf $tdir; cd - > /dev/null
10803 pool_alloc_files() {
10804 echo "Checking files allocation from directory pool"
10811 for i in $(seq -w 1 $count)
10813 local file=$tdir/file-$i
10815 check_file_in_pool $file $pool "$tlist" || \
10816 failed=$((failed + 1))
10818 [ "$failed" = 0 ] && return 0
10820 error_noexit "$failed files not allocated in $pool"
10824 pool_create_files() {
10825 echo "Creating files in pool"
10833 for i in $(seq -w 1 $count)
10835 local file=$tdir/spoo-$i
10836 $SETSTRIPE -p $pool $file
10837 check_file_in_pool $file $pool "$tlist" || \
10838 failed=$((failed + 1))
10840 [ "$failed" = 0 ] && return 0
10842 error_noexit "$failed files not allocated in $pool"
10847 echo "Checking 'lfs df' output"
10850 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10852 local res=$($LFS df --pool $FSNAME.$pool |
10854 grep "$FSNAME-OST" |
10856 [ "$res" = "$t" ] && return 0
10858 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10862 pool_file_rel_path() {
10863 echo "Creating files in a pool with relative pathname"
10868 { error_noexit "unable to create $tdir"; return 1 ; }
10869 local file="/..$tdir/$tfile-1"
10870 $SETSTRIPE -p $pool $file ||
10871 { error_noexit "unable to create $file" ; return 2 ; }
10874 $SETSTRIPE -p $pool $tfile-2 || {
10875 error_noexit "unable to create $tfile-2 in $tdir"
10880 pool_remove_first_target() {
10881 echo "Removing first target from a pool"
10884 local pname="lov.$FSNAME-*.pools.$pool"
10885 local t=$($LCTL get_param -n $pname | head -n1)
10886 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10887 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10888 error_noexit "$t not removed from $FSNAME.$pool"
10893 pool_remove_all_targets() {
10894 echo "Removing all targets from pool"
10897 local pname="lov.$FSNAME-*.pools.$pool"
10898 for t in $($LCTL get_param -n $pname | sort -u)
10900 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10902 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10903 error_noexit "Pool $FSNAME.$pool cannot be drained"
10906 # striping on an empty/nonexistant pool should fall back
10907 # to "pool of everything"
10909 error_noexit "failed to use fallback striping for empty pool"
10912 # setstripe on an empty pool should fail
10913 $SETSTRIPE -p $pool $file 2>/dev/null && {
10914 error_noexit "expected failure when creating file" \
10922 echo "Destroying pool"
10926 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10929 # striping on an empty/nonexistant pool should fall back
10930 # to "pool of everything"
10932 error_noexit "failed to use fallback striping for missing pool"
10935 # setstripe on an empty pool should fail
10936 $SETSTRIPE -p $pool $file 2>/dev/null && {
10937 error_noexit "expected failure when creating file" \
10938 "with missing pool"
10942 # get param should return err once pool is gone
10943 if wait_update $HOSTNAME "lctl get_param -n \
10944 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10946 remove_pool_from_list $FSNAME.$pool
10949 error_noexit "Pool $FSNAME.$pool is not destroyed"
10954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10955 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10957 local POOL=${POOL:-cea1}
10958 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10959 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10962 local last_ost=$(($OSTCOUNT - 1))
10964 local ost_list=$(seq $first_ost $ost_step $last_ost)
10965 local ost_range="$first_ost $last_ost $ost_step"
10966 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10967 local file_dir=$POOL_ROOT/file_tst
10971 # former test_200a test_200b
10972 pool_add $POOL || { rc=$? ; break; }
10973 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10974 # former test_200c test_200d
10975 mkdir -p $test_path
10976 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10977 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10978 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10979 || { rc=$? ; break; }
10980 # former test_200e test_200f
10981 local files=$((OSTCOUNT*3))
10982 pool_alloc_files $POOL $test_path $files "$ost_list" \
10983 || { rc=$? ; break; }
10984 pool_create_files $POOL $file_dir $files "$ost_list" \
10985 || { rc=$? ; break; }
10986 # former test_200g test_200h
10987 pool_lfs_df $POOL || { rc=$? ; break; }
10988 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10990 # former test_201a test_201b test_201c
10991 pool_remove_first_target $POOL || { rc=$? ; break; }
10993 local f=$test_path/$tfile
10994 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10995 pool_remove $POOL $f || { rc=$? ; break; }
11002 run_test 200 "OST pools"
11004 # usage: default_attr <count | size | offset>
11006 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11009 # usage: check_default_stripe_attr
11010 check_default_stripe_attr() {
11011 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11013 --stripe-count|--count)
11014 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11015 --stripe-size|--size)
11016 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11017 --stripe-index|--index)
11020 error "unknown getstripe attr '$1'"
11023 [ $ACTUAL != $EXPECTED ] &&
11024 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11028 test_mkdir -p $DIR/$tdir
11029 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11031 check_default_stripe_attr --stripe-count
11032 check_default_stripe_attr --stripe-size
11033 check_default_stripe_attr --stripe-index
11037 run_test 204a "Print default stripe attributes ================="
11040 test_mkdir -p $DIR/$tdir
11041 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11043 check_default_stripe_attr --stripe-size
11044 check_default_stripe_attr --stripe-index
11048 run_test 204b "Print default stripe size and offset ==========="
11051 test_mkdir -p $DIR/$tdir
11052 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11054 check_default_stripe_attr --stripe-count
11055 check_default_stripe_attr --stripe-index
11059 run_test 204c "Print default stripe count and offset ==========="
11062 test_mkdir -p $DIR/$tdir
11063 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11065 check_default_stripe_attr --stripe-count
11066 check_default_stripe_attr --stripe-size
11070 run_test 204d "Print default stripe count and size ============="
11073 test_mkdir -p $DIR/$tdir
11074 $SETSTRIPE -d $DIR/$tdir
11076 check_default_stripe_attr --stripe-count --raw
11077 check_default_stripe_attr --stripe-size --raw
11078 check_default_stripe_attr --stripe-index --raw
11082 run_test 204e "Print raw stripe attributes ================="
11085 test_mkdir -p $DIR/$tdir
11086 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11088 check_default_stripe_attr --stripe-size --raw
11089 check_default_stripe_attr --stripe-index --raw
11093 run_test 204f "Print raw stripe size and offset ==========="
11096 test_mkdir -p $DIR/$tdir
11097 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11099 check_default_stripe_attr --stripe-count --raw
11100 check_default_stripe_attr --stripe-index --raw
11104 run_test 204g "Print raw stripe count and offset ==========="
11107 test_mkdir -p $DIR/$tdir
11108 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11110 check_default_stripe_attr --stripe-count --raw
11111 check_default_stripe_attr --stripe-size --raw
11115 run_test 204h "Print raw stripe count and size ============="
11117 # Figure out which job scheduler is being used, if any,
11118 # or use a fake one
11119 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11120 JOBENV=SLURM_JOB_ID
11121 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11123 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11125 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11126 JOBENV=LOADL_STEP_ID
11127 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11133 verify_jobstats() {
11137 # clear old jobstats
11138 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11139 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11141 # use a new JobID for this test, or we might see an old one
11142 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11146 log "Using JobID environment variable $JOBENV=$JOBVAL"
11148 if [ $JOBENV = "FAKE_JOBID" ]; then
11149 FAKE_JOBID=$JOBVAL $cmd
11154 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11155 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11156 do_facet $FACET lctl get_param mdt.*.job_stats |
11157 grep $JOBVAL || error "No job stats found on MDT $FACET"
11159 if [ "$target" = "ost" -o "$target" = "both" ]; then
11161 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11162 grep $JOBVAL || error "No job stats found on OST $FACET"
11168 NEW_JOBENV=${1:-$OLD_JOBENV}
11169 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11170 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11173 test_205() { # Job stats
11174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11175 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11176 skip "Server doesn't support jobstats" && return 0
11177 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11180 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11181 if [ $OLD_JOBENV != $JOBENV ]; then
11182 jobstats_set $JOBENV
11183 trap jobstats_set EXIT
11187 cmd="mkdir $DIR/$tfile"
11188 verify_jobstats "$cmd" "mdt"
11190 cmd="rm -fr $DIR/$tfile"
11191 verify_jobstats "$cmd" "mdt"
11193 cmd="mknod $DIR/$tfile c 1 3"
11194 verify_jobstats "$cmd" "mdt"
11196 cmd="rm -f $DIR/$tfile"
11197 verify_jobstats "$cmd" "mdt"
11199 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11200 verify_jobstats "$cmd" "mdt"
11202 cmd="touch $DIR/$tfile"
11203 verify_jobstats "$cmd" "both"
11205 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11206 verify_jobstats "$cmd" "ost"
11208 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11209 verify_jobstats "$cmd" "ost"
11211 cmd="$TRUNCATE $DIR/$tfile 0"
11212 verify_jobstats "$cmd" "both"
11214 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11215 verify_jobstats "$cmd" "mdt"
11218 rm -f $DIR/jobstats_test_rename
11220 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11222 run_test 205 "Verify job stats"
11224 # LU-1480, LU-1773 and LU-1657
11226 mkdir -p $DIR/$tdir
11227 $SETSTRIPE -c -1 $DIR/$tdir
11228 #define OBD_FAIL_LOV_INIT 0x1403
11229 $LCTL set_param fail_loc=0xa0001403
11230 $LCTL set_param fail_val=1
11231 touch $DIR/$tdir/$tfile || true
11233 run_test 206 "fail lov_init_raid0() doesn't lbug"
11236 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11237 local fsz=`stat -c %s $DIR/$tfile`
11238 cancel_lru_locks mdc
11240 # do not return layout in getattr intent
11241 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11242 $LCTL set_param fail_loc=0x170
11243 local sz=`stat -c %s $DIR/$tfile`
11245 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11249 run_test 207a "can refresh layout at glimpse"
11252 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11253 local cksum=`md5sum $DIR/$tfile`
11254 local fsz=`stat -c %s $DIR/$tfile`
11255 cancel_lru_locks mdc
11256 cancel_lru_locks osc
11258 # do not return layout in getattr intent
11259 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11260 $LCTL set_param fail_loc=0x171
11262 # it will refresh layout after the file is opened but before read issues
11263 echo checksum is "$cksum"
11264 echo "$cksum" |md5sum -c --quiet || error "file differs"
11268 run_test 207b "can refresh layout at open"
11271 # FIXME: in this test suite, only RD lease is used. This is okay
11272 # for now as only exclusive open is supported. After generic lease
11273 # is done, this test suite should be revised. - Jinshan
11275 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11276 { skip "Need MDS version at least 2.4.52"; return 0; }
11278 echo "==== test 1: verify get lease work"
11279 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11281 echo "==== test 2: verify lease can be broken by upcoming open"
11282 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11286 $MULTIOP $DIR/$tfile oO_RDONLY:c
11287 kill -USR1 $PID && wait $PID || error "break lease error"
11289 echo "==== test 3: verify lease can't be granted if an open already exists"
11290 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11294 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11295 kill -USR1 $PID && wait $PID || error "open file error"
11297 echo "==== test 4: lease can sustain over recovery"
11298 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11304 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11306 echo "==== test 5: lease broken can't be regained by replay"
11307 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11311 # open file to break lease and then recovery
11312 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11315 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11319 run_test 208 "Exclusive open"
11322 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11323 skip_env "must have disp_stripe" && return
11326 sync; sleep 5; sync;
11328 echo 3 > /proc/sys/vm/drop_caches
11329 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11331 # open/close 500 times
11332 for i in $(seq 500); do
11336 echo 3 > /proc/sys/vm/drop_caches
11337 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11339 echo "before: $req_before, after: $req_after"
11340 [ $((req_after - req_before)) -ge 300 ] &&
11341 error "open/close requests are not freed"
11344 run_test 209 "read-only open/close requests should be freed promptly"
11348 size=$((size % 8192 + 1))
11349 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11350 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11351 rm -f $DIR/f212 $DIR/f212.xyz
11353 run_test 212 "Sendfile test ============================================"
11356 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11357 cancel_lru_locks osc
11358 lctl set_param fail_loc=0x8000040f
11359 # generate a read lock
11360 cat $DIR/$tfile > /dev/null
11361 # write to the file, it will try to cancel the above read lock.
11362 cat /etc/hosts >> $DIR/$tfile
11364 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11366 test_214() { # for bug 20133
11367 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11368 for (( i=0; i < 340; i++ )) ; do
11369 touch $DIR/$tdir/d214c/a$i
11372 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11373 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11374 ls $DIR/d214c || error "ls $DIR/d214c failed"
11375 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11376 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11378 run_test 214 "hash-indexed directory test - bug 20133"
11380 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11381 create_lnet_proc_files() {
11382 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11383 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11385 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11386 rm -f "$TMP/lnet_$1.sys_tmp"
11389 # counterpart of create_lnet_proc_files
11390 remove_lnet_proc_files() {
11391 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11394 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11395 # 3rd arg as regexp for body
11396 check_lnet_proc_stats() {
11397 local l=$(cat "$TMP/lnet_$1" |wc -l)
11398 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11400 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11403 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11404 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11405 # optional and can be regexp for 2nd line (lnet.routes case)
11406 check_lnet_proc_entry() {
11407 local blp=2 # blp stands for 'position of 1st line of body'
11408 [ -z "$5" ] || blp=3 # lnet.routes case
11410 local l=$(cat "$TMP/lnet_$1" |wc -l)
11411 # subtracting one from $blp because the body can be empty
11412 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11414 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11415 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11417 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11418 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11420 # bail out if any unexpected line happened
11421 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11422 [ "$?" != 0 ] || error "$2 misformatted"
11425 test_215() { # for bugs 18102, 21079, 21517
11426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11427 local N='(0|[1-9][0-9]*)' # non-negative numeric
11428 local P='[1-9][0-9]*' # positive numeric
11429 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11430 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11431 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11432 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11434 local L1 # regexp for 1st line
11435 local L2 # regexp for 2nd line (optional)
11436 local BR # regexp for the rest (body)
11438 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11439 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11440 create_lnet_proc_files "stats"
11441 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11442 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11443 remove_lnet_proc_files "stats"
11445 # /proc/sys/lnet/routes should look like this:
11446 # Routing disabled/enabled
11447 # net hops priority state router
11448 # where net is a string like tcp0, hops > 0, priority >= 0,
11449 # state is up/down,
11450 # router is a string like 192.168.1.1@tcp2
11451 L1="^Routing (disabled|enabled)$"
11452 L2="^net +hops +priority +state +router$"
11453 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11454 create_lnet_proc_files "routes"
11455 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11456 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11457 remove_lnet_proc_files "routes"
11459 # /proc/sys/lnet/routers should look like this:
11460 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11461 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11462 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11463 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11464 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11465 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11466 create_lnet_proc_files "routers"
11467 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11468 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11469 remove_lnet_proc_files "routers"
11471 # /proc/sys/lnet/peers should look like this:
11472 # nid refs state last max rtr min tx min queue
11473 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11474 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11475 # numeric (0 or >0 or <0), queue >= 0.
11476 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11477 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11478 create_lnet_proc_files "peers"
11479 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11480 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11481 remove_lnet_proc_files "peers"
11483 # /proc/sys/lnet/buffers should look like this:
11484 # pages count credits min
11485 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11486 L1="^pages +count +credits +min$"
11487 BR="^ +$N +$N +$I +$I$"
11488 create_lnet_proc_files "buffers"
11489 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11490 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11491 remove_lnet_proc_files "buffers"
11493 # /proc/sys/lnet/nis should look like this:
11494 # nid status alive refs peer rtr max tx min
11495 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11496 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11497 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11498 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11499 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11500 create_lnet_proc_files "nis"
11501 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11502 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11503 remove_lnet_proc_files "nis"
11505 # can we successfully write to /proc/sys/lnet/stats?
11506 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11507 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11509 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11511 test_216() { # bug 20317
11512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11513 remote_ost_nodsh && skip "remote OST with nodsh" && return
11516 local facets=$(get_facets OST)
11517 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11519 save_lustre_params client "osc.*.contention_seconds" > $p
11520 save_lustre_params $facets \
11521 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11522 save_lustre_params $facets \
11523 "ldlm.namespaces.filter-*.contended_locks" >> $p
11524 save_lustre_params $facets \
11525 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11528 # agressive lockless i/o settings
11529 for node in $(osts_nodes); do
11530 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'
11532 lctl set_param -n osc.*.contention_seconds 60
11534 $DIRECTIO write $DIR/$tfile 0 10 4096
11535 $CHECKSTAT -s 40960 $DIR/$tfile
11537 # disable lockless i/o
11538 for node in $(osts_nodes); do
11539 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'
11541 lctl set_param -n osc.*.contention_seconds 0
11544 dd if=/dev/zero of=$DIR/$tfile count=0
11545 $CHECKSTAT -s 0 $DIR/$tfile
11547 restore_lustre_params <$p
11551 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11553 test_217() { # bug 22430
11554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11558 for node in $(nodes_list); do
11559 nid=$(host_nids_address $node $NETTYPE)
11560 if [[ $nid = *-* ]] ; then
11561 echo "lctl ping $nid@$NETTYPE"
11562 lctl ping $nid@$NETTYPE
11564 echo "skipping $node (no hyphen detected)"
11568 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11571 # do directio so as not to populate the page cache
11572 log "creating a 10 Mb file"
11573 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11574 log "starting reads"
11575 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11576 log "truncating the file"
11577 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11579 kill %+ || true # reads might have finished
11580 echo "wait until dd is finished"
11582 log "removing the temporary file"
11583 rm -rf $DIR/$tfile || error "tmp file removal failed"
11585 run_test 218 "parallel read and truncate should not deadlock ======================="
11588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11589 # write one partial page
11590 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11591 # set no grant so vvp_io_commit_write will do sync write
11592 $LCTL set_param fail_loc=0x411
11593 # write a full page at the end of file
11594 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11596 $LCTL set_param fail_loc=0
11597 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11598 $LCTL set_param fail_loc=0x411
11599 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11602 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11603 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11605 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11607 test_220() { #LU-325
11608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11609 remote_ost_nodsh && skip "remote OST with nodsh" && return
11612 test_mkdir -p $DIR/$tdir
11613 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11614 awk '{print $2}' | sed -e 's/_UUID$//')
11617 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11618 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11619 osc.$mdtosc_proc1.prealloc_last_id)
11620 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11621 osc.$mdtosc_proc1.prealloc_next_id)
11625 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11626 #define OBD_FAIL_OST_ENOINO 0x229
11627 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11628 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11629 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11631 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11633 MDSOBJS=$((last_id - next_id))
11634 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11636 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11637 echo "OST still has $count kbytes free"
11639 echo "create $MDSOBJS files @next_id..."
11640 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11642 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11643 osc.$mdtosc_proc1.prealloc_last_id)
11644 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11645 osc.$mdtosc_proc1.prealloc_next_id)
11647 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11652 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11653 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11655 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11656 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11657 echo "unlink $MDSOBJS files @$next_id..."
11658 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11660 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11664 dd if=`which date` of=$MOUNT/date oflag=sync
11665 chmod +x $MOUNT/date
11667 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11668 $LCTL set_param fail_loc=0x80001401
11670 $MOUNT/date > /dev/null
11673 run_test 221 "make sure fault and truncate race to not cause OOM"
11676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11678 test_mkdir -p $DIR/$tdir
11679 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11680 createmany -o $DIR/$tdir/$tfile 10
11681 cancel_lru_locks mdc
11682 cancel_lru_locks osc
11683 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11684 $LCTL set_param fail_loc=0x31a
11685 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11686 $LCTL set_param fail_loc=0
11689 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11694 test_mkdir -p $DIR/$tdir
11695 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11696 createmany -o $DIR/$tdir/$tfile 10
11697 cancel_lru_locks mdc
11698 cancel_lru_locks osc
11699 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11700 $LCTL set_param fail_loc=0x31a
11701 rm -r $DIR/$tdir || "AGL for rmdir failed"
11702 $LCTL set_param fail_loc=0
11704 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11709 test_mkdir -p $DIR/$tdir
11710 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11711 createmany -o $DIR/$tdir/$tfile 10
11712 cancel_lru_locks mdc
11713 cancel_lru_locks osc
11714 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11715 $LCTL set_param fail_loc=0x31b
11716 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11717 $LCTL set_param fail_loc=0
11720 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11722 test_224a() { # LU-1039, MRP-303
11723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11724 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11725 $LCTL set_param fail_loc=0x508
11726 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11727 $LCTL set_param fail_loc=0
11730 run_test 224a "Don't panic on bulk IO failure"
11732 test_224b() { # LU-1039, MRP-303
11733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11734 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11735 cancel_lru_locks osc
11736 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11737 $LCTL set_param fail_loc=0x515
11738 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11739 $LCTL set_param fail_loc=0
11742 run_test 224b "Don't panic on bulk IO failure"
11744 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11747 if [ -z ${MDSSURVEY} ]; then
11748 skip_env "mds-survey not found" && return
11751 [ $MDSCOUNT -ge 2 ] &&
11752 skip "skipping now for more than one MDT" && return
11754 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11755 { skip "Need MDS version at least 2.2.51"; return; }
11757 local mds=$(facet_host $SINGLEMDS)
11758 local target=$(do_nodes $mds 'lctl dl' | \
11759 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11761 local cmd1="file_count=1000 thrhi=4"
11762 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11763 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11764 local cmd="$cmd1 $cmd2 $cmd3"
11766 rm -f ${TMP}/mds_survey*
11768 eval $cmd || error "mds-survey with zero-stripe failed"
11769 cat ${TMP}/mds_survey*
11770 rm -f ${TMP}/mds_survey*
11772 run_test 225a "Metadata survey sanity with zero-stripe"
11775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11777 if [ -z ${MDSSURVEY} ]; then
11778 skip_env "mds-survey not found" && return
11780 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11781 { skip "Need MDS version at least 2.2.51"; return; }
11783 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11784 skip_env "Need to mount OST to test" && return
11787 [ $MDSCOUNT -ge 2 ] &&
11788 skip "skipping now for more than one MDT" && return
11789 local mds=$(facet_host $SINGLEMDS)
11790 local target=$(do_nodes $mds 'lctl dl' | \
11791 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11793 local cmd1="file_count=1000 thrhi=4"
11794 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11795 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11796 local cmd="$cmd1 $cmd2 $cmd3"
11798 rm -f ${TMP}/mds_survey*
11800 eval $cmd || error "mds-survey with stripe_count failed"
11801 cat ${TMP}/mds_survey*
11802 rm -f ${TMP}/mds_survey*
11804 run_test 225b "Metadata survey sanity with stripe_count = 1"
11806 mcreate_path2fid () {
11812 local path=$DIR/$tdir/$name
11817 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11818 error "cannot create $desc"
11820 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11822 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11824 fid_path=$($LFS fid2path $MOUNT $fid)
11826 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11828 [ "$path" == "$fid_path" ] ||
11829 error "fid2path returned $fid_path, expected $path"
11831 echo "pass with $path and $fid"
11836 mkdir -p $DIR/$tdir
11838 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11839 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11840 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11841 mcreate_path2fid 0040666 0 0 dir "directory"
11842 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11843 mcreate_path2fid 0100666 0 0 file "regular file"
11844 mcreate_path2fid 0120666 0 0 link "symbolic link"
11845 mcreate_path2fid 0140666 0 0 sock "socket"
11847 run_test 226a "call path2fid and fid2path on files of all type"
11850 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11854 mkdir -p $DIR/$tdir
11855 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11856 error "create remote directory failed"
11857 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11858 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11859 "character special file (null)"
11860 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11861 "character special file (no device)"
11862 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11863 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11864 "block special file (loop)"
11865 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11866 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11867 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11869 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11871 # LU-1299 Executing or running ldd on a truncated executable does not
11872 # cause an out-of-memory condition.
11874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11875 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11876 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11877 chmod +x $MOUNT/date
11879 $MOUNT/date > /dev/null
11880 ldd $MOUNT/date > /dev/null
11883 run_test 227 "running truncated executable does not cause OOM"
11885 # LU-1512 try to reuse idle OI blocks
11887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11888 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11889 skip "non-ldiskfs backend" && return
11891 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11892 local myDIR=$DIR/$tdir
11895 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11896 $LCTL set_param fail_loc=0x80001002
11897 createmany -o $myDIR/t- 10000
11898 $LCTL set_param fail_loc=0
11899 # The guard is current the largest FID holder
11901 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11903 local IDX=$(($SEQ % 64))
11905 do_facet $SINGLEMDS sync
11906 # Make sure journal flushed.
11908 local blk1=$(do_facet $SINGLEMDS \
11909 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11910 grep Blockcount | awk '{print $4}')
11912 # Remove old files, some OI blocks will become idle.
11913 unlinkmany $myDIR/t- 10000
11914 # Create new files, idle OI blocks should be reused.
11915 createmany -o $myDIR/t- 2000
11916 do_facet $SINGLEMDS sync
11917 # Make sure journal flushed.
11919 local blk2=$(do_facet $SINGLEMDS \
11920 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11921 grep Blockcount | awk '{print $4}')
11923 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11925 run_test 228a "try to reuse idle OI blocks"
11928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11929 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11930 skip "non-ldiskfs backend" && return
11932 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11933 local myDIR=$DIR/$tdir
11936 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11937 $LCTL set_param fail_loc=0x80001002
11938 createmany -o $myDIR/t- 10000
11939 $LCTL set_param fail_loc=0
11940 # The guard is current the largest FID holder
11942 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11944 local IDX=$(($SEQ % 64))
11946 do_facet $SINGLEMDS sync
11947 # Make sure journal flushed.
11949 local blk1=$(do_facet $SINGLEMDS \
11950 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11951 grep Blockcount | awk '{print $4}')
11953 # Remove old files, some OI blocks will become idle.
11954 unlinkmany $myDIR/t- 10000
11957 stop $SINGLEMDS || error "Fail to stop MDT."
11959 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11961 df $MOUNT || error "Fail to df."
11962 # Create new files, idle OI blocks should be reused.
11963 createmany -o $myDIR/t- 2000
11964 do_facet $SINGLEMDS sync
11965 # Make sure journal flushed.
11967 local blk2=$(do_facet $SINGLEMDS \
11968 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11969 grep Blockcount | awk '{print $4}')
11971 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11973 run_test 228b "idle OI blocks can be reused after MDT restart"
11977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11978 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11979 skip "non-ldiskfs backend" && return
11981 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11982 local myDIR=$DIR/$tdir
11985 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11986 $LCTL set_param fail_loc=0x80001002
11987 # 20000 files can guarantee there are index nodes in the OI file
11988 createmany -o $myDIR/t- 20000
11989 $LCTL set_param fail_loc=0
11990 # The guard is current the largest FID holder
11992 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11994 local IDX=$(($SEQ % 64))
11996 do_facet $SINGLEMDS sync
11997 # Make sure journal flushed.
11999 local blk1=$(do_facet $SINGLEMDS \
12000 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12001 grep Blockcount | awk '{print $4}')
12003 # Remove old files, some OI blocks will become idle.
12004 unlinkmany $myDIR/t- 20000
12006 # The OI file should become empty now
12008 # Create new files, idle OI blocks should be reused.
12009 createmany -o $myDIR/t- 2000
12010 do_facet $SINGLEMDS sync
12011 # Make sure journal flushed.
12013 local blk2=$(do_facet $SINGLEMDS \
12014 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12015 grep Blockcount | awk '{print $4}')
12017 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12019 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12021 test_229() { # LU-2482, LU-3448
12022 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12023 skip "No HSM support on MDS of $(get_lustre_version)," \
12024 "need 2.4.53 at least" && return
12025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12026 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12030 # Create a file with a released layout and stripe count 2.
12031 $MULTIOP $DIR/$tfile H2c ||
12032 error "failed to create file with released layout"
12034 $GETSTRIPE -v $DIR/$tfile
12036 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12037 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12039 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12040 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12041 stat $DIR/$tfile || error "failed to stat released file"
12043 chown $RUNAS_ID $DIR/$tfile ||
12044 error "chown $RUNAS_ID $DIR/$tfile failed"
12046 chgrp $RUNAS_ID $DIR/$tfile ||
12047 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12049 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12050 rm $DIR/$tfile || error "failed to remove released file"
12052 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12056 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12059 mkdir -p $DIR/$tdir/test_230_local
12060 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12061 [ $mdt_idx -ne 0 ] &&
12062 error "create local directory on wrong MDT $mdt_idx"
12064 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12065 error "create remote directory failed"
12066 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12067 [ $mdt_idx -ne $MDTIDX ] &&
12068 error "create remote directory on wrong MDT $mdt_idx"
12070 createmany -o $DIR/$tdir/test_230/t- 10 ||
12071 error "create files on remote directory failed"
12072 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12073 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12074 rm -r $DIR/$tdir || error "unlink remote directory failed"
12076 run_test 230a "Create remote directory and files under the remote directory"
12079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12080 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12087 local migrate_dir=$DIR/$tdir/migrate_dir
12088 local other_dir=$DIR/$tdir/other_dir
12090 mkdir -p $migrate_dir
12091 mkdir -p $other_dir
12092 for ((i=0; i<10; i++)); do
12093 mkdir -p $migrate_dir/dir_${i}
12094 createmany -o $migrate_dir/dir_${i}/f 10 ||
12095 error "create files under remote dir failed $i"
12098 cp /etc/passwd $migrate_dir/$tfile
12099 cp /etc/passwd $other_dir/$tfile
12100 chattr +SAD $migrate_dir
12101 chattr +SAD $migrate_dir/$tfile
12103 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12104 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12105 local old_dir_mode=$(stat -c%f $migrate_dir)
12106 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12108 mkdir -p $migrate_dir/dir_default_stripe2
12109 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12110 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12112 mkdir -p $other_dir
12113 ln $migrate_dir/$tfile $other_dir/luna
12114 ln $migrate_dir/$tfile $migrate_dir/sofia
12115 ln $other_dir/$tfile $migrate_dir/david
12116 ln -s $migrate_dir/$tfile $other_dir/zachary
12117 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12118 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12120 $LFS mv -v -M $MDTIDX $migrate_dir ||
12121 error "migrate remote dir error"
12123 echo "migratate to MDT1, then checking.."
12124 for ((i=0; i<10; i++)); do
12125 for file in $(find $migrate_dir/dir_${i}); do
12126 mdt_index=$($LFS getstripe -M $file)
12127 [ $mdt_index == $MDTIDX ] ||
12128 error "$file is not on MDT${MDTIDX}"
12132 # the multiple link file should still in MDT0
12133 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12134 [ $mdt_index == 0 ] ||
12135 error "$file is not on MDT${MDTIDX}"
12137 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12138 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12139 error " expect $old_dir_flag get $new_dir_flag"
12141 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12142 [ "$old_file_flag" = "$new_file_flag" ] ||
12143 error " expect $old_file_flag get $new_file_flag"
12145 local new_dir_mode=$(stat -c%f $migrate_dir)
12146 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12147 error "expect mode $old_dir_mode get $new_dir_mode"
12149 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12150 [ "$old_file_mode" = "$new_file_mode" ] ||
12151 error "expect mode $old_file_mode get $new_file_mode"
12153 diff /etc/passwd $migrate_dir/$tfile ||
12154 error "$tfile different after migration"
12156 diff /etc/passwd $other_dir/luna ||
12157 error "luna different after migration"
12159 diff /etc/passwd $migrate_dir/sofia ||
12160 error "sofia different after migration"
12162 diff /etc/passwd $migrate_dir/david ||
12163 error "david different after migration"
12165 diff /etc/passwd $other_dir/zachary ||
12166 error "zachary different after migration"
12168 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12169 error "${tfile}_ln different after migration"
12171 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12172 error "${tfile}_ln_other different after migration"
12174 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12175 [ $stripe_count = 2 ] ||
12176 error "dir strpe_count $d != 2 after migration."
12178 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12179 [ $stripe_count = 2 ] ||
12180 error "file strpe_count $d != 2 after migration."
12182 #migrate back to MDT0
12184 $LFS mv -v -M $MDTIDX $migrate_dir ||
12185 error "migrate remote dir error"
12187 echo "migrate back to MDT0, checking.."
12188 for file in $(find $migrate_dir); do
12189 mdt_index=$($LFS getstripe -M $file)
12190 [ $mdt_index == $MDTIDX ] ||
12191 error "$file is not on MDT${MDTIDX}"
12194 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12195 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12196 error " expect $old_dir_flag get $new_dir_flag"
12198 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12199 [ "$old_file_flag" = "$new_file_flag" ] ||
12200 error " expect $old_file_flag get $new_file_flag"
12202 local new_dir_mode=$(stat -c%f $migrate_dir)
12203 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12204 error "expect mode $old_dir_mode get $new_dir_mode"
12206 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12207 [ "$old_file_mode" = "$new_file_mode" ] ||
12208 error "expect mode $old_file_mode get $new_file_mode"
12210 diff /etc/passwd ${migrate_dir}/$tfile ||
12211 error "$tfile different after migration"
12213 diff /etc/passwd ${other_dir}/luna ||
12214 error "luna different after migration"
12216 diff /etc/passwd ${migrate_dir}/sofia ||
12217 error "sofia different after migration"
12219 diff /etc/passwd ${other_dir}/zachary ||
12220 error "zachary different after migration"
12222 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12223 error "${tfile}_ln different after migration"
12225 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12226 error "${tfile}_ln_other different after migration"
12228 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12229 [ $stripe_count = 2 ] ||
12230 error "dir strpe_count $d != 2 after migration."
12232 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12233 [ $stripe_count = 2 ] ||
12234 error "file strpe_count $d != 2 after migration."
12236 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12238 run_test 230b "migrate directory"
12241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12242 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12247 #If migrating directory fails in the middle, all entries of
12248 #the directory is still accessiable.
12249 mkdir -p $DIR/$tdir
12251 createmany -o $DIR/$tdir/f 10 ||
12252 error "create files under ${tdir} failed"
12254 #failed after migrating 5 entries
12255 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12256 do_facet mds1 lctl set_param fail_loc=0x20001801
12257 do_facet mds1 lctl set_param fail_val=5
12258 local t=`ls $DIR/$tdir | wc -l`
12259 $LFS mv -M $MDTIDX $DIR/$tdir &&
12260 error "migrate should failed after 5 entries"
12261 local u=`ls $DIR/$tdir | wc -l`
12262 [ "$u" == "$t" ] || error "$u != $t during migration"
12264 for file in $(find $DIR/$tdir); do
12265 stat $file || error "stat $file failed"
12268 do_facet mds1 lctl set_param fail_loc=0
12269 do_facet mds1 lctl set_param fail_val=0
12271 $LFS mv -M $MDTIDX $DIR/$tdir ||
12272 error "migrate open files should failed with open files"
12274 echo "Finish migration, then checking.."
12275 for file in $(find $DIR/$tdir); do
12276 mdt_index=$($LFS getstripe -M $file)
12277 [ $mdt_index == $MDTIDX ] ||
12278 error "$file is not on MDT${MDTIDX}"
12281 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12283 run_test 230c "check directory accessiblity if migration is failed"
12286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12287 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12293 mkdir -p $DIR/$tdir
12295 for ((i=0; i<100; i++)); do
12296 mkdir -p $DIR/$tdir/dir_${i}
12297 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12298 error "create files under remote dir failed $i"
12301 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12303 echo "Finish migration, then checking.."
12304 for file in $(find $DIR/$tdir); do
12305 mdt_index=$($LFS getstripe -M $file)
12306 [ $mdt_index == $MDTIDX ] ||
12307 error "$file is not on MDT${MDTIDX}"
12310 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12312 run_test 230d "check migrate big directory"
12316 # For simplicity this test assumes that max_pages_per_rpc
12317 # is the same across all OSCs
12318 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12319 local bulk_size=$((max_pages * 4096))
12321 mkdir -p $DIR/$tdir
12323 # clear the OSC stats
12324 $LCTL set_param osc.*.stats=0 &>/dev/null
12326 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12327 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12328 oflag=direct &>/dev/null || error "dd failed"
12330 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12331 if [ x$nrpcs != "x1" ]; then
12332 error "found $nrpc ost_write RPCs, not 1 as expected"
12335 # Drop the OSC cache, otherwise we will read from it
12336 cancel_lru_locks osc
12338 # clear the OSC stats
12339 $LCTL set_param osc.*.stats=0 &>/dev/null
12341 # Client reads $bulk_size.
12342 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12343 iflag=direct &>/dev/null || error "dd failed"
12345 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12346 if [ x$nrpcs != "x1" ]; then
12347 error "found $nrpc ost_read RPCs, not 1 as expected"
12350 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12353 mkdir -p $DIR/$tdir
12355 for i in {0..1023}; do
12356 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12357 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12358 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12362 run_test 231b "must not assert on fully utilized OST request buffer"
12365 mkdir -p $DIR/$tdir
12366 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12367 $LCTL set_param fail_loc=0x31c
12369 # ignore dd failure
12370 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12372 $LCTL set_param fail_loc=0
12373 umount_client $MOUNT || error "umount failed"
12374 mount_client $MOUNT || error "mount failed"
12376 run_test 232 "failed lock should not block umount"
12379 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12380 { skip "Need MDS version at least 2.3.64"; return; }
12382 local fid=$($LFS path2fid $MOUNT)
12383 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12384 error "cannot access $MOUNT using its FID '$fid'"
12386 run_test 233a "checking that OBF of the FS root succeeds"
12389 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12390 { skip "Need MDS version at least 2.5.90"; return; }
12392 local fid=$($LFS path2fid $MOUNT/.lustre)
12393 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12394 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12396 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12397 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12398 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12400 run_test 233b "checking that OBF of the FS .lustre succeeds"
12403 local p="$TMP/sanityN-$TESTNAME.parameters"
12404 save_lustre_params client "llite.*.xattr_cache" > $p
12405 lctl set_param llite.*.xattr_cache 1 ||
12406 { skip "xattr cache is not supported"; return 0; }
12408 mkdir -p $DIR/$tdir || error "mkdir failed"
12409 touch $DIR/$tdir/$tfile || error "touch failed"
12410 # OBD_FAIL_LLITE_XATTR_ENOMEM
12411 $LCTL set_param fail_loc=0x1405
12412 if [ ! -f /etc/SuSE-release ]; then
12413 # attr pre-2.4.44-7 had a bug with rc
12414 # LU-3703 - SLES clients have older attr
12415 getfattr -n user.attr $DIR/$tdir/$tfile &&
12416 error "getfattr should have failed with ENOMEM"
12418 $LCTL set_param fail_loc=0x0
12421 restore_lustre_params < $p
12424 run_test 234 "xattr cache should not crash on ENOMEM"
12427 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12428 skip "Need MDS version at least 2.4.52" && return
12429 flock_deadlock $DIR/$tfile
12434 124) error "process hangs on a deadlock"
12436 *) error "error executing flock_deadlock $DIR/$tfile"
12440 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12444 check_swap_layouts_support && return 0
12445 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12447 local ref1=/etc/passwd
12448 local ref2=/etc/group
12449 local file1=$DIR/$tdir/f1
12450 local file2=$DIR/$tdir/f2
12452 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12453 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12454 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12455 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12456 local fd=$(free_fd)
12457 local cmd="exec $fd<>$file2"
12460 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12461 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12464 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12469 run_test 236 "Layout swap on open unlinked file"
12471 # test to verify file handle related system calls
12472 # (name_to_handle_at/open_by_handle_at)
12473 # The new system calls are supported in glibc >= 2.14.
12476 echo "Test file_handle syscalls" > $DIR/$tfile
12477 check_fhandle_syscalls $DIR/$tfile ||
12478 error "check_fhandle_syscalls failed"
12480 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12482 # LU-4659 linkea consistency
12485 ln $DIR/$tfile $DIR/$tfile.lnk
12486 touch $DIR/$tfile.new
12487 mv $DIR/$tfile.new $DIR/$tfile
12488 local fid1=$(lfs path2fid $DIR/$tfile)
12489 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12490 local path1=$(lfs fid2path $FSNAME $fid1)
12491 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12492 local path2=$(lfs fid2path $FSNAME $fid2)
12493 [ $tfile.lnk == $path2 ] ||
12494 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12497 run_test 238 "Verify linkea consistency"
12499 test_striped_dir() {
12504 mkdir -p $DIR/$tdir
12505 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12506 error "set striped dir error"
12508 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12509 if [ "$stripe_count" != "2" ]; then
12510 error "stripe_count is $stripe_count, expect 2"
12513 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12514 if [ "$stripe_index" != "$mdt_index" ]; then
12515 error "stripe_index is $stripe_index, expect $mdt_index"
12518 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12519 error "nlink error after create striped dir"
12521 mkdir $DIR/$tdir/striped_dir/a
12522 mkdir $DIR/$tdir/striped_dir/b
12524 stat $DIR/$tdir/striped_dir/a ||
12525 error "create dir under striped dir failed"
12526 stat $DIR/$tdir/striped_dir/b ||
12527 error "create dir under striped dir failed"
12529 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12530 error "nlink error after mkdir"
12532 rmdir $DIR/$tdir/striped_dir/a
12533 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12534 error "nlink error after rmdir"
12536 rmdir $DIR/$tdir/striped_dir/b
12537 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12538 error "nlink error after rmdir"
12540 rmdir $DIR/$tdir/striped_dir ||
12541 error "rmdir striped dir error"
12546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12547 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12549 test_striped_dir 0 || error "failed on striped dir on MDT0"
12550 test_striped_dir 1 || error "failed on striped dir on MDT0"
12552 run_test 300a "basic striped dir sanity test"
12555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12556 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12562 test_mkdir $DIR/$tdir || error "mkdir fail"
12563 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12564 error "set striped dir error"
12565 for ((i=0; i<10; i++)); do
12566 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12568 touch $DIR/$tdir/striped_dir/file_$i ||
12569 error "touch error $i"
12570 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12571 [ $mtime1 -eq $mtime2 ] &&
12572 error "mtime not change after create"
12574 rm -f $DIR/$tdir/striped_dir/file_$i ||
12575 error "unlink error $i"
12576 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12577 [ $mtime2 -eq $mtime3 ] &&
12578 error "mtime did not change after unlink"
12582 run_test 300b "check ctime/mtime for striped dir"
12585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12586 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12589 mkdir -p $DIR/$tdir
12590 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12591 error "set striped dir error"
12593 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12594 error "chown striped dir failed"
12596 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12597 error "create 5k files failed"
12599 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12601 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12605 run_test 300c "chown && check ls under striped directory"
12608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12609 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12613 mkdir -p $DIR/$tdir
12614 $SETSTRIPE -c 2 $DIR/$tdir
12616 #local striped directory
12617 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12618 error "set striped dir error"
12619 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12620 error "create 10 files failed"
12622 #remote striped directory
12623 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12624 error "set striped dir error"
12625 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12626 error "create 10 files failed"
12628 for file in $(find $DIR/$tdir); do
12629 stripe_count=$($GETSTRIPE -c $file)
12630 [ $stripe_count -eq 2 ] ||
12631 error "wrong stripe $stripe_count for $file"
12636 run_test 300d "check default stripe under striped directory"
12639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12640 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12644 mkdir -p $DIR/$tdir
12646 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12647 error "set striped dir error"
12649 touch $DIR/$tdir/striped_dir/a
12650 touch $DIR/$tdir/striped_dir/b
12651 touch $DIR/$tdir/striped_dir/c
12653 mkdir $DIR/$tdir/striped_dir/dir_a
12654 mkdir $DIR/$tdir/striped_dir/dir_b
12655 mkdir $DIR/$tdir/striped_dir/dir_c
12657 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12658 error "set striped dir under striped dir error"
12660 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12661 error "set striped dir under striped dir error"
12663 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12664 error "set striped dir under striped dir error"
12666 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12667 error "rename file under striped dir should fail"
12669 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12670 error "rename dir under striped dir should fail"
12672 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12673 error "rename dir under different stripes should fail"
12675 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12676 error "rename file under striped dir should succeed"
12678 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12679 error "rename dir under striped dir should succeed"
12683 run_test 300e "check rename under striped directory"
12686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12687 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12692 mkdir -p $DIR/$tdir
12694 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12695 error "set striped dir error"
12697 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12698 error "set striped dir error"
12700 touch $DIR/$tdir/striped_dir/a
12701 mkdir $DIR/$tdir/striped_dir/dir_a
12702 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12703 error "create striped dir under striped dir fails"
12705 touch $DIR/$tdir/striped_dir1/b
12706 mkdir $DIR/$tdir/striped_dir1/dir_b
12707 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12708 error "create striped dir under striped dir fails"
12710 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12711 error "rename file under different striped dir should fail"
12713 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12714 error "rename dir under different striped dir should fail"
12716 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12717 error "rename striped dir under diff striped dir should fail"
12719 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12720 error "rename file under diff striped dirs fails"
12722 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12723 error "rename dir under diff striped dirs fails"
12727 run_test 300f "check rename cross striped directory"
12730 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12735 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12736 $DIR/$tdir/striped_dir ||
12737 error "set striped dir error"
12739 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12740 error "set default stripe on striped dir error"
12742 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12744 for dir in $(find $DIR/$tdir/striped_dir/*); do
12745 stripe_count=$($LFS getdirstripe -c $dir)
12746 [ $stripe_count -eq $MDSCOUNT ] ||
12747 error "expect $MDSCOUNT get $stripe_count for $dir"
12750 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12751 #change default stripe count to 2
12752 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12753 error "set default stripe on striped dir error"
12755 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12757 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12759 #change default stripe count to 1
12760 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12761 error "set default stripe on striped dir error"
12763 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12764 for dir in $(find $DIR/$tdir/striped_dir/*); do
12765 stripe_count=$($LFS getdirstripe -c $dir)
12766 [ $stripe_count -eq 1 ] ||
12767 error "expect 1 get $stripe_count for $dir"
12769 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12771 run_test 300g "check default striped directory for striped directory"
12774 # tests that do cleanup/setup should be run at the end
12778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12780 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12781 $LCTL set_param fail_loc=0x903
12782 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12783 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12786 FAIL_ON_ERROR=true cleanup
12787 FAIL_ON_ERROR=true setup
12789 run_test 900 "umount should not race with any mgc requeue thread"
12792 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12793 check_and_cleanup_lustre
12794 if [ "$I_MOUNTED" != "yes" ]; then
12795 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true