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"
6741 run_acl_subtest 4924 || error "LU-4924 test failed"
6746 for num in $(seq $MDSCOUNT); do
6747 if [ "${identity_old[$num]}" = 1 ]; then
6748 switch_identity $num false || identity_old[$num]=$?
6752 run_test 103 "acl test ========================================="
6755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6757 lfs df || error "lfs df failed"
6758 lfs df -ih || error "lfs df -ih failed"
6759 lfs df -h $DIR || error "lfs df -h $DIR failed"
6760 lfs df -i $DIR || error "lfs df -i $DIR failed"
6761 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6762 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6764 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6765 lctl --device %$OSC deactivate
6766 lfs df || error "lfs df with deactivated OSC failed"
6767 lctl --device %$OSC activate
6768 # wait the osc back to normal
6769 wait_osc_import_state client ost FULL
6771 lfs df || error "lfs df with reactivated OSC failed"
6774 run_test 104a "lfs df [-ih] [path] test ========================="
6777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6778 [ $RUNAS_ID -eq $UID ] &&
6779 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6781 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6782 grep "Permission denied" | wc -l)))
6783 if [ $denied_cnt -ne 0 ]; then
6784 error "lfs check servers test failed"
6787 run_test 104b "$RUNAS lfs check servers test ===================="
6790 # doesn't work on 2.4 kernels
6792 if $(flock_is_enabled); then
6793 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6795 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6799 run_test 105a "flock when mounted without -o flock test ========"
6803 if $(flock_is_enabled); then
6804 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6806 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6810 run_test 105b "fcntl when mounted without -o flock test ========"
6814 if $(flock_is_enabled); then
6815 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6817 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6821 run_test 105c "lockf when mounted without -o flock test ========"
6823 test_105d() { # bug 15924
6824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6825 test_mkdir -p $DIR/$tdir
6826 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6827 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6828 $LCTL set_param fail_loc=0x80000315
6829 flocks_test 2 $DIR/$tdir
6831 run_test 105d "flock race (should not freeze) ========"
6833 test_105e() { # bug 22660 && 22040
6834 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6836 flocks_test 3 $DIR/$tfile
6838 run_test 105e "Two conflicting flocks from same process ======="
6840 test_106() { #bug 10921
6841 test_mkdir -p $DIR/$tdir
6842 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6843 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6845 run_test 106 "attempt exec of dir followed by chown of that dir"
6848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6855 local save_pattern=$(sysctl -n kernel.core_pattern)
6856 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6857 sysctl -w kernel.core_pattern=$file
6858 sysctl -w kernel.core_uses_pid=0
6866 kill -s 11 $SLEEPPID
6868 if [ -e $file ]; then
6869 size=`stat -c%s $file`
6870 [ $size -eq 0 ] && error "Fail to create core file $file"
6872 error "Fail to create core file $file"
6875 sysctl -w kernel.core_pattern=$save_pattern
6876 sysctl -w kernel.core_uses_pid=$save_uses_pid
6879 run_test 107 "Coredump on SIG"
6882 test_mkdir -p $DIR/$tdir
6883 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6884 error "mkdir with 255 char failed"
6885 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6886 error "mkdir with 256 char should fail, but did not"
6887 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6888 error "create with 255 char failed"
6889 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6890 error "create with 256 char should fail, but did not"
6895 run_test 110 "filename length checking"
6898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6899 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
6900 tail -1 | cut -c11-20)
6901 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
6902 echo "Starting with $OSTIO_pre threads"
6905 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
6906 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
6907 echo "$NUMTEST creates/unlinks"
6908 test_mkdir -p $DIR/$tdir
6909 createmany -o $DIR/$tdir/$tfile $NUMTEST
6910 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6912 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
6913 tail -1 | cut -c11-20)
6915 # don't return an error
6916 [ $OSTIO_post == $OSTIO_pre ] && echo \
6917 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6918 echo "This may be fine, depending on what ran before this test" &&
6919 echo "and how fast this system is." && return
6921 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6923 run_test 115 "verify dynamic thread creation===================="
6926 wait_delete_completed
6927 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6928 echo OST kbytes available: ${AVAIL[@]}
6929 MAXI=0; MAXV=${AVAIL[0]}
6930 MINI=0; MINV=${AVAIL[0]}
6931 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6932 #echo OST $i: ${AVAIL[i]}kb
6933 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
6934 MAXV=${AVAIL[i]}; MAXI=$i
6936 if [[ ${AVAIL[i]} -lt $MINV ]]; then
6937 MINV=${AVAIL[i]}; MINI=$i
6940 echo Min free space: OST $MINI: $MINV
6941 echo Max free space: OST $MAXI: $MAXV
6944 test_116a() { # was previously test_116()
6945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6946 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
6948 echo -n "Free space priority "
6949 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6954 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6955 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
6957 trap simple_cleanup_common EXIT
6960 # Check if we need to generate uneven OSTs
6961 test_mkdir -p $DIR/$tdir/OST${MINI}
6962 local FILL=$(($MINV / 4))
6963 local DIFF=$(($MAXV - $MINV))
6964 local DIFF2=$(($DIFF * 100 / $MINV))
6966 local threshold=$(do_facet $SINGLEMDS \
6967 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6968 threshold=${threshold%%%}
6969 echo -n "Check for uneven OSTs: "
6970 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6972 if [[ $DIFF2 -gt $threshold ]]; then
6974 echo "Don't need to fill OST$MINI"
6976 # generate uneven OSTs. Write 2% over the QOS threshold value
6978 DIFF=$(($threshold - $DIFF2 + 2))
6979 DIFF2=$(( ($MINV * $DIFF)/100 ))
6980 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6981 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6982 error "setstripe failed"
6983 DIFF=$(($DIFF2 / 2048))
6985 while [ $i -lt $DIFF ]; do
6987 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6988 bs=2M count=1 2>/dev/null
6997 DIFF=$(($MAXV - $MINV))
6998 DIFF2=$(($DIFF * 100 / $MINV))
6999 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7000 if [[ $DIFF2 -gt $threshold ]]; then
7003 echo "failed - QOS mode won't be used"
7004 skip "QOS imbalance criteria not met"
7005 simple_cleanup_common
7009 MINI1=$MINI; MINV1=$MINV
7010 MAXI1=$MAXI; MAXV1=$MAXV
7012 # now fill using QOS
7013 $SETSTRIPE -c 1 $DIR/$tdir
7014 FILL=$(($FILL / 200))
7015 if [ $FILL -gt 600 ]; then
7018 echo "writing $FILL files to QOS-assigned OSTs"
7020 while [ $i -lt $FILL ]; do
7022 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7026 echo "wrote $i 200k files"
7030 echo "Note: free space may not be updated, so measurements might be off"
7032 DIFF2=$(($MAXV - $MINV))
7033 echo "free space delta: orig $DIFF final $DIFF2"
7034 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7035 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7036 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7037 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7038 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7039 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7041 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7043 # Figure out which files were written where
7044 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7045 awk '/'$MINI1': / {print $2; exit}')
7047 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7048 echo "$MINC files created on smaller OST $MINI1"
7049 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7050 awk '/'$MAXI1': / {print $2; exit}')
7052 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7053 echo "$MAXC files created on larger OST $MAXI1"
7054 FILL=$(($MAXC * 100 / $MINC - 100))
7055 [[ $MINC -gt 0 ]] &&
7056 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7057 [[ $MAXC -gt $MINC ]] ||
7058 error_ignore LU-9 "stripe QOS didn't balance free space"
7059 simple_cleanup_common
7061 run_test 116a "stripe QOS: free space balance ==================="
7063 test_116b() { # LU-2093
7064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7065 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7066 head -1 2>/dev/null)" ] && skip "no QOS" && return
7067 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7069 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7070 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7071 do_facet $SINGLEMDS lctl set_param \
7072 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7074 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7075 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7076 do_facet $SINGLEMDS lctl set_param fail_loc=0
7078 do_facet $SINGLEMDS lctl set_param \
7079 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7081 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7083 test_117() # bug 10891
7085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7086 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7087 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7088 lctl set_param fail_loc=0x21e
7089 > $DIR/$tfile || error "truncate failed"
7090 lctl set_param fail_loc=0
7091 echo "Truncate succeeded."
7094 run_test 117 "verify osd extend =========="
7096 NO_SLOW_RESENDCOUNT=4
7097 export OLD_RESENDCOUNT=""
7098 set_resend_count () {
7099 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7100 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7101 lctl set_param -n $PROC_RESENDCOUNT $1
7102 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7105 # for reduce test_118* time (b=14842)
7106 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7108 # Reset async IO behavior after error case
7110 FILE=$DIR/reset_async
7112 # Ensure all OSCs are cleared
7113 $SETSTRIPE -c -1 $FILE
7114 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7119 test_118a() #bug 11710
7121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7124 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7125 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7126 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7128 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7129 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7134 run_test 118a "verify O_SYNC works =========="
7138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7139 remote_ost_nodsh && skip "remote OST with nodsh" && return
7143 #define OBD_FAIL_OST_ENOENT 0x217
7144 set_nodes_failloc "$(osts_nodes)" 0x217
7145 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7147 set_nodes_failloc "$(osts_nodes)" 0
7148 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7149 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7152 if [[ $RC -eq 0 ]]; then
7153 error "Must return error due to dropped pages, rc=$RC"
7157 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7158 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7162 echo "Dirty pages not leaked on ENOENT"
7164 # Due to the above error the OSC will issue all RPCs syncronously
7165 # until a subsequent RPC completes successfully without error.
7166 $MULTIOP $DIR/$tfile Ow4096yc
7171 run_test 118b "Reclaim dirty pages on fatal error =========="
7175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7177 # for 118c, restore the original resend count, LU-1940
7178 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7179 set_resend_count $OLD_RESENDCOUNT
7180 remote_ost_nodsh && skip "remote OST with nodsh" && return
7184 #define OBD_FAIL_OST_EROFS 0x216
7185 set_nodes_failloc "$(osts_nodes)" 0x216
7187 # multiop should block due to fsync until pages are written
7188 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7192 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7193 error "Multiop failed to block on fsync, pid=$MULTIPID"
7196 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7198 if [[ $WRITEBACK -eq 0 ]]; then
7199 error "No page in writeback, writeback=$WRITEBACK"
7202 set_nodes_failloc "$(osts_nodes)" 0
7205 if [[ $RC -ne 0 ]]; then
7206 error "Multiop fsync failed, rc=$RC"
7209 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7210 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7212 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7213 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7217 echo "Dirty pages flushed via fsync on EROFS"
7220 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7222 # continue to use small resend count to reduce test_118* time (b=14842)
7223 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7228 remote_ost_nodsh && skip "remote OST with nodsh" && return
7232 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7233 set_nodes_failloc "$(osts_nodes)" 0x214
7234 # multiop should block due to fsync until pages are written
7235 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7239 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7240 error "Multiop failed to block on fsync, pid=$MULTIPID"
7243 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7245 if [[ $WRITEBACK -eq 0 ]]; then
7246 error "No page in writeback, writeback=$WRITEBACK"
7249 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7250 set_nodes_failloc "$(osts_nodes)" 0
7252 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7253 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7255 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7256 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7260 echo "Dirty pages gaurenteed flushed via fsync"
7263 run_test 118d "Fsync validation inject a delay of the bulk =========="
7266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7269 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7270 lctl set_param fail_loc=0x8000040a
7272 # Should simulate EINVAL error which is fatal
7273 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7275 if [[ $RC -eq 0 ]]; then
7276 error "Must return error due to dropped pages, rc=$RC"
7279 lctl set_param fail_loc=0x0
7281 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7282 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7283 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7285 if [[ $LOCKED -ne 0 ]]; then
7286 error "Locked pages remain in cache, locked=$LOCKED"
7289 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7290 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7294 echo "No pages locked after fsync"
7299 run_test 118f "Simulate unrecoverable OSC side error =========="
7302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7305 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7306 lctl set_param fail_loc=0x406
7308 # simulate local -ENOMEM
7309 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7312 lctl set_param fail_loc=0
7313 if [[ $RC -eq 0 ]]; then
7314 error "Must return error due to dropped pages, rc=$RC"
7317 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7318 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7319 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7321 if [[ $LOCKED -ne 0 ]]; then
7322 error "Locked pages remain in cache, locked=$LOCKED"
7325 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7326 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7330 echo "No pages locked after fsync"
7335 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7339 remote_ost_nodsh && skip "remote OST with nodsh" && return
7343 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7344 set_nodes_failloc "$(osts_nodes)" 0x20e
7345 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7346 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7349 set_nodes_failloc "$(osts_nodes)" 0
7350 if [[ $RC -eq 0 ]]; then
7351 error "Must return error due to dropped pages, rc=$RC"
7354 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7355 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7356 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7358 if [[ $LOCKED -ne 0 ]]; then
7359 error "Locked pages remain in cache, locked=$LOCKED"
7362 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7363 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7367 echo "No pages locked after fsync"
7371 run_test 118h "Verify timeout in handling recoverables errors =========="
7373 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7377 remote_ost_nodsh && skip "remote OST with nodsh" && return
7381 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7382 set_nodes_failloc "$(osts_nodes)" 0x20e
7384 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7385 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7388 set_nodes_failloc "$(osts_nodes)" 0
7392 if [[ $RC -ne 0 ]]; then
7393 error "got error, but should be not, rc=$RC"
7396 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7397 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7398 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7399 if [[ $LOCKED -ne 0 ]]; then
7400 error "Locked pages remain in cache, locked=$LOCKED"
7403 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7404 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7408 echo "No pages locked after fsync"
7412 run_test 118i "Fix error before timeout in recoverable error =========="
7414 [ "$SLOW" = "no" ] && set_resend_count 4
7417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7418 remote_ost_nodsh && skip "remote OST with nodsh" && return
7422 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7423 set_nodes_failloc "$(osts_nodes)" 0x220
7425 # return -EIO from OST
7426 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7428 set_nodes_failloc "$(osts_nodes)" 0x0
7429 if [[ $RC -eq 0 ]]; then
7430 error "Must return error due to dropped pages, rc=$RC"
7433 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7434 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7435 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7436 if [[ $LOCKED -ne 0 ]]; then
7437 error "Locked pages remain in cache, locked=$LOCKED"
7440 # in recoverable error on OST we want resend and stay until it finished
7441 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7442 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7446 echo "No pages locked after fsync"
7450 run_test 118j "Simulate unrecoverable OST side error =========="
7454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7455 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7457 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7458 set_nodes_failloc "$(osts_nodes)" 0x20e
7459 test_mkdir -p $DIR/$tdir
7461 for ((i=0;i<10;i++)); do
7462 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7463 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7470 set_nodes_failloc "$(osts_nodes)" 0
7473 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7479 test_mkdir -p $DIR/$tdir
7480 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7483 run_test 118l "fsync dir ========="
7485 test_118m() # LU-3066
7487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7488 test_mkdir -p $DIR/$tdir
7489 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7492 run_test 118m "fdatasync dir ========="
7494 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7496 test_119a() # bug 11737
7498 BSIZE=$((512 * 1024))
7499 directio write $DIR/$tfile 0 1 $BSIZE
7500 # We ask to read two blocks, which is more than a file size.
7501 # directio will indicate an error when requested and actual
7502 # sizes aren't equeal (a normal situation in this case) and
7503 # print actual read amount.
7504 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7505 if [ "$NOB" != "$BSIZE" ]; then
7506 error "read $NOB bytes instead of $BSIZE"
7510 run_test 119a "Short directIO read must return actual read amount"
7512 test_119b() # bug 11737
7514 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7516 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7517 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7519 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7520 error "direct read failed"
7523 run_test 119b "Sparse directIO read must return actual read amount"
7525 test_119c() # bug 13099
7528 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7529 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7532 run_test 119c "Testing for direct read hitting hole"
7534 test_119d() # bug 15950
7536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7537 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7538 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7540 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7541 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7542 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7543 lctl set_param fail_loc=0x40d
7544 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7547 cat $DIR/$tfile > /dev/null &
7548 lctl set_param fail_loc=0
7551 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7553 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7554 error "the read rpcs have not completed in 2s"
7556 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7558 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7562 test_mkdir -p $DIR/$tdir
7563 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7564 skip "no early lock cancel on server" && return 0
7566 lru_resize_disable mdc
7567 lru_resize_disable osc
7568 cancel_lru_locks mdc
7569 # asynchronous object destroy at MDT could cause bl ast to client
7570 cancel_lru_locks osc
7572 stat $DIR/$tdir > /dev/null
7573 can1=$(do_facet $SINGLEMDS \
7574 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7575 awk '/ldlm_cancel/ {print $2}')
7576 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7577 awk '/ldlm_bl_callback/ {print $2}')
7578 test_mkdir -c1 $DIR/$tdir/d1
7579 can2=$(do_facet $SINGLEMDS \
7580 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7581 awk '/ldlm_cancel/ {print $2}')
7582 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7583 awk '/ldlm_bl_callback/ {print $2}')
7584 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7585 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7586 lru_resize_enable mdc
7587 lru_resize_enable osc
7589 run_test 120a "Early Lock Cancel: mkdir test"
7592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7593 test_mkdir $DIR/$tdir
7594 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7595 skip "no early lock cancel on server" && return 0
7596 lru_resize_disable mdc
7597 lru_resize_disable osc
7598 cancel_lru_locks mdc
7599 stat $DIR/$tdir > /dev/null
7600 can1=$(do_facet $SINGLEMDS \
7601 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7602 awk '/ldlm_cancel/ {print $2}')
7603 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7604 awk '/ldlm_bl_callback/ {print $2}')
7606 can2=$(do_facet $SINGLEMDS \
7607 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7608 awk '/ldlm_cancel/ {print $2}')
7609 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7610 awk '/ldlm_bl_callback/ {print $2}')
7611 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7612 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7613 lru_resize_enable mdc
7614 lru_resize_enable osc
7616 run_test 120b "Early Lock Cancel: create test"
7619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7620 test_mkdir -c1 $DIR/$tdir
7621 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7622 skip "no early lock cancel on server" && return 0
7623 lru_resize_disable mdc
7624 lru_resize_disable osc
7625 test_mkdir -p -c1 $DIR/$tdir/d1
7626 test_mkdir -p -c1 $DIR/$tdir/d2
7627 touch $DIR/$tdir/d1/f1
7628 cancel_lru_locks mdc
7629 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7630 can1=$(do_facet $SINGLEMDS \
7631 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7632 awk '/ldlm_cancel/ {print $2}')
7633 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7634 awk '/ldlm_bl_callback/ {print $2}')
7635 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7636 can2=$(do_facet $SINGLEMDS \
7637 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7638 awk '/ldlm_cancel/ {print $2}')
7639 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7640 awk '/ldlm_bl_callback/ {print $2}')
7641 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7642 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7643 lru_resize_enable mdc
7644 lru_resize_enable osc
7646 run_test 120c "Early Lock Cancel: link test"
7649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7650 test_mkdir -p -c1 $DIR/$tdir
7651 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7652 skip "no early lock cancel on server" && return 0
7653 lru_resize_disable mdc
7654 lru_resize_disable osc
7656 cancel_lru_locks mdc
7657 stat $DIR/$tdir > /dev/null
7658 can1=$(do_facet $SINGLEMDS \
7659 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7660 awk '/ldlm_cancel/ {print $2}')
7661 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7662 awk '/ldlm_bl_callback/ {print $2}')
7663 chmod a+x $DIR/$tdir
7664 can2=$(do_facet $SINGLEMDS \
7665 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7666 awk '/ldlm_cancel/ {print $2}')
7667 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7668 awk '/ldlm_bl_callback/ {print $2}')
7669 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7670 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7671 lru_resize_enable mdc
7672 lru_resize_enable osc
7674 run_test 120d "Early Lock Cancel: setattr test"
7677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7678 test_mkdir -p -c1 $DIR/$tdir
7679 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7680 skip "no early lock cancel on server" && return 0
7681 lru_resize_disable mdc
7682 lru_resize_disable osc
7683 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7684 cancel_lru_locks mdc
7685 cancel_lru_locks osc
7686 dd if=$DIR/$tdir/f1 of=/dev/null
7687 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7688 # XXX client can not do early lock cancel of OST lock
7689 # during unlink (LU-4206), so cancel osc lock now.
7690 cancel_lru_locks osc
7691 can1=$(do_facet $SINGLEMDS \
7692 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7693 awk '/ldlm_cancel/ {print $2}')
7694 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7695 awk '/ldlm_bl_callback/ {print $2}')
7696 unlink $DIR/$tdir/f1
7698 can2=$(do_facet $SINGLEMDS \
7699 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7700 awk '/ldlm_cancel/ {print $2}')
7701 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7702 awk '/ldlm_bl_callback/ {print $2}')
7703 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7704 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7705 lru_resize_enable mdc
7706 lru_resize_enable osc
7708 run_test 120e "Early Lock Cancel: unlink test"
7711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7712 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7713 skip "no early lock cancel on server" && return 0
7714 test_mkdir -p -c1 $DIR/$tdir
7715 lru_resize_disable mdc
7716 lru_resize_disable osc
7717 test_mkdir -p -c1 $DIR/$tdir/d1
7718 test_mkdir -p -c1 $DIR/$tdir/d2
7719 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7720 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7721 cancel_lru_locks mdc
7722 cancel_lru_locks osc
7723 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7724 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7725 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7726 # XXX client can not do early lock cancel of OST lock
7727 # during rename (LU-4206), so cancel osc lock now.
7728 cancel_lru_locks osc
7729 can1=$(do_facet $SINGLEMDS \
7730 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7731 awk '/ldlm_cancel/ {print $2}')
7732 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7733 awk '/ldlm_bl_callback/ {print $2}')
7734 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7736 can2=$(do_facet $SINGLEMDS \
7737 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7738 awk '/ldlm_cancel/ {print $2}')
7739 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7740 awk '/ldlm_bl_callback/ {print $2}')
7741 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7742 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7743 lru_resize_enable mdc
7744 lru_resize_enable osc
7746 run_test 120f "Early Lock Cancel: rename test"
7749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7750 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7751 skip "no early lock cancel on server" && return 0
7752 lru_resize_disable mdc
7753 lru_resize_disable osc
7755 echo create $count files
7756 test_mkdir -p $DIR/$tdir
7757 cancel_lru_locks mdc
7758 cancel_lru_locks osc
7761 can0=$(do_facet $SINGLEMDS \
7762 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7763 awk '/ldlm_cancel/ {print $2}')
7764 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7765 awk '/ldlm_bl_callback/ {print $2}')
7766 createmany -o $DIR/$tdir/f $count
7768 can1=$(do_facet $SINGLEMDS \
7769 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7770 awk '/ldlm_cancel/ {print $2}')
7771 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7772 awk '/ldlm_bl_callback/ {print $2}')
7774 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7775 echo rm $count files
7778 can2=$(do_facet $SINGLEMDS \
7779 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7780 awk '/ldlm_cancel/ {print $2}')
7781 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7782 awk '/ldlm_bl_callback/ {print $2}')
7784 echo total: $count removes in $((t2-t1))
7785 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7787 # wait for commitment of removal
7788 lru_resize_enable mdc
7789 lru_resize_enable osc
7791 run_test 120g "Early Lock Cancel: performance test"
7793 test_121() { #bug #10589
7794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7796 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7797 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7798 lctl set_param fail_loc=0x310
7799 cancel_lru_locks osc > /dev/null
7800 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7801 lctl set_param fail_loc=0
7802 [[ $reads -eq $writes ]] ||
7803 error "read $reads blocks, must be $writes blocks"
7805 run_test 121 "read cancel race ========="
7807 test_123a() { # was test 123, statahead(bug 11401)
7808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7810 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7811 log "testing on UP system. Performance may be not as good as expected."
7816 test_mkdir -p $DIR/$tdir
7817 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7818 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7820 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7821 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7823 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7824 lctl set_param -n llite.*.statahead_max 0
7825 lctl get_param llite.*.statahead_max
7826 cancel_lru_locks mdc
7827 cancel_lru_locks osc
7829 time ls -l $DIR/$tdir | wc -l
7831 delta=$((etime - stime))
7832 log "ls $i files without statahead: $delta sec"
7833 lctl set_param llite.*.statahead_max=$max
7835 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7836 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7837 cancel_lru_locks mdc
7838 cancel_lru_locks osc
7840 time ls -l $DIR/$tdir | wc -l
7842 delta_sa=$((etime - stime))
7843 log "ls $i files with statahead: $delta_sa sec"
7844 lctl get_param -n llite.*.statahead_stats
7845 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7847 [[ $swrong -lt $ewrong ]] &&
7848 log "statahead was stopped, maybe too many locks held!"
7849 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7851 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7852 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7853 lctl set_param -n llite.*.statahead_max 0
7854 lctl get_param llite.*.statahead_max
7855 cancel_lru_locks mdc
7856 cancel_lru_locks osc
7858 time ls -l $DIR/$tdir | wc -l
7860 delta=$((etime - stime))
7861 log "ls $i files again without statahead: $delta sec"
7862 lctl set_param llite.*.statahead_max=$max
7863 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7864 if [ $SLOWOK -eq 0 ]; then
7865 error "ls $i files is slower with statahead!"
7867 log "ls $i files is slower with statahead!"
7873 [ $delta -gt 20 ] && break
7874 [ $delta -gt 8 ] && MULT=$((50 / delta))
7875 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7883 delta=$((etime - stime))
7884 log "rm -r $DIR/$tdir/: $delta seconds"
7886 lctl get_param -n llite.*.statahead_stats
7888 run_test 123a "verify statahead work"
7890 test_123b () { # statahead(bug 15027)
7891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7892 test_mkdir -p $DIR/$tdir
7893 createmany -o $DIR/$tdir/$tfile-%d 1000
7895 cancel_lru_locks mdc
7896 cancel_lru_locks osc
7898 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7899 lctl set_param fail_loc=0x80000803
7900 ls -lR $DIR/$tdir > /dev/null
7902 lctl set_param fail_loc=0x0
7903 lctl get_param -n llite.*.statahead_stats
7908 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7912 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7913 skip "no lru resize on server" && return 0
7915 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7917 log "create $NR files at $DIR/$tdir"
7918 createmany -o $DIR/$tdir/f $NR ||
7919 error "failed to create $NR files in $DIR/$tdir"
7921 cancel_lru_locks mdc
7922 ls -l $DIR/$tdir > /dev/null
7926 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
7927 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7928 LRU_SIZE=$($LCTL get_param -n $PARAM)
7929 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
7930 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7932 log "NS=$(basename $NSDIR)"
7937 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
7938 skip "Not enough cached locks created!"
7945 # We know that lru resize allows one client to hold $LIMIT locks
7946 # for 10h. After that locks begin to be killed by client.
7948 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
7951 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7952 # killing locks. Some time was spent for creating locks. This means
7953 # that up to the moment of sleep finish we must have killed some of
7954 # them (10-100 locks). This depends on how fast ther were created.
7955 # Many of them were touched in almost the same moment and thus will
7956 # be killed in groups.
7957 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7959 # Use $LRU_SIZE_B here to take into account real number of locks
7960 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7961 local LRU_SIZE_B=$LRU_SIZE
7963 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
7964 log "OLD_LVF=$OLD_LVF"
7965 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
7967 # Let's make sure that we really have some margin. Client checks
7968 # cached locks every 10 sec.
7970 log "Sleep ${SLEEP} sec"
7972 while ((SEC<$SLEEP)); do
7976 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
7980 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7981 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
7983 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
7984 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7985 unlinkmany $DIR/$tdir/f $NR
7989 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7990 log "unlink $NR files at $DIR/$tdir"
7991 unlinkmany $DIR/$tdir/f $NR
7993 run_test 124a "lru resize ======================================="
7995 get_max_pool_limit()
7997 local limit=$($LCTL get_param \
7998 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8001 if [[ $l -gt $max ]]; then
8009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8010 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8011 skip "no lru resize on server" && return 0
8013 LIMIT=$(get_max_pool_limit)
8015 NR=$(($(default_lru_size)*20))
8016 if [[ $NR -gt $LIMIT ]]; then
8017 log "Limit lock number by $LIMIT locks"
8020 lru_resize_disable mdc
8021 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8022 error "failed to create $DIR/$tdir/disable_lru_resize"
8024 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8025 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8026 cancel_lru_locks mdc
8029 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8032 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8035 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8039 nolruresize_delta=$((etime-stime))
8040 log "ls -la time: $nolruresize_delta seconds"
8041 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8042 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8044 lru_resize_enable mdc
8045 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8046 error "failed to create $DIR/$tdir/enable_lru_resize"
8048 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8049 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8050 cancel_lru_locks mdc
8053 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8056 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8059 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8063 lruresize_delta=$((etime-stime))
8064 log "ls -la time: $lruresize_delta seconds"
8065 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8067 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8068 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8069 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8070 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8072 log "lru resize performs the same with no lru resize"
8074 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8076 run_test 124b "lru resize (performance test) ======================="
8078 test_125() { # 13358
8079 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8080 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8081 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8082 test_mkdir -p $DIR/d125 || error "mkdir failed"
8083 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8084 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8085 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8087 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8089 test_126() { # bug 12829/13455
8090 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8091 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8092 $GSS && skip "must run as gss disabled" && return
8094 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8095 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8097 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8099 run_test 126 "check that the fsgid provided by the client is taken into account"
8101 test_127a() { # bug 15521
8102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8103 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8104 $LCTL set_param osc.*.stats=0
8105 FSIZE=$((2048 * 1024))
8106 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8107 cancel_lru_locks osc
8108 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8110 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8111 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8112 echo "got $COUNT $NAME"
8113 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8114 eval $NAME=$COUNT || error "Wrong proc format"
8117 read_bytes|write_bytes)
8118 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8119 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8120 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8121 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8122 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8123 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8124 error "sumsquare is too small: $SUMSQ"
8125 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8126 error "sumsquare is too big: $SUMSQ"
8130 done < $DIR/${tfile}.tmp
8132 #check that we actually got some stats
8133 [ "$read_bytes" ] || error "Missing read_bytes stats"
8134 [ "$write_bytes" ] || error "Missing write_bytes stats"
8135 [ "$read_bytes" != 0 ] || error "no read done"
8136 [ "$write_bytes" != 0 ] || error "no write done"
8138 run_test 127a "verify the client stats are sane"
8140 test_127b() { # bug LU-333
8141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8142 $LCTL set_param llite.*.stats=0
8143 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8144 # perform 2 reads and writes so MAX is different from SUM.
8145 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8146 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8147 cancel_lru_locks osc
8148 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8149 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8151 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8152 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8153 echo "got $COUNT $NAME"
8154 eval $NAME=$COUNT || error "Wrong proc format"
8158 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8159 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8160 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8161 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8164 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8165 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8166 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8167 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8171 done < $TMP/${tfile}.tmp
8173 #check that we actually got some stats
8174 [ "$read_bytes" ] || error "Missing read_bytes stats"
8175 [ "$write_bytes" ] || error "Missing write_bytes stats"
8176 [ "$read_bytes" != 0 ] || error "no read done"
8177 [ "$write_bytes" != 0 ] || error "no write done"
8179 run_test 127b "verify the llite client stats are sane"
8181 test_128() { # bug 15212
8183 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8188 result=$(grep error $TMP/$tfile.log)
8190 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8192 run_test 128 "interactive lfs for 2 consecutive find's"
8199 local LDPROC=/proc/fs/ldiskfs
8200 local facets=$(get_facets MDS)
8202 for facet in ${facets//,/ }; do
8203 canondev=$(ldiskfs_canon \
8204 *.$(convert_facet2label $facet).mntdev $facet)
8205 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8206 LDPROC=/sys/fs/ldiskfs
8207 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8213 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8214 skip "Only applicable to ldiskfs-based MDTs"
8217 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8222 test_mkdir -p $DIR/$tdir
8224 # block size of mds1
8225 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8226 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8227 local MAX=$((MDSBLOCKSIZE * 3))
8229 local I=$(stat -c%s "$DIR/$tdir")
8231 local STRIPE_COUNT=1
8232 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8233 MAX=$((MAX*STRIPE_COUNT))
8234 while [[ $I -le $MAX ]]; do
8235 $MULTIOP $DIR/$tdir/$J Oc
8237 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8238 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8239 #and EFBIG for previous versions
8240 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8242 echo "return code $rc received as expected"
8243 multiop $DIR/$tdir/$J Oc ||
8244 error_exit "multiop failed w/o dir size limit"
8246 I=$(stat -c%s "$DIR/$tdir")
8248 if [ $(lustre_version_code $SINGLEMDS) -lt \
8249 $(version_code 2.4.51) ]
8251 [[ $I -eq $MAX ]] && return 0
8253 [[ $I -gt $MAX ]] && return 0
8255 error_exit "current dir size $I, previous limit $MAX"
8256 elif [ $rc -ne 0 ]; then
8258 error_exit "return code $rc received instead of expected " \
8259 "$EFBIG or $ENOSPC, files in dir $I"
8262 I=$(stat -c%s "$DIR/$tdir")
8266 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8268 run_test 129 "test directory size limit ========================"
8277 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8278 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8281 trap cleanup_130 EXIT RETURN
8283 local fm_file=$DIR/$tfile
8284 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8285 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8286 error "dd failed for $fm_file"
8288 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8289 filefrag -ves $fm_file
8291 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8292 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8293 [ $RC != 0 ] && error "filefrag $fm_file failed"
8295 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8296 grep -v "ext:" | grep -v "found")
8297 lun=$($GETSTRIPE -i $fm_file)
8299 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8302 for line in $filefrag_op
8304 frag_lun=`echo $line | cut -d: -f5`
8305 ext_len=`echo $line | cut -d: -f4`
8306 if (( $frag_lun != $lun )); then
8308 error "FIEMAP on 1-stripe file($fm_file) failed"
8311 (( tot_len += ext_len ))
8314 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8316 error "FIEMAP on 1-stripe file($fm_file) failed;"
8322 echo "FIEMAP on single striped file succeeded"
8324 run_test 130a "FIEMAP (1-stripe file)"
8327 [ "$OSTCOUNT" -lt "2" ] &&
8328 skip_env "skipping FIEMAP on 2-stripe file test" && return
8330 [ "$OSTCOUNT" -ge "10" ] &&
8331 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8333 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8334 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8337 trap cleanup_130 EXIT RETURN
8339 local fm_file=$DIR/$tfile
8340 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8341 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8342 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8344 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8345 error "dd failed on $fm_file"
8347 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8348 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8349 grep -v "ext:" | grep -v "found")
8351 last_lun=$(echo $filefrag_op | cut -d: -f5)
8356 for line in $filefrag_op
8358 frag_lun=`echo $line | cut -d: -f5`
8359 ext_len=`echo $line | cut -d: -f4`
8360 if (( $frag_lun != $last_lun )); then
8361 if (( tot_len != 1024 )); then
8363 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8370 (( tot_len += ext_len ))
8373 if (( num_luns != 2 || tot_len != 1024 )); then
8375 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8381 echo "FIEMAP on 2-stripe file succeeded"
8383 run_test 130b "FIEMAP (2-stripe file)"
8386 [ "$OSTCOUNT" -lt "2" ] &&
8387 skip_env "skipping FIEMAP on 2-stripe file" && return
8389 [ "$OSTCOUNT" -ge "10" ] &&
8390 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8392 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8393 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8396 trap cleanup_130 EXIT RETURN
8398 local fm_file=$DIR/$tfile
8399 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8400 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8401 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8403 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8405 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8406 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8408 last_lun=`echo $filefrag_op | cut -d: -f5`
8413 for line in $filefrag_op
8415 frag_lun=`echo $line | cut -d: -f5`
8416 ext_len=`echo $line | cut -d: -f4`
8417 if (( $frag_lun != $last_lun )); then
8418 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8419 if (( logical != 512 )); then
8421 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8424 if (( tot_len != 512 )); then
8426 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8433 (( tot_len += ext_len ))
8436 if (( num_luns != 2 || tot_len != 512 )); then
8438 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8444 echo "FIEMAP on 2-stripe file with hole succeeded"
8446 run_test 130c "FIEMAP (2-stripe file with hole)"
8449 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8451 [ "$OSTCOUNT" -ge "10" ] &&
8452 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8454 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8455 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8457 trap cleanup_130 EXIT RETURN
8459 local fm_file=$DIR/$tfile
8460 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8461 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8462 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8464 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8465 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8466 error "dd failed on $fm_file"
8468 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8469 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8470 grep -v "ext:" | grep -v "found"`
8472 last_lun=`echo $filefrag_op | cut -d: -f5`
8477 for line in $filefrag_op
8479 frag_lun=`echo $line | cut -d: -f5`
8480 ext_len=`echo $line | cut -d: -f4`
8481 if (( $frag_lun != $last_lun )); then
8482 if (( tot_len != 1024 )); then
8484 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8491 (( tot_len += ext_len ))
8494 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8496 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8502 echo "FIEMAP on N-stripe file succeeded"
8504 run_test 130d "FIEMAP (N-stripe file)"
8507 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8509 [ "$OSTCOUNT" -ge "10" ] &&
8510 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8512 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8513 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8515 trap cleanup_130 EXIT RETURN
8517 local fm_file=$DIR/$tfile
8518 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8519 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8520 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8523 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8524 for ((i = 0; i < $NUM_BLKS; i++))
8526 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8529 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8530 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8532 last_lun=`echo $filefrag_op | cut -d: -f5`
8537 for line in $filefrag_op
8539 frag_lun=`echo $line | cut -d: -f5`
8540 ext_len=`echo $line | cut -d: -f4`
8541 if (( $frag_lun != $last_lun )); then
8542 if (( tot_len != $EXPECTED_LEN )); then
8544 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8551 (( tot_len += ext_len ))
8554 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8556 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8562 echo "FIEMAP with continuation calls succeeded"
8564 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8566 # Test for writev/readv
8568 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8569 error "writev test failed"
8570 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8571 error "readv failed"
8574 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8577 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8578 error "append writev test failed"
8579 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8580 error "append writev test failed"
8583 run_test 131b "test append writev"
8586 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8589 run_test 131c "test read/write on file w/o objects"
8592 rwv -f $DIR/$tfile -w -n 1 1572864
8593 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8594 if [ "$NOB" != 1572864 ]; then
8595 error "Short read filed: read $NOB bytes instead of 1572864"
8599 run_test 131d "test short read"
8602 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8603 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8604 error "read hitting hole failed"
8607 run_test 131e "test read hitting hole"
8612 for node in $(osts_nodes); do
8613 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8614 [ x$gl = x"" ] && gl=0
8615 gl_sum=$((gl_sum + gl))
8625 if [ x$som = x"enabled" ]; then
8626 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8627 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8628 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8630 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8631 MOUNTOPT="$MOUNTOPT,som_preview"
8632 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8635 # do remount to make new mount-conf parameters actual
8642 test_132() { #1028, SOM
8643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8645 local num=$(get_mds_dir $DIR)
8646 local mymds=mds${num}
8647 local MOUNTOPT_SAVE=$MOUNTOPT
8649 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8650 cancel_lru_locks osc
8652 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8654 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8655 stat $DIR/$tfile >/dev/null
8656 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8657 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8659 som_mode_switch $som1 $gl1 $gl2
8661 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8662 cancel_lru_locks osc
8664 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8665 if [ $som1 == $som2 ]; then
8666 error "som is still "$som2
8667 if [ x$som2 = x"enabled" ]; then
8674 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8675 stat $DIR/$tfile >/dev/null
8676 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8677 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8678 som_mode_switch $som2 $gl1 $gl2
8679 MOUNTOPT=$MOUNTOPT_SAVE
8681 run_test 132 "som avoids glimpse rpc"
8687 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8689 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8691 *) error "Wrong argument $1" ;;
8694 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8695 # if the argument $3 is zero, it means any stat increment is ok.
8696 if [[ $3 -gt 0 ]]; then
8697 count=$(echo $res | awk '{ print $2 }')
8698 [[ $count -ne $3 ]] &&
8699 error "The $2 counter on $1 is wrong - expected $3"
8704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8705 remote_ost_nodsh && skip "remote OST with nodsh" && return
8706 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8708 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8709 { skip "MDS doesn't support rename stats"; return; }
8710 local testdir=$DIR/${tdir}/stats_testdir
8711 mkdir -p $DIR/${tdir}
8714 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8715 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8717 # verify mdt stats first.
8718 mkdir ${testdir} || error "mkdir failed"
8719 check_stats $SINGLEMDS "mkdir" 1
8720 touch ${testdir}/${tfile} || "touch failed"
8721 check_stats $SINGLEMDS "open" 1
8722 check_stats $SINGLEMDS "close" 1
8723 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8724 check_stats $SINGLEMDS "mknod" 1
8725 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8726 check_stats $SINGLEMDS "unlink" 1
8727 rm -f ${testdir}/${tfile} || error "file remove failed"
8728 check_stats $SINGLEMDS "unlink" 2
8730 # remove working dir and check mdt stats again.
8731 rmdir ${testdir} || error "rmdir failed"
8732 check_stats $SINGLEMDS "rmdir" 1
8734 local testdir1=$DIR/${tdir}/stats_testdir1
8736 mkdir -p ${testdir1}
8737 touch ${testdir1}/test1
8738 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8739 check_stats $SINGLEMDS "crossdir_rename" 1
8741 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8742 check_stats $SINGLEMDS "samedir_rename" 1
8746 run_test 133a "Verifying MDT stats ========================================"
8749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8750 remote_ost_nodsh && skip "remote OST with nodsh" && return
8751 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8752 local testdir=$DIR/${tdir}/stats_testdir
8753 mkdir -p ${testdir} || error "mkdir failed"
8754 touch ${testdir}/${tfile} || "touch failed"
8755 cancel_lru_locks mdc
8758 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8759 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8761 # extra mdt stats verification.
8762 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8763 check_stats $SINGLEMDS "setattr" 1
8764 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8765 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8767 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8768 check_stats $SINGLEMDS "getattr" 1
8770 $LFS df || error "lfs failed"
8771 check_stats $SINGLEMDS "statfs" 1
8775 run_test 133b "Verifying extra MDT stats =================================="
8778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8779 remote_ost_nodsh && skip "remote OST with nodsh" && return
8780 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8781 local testdir=$DIR/${tdir}/stats_testdir
8782 test_mkdir -p ${testdir} || error "mkdir failed"
8784 # verify obdfilter stats.
8785 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8787 cancel_lru_locks osc
8788 wait_delete_completed
8791 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8792 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8794 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8796 cancel_lru_locks osc
8797 check_stats ost "write" 1
8799 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8800 check_stats ost "read" 1
8802 > ${testdir}/${tfile} || error "truncate failed"
8803 check_stats ost "punch" 1
8805 rm -f ${testdir}/${tfile} || error "file remove failed"
8806 wait_delete_completed
8807 check_stats ost "destroy" 1
8811 run_test 133c "Verifying OST stats ========================================"
8818 while [ $value -ge 2 ]; do
8823 if [ $orig -gt $order ]; then
8831 local size=('K' 'M' 'G' 'T');
8833 local size_string=$value
8835 while [ $value -ge 1024 ]; do
8836 if [ $i -gt 3 ]; then
8837 #T is the biggest unit we get here, if that is bigger,
8839 size_string=${value}T
8842 value=$((value >> 10))
8843 if [ $value -lt 1024 ]; then
8844 size_string=${value}${size[$i]}
8855 local context=${2:-.}
8856 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8858 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8864 remote_ost_nodsh && skip "remote OST with nodsh" && return
8865 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8866 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8867 { skip "MDS doesn't support rename stats"; return; }
8869 local testdir1=$DIR/${tdir}/stats_testdir1
8870 local testdir2=$DIR/${tdir}/stats_testdir2
8872 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8874 mkdir -p ${testdir1} || error "mkdir failed"
8875 mkdir -p ${testdir2} || error "mkdir failed"
8877 createmany -o $testdir1/test 512 || error "createmany failed"
8879 # check samedir rename size
8880 mv ${testdir1}/test0 ${testdir1}/test_0
8882 local testdir1_size=$(ls -l $DIR/${tdir} |
8883 awk '/stats_testdir1/ {print $5}')
8884 local testdir2_size=$(ls -l $DIR/${tdir} |
8885 awk '/stats_testdir2/ {print $5}')
8887 testdir1_size=$(order_2 $testdir1_size)
8888 testdir2_size=$(order_2 $testdir2_size)
8890 testdir1_size=$(size_in_KMGT $testdir1_size)
8891 testdir2_size=$(size_in_KMGT $testdir2_size)
8893 echo "source rename dir size: ${testdir1_size}"
8894 echo "target rename dir size: ${testdir2_size}"
8896 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8897 eval $cmd || error "$cmd failed"
8898 local samedir=$($cmd | grep 'same_dir')
8899 local same_sample=$(get_rename_size $testdir1_size)
8900 [ -z "$samedir" ] && error "samedir_rename_size count error"
8901 [[ $same_sample -eq 1 ]] ||
8902 error "samedir_rename_size error $same_sample"
8903 echo "Check same dir rename stats success"
8905 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8907 # check crossdir rename size
8908 mv ${testdir1}/test_0 ${testdir2}/test_0
8910 testdir1_size=$(ls -l $DIR/${tdir} |
8911 awk '/stats_testdir1/ {print $5}')
8912 testdir2_size=$(ls -l $DIR/${tdir} |
8913 awk '/stats_testdir2/ {print $5}')
8915 testdir1_size=$(order_2 $testdir1_size)
8916 testdir2_size=$(order_2 $testdir2_size)
8918 testdir1_size=$(size_in_KMGT $testdir1_size)
8919 testdir2_size=$(size_in_KMGT $testdir2_size)
8921 echo "source rename dir size: ${testdir1_size}"
8922 echo "target rename dir size: ${testdir2_size}"
8924 eval $cmd || error "$cmd failed"
8925 local crossdir=$($cmd | grep 'crossdir')
8926 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8927 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8928 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8929 [[ $src_sample -eq 1 ]] ||
8930 error "crossdir_rename_size error $src_sample"
8931 [[ $tgt_sample -eq 1 ]] ||
8932 error "crossdir_rename_size error $tgt_sample"
8933 echo "Check cross dir rename stats success"
8936 run_test 133d "Verifying rename_stats ========================================"
8939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8940 local testdir=$DIR/${tdir}/stats_testdir
8941 local ctr f0 f1 bs=32768 count=42 sum
8943 remote_ost_nodsh && skip "remote OST with nodsh" && return
8944 mkdir -p ${testdir} || error "mkdir failed"
8946 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8948 for ctr in {write,read}_bytes; do
8950 cancel_lru_locks osc
8952 do_facet ost1 $LCTL set_param -n \
8953 "obdfilter.*.exports.clear=clear"
8955 if [ $ctr = write_bytes ]; then
8957 f1=${testdir}/${tfile}
8959 f0=${testdir}/${tfile}
8963 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8966 cancel_lru_locks osc
8968 sum=$(do_facet ost1 $LCTL get_param \
8969 "obdfilter.*.exports.*.stats" |
8970 awk -v ctr=$ctr 'BEGIN { sum = 0 }
8971 $1 == ctr { sum += $7 }
8972 END { printf("%0.0f", sum) }')
8974 if ((sum != bs * count)); then
8975 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8981 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8984 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8987 # First without trusting modes.
8988 find $proc_dirs -exec cat '{}' \; &> /dev/null
8990 # Second verifying readability.
8993 -exec cat '{}' \; &> /dev/null ||
8994 error "proc file read failed"
8996 for facet in $SINGLEMDS ost1; do
8997 do_facet $facet find $proc_dirs \
8998 ! -name req_history \
8999 -exec cat '{}' \\\; &> /dev/null
9001 do_facet $facet find $proc_dirs \
9002 ! -name req_history \
9004 -exec cat '{}' \\\; &> /dev/null ||
9005 error "proc file read failed"
9008 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9011 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9014 # Second verifying readability.
9017 -not -name force_lbug \
9018 -not -name changelog_mask \
9019 -exec badarea_io '{}' \; > /dev/null
9021 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9022 skip "Too old lustre on MDS"
9024 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9025 skip "Too old lustre on ost1"
9027 for facet in $SINGLEMDS ost1; do
9028 do_facet $facet find $proc_dirs \
9030 -not -name force_lbug \
9031 -not -name changelog_mask \
9032 -exec badarea_io '{}' \\\; &> /dev/null
9036 # remount the FS in case writes/reads /proc break the FS
9037 cleanup || error "failed to unmount"
9038 setup || error "failed to setup"
9041 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9043 test_140() { #bug-17379
9044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9045 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9046 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9047 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9049 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9050 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9052 while i=`expr $i + 1`; do
9053 test_mkdir -p $i || error "Creating dir $i"
9054 cd $i || error "Changing to $i"
9055 ln -s ../stat stat || error "Creating stat symlink"
9056 # Read the symlink until ELOOP present,
9057 # not LBUGing the system is considered success,
9058 # we didn't overrun the stack.
9059 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9061 if [ $ret -eq 40 ]; then
9064 error "Open stat symlink"
9070 echo "The symlink depth = $i"
9071 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9072 error "Invalid symlink depth"
9074 # Test recursive symlink
9075 ln -s symlink_self symlink_self
9076 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9077 echo "open symlink_self returns $ret"
9078 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9080 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9084 local TF="$TMP/$tfile"
9086 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9088 cancel_lru_locks osc
9089 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9090 remount_client $MOUNT
9092 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9095 $TRUNCATE $DIR/$tfile 6000
9096 cancel_lru_locks osc
9097 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9100 echo "12345" >>$DIR/$tfile
9101 cancel_lru_locks osc
9102 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9105 echo "12345" >>$DIR/$tfile
9106 cancel_lru_locks osc
9107 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9112 run_test 150 "truncate/append tests"
9114 #LU-2902 roc_hit was not able to read all values from lproc
9115 function roc_hit_init() {
9116 local list=$(comma_list $(osts_nodes))
9117 local dir=$DIR/$tdir-check
9118 local file=$dir/file
9124 #use setstripe to do a write to every ost
9125 for i in $(seq 0 $((OSTCOUNT-1))); do
9126 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9127 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9128 idx=$(printf %04x $i)
9129 BEFORE=$(get_osd_param $list *OST*$idx stats |
9130 awk '$1 == "cache_access" {sum += $2}
9131 END { printf("%0.0f", sum) }')
9133 cancel_lru_locks osc
9134 cat $file >/dev/null
9136 AFTER=$(get_osd_param $list *OST*$idx stats |
9137 awk '$1 == "cache_access" {sum += $2}
9138 END { printf("%0.0f", sum) }')
9140 echo BEFORE:$BEFORE AFTER:$AFTER
9141 if ! let "AFTER - BEFORE == 4"; then
9143 error "roc_hit is not safe to use"
9151 function roc_hit() {
9152 local list=$(comma_list $(osts_nodes))
9153 echo $(get_osd_param $list '' stats |
9154 awk '$1 == "cache_hit" {sum += $2}
9155 END { printf("%0.0f", sum) }')
9158 function set_cache() {
9161 if [ "$2" == "off" ]; then
9164 local list=$(comma_list $(osts_nodes))
9165 set_osd_param $list '' $1_cache_enable $on
9167 cancel_lru_locks osc
9171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9172 remote_ost_nodsh && skip "remote OST with nodsh" && return
9175 local list=$(comma_list $(osts_nodes))
9177 # check whether obdfilter is cache capable at all
9178 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9179 echo "not cache-capable obdfilter"
9183 # check cache is enabled on all obdfilters
9184 if get_osd_param $list '' read_cache_enable | grep 0; then
9185 echo "oss cache is disabled"
9189 set_osd_param $list '' writethrough_cache_enable 1
9191 # check write cache is enabled on all obdfilters
9192 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9193 echo "oss write cache is NOT enabled"
9199 #define OBD_FAIL_OBD_NO_LRU 0x609
9200 do_nodes $list $LCTL set_param fail_loc=0x609
9202 # pages should be in the case right after write
9203 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9206 local BEFORE=$(roc_hit)
9207 cancel_lru_locks osc
9208 cat $DIR/$tfile >/dev/null
9209 local AFTER=$(roc_hit)
9211 do_nodes $list $LCTL set_param fail_loc=0
9213 if ! let "AFTER - BEFORE == CPAGES"; then
9214 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9217 # the following read invalidates the cache
9218 cancel_lru_locks osc
9219 set_osd_param $list '' read_cache_enable 0
9220 cat $DIR/$tfile >/dev/null
9222 # now data shouldn't be found in the cache
9224 cancel_lru_locks osc
9225 cat $DIR/$tfile >/dev/null
9227 if let "AFTER - BEFORE != 0"; then
9228 error "IN CACHE: before: $BEFORE, after: $AFTER"
9231 set_osd_param $list '' read_cache_enable 1
9234 run_test 151 "test cache on oss and controls ==============================="
9237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9238 local TF="$TMP/$tfile"
9240 # simulate ENOMEM during write
9241 #define OBD_FAIL_OST_NOMEM 0x226
9242 lctl set_param fail_loc=0x80000226
9243 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9245 sync || error "sync failed"
9246 lctl set_param fail_loc=0
9248 # discard client's cache
9249 cancel_lru_locks osc
9251 # simulate ENOMEM during read
9252 lctl set_param fail_loc=0x80000226
9253 cmp $TF $DIR/$tfile || error "cmp failed"
9254 lctl set_param fail_loc=0
9258 run_test 152 "test read/write with enomem ============================"
9261 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9263 run_test 153 "test if fdatasync does not crash ======================="
9265 dot_lustre_fid_permission_check() {
9267 local ffid=$MOUNT/.lustre/fid/$fid
9270 echo "stat fid $fid"
9271 stat $ffid > /dev/null || error "stat $ffid failed."
9272 echo "touch fid $fid"
9273 touch $ffid || error "touch $ffid failed."
9274 echo "write to fid $fid"
9275 cat /etc/hosts > $ffid || error "write $ffid failed."
9276 echo "read fid $fid"
9277 diff /etc/hosts $ffid || error "read $ffid failed."
9278 echo "append write to fid $fid"
9279 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9280 echo "rename fid $fid"
9281 mv $ffid $test_dir/$tfile.1 &&
9282 error "rename $ffid to $tfile.1 should fail."
9283 touch $test_dir/$tfile.1
9284 mv $test_dir/$tfile.1 $ffid &&
9285 error "rename $tfile.1 to $ffid should fail."
9286 rm -f $test_dir/$tfile.1
9287 echo "truncate fid $fid"
9288 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9289 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9290 echo "link fid $fid"
9291 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9293 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9294 echo "setfacl fid $fid"
9295 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9296 echo "getfacl fid $fid"
9297 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9299 echo "unlink fid $fid"
9300 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9301 echo "mknod fid $fid"
9302 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9304 fid=[0xf00000400:0x1:0x0]
9305 ffid=$MOUNT/.lustre/fid/$fid
9307 echo "stat non-exist fid $fid"
9308 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9309 echo "write to non-exist fid $fid"
9310 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9311 echo "link new fid $fid"
9312 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9314 mkdir -p $test_dir/$tdir
9315 touch $test_dir/$tdir/$tfile
9316 fid=$($LFS path2fid $test_dir/$tdir)
9319 error "error: could not get fid for $test_dir/$dir/$tfile."
9321 ffid=$MOUNT/.lustre/fid/$fid
9324 ls $ffid > /dev/null || error "ls $ffid failed."
9325 echo "touch $fid/$tfile.1"
9326 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9328 echo "touch $MOUNT/.lustre/fid/$tfile"
9329 touch $MOUNT/.lustre/fid/$tfile && \
9330 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9332 echo "setxattr to $MOUNT/.lustre/fid"
9333 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9335 echo "listxattr for $MOUNT/.lustre/fid"
9336 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9338 echo "delxattr from $MOUNT/.lustre/fid"
9339 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9341 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9342 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9343 error "touch invalid fid should fail."
9345 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9346 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9347 error "touch non-normal fid should fail."
9349 echo "rename $tdir to $MOUNT/.lustre/fid"
9350 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9351 error "rename to $MOUNT/.lustre/fid should fail."
9353 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9355 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9356 local new_obf_mode=777
9358 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9359 chmod $new_obf_mode $DIR/.lustre/fid ||
9360 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9362 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9363 [ $obf_mode -eq $new_obf_mode ] ||
9364 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9366 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9367 chmod $old_obf_mode $DIR/.lustre/fid ||
9368 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9371 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9372 fid=$($LFS path2fid $test_dir/$tfile-2)
9373 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9374 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9375 error "create lov data thru .lustre should fail."
9376 echo "cp /etc/passwd $test_dir/$tfile-2"
9377 cp /etc/passwd $test_dir/$tfile-2 ||
9378 error "copy to $test_dir/$tfile-2 failed."
9379 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9380 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9381 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9383 rm -rf $test_dir/tfile.lnk
9384 rm -rf $test_dir/$tfile-2
9388 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9389 skip "Need MDS version at least 2.4.1" && return
9392 local FID=$($LFS path2fid $DIR/$tfile)
9393 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9395 # check that we get the same pathname back
9396 local FOUND=$($LFS fid2path $MOUNT $FID)
9397 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9398 [ "$FOUND" != "$DIR/$tfile" ] &&
9399 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9403 run_test 154A "lfs path2fid and fid2path basic checks"
9406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9407 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9408 { skip "Need MDS version at least 2.2.51"; return 0; }
9409 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9411 cp /etc/hosts $DIR/$tfile
9413 fid=$($LFS path2fid $DIR/$tfile)
9415 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9417 dot_lustre_fid_permission_check "$fid" $DIR ||
9418 error "dot lustre permission check $fid failed"
9420 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9422 touch $MOUNT/.lustre/file &&
9423 error "creation is not allowed under .lustre"
9425 mkdir $MOUNT/.lustre/dir &&
9426 error "mkdir is not allowed under .lustre"
9430 run_test 154a "Open-by-FID"
9433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9434 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9435 { skip "Need MDS version at least 2.2.51"; return 0; }
9437 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9439 local remote_dir=$DIR/$tdir/remote_dir
9444 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9445 error "create remote directory failed"
9447 cp /etc/hosts $remote_dir/$tfile
9449 fid=$($LFS path2fid $remote_dir/$tfile)
9451 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9453 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9454 error "dot lustre permission check $fid failed"
9457 run_test 154b "Open-by-FID for remote directory"
9460 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9461 skip "Need MDS version at least 2.4.1" && return
9463 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9464 local FID1=$($LFS path2fid $DIR/$tfile.1)
9465 local FID2=$($LFS path2fid $DIR/$tfile.2)
9466 local FID3=$($LFS path2fid $DIR/$tfile.3)
9469 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9470 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9471 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9473 [ "$FID" = "${!want}" ] ||
9474 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9478 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9479 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9480 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9484 run_test 154c "lfs path2fid and fid2path multiple arguments"
9487 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9488 skip "Need MDS version at least 2.5.53" && return
9491 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9495 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9502 fid=$($LFS path2fid $DIR/$tfile)
9505 cmd="exec $fd<$DIR/$tfile"
9507 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9508 echo $fid_list | grep $fid
9511 cmd="exec $fd>/dev/null"
9513 if [ $rc -ne 0 ]; then
9514 error "FID $fid not found in open files list $fid_list"
9517 run_test 154d "Verify open file fid"
9519 test_155_small_load() {
9520 local temp=$TMP/$tfile
9521 local file=$DIR/$tfile
9523 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9524 error "dd of=$temp bs=6096 count=1 failed"
9526 cancel_lru_locks osc
9527 cmp $temp $file || error "$temp $file differ"
9529 $TRUNCATE $temp 6000
9530 $TRUNCATE $file 6000
9531 cmp $temp $file || error "$temp $file differ (truncate1)"
9533 echo "12345" >>$temp
9534 echo "12345" >>$file
9535 cmp $temp $file || error "$temp $file differ (append1)"
9537 echo "12345" >>$temp
9538 echo "12345" >>$file
9539 cmp $temp $file || error "$temp $file differ (append2)"
9545 test_155_big_load() {
9546 remote_ost_nodsh && skip "remote OST with nodsh" && return
9547 local temp=$TMP/$tfile
9548 local file=$DIR/$tfile
9551 local cache_size=$(do_facet ost$((MAXI+1)) \
9552 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9553 local large_file_size=$((cache_size * 2))
9555 echo "OSS cache size: $cache_size KB"
9556 echo "Large file size: $large_file_size KB"
9558 [ $MAXV -le $large_file_size ] && \
9559 skip_env "max available OST size needs > $large_file_size KB" && \
9562 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9564 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9565 error "dd of=$temp bs=$large_file_size count=1k failed"
9568 cancel_lru_locks osc
9569 cmp $temp $file || error "$temp $file differ"
9576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9578 set_cache writethrough on
9581 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9586 set_cache writethrough off
9589 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9594 set_cache writethrough on
9597 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9602 set_cache writethrough off
9605 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9610 set_cache writethrough on
9613 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9618 set_cache writethrough off
9621 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9626 set_cache writethrough on
9629 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9634 set_cache writethrough off
9637 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9644 local file="$DIR/$tfile"
9646 [ "$(facet_fstype ost1)" = "zfs" ] &&
9647 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9652 log "Turn on read and write cache"
9654 set_cache writethrough on
9656 log "Write data and read it back."
9657 log "Read should be satisfied from the cache."
9658 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9660 cancel_lru_locks osc
9661 cat $file >/dev/null
9663 if ! let "AFTER - BEFORE == CPAGES"; then
9664 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9666 log "cache hits:: before: $BEFORE, after: $AFTER"
9669 log "Read again; it should be satisfied from the cache."
9671 cancel_lru_locks osc
9672 cat $file >/dev/null
9674 if ! let "AFTER - BEFORE == CPAGES"; then
9675 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9677 log "cache hits:: before: $BEFORE, after: $AFTER"
9681 log "Turn off the read cache and turn on the write cache"
9683 set_cache writethrough on
9685 log "Read again; it should be satisfied from the cache."
9687 cancel_lru_locks osc
9688 cat $file >/dev/null
9690 if ! let "AFTER - BEFORE == CPAGES"; then
9691 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9693 log "cache hits:: before: $BEFORE, after: $AFTER"
9696 log "Read again; it should not be satisfied from the cache."
9698 cancel_lru_locks osc
9699 cat $file >/dev/null
9701 if ! let "AFTER - BEFORE == 0"; then
9702 error "IN CACHE: before: $BEFORE, after: $AFTER"
9704 log "cache hits:: before: $BEFORE, after: $AFTER"
9707 log "Write data and read it back."
9708 log "Read should be satisfied from the cache."
9709 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9711 cancel_lru_locks osc
9712 cat $file >/dev/null
9714 if ! let "AFTER - BEFORE == CPAGES"; then
9715 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9717 log "cache hits:: before: $BEFORE, after: $AFTER"
9720 log "Read again; it should not be satisfied from the cache."
9722 cancel_lru_locks osc
9723 cat $file >/dev/null
9725 if ! let "AFTER - BEFORE == 0"; then
9726 error "IN CACHE: before: $BEFORE, after: $AFTER"
9728 log "cache hits:: before: $BEFORE, after: $AFTER"
9732 log "Turn off read and write cache"
9734 set_cache writethrough off
9736 log "Write data and read it back"
9737 log "It should not be satisfied from the cache."
9739 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9740 cancel_lru_locks osc
9742 cat $file >/dev/null
9744 if ! let "AFTER - BEFORE == 0"; then
9745 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9747 log "cache hits:: before: $BEFORE, after: $AFTER"
9750 log "Turn on the read cache and turn off the write cache"
9752 set_cache writethrough off
9754 log "Write data and read it back"
9755 log "It should not be satisfied from the cache."
9757 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9759 cancel_lru_locks osc
9760 cat $file >/dev/null
9762 if ! let "AFTER - BEFORE == 0"; then
9763 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9765 log "cache hits:: before: $BEFORE, after: $AFTER"
9768 log "Read again; it should be satisfied from the cache."
9770 cancel_lru_locks osc
9771 cat $file >/dev/null
9773 if ! let "AFTER - BEFORE == CPAGES"; then
9774 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9776 log "cache hits:: before: $BEFORE, after: $AFTER"
9781 run_test 156 "Verification of tunables ============================"
9785 if [[ $MDSCOUNT -gt 1 ]]; then
9786 error_ignore bz17935 $*
9794 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9796 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9798 if [ $MASK -eq 1 ]; then
9799 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9801 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9805 changelog_extract_field() {
9811 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9812 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9818 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9819 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9820 { skip "Need MDS version at least 2.2.0"; return; }
9822 local CL_USERS="mdd.$MDT0.changelog_users"
9823 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9824 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9825 echo "Registered as changelog user $USER"
9826 $GET_CL_USERS | grep -q $USER ||
9827 error "User $USER not found in changelog_users"
9830 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9831 touch $DIR/$tdir/pics/2008/zachy/timestamp
9832 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9833 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9834 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9835 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9836 rm $DIR/$tdir/pics/desktop.jpg
9838 $LFS changelog $MDT0 | tail -5
9840 echo "verifying changelog mask"
9841 changelog_chmask "MKDIR"
9842 changelog_chmask "CLOSE"
9844 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9845 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9847 changelog_chmask "MKDIR"
9848 changelog_chmask "CLOSE"
9850 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9851 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9853 $LFS changelog $MDT0
9854 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9855 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9856 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9857 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9860 echo "verifying target fid"
9861 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9862 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9863 [ "$fidc" == "$fidf" ] ||
9864 err17935 "fid in changelog $fidc != file fid $fidf"
9865 echo "verifying parent fid"
9866 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9867 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9868 [ "$fidc" == "$fidf" ] ||
9869 err17935 "pfid in changelog $fidc != dir fid $fidf"
9871 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9872 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9873 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9874 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9875 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9876 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9878 MIN_REC=$($GET_CL_USERS |
9879 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9880 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9881 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9882 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9883 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9885 # LU-3446 changelog index reset on MDT restart
9886 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9887 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9888 $LFS changelog_clear $MDT0 $USER 0
9889 stop $SINGLEMDS || error "Fail to stop MDT."
9890 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9891 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9892 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9893 [ $CUR_REC1 == $CUR_REC2 ] ||
9894 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9896 echo "verifying user deregister"
9897 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9898 $GET_CL_USERS | grep -q $USER &&
9899 error "User $USER still in changelog_users"
9901 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9902 if [ $USERS -eq 0 ]; then
9903 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9904 touch $DIR/$tdir/chloe
9905 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9906 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9907 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9909 echo "$USERS other changelog users; can't verify off"
9912 run_test 160a "changelog sanity"
9914 test_160b() { # LU-3587
9915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9916 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9917 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9918 { skip "Need MDS version at least 2.2.0"; return; }
9920 local CL_USERS="mdd.$MDT0.changelog_users"
9921 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9922 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9923 echo "Registered as changelog user $USER"
9924 $GET_CL_USERS | grep -q $USER ||
9925 error "User $USER not found in changelog_users"
9927 local LONGNAME1=$(str_repeat a 255)
9928 local LONGNAME2=$(str_repeat b 255)
9931 echo "creating very long named file"
9932 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9933 echo "moving very long named file"
9934 mv $LONGNAME1 $LONGNAME2
9936 $LFS changelog $MDT0 | grep RENME
9938 echo "deregistering $USER"
9939 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9943 run_test 160b "Verify that very long rename doesn't crash in changelog"
9947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9950 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9951 changelog_register -n)
9955 $MCREATE $DIR/$tdir/foo_160c
9956 changelog_chmask "TRUNC"
9957 $TRUNCATE $DIR/$tdir/foo_160c 200
9958 changelog_chmask "TRUNC"
9959 $TRUNCATE $DIR/$tdir/foo_160c 199
9960 $LFS changelog $MDT0
9961 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9962 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9963 $LFS changelog_clear $MDT0 $USER 0
9965 # Deregistration step
9966 echo "deregistering $USER"
9967 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9969 run_test 160c "verify that changelog log catch the truncate event"
9972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9973 test_mkdir -p -c1 $DIR/$tdir
9974 cp /etc/hosts $DIR/$tdir/$tfile
9975 test_mkdir -c1 $DIR/$tdir/foo1
9976 test_mkdir -c1 $DIR/$tdir/foo2
9977 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9978 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9979 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9980 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9981 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9982 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9983 $LFS fid2path $DIR $FID
9984 err17935 "bad link ea"
9987 rm $DIR/$tdir/foo2/zachary
9989 rm $DIR/$tdir/foo2/thor
9991 rm $DIR/$tdir/$tfile
9993 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9994 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9996 $LFS fid2path $DIR $FID
9997 err17935 "bad link rename"
9999 rm $DIR/$tdir/foo2/maggie
10002 local longname=filename_avg_len_is_thirty_two_
10003 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10004 error "failed to hardlink many files"
10005 links=$($LFS fid2path $DIR $FID | wc -l)
10006 echo -n "${links}/1000 links in link EA"
10007 [[ $links -gt 60 ]] ||
10008 err17935 "expected at least 60 links in link EA"
10009 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10010 error "failed to unlink many hardlinks"
10012 run_test 161a "link ea sanity"
10015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10016 [ $MDSCOUNT -lt 2 ] &&
10017 skip "skipping remote directory test" && return
10019 local remote_dir=$DIR/$tdir/remote_dir
10021 mkdir -p $DIR/$tdir
10022 $LFS mkdir -i $MDTIDX $remote_dir ||
10023 error "create remote directory failed"
10025 cp /etc/hosts $remote_dir/$tfile
10026 mkdir -p $remote_dir/foo1
10027 mkdir -p $remote_dir/foo2
10028 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10029 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10030 ln $remote_dir/$tfile $remote_dir/foo1/luna
10031 ln $remote_dir/$tfile $remote_dir/foo2/thor
10033 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10035 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10036 $LFS fid2path $DIR $FID
10037 err17935 "bad link ea"
10040 rm $remote_dir/foo2/zachary
10042 rm $remote_dir/foo2/thor
10044 rm $remote_dir/$tfile
10046 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10047 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10048 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10049 $LFS fid2path $DIR $FID
10050 err17935 "bad link rename"
10052 rm $remote_dir/foo2/maggie
10055 local longname=filename_avg_len_is_thirty_two_
10056 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10057 error "failed to hardlink many files"
10058 links=$($LFS fid2path $DIR $FID | wc -l)
10059 echo -n "${links}/1000 links in link EA"
10060 [[ ${links} -gt 60 ]] ||
10061 err17935 "expected at least 60 links in link EA"
10062 unlinkmany $remote_dir/foo2/$longname 1000 ||
10063 error "failed to unlink many hardlinks"
10065 run_test 161b "link ea sanity under remote directory"
10068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10069 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10070 skip "Need MDS version at least 2.1.5" && return
10072 # define CLF_RENAME_LAST 0x0001
10073 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10074 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10075 changelog_register -n)
10077 mkdir -p $DIR/$tdir
10078 touch $DIR/$tdir/foo_161c
10079 touch $DIR/$tdir/bar_161c
10080 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10081 $LFS changelog $MDT0 | grep RENME
10082 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10084 $LFS changelog_clear $MDT0 $USER 0
10085 if [ x$flags != "x0x1" ]; then
10086 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10088 error "flag $flags is not 0x1"
10090 echo "rename overwrite a target having nlink = 1," \
10091 "changelog record has flags of $flags"
10093 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10094 touch $DIR/$tdir/foo_161c
10095 touch $DIR/$tdir/bar_161c
10096 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10097 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10098 $LFS changelog $MDT0 | grep RENME
10099 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10100 $LFS changelog_clear $MDT0 $USER 0
10101 if [ x$flags != "x0x0" ]; then
10102 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10104 error "flag $flags is not 0x0"
10106 echo "rename overwrite a target having nlink > 1," \
10107 "changelog record has flags of $flags"
10109 # rename doesn't overwrite a target (changelog flag 0x0)
10110 touch $DIR/$tdir/foo_161c
10111 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10112 $LFS changelog $MDT0 | grep RENME
10113 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10114 $LFS changelog_clear $MDT0 $USER 0
10115 if [ x$flags != "x0x0" ]; then
10116 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10118 error "flag $flags is not 0x0"
10120 echo "rename doesn't overwrite a target," \
10121 "changelog record has flags of $flags"
10123 # define CLF_UNLINK_LAST 0x0001
10124 # unlink a file having nlink = 1 (changelog flag 0x1)
10125 rm -f $DIR/$tdir/foo2_161c
10126 $LFS changelog $MDT0 | grep UNLNK
10127 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10128 $LFS changelog_clear $MDT0 $USER 0
10129 if [ x$flags != "x0x1" ]; then
10130 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10132 error "flag $flags is not 0x1"
10134 echo "unlink a file having nlink = 1," \
10135 "changelog record has flags of $flags"
10137 # unlink a file having nlink > 1 (changelog flag 0x0)
10138 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10139 rm -f $DIR/$tdir/foobar_161c
10140 $LFS changelog $MDT0 | grep UNLNK
10141 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10142 $LFS changelog_clear $MDT0 $USER 0
10143 if [ x$flags != "x0x0" ]; then
10144 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10146 error "flag $flags is not 0x0"
10148 echo "unlink a file having nlink > 1," \
10149 "changelog record has flags of $flags"
10150 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10152 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10159 local path=$(${LFS} fid2path $*)
10162 if [ $RC -ne 0 ]; then
10163 err17935 "path looked up of $expected failed. Error $RC"
10165 elif [ "${path}" != "${expected}" ]; then
10166 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10169 echo "fid $fid resolves to path $path (expected $expected)"
10173 # Make changes to filesystem
10174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10175 test_mkdir -p -c1 $DIR/$tdir/d2
10176 touch $DIR/$tdir/d2/$tfile
10177 touch $DIR/$tdir/d2/x1
10178 touch $DIR/$tdir/d2/x2
10179 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10180 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10182 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10183 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10186 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10187 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10188 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10190 # softlink to wrong file
10191 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10192 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10193 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10196 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10197 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10198 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10199 # fid2path dir/fsname should both work
10200 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10201 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10203 # hardlink count: check that there are 2 links
10204 # Doesnt work with CMD yet: 17935
10205 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10206 err17935 "expected 2 links"
10208 # hardlink indexing: remove the first link
10209 rm $DIR/$tdir/d2/p/q/r/hlink
10210 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10214 run_test 162 "path lookup sanity"
10217 # do directio so as not to populate the page cache
10218 log "creating a 10 Mb file"
10219 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10220 log "starting reads"
10221 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10222 log "truncating the file"
10223 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10225 kill %+ || true # reads might have finished
10226 echo "wait until dd is finished"
10228 log "removing the temporary file"
10229 rm -rf $DIR/$tfile || error "tmp file removal failed"
10231 run_test 169 "parallel read and truncate should not deadlock"
10234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10235 $LCTL clear # bug 18514
10236 $LCTL debug_daemon start $TMP/${tfile}_log_good
10238 $LCTL debug_daemon stop
10239 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10240 error "sed failed to read log_good"
10242 $LCTL debug_daemon start $TMP/${tfile}_log_good
10244 $LCTL debug_daemon stop
10246 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10247 error "lctl df log_bad failed"
10249 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10250 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10252 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10253 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10255 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10256 error "bad_line good_line1 good_line2 are empty"
10258 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10259 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10260 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10262 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10263 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10264 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10266 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10267 error "bad_line_new good_line_new are empty"
10269 local expected_good=$((good_line1 + good_line2*2))
10271 rm -f $TMP/${tfile}*
10272 # LU-231, short malformed line may not be counted into bad lines
10273 if [ $bad_line -ne $bad_line_new ] &&
10274 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10275 error "expected $bad_line bad lines, but got $bad_line_new"
10279 if [ $expected_good -ne $good_line_new ]; then
10280 error "expected $expected_good good lines, but got $good_line_new"
10285 run_test 170 "test lctl df to handle corrupted log ====================="
10287 test_171() { # bug20592
10288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10289 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10290 $LCTL set_param fail_loc=0x50e
10291 $LCTL set_param fail_val=3000
10292 multiop_bg_pause $DIR/$tfile O_s || true
10294 kill -USR1 $MULTIPID
10298 if dmesg | grep "recursive fault"; then
10299 error "caught a recursive fault"
10301 $LCTL set_param fail_loc=0
10304 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10306 # it would be good to share it with obdfilter-survey/libecho code
10307 setup_obdecho_osc () {
10310 local obdfilter_name=$2
10311 echo "Creating new osc for $obdfilter_name on $ost_nid"
10312 # make sure we can find loopback nid
10313 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10315 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10316 ${obdfilter_name}_osc_UUID || rc=2; }
10317 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10318 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10322 cleanup_obdecho_osc () {
10323 local obdfilter_name=$1
10324 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10325 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10332 local pages=${3:-64}
10337 local obd_size=$(get_obd_size $node $OBD)
10338 local page_size=$(get_page_size $node)
10339 if [[ -n "$obd_size" ]]; then
10340 local new_count=$((obd_size / (pages * page_size / 1024)))
10341 [[ $new_count -ge $count ]] || count=$new_count
10344 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10345 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10347 if [ $rc -eq 0 ]; then
10348 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10349 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10351 echo "New object id is $id"
10352 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10354 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10355 "test_brw $count w v $pages $id" || rc=4; }
10356 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10358 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10359 "cleanup" || rc=5; }
10360 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10361 "detach" || rc=6; }
10362 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10368 remote_ost_nodsh && skip "remote OST with nodsh" && return
10370 local rmmod_local=0
10372 if ! module_loaded obdecho; then
10373 load_module obdecho/obdecho
10377 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10378 local host=$(lctl get_param -n osc.$osc.import |
10379 awk '/current_connection:/ {print $2}' )
10380 local target=$(lctl get_param -n osc.$osc.import |
10381 awk '/target:/ {print $2}' )
10382 target=${target%_UUID}
10384 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10385 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10386 [[ -n $target ]] && cleanup_obdecho_osc $target
10387 [ $rmmod_local -eq 1 ] && rmmod obdecho
10390 run_test 180a "test obdecho on osc"
10393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10394 remote_ost_nodsh && skip "remote OST with nodsh" && return
10396 local rmmod_remote=0
10398 do_facet ost1 "lsmod | grep -q obdecho || " \
10399 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10400 "modprobe obdecho; }" && rmmod_remote=1
10401 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10402 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10403 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10406 run_test 180b "test obdecho directly on obdfilter"
10408 test_180c() { # LU-2598
10409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10410 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10411 skip "Need MDS version at least 2.4.0" && return
10414 local rmmod_remote=false
10415 local pages=16384 # 64MB bulk I/O RPC size
10418 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10419 rmmod_remote=true || error "failed to load module obdecho"
10421 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10423 if [ -n "$target" ]; then
10424 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10426 echo "there is no obdfilter target on ost1"
10429 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10432 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10434 test_181() { # bug 22177
10435 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10436 # create enough files to index the directory
10437 createmany -o $DIR/$tdir/foobar 4000
10438 # print attributes for debug purpose
10441 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10443 # remove the files & current working dir
10444 unlinkmany $DIR/$tdir/foobar 4000
10446 kill -USR1 $MULTIPID
10448 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10451 run_test 181 "Test open-unlinked dir ========================"
10454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10455 # disable MDC RPC lock wouldn't crash client
10459 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10460 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10461 $LCTL set_param fail_loc=0x804
10463 for (( i=0; i < $tcount; i++ )) ; do
10464 mkdir $DIR/$tdir/$i
10465 createmany -o $DIR/$tdir/$i/f- $fcount &
10469 for (( i=0; i < $tcount; i++ )) ; do
10470 unlinkmany $DIR/$tdir/$i/f- $fcount &
10476 $LCTL set_param fail_loc=0
10478 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10480 test_183() { # LU-2275
10481 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10482 skip "Need MDS version at least 2.3.56" && return
10484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10485 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10486 echo aaa > $DIR/$tdir/$tfile
10488 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10489 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10491 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10492 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10494 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10496 # Flush negative dentry cache
10497 touch $DIR/$tdir/$tfile
10499 # We are not checking for any leaked references here, they'll
10500 # become evident next time we do cleanup with module unload.
10503 run_test 183 "No crash or request leak in case of strange dispositions ========"
10505 # test suite 184 is for LU-2016, LU-2017
10507 check_swap_layouts_support && return 0
10509 dir0=$DIR/$tdir/$testnum
10510 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10515 $SETSTRIPE -c1 $file1
10517 $SETSTRIPE -c2 $file2
10519 gen1=$($GETSTRIPE -g $file1)
10520 gen2=$($GETSTRIPE -g $file2)
10522 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10523 gen=$($GETSTRIPE -g $file1)
10524 [[ $gen1 != $gen ]] ||
10525 "Layout generation on $file1 does not change"
10526 gen=$($GETSTRIPE -g $file2)
10527 [[ $gen2 != $gen ]] ||
10528 "Layout generation on $file2 does not change"
10530 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10531 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10533 run_test 184a "Basic layout swap"
10536 check_swap_layouts_support && return 0
10538 dir0=$DIR/$tdir/$testnum
10539 mkdir -p $dir0 || error "creating dir $dir0"
10546 $SETSTRIPE -c1 $file1
10547 $SETSTRIPE -c2 $file2
10548 $SETSTRIPE -c1 $file3
10549 chown $RUNAS_ID $file3
10550 gen1=$($GETSTRIPE -g $file1)
10551 gen2=$($GETSTRIPE -g $file2)
10553 $LFS swap_layouts $dir1 $dir2 &&
10554 error "swap of directories layouts should fail"
10555 $LFS swap_layouts $dir1 $file1 &&
10556 error "swap of directory and file layouts should fail"
10557 $RUNAS $LFS swap_layouts $file1 $file2 &&
10558 error "swap of file we cannot write should fail"
10559 $LFS swap_layouts $file1 $file3 &&
10560 error "swap of file with different owner should fail"
10561 /bin/true # to clear error code
10563 run_test 184b "Forbidden layout swap (will generate errors)"
10566 check_swap_layouts_support && return 0
10568 local dir0=$DIR/$tdir/$testnum
10569 mkdir -p $dir0 || error "creating dir $dir0"
10571 local ref1=$dir0/ref1
10572 local ref2=$dir0/ref2
10573 local file1=$dir0/file1
10574 local file2=$dir0/file2
10575 # create a file large enough for the concurent test
10576 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10577 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10578 echo "ref file size: ref1($(stat -c %s $ref1))," \
10579 "ref2($(stat -c %s $ref2))"
10582 dd if=$ref1 of=$file1 bs=16k &
10585 # Make sure dd starts to copy file
10586 while [ ! -f $file1 ]; do sleep 0.1; done
10588 $LFS swap_layouts $file1 $file2
10591 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10592 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10594 # how many bytes copied before swapping layout
10595 local copied=$(stat -c %s $file2)
10596 local remaining=$(stat -c %s $ref1)
10597 remaining=$((remaining - copied))
10598 echo "Copied $copied bytes before swapping layout..."
10600 cmp -n $copied $file1 $ref2 | grep differ &&
10601 error "Content mismatch [0, $copied) of ref2 and file1"
10602 cmp -n $copied $file2 $ref1 ||
10603 error "Content mismatch [0, $copied) of ref1 and file2"
10604 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10605 error "Content mismatch [$copied, EOF) of ref1 and file1"
10608 rm -f $ref1 $ref2 $file1 $file2
10610 run_test 184c "Concurrent write and layout swap"
10613 check_swap_layouts_support && return 0
10614 [ -z "$(which getfattr 2>/dev/null)" ] &&
10615 skip "no getfattr command" && return 0
10617 local file1=$DIR/$tdir/$tfile-1
10618 local file2=$DIR/$tdir/$tfile-2
10619 local file3=$DIR/$tdir/$tfile-3
10623 mkdir -p $DIR/$tdir
10624 touch $file1 || error "create $file1 failed"
10625 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10626 error "create $file2 failed"
10627 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10628 error "create $file3 failed"
10629 lovea1=$($LFS getstripe $file1 | sed 1d)
10631 $LFS swap_layouts $file2 $file3 ||
10632 error "swap $file2 $file3 layouts failed"
10633 $LFS swap_layouts $file1 $file2 ||
10634 error "swap $file1 $file2 layouts failed"
10636 lovea2=$($LFS getstripe $file2 | sed 1d)
10637 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10639 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10640 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10642 run_test 184d "allow stripeless layouts swap"
10645 test_185() { # LU-2441
10646 # LU-3553 - no volatile file support in old servers
10647 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10648 { skip "Need MDS version at least 2.3.60"; return 0; }
10650 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10651 touch $DIR/$tdir/spoo
10652 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10653 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10654 error "cannot create/write a volatile file"
10655 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10656 error "FID is still valid after close"
10658 multiop_bg_pause $DIR/$tdir vVw4096_c
10665 # assume that the next FID for this client is sequential, since stdout
10666 # is unfortunately eaten by multiop_bg_pause
10667 local n=$((${fidv[1]} + 1))
10668 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10669 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10670 error "FID is missing before close"
10671 kill -USR1 $multi_pid
10672 # 1 second delay, so if mtime change we will see it
10674 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10675 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10677 run_test 185 "Volatile file support"
10680 local dir0=$DIR/$tdir/$testnum
10681 mkdir -p $dir0 || error "creating dir $dir0"
10683 local file=$dir0/file1
10684 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10685 local dv1=$($LFS data_version $file)
10686 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10687 local dv2=$($LFS data_version $file)
10688 [[ $dv1 != $dv2 ]] ||
10689 error "data version did not change on write $dv1 == $dv2"
10694 run_test 187a "Test data version change"
10697 local dir0=$DIR/$tdir/$testnum
10698 mkdir -p $dir0 || error "creating dir $dir0"
10700 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10701 [[ ${DV[0]} != ${DV[1]} ]] ||
10702 error "data version did not change on write"\
10703 " ${DV[0]} == ${DV[1]}"
10708 run_test 187b "Test data version change on volatile file"
10711 check_file_in_pool()
10716 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10719 for t in $tlist ; do
10720 [ "$i" -eq "$t" ] && continue 2
10723 echo "pool list: $tlist"
10724 echo "striping: $res"
10725 error_noexit "$file not allocated in $pool"
10732 echo "Creating new pool"
10735 create_pool $FSNAME.$pool ||
10736 { error_noexit "No pool created, result code $?"; return 1; }
10737 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10738 { error_noexit "$pool not in lfs pool_list"; return 2; }
10741 pool_add_targets() {
10742 echo "Adding targets to pool"
10748 local list=$(seq $first $step $last)
10750 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10751 do_facet mgs $LCTL pool_add \
10752 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10753 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10754 | sort -u | tr '\n' ' ' " "$t" || {
10755 error_noexit "Add to pool failed"
10758 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10759 local addcount=$(((last - first) / step + 1))
10760 [ $lfscount -eq $addcount ] || {
10761 error_noexit "lfs pool_list bad ost count" \
10762 "$lfscount != $addcount"
10770 echo "Setting pool on directory $tdir"
10772 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10774 error_noexit "Cannot set pool $pool to $tdir"
10781 echo "Checking pool on directory $tdir"
10783 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10784 [ "$res" = "$pool" ] && return 0
10786 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10790 pool_dir_rel_path() {
10791 echo "Testing relative path works well"
10796 mkdir -p $root/$tdir/$tdir
10798 pool_set_dir $pool $tdir || return 1
10799 pool_set_dir $pool ./$tdir || return 2
10800 pool_set_dir $pool ../$tdir || return 3
10801 pool_set_dir $pool ../$tdir/$tdir || return 4
10802 rm -rf $tdir; cd - > /dev/null
10805 pool_alloc_files() {
10806 echo "Checking files allocation from directory pool"
10813 for i in $(seq -w 1 $count)
10815 local file=$tdir/file-$i
10817 check_file_in_pool $file $pool "$tlist" || \
10818 failed=$((failed + 1))
10820 [ "$failed" = 0 ] && return 0
10822 error_noexit "$failed files not allocated in $pool"
10826 pool_create_files() {
10827 echo "Creating files in pool"
10835 for i in $(seq -w 1 $count)
10837 local file=$tdir/spoo-$i
10838 $SETSTRIPE -p $pool $file
10839 check_file_in_pool $file $pool "$tlist" || \
10840 failed=$((failed + 1))
10842 [ "$failed" = 0 ] && return 0
10844 error_noexit "$failed files not allocated in $pool"
10849 echo "Checking 'lfs df' output"
10852 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10854 local res=$($LFS df --pool $FSNAME.$pool |
10856 grep "$FSNAME-OST" |
10858 [ "$res" = "$t" ] && return 0
10860 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10864 pool_file_rel_path() {
10865 echo "Creating files in a pool with relative pathname"
10870 { error_noexit "unable to create $tdir"; return 1 ; }
10871 local file="/..$tdir/$tfile-1"
10872 $SETSTRIPE -p $pool $file ||
10873 { error_noexit "unable to create $file" ; return 2 ; }
10876 $SETSTRIPE -p $pool $tfile-2 || {
10877 error_noexit "unable to create $tfile-2 in $tdir"
10882 pool_remove_first_target() {
10883 echo "Removing first target from a pool"
10886 local pname="lov.$FSNAME-*.pools.$pool"
10887 local t=$($LCTL get_param -n $pname | head -n1)
10888 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10889 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10890 error_noexit "$t not removed from $FSNAME.$pool"
10895 pool_remove_all_targets() {
10896 echo "Removing all targets from pool"
10899 local pname="lov.$FSNAME-*.pools.$pool"
10900 for t in $($LCTL get_param -n $pname | sort -u)
10902 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10904 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10905 error_noexit "Pool $FSNAME.$pool cannot be drained"
10908 # striping on an empty/nonexistant pool should fall back
10909 # to "pool of everything"
10911 error_noexit "failed to use fallback striping for empty pool"
10914 # setstripe on an empty pool should fail
10915 $SETSTRIPE -p $pool $file 2>/dev/null && {
10916 error_noexit "expected failure when creating file" \
10924 echo "Destroying pool"
10928 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10931 # striping on an empty/nonexistant pool should fall back
10932 # to "pool of everything"
10934 error_noexit "failed to use fallback striping for missing pool"
10937 # setstripe on an empty pool should fail
10938 $SETSTRIPE -p $pool $file 2>/dev/null && {
10939 error_noexit "expected failure when creating file" \
10940 "with missing pool"
10944 # get param should return err once pool is gone
10945 if wait_update $HOSTNAME "lctl get_param -n \
10946 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10948 remove_pool_from_list $FSNAME.$pool
10951 error_noexit "Pool $FSNAME.$pool is not destroyed"
10956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10957 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10959 local POOL=${POOL:-cea1}
10960 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10961 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10964 local last_ost=$(($OSTCOUNT - 1))
10966 local ost_list=$(seq $first_ost $ost_step $last_ost)
10967 local ost_range="$first_ost $last_ost $ost_step"
10968 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10969 local file_dir=$POOL_ROOT/file_tst
10973 # former test_200a test_200b
10974 pool_add $POOL || { rc=$? ; break; }
10975 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10976 # former test_200c test_200d
10977 mkdir -p $test_path
10978 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10979 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10980 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10981 || { rc=$? ; break; }
10982 # former test_200e test_200f
10983 local files=$((OSTCOUNT*3))
10984 pool_alloc_files $POOL $test_path $files "$ost_list" \
10985 || { rc=$? ; break; }
10986 pool_create_files $POOL $file_dir $files "$ost_list" \
10987 || { rc=$? ; break; }
10988 # former test_200g test_200h
10989 pool_lfs_df $POOL || { rc=$? ; break; }
10990 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10992 # former test_201a test_201b test_201c
10993 pool_remove_first_target $POOL || { rc=$? ; break; }
10995 local f=$test_path/$tfile
10996 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10997 pool_remove $POOL $f || { rc=$? ; break; }
11004 run_test 200 "OST pools"
11006 # usage: default_attr <count | size | offset>
11008 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11011 # usage: check_default_stripe_attr
11012 check_default_stripe_attr() {
11013 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11015 --stripe-count|--count)
11016 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11017 --stripe-size|--size)
11018 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11019 --stripe-index|--index)
11022 error "unknown getstripe attr '$1'"
11025 [ $ACTUAL != $EXPECTED ] &&
11026 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11030 test_mkdir -p $DIR/$tdir
11031 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11033 check_default_stripe_attr --stripe-count
11034 check_default_stripe_attr --stripe-size
11035 check_default_stripe_attr --stripe-index
11039 run_test 204a "Print default stripe attributes ================="
11042 test_mkdir -p $DIR/$tdir
11043 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11045 check_default_stripe_attr --stripe-size
11046 check_default_stripe_attr --stripe-index
11050 run_test 204b "Print default stripe size and offset ==========="
11053 test_mkdir -p $DIR/$tdir
11054 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11056 check_default_stripe_attr --stripe-count
11057 check_default_stripe_attr --stripe-index
11061 run_test 204c "Print default stripe count and offset ==========="
11064 test_mkdir -p $DIR/$tdir
11065 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11067 check_default_stripe_attr --stripe-count
11068 check_default_stripe_attr --stripe-size
11072 run_test 204d "Print default stripe count and size ============="
11075 test_mkdir -p $DIR/$tdir
11076 $SETSTRIPE -d $DIR/$tdir
11078 check_default_stripe_attr --stripe-count --raw
11079 check_default_stripe_attr --stripe-size --raw
11080 check_default_stripe_attr --stripe-index --raw
11084 run_test 204e "Print raw stripe attributes ================="
11087 test_mkdir -p $DIR/$tdir
11088 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11090 check_default_stripe_attr --stripe-size --raw
11091 check_default_stripe_attr --stripe-index --raw
11095 run_test 204f "Print raw stripe size and offset ==========="
11098 test_mkdir -p $DIR/$tdir
11099 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11101 check_default_stripe_attr --stripe-count --raw
11102 check_default_stripe_attr --stripe-index --raw
11106 run_test 204g "Print raw stripe count and offset ==========="
11109 test_mkdir -p $DIR/$tdir
11110 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11112 check_default_stripe_attr --stripe-count --raw
11113 check_default_stripe_attr --stripe-size --raw
11117 run_test 204h "Print raw stripe count and size ============="
11119 # Figure out which job scheduler is being used, if any,
11120 # or use a fake one
11121 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11122 JOBENV=SLURM_JOB_ID
11123 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11125 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11127 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11128 JOBENV=LOADL_STEP_ID
11129 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11135 verify_jobstats() {
11139 # clear old jobstats
11140 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11141 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11143 # use a new JobID for this test, or we might see an old one
11144 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11148 log "Using JobID environment variable $JOBENV=$JOBVAL"
11150 if [ $JOBENV = "FAKE_JOBID" ]; then
11151 FAKE_JOBID=$JOBVAL $cmd
11156 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11157 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11158 do_facet $FACET lctl get_param mdt.*.job_stats |
11159 grep $JOBVAL || error "No job stats found on MDT $FACET"
11161 if [ "$target" = "ost" -o "$target" = "both" ]; then
11163 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11164 grep $JOBVAL || error "No job stats found on OST $FACET"
11170 NEW_JOBENV=${1:-$OLD_JOBENV}
11171 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11172 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11175 test_205() { # Job stats
11176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11177 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11178 skip "Server doesn't support jobstats" && return 0
11179 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11182 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11183 if [ $OLD_JOBENV != $JOBENV ]; then
11184 jobstats_set $JOBENV
11185 trap jobstats_set EXIT
11189 cmd="mkdir $DIR/$tfile"
11190 verify_jobstats "$cmd" "mdt"
11192 cmd="rm -fr $DIR/$tfile"
11193 verify_jobstats "$cmd" "mdt"
11195 cmd="mknod $DIR/$tfile c 1 3"
11196 verify_jobstats "$cmd" "mdt"
11198 cmd="rm -f $DIR/$tfile"
11199 verify_jobstats "$cmd" "mdt"
11201 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11202 verify_jobstats "$cmd" "mdt"
11204 cmd="touch $DIR/$tfile"
11205 verify_jobstats "$cmd" "both"
11207 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11208 verify_jobstats "$cmd" "ost"
11210 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11211 verify_jobstats "$cmd" "ost"
11213 cmd="$TRUNCATE $DIR/$tfile 0"
11214 verify_jobstats "$cmd" "both"
11216 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11217 verify_jobstats "$cmd" "mdt"
11220 rm -f $DIR/jobstats_test_rename
11222 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11224 run_test 205 "Verify job stats"
11226 # LU-1480, LU-1773 and LU-1657
11228 mkdir -p $DIR/$tdir
11229 $SETSTRIPE -c -1 $DIR/$tdir
11230 #define OBD_FAIL_LOV_INIT 0x1403
11231 $LCTL set_param fail_loc=0xa0001403
11232 $LCTL set_param fail_val=1
11233 touch $DIR/$tdir/$tfile || true
11235 run_test 206 "fail lov_init_raid0() doesn't lbug"
11238 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11239 local fsz=`stat -c %s $DIR/$tfile`
11240 cancel_lru_locks mdc
11242 # do not return layout in getattr intent
11243 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11244 $LCTL set_param fail_loc=0x170
11245 local sz=`stat -c %s $DIR/$tfile`
11247 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11251 run_test 207a "can refresh layout at glimpse"
11254 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11255 local cksum=`md5sum $DIR/$tfile`
11256 local fsz=`stat -c %s $DIR/$tfile`
11257 cancel_lru_locks mdc
11258 cancel_lru_locks osc
11260 # do not return layout in getattr intent
11261 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11262 $LCTL set_param fail_loc=0x171
11264 # it will refresh layout after the file is opened but before read issues
11265 echo checksum is "$cksum"
11266 echo "$cksum" |md5sum -c --quiet || error "file differs"
11270 run_test 207b "can refresh layout at open"
11273 # FIXME: in this test suite, only RD lease is used. This is okay
11274 # for now as only exclusive open is supported. After generic lease
11275 # is done, this test suite should be revised. - Jinshan
11277 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11278 { skip "Need MDS version at least 2.4.52"; return 0; }
11280 echo "==== test 1: verify get lease work"
11281 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11283 echo "==== test 2: verify lease can be broken by upcoming open"
11284 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11288 $MULTIOP $DIR/$tfile oO_RDONLY:c
11289 kill -USR1 $PID && wait $PID || error "break lease error"
11291 echo "==== test 3: verify lease can't be granted if an open already exists"
11292 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11296 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11297 kill -USR1 $PID && wait $PID || error "open file error"
11299 echo "==== test 4: lease can sustain over recovery"
11300 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11306 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11308 echo "==== test 5: lease broken can't be regained by replay"
11309 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11313 # open file to break lease and then recovery
11314 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11317 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11321 run_test 208 "Exclusive open"
11324 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11325 skip_env "must have disp_stripe" && return
11328 sync; sleep 5; sync;
11330 echo 3 > /proc/sys/vm/drop_caches
11331 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11333 # open/close 500 times
11334 for i in $(seq 500); do
11338 echo 3 > /proc/sys/vm/drop_caches
11339 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11341 echo "before: $req_before, after: $req_after"
11342 [ $((req_after - req_before)) -ge 300 ] &&
11343 error "open/close requests are not freed"
11346 run_test 209 "read-only open/close requests should be freed promptly"
11350 size=$((size % 8192 + 1))
11351 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11352 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11353 rm -f $DIR/f212 $DIR/f212.xyz
11355 run_test 212 "Sendfile test ============================================"
11358 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11359 cancel_lru_locks osc
11360 lctl set_param fail_loc=0x8000040f
11361 # generate a read lock
11362 cat $DIR/$tfile > /dev/null
11363 # write to the file, it will try to cancel the above read lock.
11364 cat /etc/hosts >> $DIR/$tfile
11366 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11368 test_214() { # for bug 20133
11369 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11370 for (( i=0; i < 340; i++ )) ; do
11371 touch $DIR/$tdir/d214c/a$i
11374 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11375 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11376 ls $DIR/d214c || error "ls $DIR/d214c failed"
11377 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11378 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11380 run_test 214 "hash-indexed directory test - bug 20133"
11382 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11383 create_lnet_proc_files() {
11384 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11385 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11387 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11388 rm -f "$TMP/lnet_$1.sys_tmp"
11391 # counterpart of create_lnet_proc_files
11392 remove_lnet_proc_files() {
11393 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11396 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11397 # 3rd arg as regexp for body
11398 check_lnet_proc_stats() {
11399 local l=$(cat "$TMP/lnet_$1" |wc -l)
11400 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11402 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11405 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11406 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11407 # optional and can be regexp for 2nd line (lnet.routes case)
11408 check_lnet_proc_entry() {
11409 local blp=2 # blp stands for 'position of 1st line of body'
11410 [ -z "$5" ] || blp=3 # lnet.routes case
11412 local l=$(cat "$TMP/lnet_$1" |wc -l)
11413 # subtracting one from $blp because the body can be empty
11414 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11416 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11417 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11419 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11420 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11422 # bail out if any unexpected line happened
11423 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11424 [ "$?" != 0 ] || error "$2 misformatted"
11427 test_215() { # for bugs 18102, 21079, 21517
11428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11429 local N='(0|[1-9][0-9]*)' # non-negative numeric
11430 local P='[1-9][0-9]*' # positive numeric
11431 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11432 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11433 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11434 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11436 local L1 # regexp for 1st line
11437 local L2 # regexp for 2nd line (optional)
11438 local BR # regexp for the rest (body)
11440 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11441 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11442 create_lnet_proc_files "stats"
11443 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11444 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11445 remove_lnet_proc_files "stats"
11447 # /proc/sys/lnet/routes should look like this:
11448 # Routing disabled/enabled
11449 # net hops priority state router
11450 # where net is a string like tcp0, hops > 0, priority >= 0,
11451 # state is up/down,
11452 # router is a string like 192.168.1.1@tcp2
11453 L1="^Routing (disabled|enabled)$"
11454 L2="^net +hops +priority +state +router$"
11455 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11456 create_lnet_proc_files "routes"
11457 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11458 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11459 remove_lnet_proc_files "routes"
11461 # /proc/sys/lnet/routers should look like this:
11462 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11463 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11464 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11465 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11466 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11467 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11468 create_lnet_proc_files "routers"
11469 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11470 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11471 remove_lnet_proc_files "routers"
11473 # /proc/sys/lnet/peers should look like this:
11474 # nid refs state last max rtr min tx min queue
11475 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11476 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11477 # numeric (0 or >0 or <0), queue >= 0.
11478 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11479 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11480 create_lnet_proc_files "peers"
11481 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11482 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11483 remove_lnet_proc_files "peers"
11485 # /proc/sys/lnet/buffers should look like this:
11486 # pages count credits min
11487 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11488 L1="^pages +count +credits +min$"
11489 BR="^ +$N +$N +$I +$I$"
11490 create_lnet_proc_files "buffers"
11491 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11492 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11493 remove_lnet_proc_files "buffers"
11495 # /proc/sys/lnet/nis should look like this:
11496 # nid status alive refs peer rtr max tx min
11497 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11498 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11499 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11500 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11501 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11502 create_lnet_proc_files "nis"
11503 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11504 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11505 remove_lnet_proc_files "nis"
11507 # can we successfully write to /proc/sys/lnet/stats?
11508 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11509 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11511 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11513 test_216() { # bug 20317
11514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11515 remote_ost_nodsh && skip "remote OST with nodsh" && return
11518 local facets=$(get_facets OST)
11519 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11521 save_lustre_params client "osc.*.contention_seconds" > $p
11522 save_lustre_params $facets \
11523 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11524 save_lustre_params $facets \
11525 "ldlm.namespaces.filter-*.contended_locks" >> $p
11526 save_lustre_params $facets \
11527 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11530 # agressive lockless i/o settings
11531 for node in $(osts_nodes); do
11532 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'
11534 lctl set_param -n osc.*.contention_seconds 60
11536 $DIRECTIO write $DIR/$tfile 0 10 4096
11537 $CHECKSTAT -s 40960 $DIR/$tfile
11539 # disable lockless i/o
11540 for node in $(osts_nodes); do
11541 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'
11543 lctl set_param -n osc.*.contention_seconds 0
11546 dd if=/dev/zero of=$DIR/$tfile count=0
11547 $CHECKSTAT -s 0 $DIR/$tfile
11549 restore_lustre_params <$p
11553 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11555 test_217() { # bug 22430
11556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11560 for node in $(nodes_list); do
11561 nid=$(host_nids_address $node $NETTYPE)
11562 if [[ $nid = *-* ]] ; then
11563 echo "lctl ping $nid@$NETTYPE"
11564 lctl ping $nid@$NETTYPE
11566 echo "skipping $node (no hyphen detected)"
11570 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11573 # do directio so as not to populate the page cache
11574 log "creating a 10 Mb file"
11575 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11576 log "starting reads"
11577 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11578 log "truncating the file"
11579 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11581 kill %+ || true # reads might have finished
11582 echo "wait until dd is finished"
11584 log "removing the temporary file"
11585 rm -rf $DIR/$tfile || error "tmp file removal failed"
11587 run_test 218 "parallel read and truncate should not deadlock ======================="
11590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11591 # write one partial page
11592 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11593 # set no grant so vvp_io_commit_write will do sync write
11594 $LCTL set_param fail_loc=0x411
11595 # write a full page at the end of file
11596 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11598 $LCTL set_param fail_loc=0
11599 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11600 $LCTL set_param fail_loc=0x411
11601 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11604 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11605 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11607 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11609 test_220() { #LU-325
11610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11611 remote_ost_nodsh && skip "remote OST with nodsh" && return
11614 test_mkdir -p $DIR/$tdir
11615 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11616 awk '{print $2}' | sed -e 's/_UUID$//')
11619 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11620 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11621 osc.$mdtosc_proc1.prealloc_last_id)
11622 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11623 osc.$mdtosc_proc1.prealloc_next_id)
11627 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11628 #define OBD_FAIL_OST_ENOINO 0x229
11629 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11630 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11631 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11633 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11635 MDSOBJS=$((last_id - next_id))
11636 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11638 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11639 echo "OST still has $count kbytes free"
11641 echo "create $MDSOBJS files @next_id..."
11642 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11644 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11645 osc.$mdtosc_proc1.prealloc_last_id)
11646 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11647 osc.$mdtosc_proc1.prealloc_next_id)
11649 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11654 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11655 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11657 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11658 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11659 echo "unlink $MDSOBJS files @$next_id..."
11660 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11662 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11666 dd if=`which date` of=$MOUNT/date oflag=sync
11667 chmod +x $MOUNT/date
11669 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11670 $LCTL set_param fail_loc=0x80001401
11672 $MOUNT/date > /dev/null
11675 run_test 221 "make sure fault and truncate race to not cause OOM"
11678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11680 test_mkdir -p $DIR/$tdir
11681 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11682 createmany -o $DIR/$tdir/$tfile 10
11683 cancel_lru_locks mdc
11684 cancel_lru_locks osc
11685 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11686 $LCTL set_param fail_loc=0x31a
11687 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11688 $LCTL set_param fail_loc=0
11691 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11696 test_mkdir -p $DIR/$tdir
11697 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11698 createmany -o $DIR/$tdir/$tfile 10
11699 cancel_lru_locks mdc
11700 cancel_lru_locks osc
11701 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11702 $LCTL set_param fail_loc=0x31a
11703 rm -r $DIR/$tdir || "AGL for rmdir failed"
11704 $LCTL set_param fail_loc=0
11706 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11711 test_mkdir -p $DIR/$tdir
11712 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11713 createmany -o $DIR/$tdir/$tfile 10
11714 cancel_lru_locks mdc
11715 cancel_lru_locks osc
11716 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11717 $LCTL set_param fail_loc=0x31b
11718 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11719 $LCTL set_param fail_loc=0
11722 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11724 test_224a() { # LU-1039, MRP-303
11725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11726 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11727 $LCTL set_param fail_loc=0x508
11728 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11729 $LCTL set_param fail_loc=0
11732 run_test 224a "Don't panic on bulk IO failure"
11734 test_224b() { # LU-1039, MRP-303
11735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11736 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11737 cancel_lru_locks osc
11738 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11739 $LCTL set_param fail_loc=0x515
11740 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11741 $LCTL set_param fail_loc=0
11744 run_test 224b "Don't panic on bulk IO failure"
11746 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11749 if [ -z ${MDSSURVEY} ]; then
11750 skip_env "mds-survey not found" && return
11753 [ $MDSCOUNT -ge 2 ] &&
11754 skip "skipping now for more than one MDT" && return
11756 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11757 { skip "Need MDS version at least 2.2.51"; return; }
11759 local mds=$(facet_host $SINGLEMDS)
11760 local target=$(do_nodes $mds 'lctl dl' | \
11761 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11763 local cmd1="file_count=1000 thrhi=4"
11764 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11765 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11766 local cmd="$cmd1 $cmd2 $cmd3"
11768 rm -f ${TMP}/mds_survey*
11770 eval $cmd || error "mds-survey with zero-stripe failed"
11771 cat ${TMP}/mds_survey*
11772 rm -f ${TMP}/mds_survey*
11774 run_test 225a "Metadata survey sanity with zero-stripe"
11777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11779 if [ -z ${MDSSURVEY} ]; then
11780 skip_env "mds-survey not found" && return
11782 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11783 { skip "Need MDS version at least 2.2.51"; return; }
11785 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11786 skip_env "Need to mount OST to test" && return
11789 [ $MDSCOUNT -ge 2 ] &&
11790 skip "skipping now for more than one MDT" && return
11791 local mds=$(facet_host $SINGLEMDS)
11792 local target=$(do_nodes $mds 'lctl dl' | \
11793 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11795 local cmd1="file_count=1000 thrhi=4"
11796 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11797 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11798 local cmd="$cmd1 $cmd2 $cmd3"
11800 rm -f ${TMP}/mds_survey*
11802 eval $cmd || error "mds-survey with stripe_count failed"
11803 cat ${TMP}/mds_survey*
11804 rm -f ${TMP}/mds_survey*
11806 run_test 225b "Metadata survey sanity with stripe_count = 1"
11808 mcreate_path2fid () {
11814 local path=$DIR/$tdir/$name
11819 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11820 error "cannot create $desc"
11822 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11824 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11826 fid_path=$($LFS fid2path $MOUNT $fid)
11828 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11830 [ "$path" == "$fid_path" ] ||
11831 error "fid2path returned $fid_path, expected $path"
11833 echo "pass with $path and $fid"
11838 mkdir -p $DIR/$tdir
11840 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11841 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11842 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11843 mcreate_path2fid 0040666 0 0 dir "directory"
11844 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11845 mcreate_path2fid 0100666 0 0 file "regular file"
11846 mcreate_path2fid 0120666 0 0 link "symbolic link"
11847 mcreate_path2fid 0140666 0 0 sock "socket"
11849 run_test 226a "call path2fid and fid2path on files of all type"
11852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11856 mkdir -p $DIR/$tdir
11857 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11858 error "create remote directory failed"
11859 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11860 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11861 "character special file (null)"
11862 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11863 "character special file (no device)"
11864 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11865 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11866 "block special file (loop)"
11867 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11868 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11869 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11871 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11873 # LU-1299 Executing or running ldd on a truncated executable does not
11874 # cause an out-of-memory condition.
11876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11877 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11878 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11879 chmod +x $MOUNT/date
11881 $MOUNT/date > /dev/null
11882 ldd $MOUNT/date > /dev/null
11885 run_test 227 "running truncated executable does not cause OOM"
11887 # LU-1512 try to reuse idle OI blocks
11889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11890 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11891 skip "non-ldiskfs backend" && return
11893 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11894 local myDIR=$DIR/$tdir
11897 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11898 $LCTL set_param fail_loc=0x80001002
11899 createmany -o $myDIR/t- 10000
11900 $LCTL set_param fail_loc=0
11901 # The guard is current the largest FID holder
11903 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11905 local IDX=$(($SEQ % 64))
11907 do_facet $SINGLEMDS sync
11908 # Make sure journal flushed.
11910 local blk1=$(do_facet $SINGLEMDS \
11911 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11912 grep Blockcount | awk '{print $4}')
11914 # Remove old files, some OI blocks will become idle.
11915 unlinkmany $myDIR/t- 10000
11916 # Create new files, idle OI blocks should be reused.
11917 createmany -o $myDIR/t- 2000
11918 do_facet $SINGLEMDS sync
11919 # Make sure journal flushed.
11921 local blk2=$(do_facet $SINGLEMDS \
11922 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11923 grep Blockcount | awk '{print $4}')
11925 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11927 run_test 228a "try to reuse idle OI blocks"
11930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11931 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11932 skip "non-ldiskfs backend" && return
11934 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11935 local myDIR=$DIR/$tdir
11938 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11939 $LCTL set_param fail_loc=0x80001002
11940 createmany -o $myDIR/t- 10000
11941 $LCTL set_param fail_loc=0
11942 # The guard is current the largest FID holder
11944 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11946 local IDX=$(($SEQ % 64))
11948 do_facet $SINGLEMDS sync
11949 # Make sure journal flushed.
11951 local blk1=$(do_facet $SINGLEMDS \
11952 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11953 grep Blockcount | awk '{print $4}')
11955 # Remove old files, some OI blocks will become idle.
11956 unlinkmany $myDIR/t- 10000
11959 stop $SINGLEMDS || error "Fail to stop MDT."
11961 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11963 df $MOUNT || error "Fail to df."
11964 # Create new files, idle OI blocks should be reused.
11965 createmany -o $myDIR/t- 2000
11966 do_facet $SINGLEMDS sync
11967 # Make sure journal flushed.
11969 local blk2=$(do_facet $SINGLEMDS \
11970 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11971 grep Blockcount | awk '{print $4}')
11973 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11975 run_test 228b "idle OI blocks can be reused after MDT restart"
11979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11980 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11981 skip "non-ldiskfs backend" && return
11983 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11984 local myDIR=$DIR/$tdir
11987 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11988 $LCTL set_param fail_loc=0x80001002
11989 # 20000 files can guarantee there are index nodes in the OI file
11990 createmany -o $myDIR/t- 20000
11991 $LCTL set_param fail_loc=0
11992 # The guard is current the largest FID holder
11994 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11996 local IDX=$(($SEQ % 64))
11998 do_facet $SINGLEMDS sync
11999 # Make sure journal flushed.
12001 local blk1=$(do_facet $SINGLEMDS \
12002 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12003 grep Blockcount | awk '{print $4}')
12005 # Remove old files, some OI blocks will become idle.
12006 unlinkmany $myDIR/t- 20000
12008 # The OI file should become empty now
12010 # Create new files, idle OI blocks should be reused.
12011 createmany -o $myDIR/t- 2000
12012 do_facet $SINGLEMDS sync
12013 # Make sure journal flushed.
12015 local blk2=$(do_facet $SINGLEMDS \
12016 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12017 grep Blockcount | awk '{print $4}')
12019 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12021 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12023 test_229() { # LU-2482, LU-3448
12024 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12025 skip "No HSM support on MDS of $(get_lustre_version)," \
12026 "need 2.4.53 at least" && return
12027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12028 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12032 # Create a file with a released layout and stripe count 2.
12033 $MULTIOP $DIR/$tfile H2c ||
12034 error "failed to create file with released layout"
12036 $GETSTRIPE -v $DIR/$tfile
12038 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12039 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12041 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12042 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12043 stat $DIR/$tfile || error "failed to stat released file"
12045 chown $RUNAS_ID $DIR/$tfile ||
12046 error "chown $RUNAS_ID $DIR/$tfile failed"
12048 chgrp $RUNAS_ID $DIR/$tfile ||
12049 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12051 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12052 rm $DIR/$tfile || error "failed to remove released file"
12054 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12058 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12061 mkdir -p $DIR/$tdir/test_230_local
12062 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12063 [ $mdt_idx -ne 0 ] &&
12064 error "create local directory on wrong MDT $mdt_idx"
12066 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12067 error "create remote directory failed"
12068 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12069 [ $mdt_idx -ne $MDTIDX ] &&
12070 error "create remote directory on wrong MDT $mdt_idx"
12072 createmany -o $DIR/$tdir/test_230/t- 10 ||
12073 error "create files on remote directory failed"
12074 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12075 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12076 rm -r $DIR/$tdir || error "unlink remote directory failed"
12078 run_test 230a "Create remote directory and files under the remote directory"
12081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12082 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12089 local migrate_dir=$DIR/$tdir/migrate_dir
12090 local other_dir=$DIR/$tdir/other_dir
12092 mkdir -p $migrate_dir
12093 mkdir -p $other_dir
12094 for ((i=0; i<10; i++)); do
12095 mkdir -p $migrate_dir/dir_${i}
12096 createmany -o $migrate_dir/dir_${i}/f 10 ||
12097 error "create files under remote dir failed $i"
12100 cp /etc/passwd $migrate_dir/$tfile
12101 cp /etc/passwd $other_dir/$tfile
12102 chattr +SAD $migrate_dir
12103 chattr +SAD $migrate_dir/$tfile
12105 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12106 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12107 local old_dir_mode=$(stat -c%f $migrate_dir)
12108 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12110 mkdir -p $migrate_dir/dir_default_stripe2
12111 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12112 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12114 mkdir -p $other_dir
12115 ln $migrate_dir/$tfile $other_dir/luna
12116 ln $migrate_dir/$tfile $migrate_dir/sofia
12117 ln $other_dir/$tfile $migrate_dir/david
12118 ln -s $migrate_dir/$tfile $other_dir/zachary
12119 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12120 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12122 $LFS mv -v -M $MDTIDX $migrate_dir ||
12123 error "migrate remote dir error"
12125 echo "migratate to MDT1, then checking.."
12126 for ((i=0; i<10; i++)); do
12127 for file in $(find $migrate_dir/dir_${i}); do
12128 mdt_index=$($LFS getstripe -M $file)
12129 [ $mdt_index == $MDTIDX ] ||
12130 error "$file is not on MDT${MDTIDX}"
12134 # the multiple link file should still in MDT0
12135 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12136 [ $mdt_index == 0 ] ||
12137 error "$file is not on MDT${MDTIDX}"
12139 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12140 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12141 error " expect $old_dir_flag get $new_dir_flag"
12143 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12144 [ "$old_file_flag" = "$new_file_flag" ] ||
12145 error " expect $old_file_flag get $new_file_flag"
12147 local new_dir_mode=$(stat -c%f $migrate_dir)
12148 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12149 error "expect mode $old_dir_mode get $new_dir_mode"
12151 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12152 [ "$old_file_mode" = "$new_file_mode" ] ||
12153 error "expect mode $old_file_mode get $new_file_mode"
12155 diff /etc/passwd $migrate_dir/$tfile ||
12156 error "$tfile different after migration"
12158 diff /etc/passwd $other_dir/luna ||
12159 error "luna different after migration"
12161 diff /etc/passwd $migrate_dir/sofia ||
12162 error "sofia different after migration"
12164 diff /etc/passwd $migrate_dir/david ||
12165 error "david different after migration"
12167 diff /etc/passwd $other_dir/zachary ||
12168 error "zachary different after migration"
12170 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12171 error "${tfile}_ln different after migration"
12173 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12174 error "${tfile}_ln_other different after migration"
12176 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12177 [ $stripe_count = 2 ] ||
12178 error "dir strpe_count $d != 2 after migration."
12180 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12181 [ $stripe_count = 2 ] ||
12182 error "file strpe_count $d != 2 after migration."
12184 #migrate back to MDT0
12186 $LFS mv -v -M $MDTIDX $migrate_dir ||
12187 error "migrate remote dir error"
12189 echo "migrate back to MDT0, checking.."
12190 for file in $(find $migrate_dir); do
12191 mdt_index=$($LFS getstripe -M $file)
12192 [ $mdt_index == $MDTIDX ] ||
12193 error "$file is not on MDT${MDTIDX}"
12196 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12197 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12198 error " expect $old_dir_flag get $new_dir_flag"
12200 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12201 [ "$old_file_flag" = "$new_file_flag" ] ||
12202 error " expect $old_file_flag get $new_file_flag"
12204 local new_dir_mode=$(stat -c%f $migrate_dir)
12205 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12206 error "expect mode $old_dir_mode get $new_dir_mode"
12208 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12209 [ "$old_file_mode" = "$new_file_mode" ] ||
12210 error "expect mode $old_file_mode get $new_file_mode"
12212 diff /etc/passwd ${migrate_dir}/$tfile ||
12213 error "$tfile different after migration"
12215 diff /etc/passwd ${other_dir}/luna ||
12216 error "luna different after migration"
12218 diff /etc/passwd ${migrate_dir}/sofia ||
12219 error "sofia different after migration"
12221 diff /etc/passwd ${other_dir}/zachary ||
12222 error "zachary different after migration"
12224 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12225 error "${tfile}_ln different after migration"
12227 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12228 error "${tfile}_ln_other different after migration"
12230 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12231 [ $stripe_count = 2 ] ||
12232 error "dir strpe_count $d != 2 after migration."
12234 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12235 [ $stripe_count = 2 ] ||
12236 error "file strpe_count $d != 2 after migration."
12238 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12240 run_test 230b "migrate directory"
12243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12244 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12249 #If migrating directory fails in the middle, all entries of
12250 #the directory is still accessiable.
12251 mkdir -p $DIR/$tdir
12253 createmany -o $DIR/$tdir/f 10 ||
12254 error "create files under ${tdir} failed"
12256 #failed after migrating 5 entries
12257 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12258 do_facet mds1 lctl set_param fail_loc=0x20001801
12259 do_facet mds1 lctl set_param fail_val=5
12260 local t=`ls $DIR/$tdir | wc -l`
12261 $LFS mv -M $MDTIDX $DIR/$tdir &&
12262 error "migrate should failed after 5 entries"
12263 local u=`ls $DIR/$tdir | wc -l`
12264 [ "$u" == "$t" ] || error "$u != $t during migration"
12266 for file in $(find $DIR/$tdir); do
12267 stat $file || error "stat $file failed"
12270 do_facet mds1 lctl set_param fail_loc=0
12271 do_facet mds1 lctl set_param fail_val=0
12273 $LFS mv -M $MDTIDX $DIR/$tdir ||
12274 error "migrate open files should failed with open files"
12276 echo "Finish migration, then checking.."
12277 for file in $(find $DIR/$tdir); do
12278 mdt_index=$($LFS getstripe -M $file)
12279 [ $mdt_index == $MDTIDX ] ||
12280 error "$file is not on MDT${MDTIDX}"
12283 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12285 run_test 230c "check directory accessiblity if migration is failed"
12288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12289 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12295 mkdir -p $DIR/$tdir
12297 for ((i=0; i<100; i++)); do
12298 mkdir -p $DIR/$tdir/dir_${i}
12299 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12300 error "create files under remote dir failed $i"
12303 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12305 echo "Finish migration, then checking.."
12306 for file in $(find $DIR/$tdir); do
12307 mdt_index=$($LFS getstripe -M $file)
12308 [ $mdt_index == $MDTIDX ] ||
12309 error "$file is not on MDT${MDTIDX}"
12312 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12314 run_test 230d "check migrate big directory"
12318 # For simplicity this test assumes that max_pages_per_rpc
12319 # is the same across all OSCs
12320 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12321 local bulk_size=$((max_pages * 4096))
12323 mkdir -p $DIR/$tdir
12325 # clear the OSC stats
12326 $LCTL set_param osc.*.stats=0 &>/dev/null
12328 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12329 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12330 oflag=direct &>/dev/null || error "dd failed"
12332 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12333 if [ x$nrpcs != "x1" ]; then
12334 error "found $nrpc ost_write RPCs, not 1 as expected"
12337 # Drop the OSC cache, otherwise we will read from it
12338 cancel_lru_locks osc
12340 # clear the OSC stats
12341 $LCTL set_param osc.*.stats=0 &>/dev/null
12343 # Client reads $bulk_size.
12344 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12345 iflag=direct &>/dev/null || error "dd failed"
12347 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12348 if [ x$nrpcs != "x1" ]; then
12349 error "found $nrpc ost_read RPCs, not 1 as expected"
12352 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12355 mkdir -p $DIR/$tdir
12357 for i in {0..1023}; do
12358 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12359 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12360 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12364 run_test 231b "must not assert on fully utilized OST request buffer"
12367 mkdir -p $DIR/$tdir
12368 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12369 $LCTL set_param fail_loc=0x31c
12371 # ignore dd failure
12372 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12374 $LCTL set_param fail_loc=0
12375 umount_client $MOUNT || error "umount failed"
12376 mount_client $MOUNT || error "mount failed"
12378 run_test 232 "failed lock should not block umount"
12381 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12382 { skip "Need MDS version at least 2.3.64"; return; }
12384 local fid=$($LFS path2fid $MOUNT)
12385 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12386 error "cannot access $MOUNT using its FID '$fid'"
12388 run_test 233a "checking that OBF of the FS root succeeds"
12391 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12392 { skip "Need MDS version at least 2.5.90"; return; }
12394 local fid=$($LFS path2fid $MOUNT/.lustre)
12395 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12396 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12398 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12399 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12400 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12402 run_test 233b "checking that OBF of the FS .lustre succeeds"
12405 local p="$TMP/sanityN-$TESTNAME.parameters"
12406 save_lustre_params client "llite.*.xattr_cache" > $p
12407 lctl set_param llite.*.xattr_cache 1 ||
12408 { skip "xattr cache is not supported"; return 0; }
12410 mkdir -p $DIR/$tdir || error "mkdir failed"
12411 touch $DIR/$tdir/$tfile || error "touch failed"
12412 # OBD_FAIL_LLITE_XATTR_ENOMEM
12413 $LCTL set_param fail_loc=0x1405
12414 if [ ! -f /etc/SuSE-release ]; then
12415 # attr pre-2.4.44-7 had a bug with rc
12416 # LU-3703 - SLES clients have older attr
12417 getfattr -n user.attr $DIR/$tdir/$tfile &&
12418 error "getfattr should have failed with ENOMEM"
12420 $LCTL set_param fail_loc=0x0
12423 restore_lustre_params < $p
12426 run_test 234 "xattr cache should not crash on ENOMEM"
12429 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12430 skip "Need MDS version at least 2.4.52" && return
12431 flock_deadlock $DIR/$tfile
12436 124) error "process hangs on a deadlock"
12438 *) error "error executing flock_deadlock $DIR/$tfile"
12442 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12446 check_swap_layouts_support && return 0
12447 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12449 local ref1=/etc/passwd
12450 local ref2=/etc/group
12451 local file1=$DIR/$tdir/f1
12452 local file2=$DIR/$tdir/f2
12454 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12455 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12456 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12457 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12458 local fd=$(free_fd)
12459 local cmd="exec $fd<>$file2"
12462 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12463 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12466 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12471 run_test 236 "Layout swap on open unlinked file"
12473 # test to verify file handle related system calls
12474 # (name_to_handle_at/open_by_handle_at)
12475 # The new system calls are supported in glibc >= 2.14.
12478 echo "Test file_handle syscalls" > $DIR/$tfile
12479 check_fhandle_syscalls $DIR/$tfile ||
12480 error "check_fhandle_syscalls failed"
12482 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12484 # LU-4659 linkea consistency
12487 ln $DIR/$tfile $DIR/$tfile.lnk
12488 touch $DIR/$tfile.new
12489 mv $DIR/$tfile.new $DIR/$tfile
12490 local fid1=$(lfs path2fid $DIR/$tfile)
12491 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12492 local path1=$(lfs fid2path $FSNAME $fid1)
12493 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12494 local path2=$(lfs fid2path $FSNAME $fid2)
12495 [ $tfile.lnk == $path2 ] ||
12496 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12499 run_test 238 "Verify linkea consistency"
12501 test_striped_dir() {
12506 mkdir -p $DIR/$tdir
12507 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12508 error "set striped dir error"
12510 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12511 if [ "$stripe_count" != "2" ]; then
12512 error "stripe_count is $stripe_count, expect 2"
12515 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12516 if [ "$stripe_index" != "$mdt_index" ]; then
12517 error "stripe_index is $stripe_index, expect $mdt_index"
12520 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12521 error "nlink error after create striped dir"
12523 mkdir $DIR/$tdir/striped_dir/a
12524 mkdir $DIR/$tdir/striped_dir/b
12526 stat $DIR/$tdir/striped_dir/a ||
12527 error "create dir under striped dir failed"
12528 stat $DIR/$tdir/striped_dir/b ||
12529 error "create dir under striped dir failed"
12531 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12532 error "nlink error after mkdir"
12534 rmdir $DIR/$tdir/striped_dir/a
12535 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12536 error "nlink error after rmdir"
12538 rmdir $DIR/$tdir/striped_dir/b
12539 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12540 error "nlink error after rmdir"
12542 rmdir $DIR/$tdir/striped_dir ||
12543 error "rmdir striped dir error"
12548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12549 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12551 test_striped_dir 0 || error "failed on striped dir on MDT0"
12552 test_striped_dir 1 || error "failed on striped dir on MDT0"
12554 run_test 300a "basic striped dir sanity test"
12557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12558 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12564 test_mkdir $DIR/$tdir || error "mkdir fail"
12565 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12566 error "set striped dir error"
12567 for ((i=0; i<10; i++)); do
12568 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12570 touch $DIR/$tdir/striped_dir/file_$i ||
12571 error "touch error $i"
12572 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12573 [ $mtime1 -eq $mtime2 ] &&
12574 error "mtime not change after create"
12576 rm -f $DIR/$tdir/striped_dir/file_$i ||
12577 error "unlink error $i"
12578 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12579 [ $mtime2 -eq $mtime3 ] &&
12580 error "mtime did not change after unlink"
12584 run_test 300b "check ctime/mtime for striped dir"
12587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12588 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12591 mkdir -p $DIR/$tdir
12592 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12593 error "set striped dir error"
12595 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12596 error "chown striped dir failed"
12598 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12599 error "create 5k files failed"
12601 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12603 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12607 run_test 300c "chown && check ls under striped directory"
12610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12611 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12615 mkdir -p $DIR/$tdir
12616 $SETSTRIPE -c 2 $DIR/$tdir
12618 #local striped directory
12619 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12620 error "set striped dir error"
12621 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12622 error "create 10 files failed"
12624 #remote striped directory
12625 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12626 error "set striped dir error"
12627 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12628 error "create 10 files failed"
12630 for file in $(find $DIR/$tdir); do
12631 stripe_count=$($GETSTRIPE -c $file)
12632 [ $stripe_count -eq 2 ] ||
12633 error "wrong stripe $stripe_count for $file"
12638 run_test 300d "check default stripe under striped directory"
12641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12646 mkdir -p $DIR/$tdir
12648 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12649 error "set striped dir error"
12651 touch $DIR/$tdir/striped_dir/a
12652 touch $DIR/$tdir/striped_dir/b
12653 touch $DIR/$tdir/striped_dir/c
12655 mkdir $DIR/$tdir/striped_dir/dir_a
12656 mkdir $DIR/$tdir/striped_dir/dir_b
12657 mkdir $DIR/$tdir/striped_dir/dir_c
12659 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12660 error "set striped dir under striped dir error"
12662 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12663 error "set striped dir under striped dir error"
12665 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12666 error "set striped dir under striped dir error"
12668 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12669 error "rename file under striped dir should fail"
12671 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12672 error "rename dir under striped dir should fail"
12674 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12675 error "rename dir under different stripes should fail"
12677 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12678 error "rename file under striped dir should succeed"
12680 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12681 error "rename dir under striped dir should succeed"
12685 run_test 300e "check rename under striped directory"
12688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12689 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12694 mkdir -p $DIR/$tdir
12696 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12697 error "set striped dir error"
12699 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12700 error "set striped dir error"
12702 touch $DIR/$tdir/striped_dir/a
12703 mkdir $DIR/$tdir/striped_dir/dir_a
12704 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12705 error "create striped dir under striped dir fails"
12707 touch $DIR/$tdir/striped_dir1/b
12708 mkdir $DIR/$tdir/striped_dir1/dir_b
12709 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12710 error "create striped dir under striped dir fails"
12712 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12713 error "rename file under different striped dir should fail"
12715 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12716 error "rename dir under different striped dir should fail"
12718 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12719 error "rename striped dir under diff striped dir should fail"
12721 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12722 error "rename file under diff striped dirs fails"
12724 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12725 error "rename dir under diff striped dirs fails"
12729 run_test 300f "check rename cross striped directory"
12732 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12737 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12738 $DIR/$tdir/striped_dir ||
12739 error "set striped dir error"
12741 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12742 error "set default stripe on striped dir error"
12744 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12746 for dir in $(find $DIR/$tdir/striped_dir/*); do
12747 stripe_count=$($LFS getdirstripe -c $dir)
12748 [ $stripe_count -eq $MDSCOUNT ] ||
12749 error "expect $MDSCOUNT get $stripe_count for $dir"
12752 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12753 #change default stripe count to 2
12754 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12755 error "set default stripe on striped dir error"
12757 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12759 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12761 #change default stripe count to 1
12762 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12763 error "set default stripe on striped dir error"
12765 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12766 for dir in $(find $DIR/$tdir/striped_dir/*); do
12767 stripe_count=$($LFS getdirstripe -c $dir)
12768 [ $stripe_count -eq 1 ] ||
12769 error "expect 1 get $stripe_count for $dir"
12771 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12773 run_test 300g "check default striped directory for striped directory"
12776 # tests that do cleanup/setup should be run at the end
12780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12782 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12783 $LCTL set_param fail_loc=0x903
12784 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12785 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12788 FAIL_ON_ERROR=true cleanup
12789 FAIL_ON_ERROR=true setup
12791 run_test 900 "umount should not race with any mgc requeue thread"
12794 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12795 check_and_cleanup_lustre
12796 if [ "$I_MOUNTED" != "yes" ]; then
12797 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true