2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
42 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
43 CREATETEST=${CREATETEST:-createtest}
45 LFIND=${LFIND:-"$LFS find"}
46 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
48 MCREATE=${MCREATE:-mcreate}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
59 UMOUNT=${UMOUNT:-"umount -d"}
61 CHECK_GRANT=${CHECK_GRANT:-"yes"}
62 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
63 export PARALLEL=${PARALLEL:-"no"}
65 export NAME=${NAME:-local}
72 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
73 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
74 . $LUSTRE/tests/test-framework.sh
76 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
81 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
82 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
89 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
90 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
99 check_kernel_version() {
101 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
103 patchless|patchless_client) return 0;;
104 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
106 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
110 check_swap_layouts_support()
112 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
113 { skip "Does not support layout lock."; return 0; }
117 if [ "$ONLY" == "cleanup" ]; then
122 check_and_setup_lustre
127 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
128 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
129 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
130 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
131 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
132 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
133 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
134 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
136 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
137 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
138 rm -rf $DIR/[Rdfs][0-9]*
140 # $RUNAS_ID may get set incorrectly somewhere else
141 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
143 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
147 if [ "${ONLY}" = "MOUNT" ] ; then
148 echo "Lustre is up, please go on"
152 echo "preparing for tests involving mounts"
153 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
155 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
156 echo # add a newline after mke2fs.
160 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
161 lctl set_param debug=-1 2> /dev/null || true
164 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
166 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
168 run_test 0a "touch; rm ====================="
171 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
172 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
174 run_test 0b "chmod 0755 $DIR ============================="
177 $LCTL get_param mdc.*.import | grep "state: FULL" ||
178 error "import not FULL"
179 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
182 run_test 0c "check import proc ============================="
185 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
186 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
187 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
188 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
191 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
193 run_test 1 "mkdir; remkdir; rmdir =============================="
196 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
197 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
198 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
200 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
202 run_test 2 "mkdir; touch; rmdir; check file ===================="
205 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
206 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
207 touch $DIR/$tdir/$tfile
208 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
210 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
212 run_test 3 "mkdir; touch; rmdir; check dir ====================="
214 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
218 test_mkdir $DIR/$tdir ||
219 error "Create remote directory failed"
221 touch $DIR/$tdir/$tfile ||
222 error "Create file under remote directory failed"
225 error "Expect error removing in-use dir $DIR/$tdir"
227 test -d $DIR/$tdir || error "Remote directory disappeared"
229 rm -rf $DIR/$tdir || error "remove remote dir error"
231 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
234 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
235 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
236 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
237 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
238 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
240 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
243 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
244 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
245 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
246 error "$tfile does not have perm 0666 or UID $UID"
247 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
248 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
249 error "$tfile should be 0666 and owned by UID $UID"
251 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
254 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
256 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
257 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
258 error "$tfile should be owned by UID $RUNAS_ID"
259 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
260 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
261 error "$tfile should be owned by UID $RUNAS_ID"
263 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
266 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
268 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
269 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
270 error "$tfile should be owned by GID $UID"
271 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
272 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
273 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
275 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
278 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
279 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
280 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
281 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
282 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
283 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
284 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
285 error "$tdir/d/subdir should be GID $RUNAS_GID"
287 run_test 6g "Is new dir in sgid dir inheriting group?"
289 test_6h() { # bug 7331
290 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
291 touch $DIR/$tfile || error "touch failed"
292 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
293 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
294 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
295 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
296 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
298 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
301 test_mkdir $DIR/$tdir
302 $MCREATE $DIR/$tdir/$tfile
303 chmod 0666 $DIR/$tdir/$tfile
304 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
305 error "$tdir/$tfile should be mode 0666"
307 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
310 if [ ! -d $DIR/$tdir ]; then
313 $MCREATE $DIR/$tdir/$tfile
314 echo -n foo > $DIR/$tdir/$tfile
315 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
316 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
318 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
321 test_mkdir $DIR/$tdir
322 touch $DIR/$tdir/$tfile
323 chmod 0666 $DIR/$tdir/$tfile
324 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
325 error "$tfile mode not 0666"
327 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
330 test_mkdir $DIR/$tdir
331 test_mkdir $DIR/$tdir/d2
332 test_mkdir $DIR/$tdir/d2/d3
333 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
335 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
338 test_mkdir $DIR/$tdir
339 test_mkdir $DIR/$tdir/d2
340 touch $DIR/$tdir/d2/$tfile
341 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
342 error "$tdir/d2/$tfile not a file"
344 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
347 test_mkdir $DIR/$tdir
348 test_mkdir $DIR/$tdir/d2
349 chmod 0666 $DIR/$tdir/d2
350 chmod 0705 $DIR/$tdir/d2
351 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
352 error "$tdir/d2 mode not 0705"
354 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
357 test_mkdir $DIR/$tdir
358 touch $DIR/$tdir/$tfile
359 chmod 0666 $DIR/$tdir/$tfile
360 chmod 0654 $DIR/$tdir/$tfile
361 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
362 error "$tdir/d2 mode not 0654"
364 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
367 test_mkdir $DIR/$tdir
368 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
370 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
371 error "$tdir/$tfile size not 0 after truncate"
373 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
376 test_mkdir $DIR/$tdir
377 touch $DIR/$tdir/$tfile
379 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
381 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
384 test_mkdir $DIR/$tdir
385 touch $DIR/$tdir/$tfile
386 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
387 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
388 error "$tdir/${tfile_2} not a file after rename"
390 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
395 rm -rf $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
398 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 test_mkdir -p $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
405 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
406 error "$tdir/l-exist not a symlink"
407 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
408 error "$tdir/l-exist not referencing a file"
409 rm -f $DIR/$tdir/l-exist
410 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
412 run_test 17a "symlinks: create, remove (real) =================="
415 test_mkdir -p $DIR/$tdir
416 ln -s no-such-file $DIR/$tdir/l-dangle
418 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
419 error "$tdir/l-dangle not referencing no-such-file"
420 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
421 error "$tdir/l-dangle not referencing non-existent file"
422 rm -f $DIR/$tdir/l-dangle
423 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
425 run_test 17b "symlinks: create, remove (dangling) =============="
427 test_17c() { # bug 3440 - don't save failed open RPC for replay
428 test_mkdir -p $DIR/$tdir
429 ln -s foo $DIR/$tdir/$tfile
430 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
432 run_test 17c "symlinks: open dangling (should return error) ===="
435 test_mkdir -p $DIR/$tdir
436 ln -s foo $DIR/$tdir/$tfile
437 touch $DIR/$tdir/$tfile || error "creating to new symlink"
439 run_test 17d "symlinks: create dangling ========================"
442 test_mkdir -p $DIR/$tdir
443 local foo=$DIR/$tdir/$tfile
444 ln -s $foo $foo || error "create symlink failed"
445 ls -l $foo || error "ls -l failed"
446 ls $foo && error "ls not failed" || true
448 run_test 17e "symlinks: create recursive symlink (should return error) ===="
451 test_mkdir -p $DIR/$tdir
452 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
456 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
457 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
460 run_test 17f "symlinks: long and very long symlink name ========================"
462 # str_repeat(S, N) generate a string that is string S repeated N times
467 while [ $((n -= 1)) -ge 0 ]; do
473 # Long symlinks and LU-2241
475 test_mkdir -p $DIR/$tdir
476 local TESTS="59 60 61 4094 4095"
478 # Fix for inode size boundary in 2.1.4
479 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
482 # Patch not applied to 2.2 or 2.3 branches
483 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
484 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
487 # skip long symlink name for rhel6.5.
488 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
489 grep -q '6.5' /etc/redhat-release &>/dev/null &&
490 TESTS="59 60 61 4062 4063"
493 local SYMNAME=$(str_repeat 'x' $i)
494 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
495 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
498 run_test 17g "symlinks: really long symlink name and inode boundaries"
500 test_17h() { #bug 17378
501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
504 test_mkdir -p $DIR/$tdir
505 if [[ $MDSCOUNT -gt 1 ]]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 $SETSTRIPE -c -1 $DIR/$tdir
511 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
513 touch $DIR/$tdir/$tfile || true
515 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
517 test_17i() { #bug 20018
518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
520 test_mkdir -c1 $DIR/$tdir
521 local foo=$DIR/$tdir/$tfile
523 if [[ $MDSCOUNT -gt 1 ]]; then
524 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
528 ln -s $foo $foo || error "create symlink failed"
529 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
530 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
531 ls -l $foo && error "error not detected"
534 run_test 17i "don't panic on short symlink"
536 test_17k() { #bug 22301
537 [[ -z "$(which rsync 2>/dev/null)" ]] &&
538 skip "no rsync command" && return 0
539 rsync --help | grep -q xattr ||
540 skip_env "$(rsync --version | head -n1) does not support xattrs"
541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
542 test_mkdir -p $DIR/$tdir
543 test_mkdir -p $DIR/$tdir.new
544 touch $DIR/$tdir/$tfile
545 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
546 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
547 error "rsync failed with xattrs enabled"
549 run_test 17k "symlinks: rsync with xattrs enabled ========================="
551 test_17l() { # LU-279
552 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
553 skip "no getfattr command" && return 0
555 touch $DIR/$tdir/$tfile
556 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
557 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
558 # -h to not follow symlinks. -m '' to list all the xattrs.
559 # grep to remove first line: '# file: $path'.
560 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
562 lgetxattr_size_check $path $xattr ||
563 error "lgetxattr_size_check $path $xattr failed"
567 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
571 local short_sym="0123456789"
572 local WDIR=$DIR/${tdir}m
579 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
580 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
581 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
583 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
584 skip "only for ldiskfs MDT" && return 0
586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
590 # create a long symlink file
591 for ((i = 0; i < 4; ++i)); do
592 long_sym=${long_sym}${long_sym}
595 echo "create 512 short and long symlink files under $WDIR"
596 for ((i = 0; i < 256; ++i)); do
597 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
598 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
604 wait_delete_completed
606 echo "recreate the 512 symlink files with a shorter string"
607 for ((i = 0; i < 512; ++i)); do
608 # rewrite the symlink file with a shorter string
609 ln -sf ${long_sym} $WDIR/long-$i
610 ln -sf ${short_sym} $WDIR/short-$i
613 mds_index=$($LFS getstripe -M $WDIR)
614 mds_index=$((mds_index+1))
615 devname=$(mdsdevname $mds_index)
616 cmd="$E2FSCK -fnvd $devname"
618 echo "stop and checking mds${mds_index}: $cmd"
619 # e2fsck should not return error
621 do_facet mds${mds_index} $cmd || rc=$?
623 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
624 df $MOUNT > /dev/null 2>&1
625 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
626 "short/long symlink MDT: rc=$rc"
629 run_test 17m "run e2fsck against MDT which contains short/long symlink"
631 check_fs_consistency_17n() {
637 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
638 # so it only check MDT1/MDT2 instead of all of MDTs.
639 for mdt_index in $(seq 1 2); do
640 devname=$(mdsdevname $mdt_index)
641 cmd="$E2FSCK -fnvd $devname"
643 echo "stop and checking mds${mdt_index}: $cmd"
644 # e2fsck should not return error
646 do_facet mds${mdt_index} $cmd || rc=$?
648 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
649 error "mount mds${mdt_index} failed"
650 df $MOUNT > /dev/null 2>&1
651 [ $rc -ne 0 ] && break
659 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
660 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
661 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
663 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
664 skip "only for ldiskfs MDT" && return 0
666 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
671 for ((i=0; i<10; i++)); do
672 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
673 error "create remote dir error $i"
674 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
675 error "create files under remote dir failed $i"
678 check_fs_consistency_17n ||
679 error "e2fsck report error after create files under remote dir"
681 for ((i=0;i<10;i++)); do
682 rm -rf $DIR/$tdir/remote_dir_${i} ||
683 error "destroy remote dir error $i"
686 check_fs_consistency_17n ||
687 error "e2fsck report error after unlink files under remote dir"
689 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
690 skip "lustre < 2.4.50 does not support migrate mv " && return
692 for ((i=0; i<10; i++)); do
693 mkdir -p $DIR/$tdir/remote_dir_${i}
694 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
695 error "create files under remote dir failed $i"
696 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
697 error "migrate remote dir error $i"
699 check_fs_consistency_17n || error "e2fsck report error after migration"
701 for ((i=0;i<10;i++)); do
702 rm -rf $DIR/$tdir/remote_dir_${i} ||
703 error "destroy remote dir error $i"
706 check_fs_consistency_17n || error "e2fsck report error after unlink"
708 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
711 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
712 skip "Need MDS version at least 2.3.64" && return
714 local WDIR=$DIR/${tdir}o
720 mdt_index=$($LFS getstripe -M $WDIR)
721 mdt_index=$((mdt_index+1))
722 mdtdevname=$(mdsdevname $mdt_index)
726 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
727 error "mount mds${mdt_index} failed"
729 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
730 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
731 ls -l $WDIR/$tfile && rc=1
732 do_facet mds${mdt_index} lctl set_param fail_loc=0
733 [[ $rc -ne 0 ]] && error "stat file should fail"
736 run_test 17o "stat file with incompat LMA feature"
739 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
740 ls $DIR || error "Failed to ls $DIR: $?"
742 run_test 18 "touch .../f ; ls ... =============================="
748 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
750 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
753 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
755 run_test 19b "ls -l .../f19 (should return error) =============="
758 [ $RUNAS_ID -eq $UID ] &&
759 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
760 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
762 run_test 19c "$RUNAS touch .../f19 (should return error) =="
765 cat $DIR/f19 && error || true
767 run_test 19d "cat .../f19 (should return error) =============="
779 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
781 run_test 20 "touch .../f ; ls -l ... ==========================="
784 test_mkdir -p $DIR/$tdir
785 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
786 ln -s dangle $DIR/$tdir/link
787 echo foo >> $DIR/$tdir/link
788 cat $DIR/$tdir/dangle
789 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
790 $CHECKSTAT -f -t file $DIR/$tdir/link ||
791 error "$tdir/link not linked to a file"
793 run_test 21 "write to dangling link ============================"
797 test_mkdir -p $DIR/$tdir
798 chown $RUNAS_ID:$RUNAS_GID $WDIR
799 (cd $WDIR || error "cd $WDIR failed";
800 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
802 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
803 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
804 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
806 run_test 22 "unpack tar archive as non-root user ==============="
810 test_mkdir -p $DIR/$tdir
811 local file=$DIR/$tdir/$tfile
813 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
814 openfile -f O_CREAT:O_EXCL $file &&
815 error "$file recreate succeeded" || true
817 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
819 test_23b() { # bug 18988
820 test_mkdir -p $DIR/$tdir
821 local file=$DIR/$tdir/$tfile
824 echo foo > $file || error "write filed"
825 echo bar >> $file || error "append filed"
826 $CHECKSTAT -s 8 $file || error "wrong size"
829 run_test 23b "O_APPEND check =========================="
833 echo '-- same directory rename'
834 test_mkdir $DIR/$tdir
835 touch $DIR/$tdir/$tfile.1
836 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
837 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
839 run_test 24a "rename file to non-existent target"
842 test_mkdir $DIR/$tdir
843 touch $DIR/$tdir/$tfile.{1,2}
844 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
845 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
846 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
848 run_test 24b "rename file to existing target"
851 test_mkdir $DIR/$tdir
852 test_mkdir $DIR/$tdir/d$testnum.1
853 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
854 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
855 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
857 run_test 24c "rename directory to non-existent target"
860 test_mkdir -c1 $DIR/$tdir
861 test_mkdir -c1 $DIR/$tdir/d$testnum.1
862 test_mkdir -c1 $DIR/$tdir/d$testnum.2
863 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
864 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
865 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
867 run_test 24d "rename directory to existing target"
870 echo '-- cross directory renames --'
874 mv $DIR/R5a/f $DIR/R5b/g
875 $CHECKSTAT -a $DIR/R5a/f || error
876 $CHECKSTAT -t file $DIR/R5b/g || error
878 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
883 touch $DIR/R6a/f $DIR/R6b/g
884 mv $DIR/R6a/f $DIR/R6b/g
885 $CHECKSTAT -a $DIR/R6a/f || error
886 $CHECKSTAT -t file $DIR/R6b/g || error
888 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
893 test_mkdir $DIR/R7a/d
894 mv $DIR/R7a/d $DIR/R7b/e
895 $CHECKSTAT -a $DIR/R7a/d || error
896 $CHECKSTAT -t dir $DIR/R7b/e || error
898 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
901 test_mkdir -c1 $DIR/R8a
902 test_mkdir -c1 $DIR/R8b
903 test_mkdir -c1 $DIR/R8a/d
904 test_mkdir -c1 $DIR/R8b/e
905 mrename $DIR/R8a/d $DIR/R8b/e
906 $CHECKSTAT -a $DIR/R8a/d || error
907 $CHECKSTAT -t dir $DIR/R8b/e || error
909 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
912 echo "-- rename error cases"
916 mrename $DIR/R9/f $DIR/R9/a
917 $CHECKSTAT -t file $DIR/R9/f || error
918 $CHECKSTAT -t dir $DIR/R9/a || error
919 $CHECKSTAT -a $DIR/R9/a/f || error
921 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
925 mrename $DIR/R10/f $DIR/R10/g
926 $CHECKSTAT -t dir $DIR/R10 || error
927 $CHECKSTAT -a $DIR/R10/f || error
928 $CHECKSTAT -a $DIR/R10/g || error
930 run_test 24j "source does not exist ============================"
934 test_mkdir $DIR/R11a/d
936 mv $DIR/R11a/f $DIR/R11a/d
937 $CHECKSTAT -a $DIR/R11a/f || error
938 $CHECKSTAT -t file $DIR/R11a/d/f || error
940 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
942 # bug 2429 - rename foo foo foo creates invalid file
945 $MULTIOP $f OcNs || error
947 run_test 24l "Renaming a file to itself ========================"
951 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
952 # on ext3 this does not remove either the source or target files
953 # though the "expected" operation would be to remove the source
954 $CHECKSTAT -t file ${f} || error "${f} missing"
955 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
957 run_test 24m "Renaming a file to a hard link to itself ========="
961 # this stats the old file after it was renamed, so it should fail
965 $CHECKSTAT ${f}.rename
968 run_test 24n "Statting the old file after renaming (Posix rename 2)"
971 check_kernel_version 37 || return 0
972 test_mkdir -p $DIR/d24o
973 rename_many -s random -v -n 10 $DIR/d24o
975 run_test 24o "rename of files during htree split ==============="
980 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
981 mrename $DIR/R12a $DIR/R12b
982 $CHECKSTAT -a $DIR/R12a || error
983 $CHECKSTAT -t dir $DIR/R12b || error
984 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
985 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
987 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
989 cleanup_multiop_pause() {
995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
998 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
999 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1002 trap cleanup_multiop_pause EXIT
1003 mrename $DIR/R13a $DIR/R13b
1004 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1005 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1006 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1007 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1008 cleanup_multiop_pause
1009 wait $MULTIPID || error "multiop close failed"
1011 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1013 test_24r() { #bug 3789
1014 test_mkdir $DIR/R14a
1015 test_mkdir $DIR/R14a/b
1016 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1017 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1018 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1020 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1023 test_mkdir $DIR/R15a
1024 test_mkdir $DIR/R15a/b
1025 test_mkdir $DIR/R15a/b/c
1026 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1027 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1028 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1030 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1032 test_mkdir $DIR/R16a
1033 test_mkdir $DIR/R16a/b
1034 test_mkdir $DIR/R16a/b/c
1035 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1036 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1037 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1039 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1041 test_24u() { # bug12192
1042 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1043 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1045 run_test 24u "create stripe file"
1051 simple_cleanup_common() {
1054 wait_delete_completed
1057 max_pages_per_rpc() {
1058 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1062 local NRFILES=100000
1063 local FREE_INODES=$(mdt_free_inodes 0)
1064 [[ $FREE_INODES -lt $NRFILES ]] &&
1065 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1069 trap simple_cleanup_common EXIT
1071 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1072 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1075 createmany -m $DIR/$tdir/$tfile $NRFILES
1077 cancel_lru_locks mdc
1078 lctl set_param mdc.*.stats clear
1080 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1082 # LU-5 large readdir
1083 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1084 # 8 bytes for name(filename is mostly 5 in this test) +
1085 # 8 bytes for luda_type
1086 # take into account of overhead in lu_dirpage header and end mark in
1087 # each page, plus one in RPC_NUM calculation.
1089 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1090 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1091 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1092 awk '/^mds_readpage/ {print $2}')
1093 [[ $mds_readpage -gt $RPC_NUM ]] &&
1094 error "large readdir doesn't take effect"
1096 simple_cleanup_common
1098 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1100 test_24w() { # bug21506
1102 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1103 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1104 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1105 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1106 [[ "$SZ1" -eq "$SZ2" ]] ||
1107 error "Error reading at the end of the file $tfile"
1109 run_test 24w "Reading a file larger than 4Gb"
1112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1115 local remote_dir=$DIR/$tdir/remote_dir
1118 $LFS mkdir -i $MDTIDX $remote_dir ||
1119 error "create remote directory failed"
1121 mkdir -p $DIR/$tdir/src_dir
1122 touch $DIR/$tdir/src_file
1123 mkdir -p $remote_dir/tgt_dir
1124 touch $remote_dir/tgt_file
1126 mrename $remote_dir $DIR/ &&
1127 error "rename dir cross MDT works!"
1129 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1130 error "rename dir cross MDT works!"
1132 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1133 error "rename file cross MDT works!"
1135 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1136 error "ln file cross MDT should not work!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24x "cross rename/link should be failed"
1143 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1146 local remote_dir=$DIR/$tdir/remote_dir
1149 $LFS mkdir -i $MDTIDX $remote_dir ||
1150 error "create remote directory failed"
1152 mkdir -p $remote_dir/src_dir
1153 touch $remote_dir/src_file
1154 mkdir -p $remote_dir/tgt_dir
1155 touch $remote_dir/tgt_file
1157 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1158 error "rename subdir in the same remote dir failed!"
1160 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1161 error "rename files in the same remote dir failed!"
1163 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1164 error "link files in the same remote dir failed!"
1166 rm -rf $DIR/$tdir || error "Can not delete directories"
1168 run_test 24y "rename/link on the same dir should succeed"
1171 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1174 local remote_src=$DIR/$tdir/remote_dir
1175 local remote_tgt=$DIR/$tdir/remote_tgt
1178 $LFS mkdir -i $MDTIDX $remote_src ||
1179 error "create remote directory failed"
1181 $LFS mkdir -i $MDTIDX $remote_tgt ||
1182 error "create remote directory failed"
1184 mrename $remote_src $remote_tgt &&
1185 error "rename remote dirs should not work!"
1187 # If target dir does not exists, it should succeed
1189 mrename $remote_src $remote_tgt ||
1190 error "rename remote dirs(tgt dir does not exists) failed!"
1192 rm -rf $DIR/$tdir || error "Can not delete directories"
1194 run_test 24z "rename one remote dir to another remote dir should fail"
1196 test_24A() { # LU-3182
1201 createmany -m $DIR/$tdir/$tfile $NFILES
1202 local t=$(ls $DIR/$tdir | wc -l)
1203 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1204 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1205 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1206 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1209 rm -rf $DIR/$tdir || error "Can not delete directories"
1211 run_test 24A "readdir() returns correct number of entries."
1213 test_24B() { # LU-4805
1214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1218 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1219 error "create striped dir failed"
1221 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1222 [ $count -eq 2 ] || error "Expected 2, got $count"
1224 touch $DIR/$tdir/striped_dir/a
1226 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1227 [ $count -eq 3 ] || error "Expected 3, got $count"
1229 touch $DIR/$tdir/striped_dir/.f
1231 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1232 [ $count -eq 4 ] || error "Expected 4, got $count"
1234 rm -rf $DIR/$tdir || error "Can not delete directories"
1236 run_test 24B "readdir for striped dir return correct number of entries"
1239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1245 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1246 error "create striped dir failed"
1248 cd $DIR/$tdir/d0/striped_dir
1250 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1251 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1252 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1254 [ "$d0_ino" = "$parent_ino" ] ||
1255 error ".. wrong, expect $d0_ino, get $parent_ino"
1257 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1258 error "mv striped dir failed"
1260 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1262 [ "$d1_ino" = "$parent_ino" ] ||
1263 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1265 run_test 24C "check .. in striped dir"
1268 echo '== symlink sanity ============================================='
1272 touch $DIR/s25/foo || error
1274 run_test 25a "create file in symlinked directory ==============="
1277 [ ! -d $DIR/d25 ] && test_25a
1278 $CHECKSTAT -t file $DIR/s25/foo || error
1280 run_test 25b "lookup file in symlinked directory ==============="
1284 test_mkdir $DIR/d26/d26-2
1285 ln -s d26/d26-2 $DIR/s26
1286 touch $DIR/s26/foo || error
1288 run_test 26a "multiple component symlink ======================="
1291 test_mkdir -p $DIR/d26b/d26-2
1292 ln -s d26b/d26-2/foo $DIR/s26-2
1293 touch $DIR/s26-2 || error
1295 run_test 26b "multiple component symlink at end of lookup ======"
1298 test_mkdir $DIR/d26.2
1299 touch $DIR/d26.2/foo
1300 ln -s d26.2 $DIR/s26.2-1
1301 ln -s s26.2-1 $DIR/s26.2-2
1302 ln -s s26.2-2 $DIR/s26.2-3
1303 chmod 0666 $DIR/s26.2-3/foo
1305 run_test 26c "chain of symlinks ================================"
1307 # recursive symlinks (bug 439)
1309 ln -s d26-3/foo $DIR/d26-3
1311 run_test 26d "create multiple component recursive symlink ======"
1314 [ ! -h $DIR/d26-3 ] && test_26d
1317 run_test 26e "unlink multiple component recursive symlink ======"
1319 # recursive symlinks (bug 7022)
1321 test_mkdir -p $DIR/$tdir
1322 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1323 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1324 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1325 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1326 cd $tfile || error "cd $tfile failed"
1327 ln -s .. dotdot || error "ln dotdot failed"
1328 ln -s dotdot/lndir lndir || error "ln lndir failed"
1329 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1330 output=`ls $tfile/$tfile/lndir/bar1`
1331 [ "$output" = bar1 ] && error "unexpected output"
1332 rm -r $tfile || error "rm $tfile failed"
1333 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1335 run_test 26f "rm -r of a directory which has recursive symlink ="
1338 echo '== stripe sanity =============================================='
1339 test_mkdir -p $DIR/d27 || error "mkdir failed"
1341 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1342 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1343 log "== test_27a: write to one stripe file ========================="
1344 cp /etc/hosts $DIR/d27/f0 || error
1346 run_test 27a "one stripe file =================================="
1349 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1350 test_mkdir -p $DIR/d27
1351 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1352 $GETSTRIPE -c $DIR/d27/f01
1353 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1354 error "two-stripe file doesn't have two stripes"
1356 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1358 run_test 27b "create and write to two stripe file"
1361 test_mkdir -p $DIR/d27
1362 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1363 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1364 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1366 run_test 27d "create file with default settings ================"
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1371 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1372 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1374 run_test 27e "setstripe existing file (should return error) ======"
1377 test_mkdir -p $DIR/d27
1378 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1379 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1380 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1382 run_test 27f "setstripe with bad stripe size (should return error)"
1385 test_mkdir -p $DIR/d27
1386 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1387 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1388 error "$DIR/d27/fnone has object"
1390 run_test 27g "$GETSTRIPE with no objects"
1393 touch $DIR/d27/fsome || error "touch failed"
1394 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1396 run_test 27i "$GETSTRIPE with some objects"
1399 test_mkdir -p $DIR/d27
1400 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1402 run_test 27j "setstripe with bad stripe offset (should return error)"
1404 test_27k() { # bug 2844
1405 test_mkdir -p $DIR/d27
1407 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1408 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1409 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1410 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1411 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1412 dd if=/dev/zero of=$FILE bs=4k count=1
1413 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1414 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1416 run_test 27k "limit i_blksize for broken user apps ============="
1419 test_mkdir -p $DIR/d27
1420 mcreate $DIR/f27l || error "creating file"
1421 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1422 error "setstripe should have failed" || true
1424 run_test 27l "check setstripe permissions (should return error)"
1427 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1429 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1430 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1433 trap simple_cleanup_common EXIT
1434 test_mkdir -p $DIR/$tdir
1435 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1436 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1437 error "dd should fill OST0"
1439 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1441 [ $i -gt 256 ] && break
1444 touch $DIR/$tdir/f27m_$i
1445 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1446 error "OST0 was full but new created file still use it"
1448 touch $DIR/$tdir/f27m_$i
1449 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1450 error "OST0 was full but new created file still use it"
1451 simple_cleanup_common
1453 run_test 27m "create file while OST0 was full =================="
1456 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1460 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1461 # if the OST isn't full anymore.
1463 local OSTIDX=${1:-""}
1465 local list=$(comma_list $(osts_nodes))
1466 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1468 do_nodes $list lctl set_param fail_loc=0
1469 sync # initiate all OST_DESTROYs from MDS to OST
1473 exhaust_precreations() {
1476 local FAILIDX=${3:-$OSTIDX}
1478 test_mkdir -p $DIR/$tdir
1479 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1480 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1482 local OST=$(ostname_from_index $OSTIDX)
1483 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1484 sed -e 's/_UUID$//;s/^.*-//')
1487 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1488 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1489 osc.$mdtosc_proc1.prealloc_last_id)
1490 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1491 osc.$mdtosc_proc1.prealloc_next_id)
1493 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1494 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1496 test_mkdir -p $DIR/$tdir/${OST}
1497 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1498 #define OBD_FAIL_OST_ENOSPC 0x215
1499 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1500 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1501 echo "Creating to objid $last_id on ost $OST..."
1502 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1503 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1504 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1508 exhaust_all_precreations() {
1510 for (( i=0; i < OSTCOUNT; i++ )) ; do
1511 exhaust_precreations $i $1 -1
1516 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1519 remote_ost_nodsh && skip "remote OST with nodsh" && return
1522 rm -f $DIR/$tdir/$tfile
1523 exhaust_precreations 0 0x80000215
1524 $SETSTRIPE -c -1 $DIR/$tdir
1525 touch $DIR/$tdir/$tfile || error
1526 $GETSTRIPE $DIR/$tdir/$tfile
1529 run_test 27n "create file with some full OSTs =================="
1532 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1534 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1535 remote_ost_nodsh && skip "remote OST with nodsh" && return
1538 rm -f $DIR/$tdir/$tfile
1539 exhaust_all_precreations 0x215
1541 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1546 run_test 27o "create file with all full OSTs (should error) ===="
1549 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1551 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1552 remote_ost_nodsh && skip "remote OST with nodsh" && return
1555 rm -f $DIR/$tdir/$tfile
1556 test_mkdir -p $DIR/$tdir
1558 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1559 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1560 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1562 exhaust_precreations 0 0x80000215
1563 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1564 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1565 $GETSTRIPE $DIR/$tdir/$tfile
1569 run_test 27p "append to a truncated file with some full OSTs ==="
1572 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1575 remote_ost_nodsh && skip "remote OST with nodsh" && return
1578 rm -f $DIR/$tdir/$tfile
1580 test_mkdir -p $DIR/$tdir
1581 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1582 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1583 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1585 exhaust_all_precreations 0x215
1587 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1588 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1592 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1595 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1597 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1598 remote_ost_nodsh && skip "remote OST with nodsh" && return
1601 rm -f $DIR/$tdir/$tfile
1602 exhaust_precreations 0 0x80000215
1604 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1608 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1610 test_27s() { # bug 10725
1611 test_mkdir -p $DIR/$tdir
1612 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1613 local stripe_count=0
1614 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1615 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1616 error "stripe width >= 2^32 succeeded" || true
1619 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1621 test_27t() { # bug 10864
1626 $WLFS getstripe $tfile
1629 run_test 27t "check that utils parse path correctly"
1631 test_27u() { # bug 4900
1632 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1633 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1635 local list=$(comma_list $(mdts_nodes))
1637 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1638 do_nodes $list $LCTL set_param fail_loc=0x139
1639 test_mkdir -p $DIR/$tdir
1641 createmany -o $DIR/$tdir/t- 1000
1642 do_nodes $list $LCTL set_param fail_loc=0
1644 TLOG=$DIR/$tfile.getstripe
1645 $GETSTRIPE $DIR/$tdir > $TLOG
1646 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1647 unlinkmany $DIR/$tdir/t- 1000
1648 [[ $OBJS -gt 0 ]] &&
1649 error "$OBJS objects created on OST-0. See $TLOG" || pass
1651 run_test 27u "skip object creation on OSC w/o objects =========="
1653 test_27v() { # bug 4900
1654 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1656 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1657 remote_ost_nodsh && skip "remote OST with nodsh" && return
1659 exhaust_all_precreations 0x215
1662 test_mkdir -p $DIR/$tdir
1663 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1665 touch $DIR/$tdir/$tfile
1666 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1668 for (( i=1; i < OSTCOUNT; i++ )); do
1669 do_facet ost$i lctl set_param fail_loc=0x705
1671 local START=`date +%s`
1672 createmany -o $DIR/$tdir/$tfile 32
1674 local FINISH=`date +%s`
1675 local TIMEOUT=`lctl get_param -n timeout`
1676 local PROCESS=$((FINISH - START))
1677 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1678 error "$FINISH - $START >= $TIMEOUT / 2"
1679 sleep $((TIMEOUT / 2 - PROCESS))
1682 run_test 27v "skip object creation on slow OST ================="
1684 test_27w() { # bug 10997
1685 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1686 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1687 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1688 error "stripe size $size != 65536" || true
1689 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1690 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1692 run_test 27w "check $SETSTRIPE -S option"
1695 [[ $OSTCOUNT -lt 2 ]] &&
1696 skip_env "skipping multiple stripe count/offset test" && return
1698 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1699 for i in $(seq 1 $OSTCOUNT); do
1701 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1702 error "setstripe -c $i -i $offset failed"
1703 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1704 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1705 [ $count -ne $i ] && error "stripe count $count != $i" || true
1706 [ $index -ne $offset ] &&
1707 error "stripe offset $index != $offset" || true
1710 run_test 27wa "check $SETSTRIPE -c -i options"
1713 remote_ost_nodsh && skip "remote OST with nodsh" && return
1714 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1716 OFFSET=$(($OSTCOUNT - 1))
1718 local OST=$(ostname_from_index $OSTIDX)
1720 test_mkdir -p $DIR/$tdir
1721 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1722 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1724 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1725 for i in `seq 0 $OFFSET`; do
1726 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1727 error "OST0 was degraded but new created file still use it"
1729 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1731 run_test 27x "create files while OST0 is degraded"
1734 [[ $OSTCOUNT -lt 2 ]] &&
1735 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1736 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1737 remote_ost_nodsh && skip "remote OST with nodsh" && return
1738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1740 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1741 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1742 osc.$mdtosc.prealloc_last_id)
1743 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1744 osc.$mdtosc.prealloc_next_id)
1745 local fcount=$((last_id - next_id))
1746 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1747 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1749 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1750 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1751 local OST_DEACTIVE_IDX=-1
1756 for OSC in $MDS_OSCS; do
1757 OST=$(osc_to_ost $OSC)
1758 OSTIDX=$(index_from_ostuuid $OST)
1759 if [ $OST_DEACTIVE_IDX == -1 ]; then
1760 OST_DEACTIVE_IDX=$OSTIDX
1762 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1763 echo $OSC "is Deactivated:"
1764 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1768 OSTIDX=$(index_from_ostuuid $OST)
1770 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1772 for OSC in $MDS_OSCS; do
1773 OST=$(osc_to_ost $OSC)
1774 OSTIDX=$(index_from_ostuuid $OST)
1775 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1776 echo $OST "is degraded:"
1777 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1778 obdfilter.$OST.degraded=1
1783 createmany -o $DIR/$tdir/$tfile $fcount
1785 for OSC in $MDS_OSCS; do
1786 OST=$(osc_to_ost $OSC)
1787 OSTIDX=$(index_from_ostuuid $OST)
1788 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1789 echo $OST "is recovered from degraded:"
1790 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1791 obdfilter.$OST.degraded=0
1793 do_facet $SINGLEMDS lctl --device %$OSC activate
1797 # all osp devices get activated, hence -1 stripe count restored
1800 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1801 # devices get activated.
1803 $SETSTRIPE -c -1 $DIR/$tfile
1804 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1806 [ $stripecnt -ne $OSTCOUNT ] &&
1807 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1810 run_test 27y "create files while OST0 is degraded and the rest inactive"
1816 lmm_count=$($GETSTRIPE -c $1)
1817 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1818 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1820 local old_ifs="$IFS"
1822 fid=($($LFS path2fid $1))
1825 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1826 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1828 # compare lmm_seq and lu_fid->f_seq
1829 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1830 # compare lmm_object_id and lu_fid->oid
1831 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1833 # check the trusted.fid attribute of the OST objects of the file
1834 local have_obdidx=false
1836 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1837 # skip lines up to and including "obdidx"
1838 [ -z "$obdidx" ] && break
1839 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1840 $have_obdidx || continue
1842 local ost=$((obdidx + 1))
1843 local dev=$(ostdevname $ost)
1846 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1848 seq=$(echo $seq | sed -e "s/^0x//g")
1849 if [ $seq == 0 ]; then
1850 oid_hex=$(echo $oid)
1852 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1854 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1858 # Don't unmount/remount the OSTs if we don't need to do that.
1859 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1860 # update too, until that use mount/ll_decode_filter_fid/mount.
1861 # Re-enable when debugfs will understand new filter_fid.
1863 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1864 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1865 $dev 2>/dev/null" | grep "parent=")
1868 mount_fstype ost$ost
1869 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1870 $(facet_mntpt ost$ost)/$obj_file)
1871 unmount_fstype ost$ost
1872 start ost$ost $dev $OST_MOUNT_OPTS
1875 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1877 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1879 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1880 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1881 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1882 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1883 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1885 if echo $ff_parent | grep -q 'stripe='; then
1886 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1889 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1890 # into f_ver in this case. See the comment on
1893 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1897 # compare lmm_seq and filter_fid->ff_parent.f_seq
1898 [ $ff_pseq = $lmm_seq ] ||
1899 error "FF parent SEQ $ff_pseq != $lmm_seq"
1900 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1901 [ $ff_poid = $lmm_oid ] ||
1902 error "FF parent OID $ff_poid != $lmm_oid"
1903 (($ff_pstripe == $stripe_nr)) ||
1904 error "FF stripe $ff_pstripe != $stripe_nr"
1906 stripe_nr=$((stripe_nr + 1))
1911 remote_ost_nodsh && skip "remote OST with nodsh" && return
1912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1913 test_mkdir -p $DIR/$tdir
1915 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1916 { error "setstripe -c -1 failed"; return 1; }
1917 # We need to send a write to every object to get parent FID info set.
1918 # This _should_ also work for setattr, but does not currently.
1919 # touch $DIR/$tdir/$tfile-1 ||
1920 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1921 { error "dd $tfile-1 failed"; return 2; }
1922 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1923 { error "setstripe -c -1 failed"; return 3; }
1924 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1925 { error "dd $tfile-2 failed"; return 4; }
1927 # make sure write RPCs have been sent to OSTs
1930 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1931 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1933 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1935 test_27A() { # b=19102
1936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1937 local restore_size=$($GETSTRIPE -S $MOUNT)
1938 local restore_count=$($GETSTRIPE -c $MOUNT)
1939 local restore_offset=$($GETSTRIPE -i $MOUNT)
1940 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1941 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1942 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1943 local default_size=$($GETSTRIPE -S $MOUNT)
1944 local default_offset=$($GETSTRIPE -i $MOUNT)
1945 local dsize=$((1024 * 1024))
1946 [ $default_size -eq $dsize ] ||
1947 error "stripe size $default_size != $dsize"
1948 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1949 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1951 run_test 27A "check filesystem-wide default LOV EA values"
1953 test_27B() { # LU-2523
1954 test_mkdir -p $DIR/$tdir
1955 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1957 # open f1 with O_LOV_DELAY_CREATE
1959 # call setstripe ioctl on open file descriptor for f1
1961 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1965 # open f1 with O_LOV_DELAY_CREATE
1967 # call setstripe ioctl on open file descriptor for f1
1969 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1971 # Allow multiop to fail in imitation of NFS's busted semantics.
1974 run_test 27B "call setstripe on open unlinked file/rename victim"
1976 test_27C() { #LU-2871
1977 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1985 test_mkdir -p $DIR/$tdir
1987 for i in $(seq 0 $((OSTCOUNT - 1))); do
1988 # set stripe across all OSTs starting from OST$i
1989 $SETSTRIPE -i $i -c -1 $tfile$i
1990 # get striping information
1991 ost_idx=($($GETSTRIPE $tfile$i |
1992 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1996 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1997 error "${#ost_idx[@]} != $OSTCOUNT"
1999 for index in $(seq 0 $((OSTCOUNT - 1))); do
2001 for j in $(echo ${ost_idx[@]}); do
2002 if [ $index -eq $j ]; then
2008 error "Can not find $index in ${ost_idx[@]}"
2012 run_test 27C "check full striping across all OSTs"
2014 # createtest also checks that device nodes are created and
2015 # then visible correctly (#2091)
2016 test_28() { # bug 2091
2018 $CREATETEST $DIR/d28/ct || error
2020 run_test 28 "create/mknod/mkdir with bad file types ============"
2023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2024 cancel_lru_locks mdc
2030 declare -i LOCKCOUNTORIG=0
2031 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2032 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2034 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2036 declare -i LOCKUNUSEDCOUNTORIG=0
2037 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2038 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2045 declare -i LOCKCOUNTCURRENT=0
2046 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2047 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2050 declare -i LOCKUNUSEDCOUNTCURRENT=0
2051 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2052 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2055 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2056 $LCTL set_param -n ldlm.dump_namespaces ""
2057 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2058 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2059 log "dumped log to $TMP/test_29.dk (bug 5793)"
2062 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2063 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2064 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2065 log "dumped log to $TMP/test_29.dk (bug 5793)"
2069 run_test 29 "IT_GETATTR regression ============================"
2071 test_30a() { # was test_30
2072 cp $(which ls) $DIR || cp /bin/ls $DIR
2076 run_test 30a "execute binary from Lustre (execve) =============="
2079 cp `which ls` $DIR || cp /bin/ls $DIR
2081 $RUNAS $DIR/ls / || error
2084 run_test 30b "execute binary from Lustre as non-root ==========="
2086 test_30c() { # b=22376
2087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2088 cp `which ls` $DIR || cp /bin/ls $DIR
2090 cancel_lru_locks mdc
2091 cancel_lru_locks osc
2092 $RUNAS $DIR/ls / || error
2095 run_test 30c "execute binary from Lustre without read perms ===="
2098 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2099 $CHECKSTAT -a $DIR/f31 || error
2101 run_test 31a "open-unlink file =================================="
2104 touch $DIR/f31 || error
2105 ln $DIR/f31 $DIR/f31b || error
2106 $MULTIOP $DIR/f31b Ouc || error
2107 $CHECKSTAT -t file $DIR/f31 || error
2109 run_test 31b "unlink file with multiple links while open ======="
2112 touch $DIR/f31 || error
2113 ln $DIR/f31 $DIR/f31c || error
2114 multiop_bg_pause $DIR/f31 O_uc || return 1
2116 $MULTIOP $DIR/f31c Ouc
2117 kill -USR1 $MULTIPID
2120 run_test 31c "open-unlink file with multiple links ============="
2123 opendirunlink $DIR/d31d $DIR/d31d || error
2124 $CHECKSTAT -a $DIR/d31d || error
2126 run_test 31d "remove of open directory ========================="
2128 test_31e() { # bug 2904
2129 check_kernel_version 34 || return 0
2130 openfilleddirunlink $DIR/d31e || error
2132 run_test 31e "remove of open non-empty directory ==============="
2134 test_31f() { # bug 4554
2135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2137 test_mkdir $DIR/d31f
2138 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2139 cp /etc/hosts $DIR/d31f
2141 $GETSTRIPE $DIR/d31f/hosts
2142 multiop_bg_pause $DIR/d31f D_c || return 1
2145 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2146 test_mkdir $DIR/d31f
2147 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2148 cp /etc/hosts $DIR/d31f
2150 $GETSTRIPE $DIR/d31f/hosts
2151 multiop_bg_pause $DIR/d31f D_c || return 1
2154 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2155 wait $MULTIPID || error "first opendir $MULTIPID failed"
2159 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2160 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2163 run_test 31f "remove of open directory with open-unlink file ==="
2166 echo "-- cross directory link --"
2167 test_mkdir -c1 $DIR/${tdir}ga
2168 test_mkdir -c1 $DIR/${tdir}gb
2169 touch $DIR/${tdir}ga/f
2170 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2171 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2172 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2173 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2174 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2176 run_test 31g "cross directory link==============="
2179 echo "-- cross directory link --"
2180 test_mkdir -c1 $DIR/${tdir}
2181 test_mkdir -c1 $DIR/${tdir}/dir
2182 touch $DIR/${tdir}/f
2183 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2184 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2185 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2186 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2187 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2189 run_test 31h "cross directory link under child==============="
2192 echo "-- cross directory link --"
2193 test_mkdir -c1 $DIR/$tdir
2194 test_mkdir -c1 $DIR/$tdir/dir
2195 touch $DIR/$tdir/dir/f
2196 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2197 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2198 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2199 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2200 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2202 run_test 31i "cross directory link under parent==============="
2205 test_mkdir -c1 -p $DIR/$tdir
2206 test_mkdir -c1 -p $DIR/$tdir/dir1
2207 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2208 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2209 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2210 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2213 run_test 31j "link for directory==============="
2216 test_mkdir -c1 -p $DIR/$tdir
2218 touch $DIR/$tdir/exist
2219 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2220 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2221 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2222 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2223 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2224 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2225 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2228 run_test 31k "link to file: the same, non-existing, dir==============="
2234 touch $DIR/d31m2/exist
2235 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2236 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2237 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2238 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2239 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2240 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2243 run_test 31m "link to file: the same, non-existing, dir==============="
2246 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2247 nlink=$(stat --format=%h $DIR/$tfile)
2248 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2250 local cmd="exec $fd<$DIR/$tfile"
2253 trap "eval $cmd" EXIT
2254 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2255 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2256 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2257 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2258 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2261 run_test 31n "check link count of unlinked file"
2264 local TEMPNAME=$(mktemp $1_XXXXXX)
2265 mlink $TEMPNAME $1 2> /dev/null &&
2266 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2270 test_31o() { # LU-2901
2272 for LOOP in $(seq 100); do
2273 rm -f $DIR/$tdir/$tfile*
2274 for THREAD in $(seq 8); do
2275 link_one $DIR/$tdir/$tfile.$LOOP &
2278 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2279 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2280 error "$LINKS duplicate links to $tfile.$LOOP" &&
2284 run_test 31o "duplicate hard links with same filename"
2287 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2290 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2291 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2293 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2294 error "open unlink test1 failed"
2295 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2296 error "open unlink test2 failed"
2298 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2299 error "test1 still exists"
2300 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2301 error "test2 still exists"
2303 run_test 31p "remove of open striped directory"
2305 cleanup_test32_mount() {
2307 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2312 echo "== more mountpoints and symlinks ================="
2313 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2314 trap cleanup_test32_mount EXIT
2315 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2316 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2317 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2318 cleanup_test32_mount
2320 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2324 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2325 trap cleanup_test32_mount EXIT
2326 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2327 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2328 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2329 cleanup_test32_mount
2331 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2335 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2336 trap cleanup_test32_mount EXIT
2337 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2338 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2339 test_mkdir -p $DIR/$tdir/d2/test_dir
2340 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2341 cleanup_test32_mount
2343 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2347 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2348 trap cleanup_test32_mount EXIT
2349 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2350 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2351 test_mkdir -p $DIR/$tdir/d2/test_dir
2352 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2353 cleanup_test32_mount
2355 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2358 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2359 test_mkdir -p $DIR/d32e/tmp
2360 TMP_DIR=$DIR/d32e/tmp
2361 ln -s $DIR/d32e $TMP_DIR/symlink11
2362 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2363 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2364 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2366 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2369 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2370 test_mkdir -p $DIR/d32f/tmp
2371 TMP_DIR=$DIR/d32f/tmp
2372 ln -s $DIR/d32f $TMP_DIR/symlink11
2373 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2374 ls $DIR/d32f/tmp/symlink11 || error
2375 ls $DIR/d32f/symlink01 || error
2377 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2380 TMP_DIR=$DIR/$tdir/tmp
2381 test_mkdir -p $DIR/$tdir/tmp
2382 test_mkdir $DIR/${tdir}2
2383 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2384 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2385 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2386 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2387 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2388 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2390 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2393 rm -fr $DIR/$tdir $DIR/${tdir}2
2394 TMP_DIR=$DIR/$tdir/tmp
2395 test_mkdir -p $DIR/$tdir/tmp
2396 test_mkdir $DIR/${tdir}2
2397 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2398 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2399 ls $TMP_DIR/symlink12 || error
2400 ls $DIR/$tdir/symlink02 || error
2402 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2406 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2407 trap cleanup_test32_mount EXIT
2408 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2409 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2410 touch $DIR/$tdir/test_file
2411 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2412 cleanup_test32_mount
2414 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2418 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2419 trap cleanup_test32_mount EXIT
2420 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2421 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2422 touch $DIR/$tdir/test_file
2423 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2424 cleanup_test32_mount
2426 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2431 trap cleanup_test32_mount EXIT
2432 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2433 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2434 test_mkdir -p $DIR/$tdir/d2
2435 touch $DIR/$tdir/d2/test_file || error
2436 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2437 cleanup_test32_mount
2439 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2444 trap cleanup_test32_mount EXIT
2445 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2446 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2447 test_mkdir -p $DIR/$tdir/d2
2448 touch $DIR/$tdir/d2/test_file
2449 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2450 cleanup_test32_mount
2452 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2456 test_mkdir -p $DIR/d32m/tmp
2457 TMP_DIR=$DIR/d32m/tmp
2458 ln -s $DIR $TMP_DIR/symlink11
2459 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2460 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2461 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2463 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2467 test_mkdir -p $DIR/d32n/tmp
2468 TMP_DIR=$DIR/d32n/tmp
2469 ln -s $DIR $TMP_DIR/symlink11
2470 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2471 ls -l $DIR/d32n/tmp/symlink11 || error
2472 ls -l $DIR/d32n/symlink01 || error
2474 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2478 test_mkdir -p $DIR/d32o/tmp
2479 TMP_DIR=$DIR/d32o/tmp
2480 ln -s $DIR/$tfile $TMP_DIR/symlink12
2481 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2482 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2483 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2484 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2485 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2487 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2497 test_mkdir -p $DIR/d32p/tmp
2499 TMP_DIR=$DIR/d32p/tmp
2501 ln -s $DIR/$tfile $TMP_DIR/symlink12
2503 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2505 cat $DIR/d32p/tmp/symlink12 || error
2507 cat $DIR/d32p/symlink02 || error
2510 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2512 cleanup_testdir_mount() {
2514 $UMOUNT -d $DIR/$tdir
2518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2519 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2520 trap cleanup_testdir_mount EXIT
2521 test_mkdir -p $DIR/$tdir
2522 touch $DIR/$tdir/under_the_mount
2523 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2524 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2525 cleanup_testdir_mount
2527 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2531 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2532 trap cleanup_testdir_mount EXIT
2533 test_mkdir -p $DIR/$tdir
2534 touch $DIR/$tdir/under_the_mount
2535 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2536 ls $DIR/$tdir | grep -q under_the_mount && error || true
2537 cleanup_testdir_mount
2539 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2544 chmod 444 $DIR/$tfile
2545 chown $RUNAS_ID $DIR/$tfile
2547 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2550 run_test 33aa "write file with mode 444 (should return error) ===="
2554 test_mkdir -p $DIR/d33
2555 chown $RUNAS_ID $DIR/d33
2556 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2557 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2558 error "open RDWR" || true
2560 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2564 test_mkdir -p $DIR/d33
2565 chown $RUNAS_ID $DIR/d33
2566 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2568 run_test 33b "test open file with malformed flags (No panic)"
2571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2577 remote_ost_nodsh && skip "remote OST with nodsh" && return
2580 test_mkdir -p $DIR/d33
2581 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2584 for ostnum in $(seq $OSTCOUNT); do
2585 # test-framework's OST numbering is one-based, while Lustre's
2587 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2588 # Parsing llobdstat's output sucks; we could grep the /proc
2589 # path, but that's likely to not be as portable as using the
2590 # llobdstat utility. So we parse lctl output instead.
2591 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2592 obdfilter/$ostname/stats |
2593 awk '/^write_bytes/ {print $7}' )
2594 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2595 if (( ${write_bytes:-0} > 0 ))
2602 $all_zeros || return 0
2605 echo foo > $DIR/d33/bar
2609 # Total up write_bytes after writing. We'd better find non-zeros.
2610 for ostnum in $(seq $OSTCOUNT); do
2611 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2612 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2613 obdfilter/$ostname/stats |
2614 awk '/^write_bytes/ {print $7}' )
2615 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2616 if (( ${write_bytes:-0} > 0 ))
2625 for ostnum in $(seq $OSTCOUNT); do
2626 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2627 echo "Check that write_bytes is present in obdfilter/*/stats:"
2628 do_facet ost$ostnum lctl get_param -n \
2629 obdfilter/$ostname/stats
2631 error "OST not keeping write_bytes stats (b22312)"
2634 run_test 33c "test llobdstat and write_bytes"
2637 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2640 local remote_dir=$DIR/$tdir/remote_dir
2643 $LFS mkdir -i $MDTIDX $remote_dir ||
2644 error "create remote directory failed"
2646 touch $remote_dir/$tfile
2647 chmod 444 $remote_dir/$tfile
2648 chown $RUNAS_ID $remote_dir/$tfile
2650 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2652 chown $RUNAS_ID $remote_dir
2653 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2654 error "create" || true
2655 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2656 error "open RDWR" || true
2657 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2658 error "create" || true
2660 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2663 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2667 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2668 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2669 mkdir $DIR/$tdir/local_dir
2671 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2672 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2673 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2675 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2676 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2678 rmdir $DIR/$tdir/* || error "rmdir failed"
2681 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2682 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2683 mkdir $DIR/$tdir/local_dir
2685 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2686 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2687 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2689 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2690 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2692 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2695 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2696 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2697 mkdir $DIR/$tdir/local_dir
2699 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2700 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2701 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2703 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2704 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2706 run_test 33e "mkdir and striped directory should have same mode"
2708 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2711 $MCREATE $DIR/f34 || error
2712 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2713 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2714 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2715 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2717 run_test 34a "truncate file that has not been opened ==========="
2720 [ ! -f $DIR/f34 ] && test_34a
2721 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2722 $OPENFILE -f O_RDONLY $DIR/f34
2723 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2724 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2726 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2729 [ ! -f $DIR/f34 ] && test_34a
2730 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2731 $OPENFILE -f O_RDWR $DIR/f34
2732 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2733 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2735 run_test 34c "O_RDWR opening file-with-size works =============="
2738 [ ! -f $DIR/f34 ] && test_34a
2739 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2740 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2743 run_test 34d "write to sparse file ============================="
2747 $MCREATE $DIR/f34e || error
2748 $TRUNCATE $DIR/f34e 1000 || error
2749 $CHECKSTAT -s 1000 $DIR/f34e || error
2750 $OPENFILE -f O_RDWR $DIR/f34e
2751 $CHECKSTAT -s 1000 $DIR/f34e || error
2753 run_test 34e "create objects, some with size and some without =="
2755 test_34f() { # bug 6242, 6243
2756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2759 $MCREATE $DIR/f34f || error
2760 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2761 dd if=$DIR/f34f of=$TMP/f34f
2762 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2763 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2764 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2765 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2766 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2768 run_test 34f "read from a file with no objects until EOF ======="
2771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2772 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2773 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2774 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2775 cancel_lru_locks osc
2776 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2777 error "wrong size after lock cancel"
2779 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2780 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2781 error "expanding truncate failed"
2782 cancel_lru_locks osc
2783 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2784 error "wrong expanded size after lock cancel"
2786 run_test 34g "truncate long file ==============================="
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2793 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2794 sync # Flush the cache so that multiop below does not block on cache
2795 # flush when getting the group lock
2796 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2799 # Since just timed wait is not good enough, let's do a sync write
2800 # that way we are sure enough time for a roundtrip + processing
2801 # passed + 2 seconds of extra margin.
2802 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2806 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2807 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2811 local nsz=`stat -c %s $DIR/$tfile`
2812 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2814 run_test 34h "ftruncate file under grouplock should not block"
2817 cp /bin/sh $DIR/f35a
2819 chown $RUNAS_ID $DIR/f35a
2820 $RUNAS $DIR/f35a && error || true
2823 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2827 utime $DIR/f36 || error
2829 run_test 36a "MDS utime check (mknod, utime) ==================="
2833 utime $DIR/f36 || error
2835 run_test 36b "OST utime check (open, utime) ===================="
2840 chown $RUNAS_ID $DIR/d36
2841 $RUNAS utime $DIR/d36/f36 || error
2843 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2846 [ ! -d $DIR/d36 ] && test_36c
2847 echo "" > $DIR/d36/f36
2848 $RUNAS utime $DIR/d36/f36 || error
2850 run_test 36d "non-root OST utime check (open, utime) ==========="
2853 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2854 test_mkdir -p $DIR/$tdir
2855 touch $DIR/$tdir/$tfile
2856 $RUNAS utime $DIR/$tdir/$tfile && \
2857 error "utime worked, expected failure" || true
2859 run_test 36e "utime on non-owned file (should return error) ===="
2863 local LANG_SAVE=$LANG
2864 local LC_LANG_SAVE=$LC_LANG
2865 export LANG=C LC_LANG=C # for date language
2867 DATESTR="Dec 20 2000"
2868 test_mkdir -p $DIR/$tdir
2869 lctl set_param fail_loc=$fl
2871 cp /etc/hosts $DIR/$tdir/$tfile
2872 sync & # write RPC generated with "current" inode timestamp, but delayed
2874 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2875 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2876 cancel_lru_locks osc
2877 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2879 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2880 echo "BEFORE: $LS_BEFORE" && \
2881 echo "AFTER : $LS_AFTER" && \
2882 echo "WANT : $DATESTR" && \
2883 error "$DIR/$tdir/$tfile timestamps changed" || true
2885 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2890 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2891 subr_36fh "0x80000214"
2893 run_test 36f "utime on file racing with OST BRW write =========="
2896 remote_ost_nodsh && skip "remote OST with nodsh" && return
2897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2902 test_mkdir -p $DIR/$tdir
2903 fmd_max_age=$(do_facet ost1 \
2904 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2907 fmd_before=$(do_facet ost1 \
2908 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2909 touch $DIR/$tdir/$tfile
2910 sleep $((fmd_max_age + 12))
2911 fmd_after=$(do_facet ost1 \
2912 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2914 echo "fmd_before: $fmd_before"
2915 echo "fmd_after: $fmd_after"
2916 [[ $fmd_after -gt $fmd_before ]] &&
2917 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2918 error "fmd didn't expire after ping" || true
2920 run_test 36g "filter mod data cache expiry ====================="
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2924 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2925 subr_36fh "0x80000227"
2927 run_test 36h "utime on file racing with OST BRW write =========="
2930 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2933 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2935 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2936 local new_mtime=$((mtime + 200))
2938 #change Modify time of striped dir
2939 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2940 error "change mtime failed"
2942 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2944 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2946 run_test 36i "change mtime on striped directory"
2948 # test_37 - duplicate with tests 32q 32r
2951 local file=$DIR/$tfile
2953 openfile -f O_DIRECTORY $file
2956 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2957 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2959 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2963 touch $DIR/${tfile}2
2964 # ls -l $DIR/$tfile $DIR/${tfile}2
2965 # ls -lu $DIR/$tfile $DIR/${tfile}2
2966 # ls -lc $DIR/$tfile $DIR/${tfile}2
2968 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2969 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2971 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2973 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2975 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2976 error "O_TRUNC didn't change timestamps"
2979 run_test 39 "mtime changed on create ==========================="
2982 test_mkdir -p -c1 $DIR/$tdir
2983 cp -p /etc/passwd $DIR/$tdir/fopen
2984 cp -p /etc/passwd $DIR/$tdir/flink
2985 cp -p /etc/passwd $DIR/$tdir/funlink
2986 cp -p /etc/passwd $DIR/$tdir/frename
2987 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2990 echo "aaaaaa" >> $DIR/$tdir/fopen
2991 echo "aaaaaa" >> $DIR/$tdir/flink
2992 echo "aaaaaa" >> $DIR/$tdir/funlink
2993 echo "aaaaaa" >> $DIR/$tdir/frename
2995 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2996 local link_new=`stat -c %Y $DIR/$tdir/flink`
2997 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2998 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3000 cat $DIR/$tdir/fopen > /dev/null
3001 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3002 rm -f $DIR/$tdir/funlink2
3003 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3005 for (( i=0; i < 2; i++ )) ; do
3006 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3007 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3008 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3009 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3011 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3012 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3013 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3014 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3016 cancel_lru_locks osc
3017 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3020 run_test 39b "mtime change on open, link, unlink, rename ======"
3022 # this should be set to past
3023 TEST_39_MTIME=`date -d "1 year ago" +%s`
3029 local mtime0=`stat -c %Y $DIR1/$tfile`
3031 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3032 local mtime1=`stat -c %Y $DIR1/$tfile`
3033 [ "$mtime1" = $TEST_39_MTIME ] || \
3034 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3037 echo hello >> $DIR1/$tfile
3039 local mtime2=`stat -c %Y $DIR1/$tfile`
3040 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3041 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3043 mv $DIR1/$tfile $DIR1/$tfile-1
3045 for (( i=0; i < 2; i++ )) ; do
3046 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3047 [ "$mtime2" = "$mtime3" ] || \
3048 error "mtime ($mtime2) changed (to $mtime3) on rename"
3050 cancel_lru_locks osc
3051 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3054 run_test 39c "mtime change on rename ==========================="
3058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3061 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3063 for (( i=0; i < 2; i++ )) ; do
3064 local mtime=`stat -c %Y $DIR1/$tfile`
3065 [ $mtime = $TEST_39_MTIME ] || \
3066 error "mtime($mtime) is not set to $TEST_39_MTIME"
3068 cancel_lru_locks osc
3069 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3072 run_test 39d "create, utime, stat =============================="
3076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 local mtime1=`stat -c %Y $DIR1/$tfile`
3080 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3082 for (( i=0; i < 2; i++ )) ; do
3083 local mtime2=`stat -c %Y $DIR1/$tfile`
3084 [ $mtime2 = $TEST_39_MTIME ] || \
3085 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3087 cancel_lru_locks osc
3088 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3091 run_test 39e "create, stat, utime, stat ========================"
3095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3097 mtime1=`stat -c %Y $DIR1/$tfile`
3100 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3102 for (( i=0; i < 2; i++ )) ; do
3103 local mtime2=`stat -c %Y $DIR1/$tfile`
3104 [ $mtime2 = $TEST_39_MTIME ] || \
3105 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3107 cancel_lru_locks osc
3108 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3111 run_test 39f "create, stat, sleep, utime, stat ================="
3115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3116 echo hello >> $DIR1/$tfile
3117 local mtime1=`stat -c %Y $DIR1/$tfile`
3120 chmod o+r $DIR1/$tfile
3122 for (( i=0; i < 2; i++ )) ; do
3123 local mtime2=`stat -c %Y $DIR1/$tfile`
3124 [ "$mtime1" = "$mtime2" ] || \
3125 error "lost mtime: $mtime2, should be $mtime1"
3127 cancel_lru_locks osc
3128 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3131 run_test 39g "write, chmod, stat ==============================="
3135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3140 echo hello >> $DIR1/$tfile
3141 local mtime1=`stat -c %Y $DIR1/$tfile`
3143 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3145 if [ "$d1" != "$d2" ]; then
3146 echo "write and touch not within one second"
3148 for (( i=0; i < 2; i++ )) ; do
3149 local mtime2=`stat -c %Y $DIR1/$tfile`
3150 [ "$mtime2" = $TEST_39_MTIME ] || \
3151 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3153 cancel_lru_locks osc
3154 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3158 run_test 39h "write, utime within one second, stat ============="
3161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3165 echo hello >> $DIR1/$tfile
3166 local mtime1=`stat -c %Y $DIR1/$tfile`
3168 mv $DIR1/$tfile $DIR1/$tfile-1
3170 for (( i=0; i < 2; i++ )) ; do
3171 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3173 [ "$mtime1" = "$mtime2" ] || \
3174 error "lost mtime: $mtime2, should be $mtime1"
3176 cancel_lru_locks osc
3177 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3180 run_test 39i "write, rename, stat =============================="
3183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3184 start_full_debug_logging
3188 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3189 lctl set_param fail_loc=0x80000412
3190 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3191 error "multiop failed"
3193 local mtime1=`stat -c %Y $DIR1/$tfile`
3195 mv $DIR1/$tfile $DIR1/$tfile-1
3197 kill -USR1 $multipid
3198 wait $multipid || error "multiop close failed"
3200 for (( i=0; i < 2; i++ )) ; do
3201 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3202 [ "$mtime1" = "$mtime2" ] ||
3203 error "mtime is lost on close: $mtime2, " \
3206 cancel_lru_locks osc
3207 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3209 lctl set_param fail_loc=0
3210 stop_full_debug_logging
3212 run_test 39j "write, rename, close, stat ======================="
3215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3219 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3221 local mtime1=`stat -c %Y $DIR1/$tfile`
3223 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3225 kill -USR1 $multipid
3226 wait $multipid || error "multiop close failed"
3228 for (( i=0; i < 2; i++ )) ; do
3229 local mtime2=`stat -c %Y $DIR1/$tfile`
3231 [ "$mtime2" = $TEST_39_MTIME ] || \
3232 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3234 cancel_lru_locks osc
3235 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3238 run_test 39k "write, utime, close, stat ========================"
3240 # this should be set to future
3241 TEST_39_ATIME=`date -d "1 year" +%s`
3244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3245 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3246 local atime_diff=$(do_facet $SINGLEMDS \
3247 lctl get_param -n mdd.*MDT0000*.atime_diff)
3251 # test setting directory atime to future
3252 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3253 local atime=$(stat -c %X $DIR/$tdir)
3254 [ "$atime" = $TEST_39_ATIME ] || \
3255 error "atime is not set to future: $atime, $TEST_39_ATIME"
3257 # test setting directory atime from future to now
3258 local d1=$(date +%s)
3260 local d2=$(date +%s)
3262 cancel_lru_locks mdc
3263 atime=$(stat -c %X $DIR/$tdir)
3264 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3265 error "atime is not updated from future: $atime, $d1<atime<$d2"
3267 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3270 # test setting directory atime when now > dir atime + atime_diff
3274 cancel_lru_locks mdc
3275 atime=$(stat -c %X $DIR/$tdir)
3276 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3277 error "atime is not updated : $atime, should be $d2"
3279 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3282 # test not setting directory atime when now < dir atime + atime_diff
3284 cancel_lru_locks mdc
3285 atime=$(stat -c %X $DIR/$tdir)
3286 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3287 error "atime is updated to $atime, should remain $d1<atime<$d2"
3289 do_facet $SINGLEMDS \
3290 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3292 run_test 39l "directory atime update ==========================="
3295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3298 local far_past_mtime=$(date -d "May 29 1953" +%s)
3299 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3301 touch -m -d @$far_past_mtime $DIR1/$tfile
3302 touch -a -d @$far_past_atime $DIR1/$tfile
3304 for (( i=0; i < 2; i++ )) ; do
3305 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3306 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3307 error "atime or mtime set incorrectly"
3309 cancel_lru_locks osc
3310 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3313 run_test 39m "test atime and mtime before 1970"
3315 test_39n() { # LU-3832
3316 local atime_diff=$(do_facet $SINGLEMDS \
3317 lctl get_param -n mdd.*MDT0000*.atime_diff)
3322 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3325 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3326 atime0=$(stat -c %X $DIR/$tfile)
3329 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3330 atime1=$(stat -c %X $DIR/$tfile)
3333 cancel_lru_locks mdc
3334 cancel_lru_locks osc
3335 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3336 atime2=$(stat -c %X $DIR/$tfile)
3338 do_facet $SINGLEMDS \
3339 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3341 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3342 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3344 run_test 39n "check that O_NOATIME is honored"
3347 TESTDIR=$DIR/$tdir/$tfile
3348 [ -e $TESTDIR ] && rm -rf $TESTDIR
3349 test_mkdir -p $TESTDIR
3355 links2=$(stat -c %h .)
3356 [ $(($links1 + 2)) != $links2 ] &&
3357 error "wrong links count $(($links1 + 2)) != $links2"
3359 links3=$(stat -c %h .)
3360 [ $(($links1 + 1)) != $links3 ] &&
3361 error "wrong links count $links1 != $links3"
3364 run_test 39o "directory cached attributes updated after create ========"
3367 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3369 TESTDIR=$DIR/$tdir/$tfile
3370 [ -e $TESTDIR ] && rm -rf $TESTDIR
3375 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3376 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3378 links2=$(stat -c %h .)
3379 [ $(($links1 + 2)) != $links2 ] &&
3380 error "wrong links count $(($links1 + 2)) != $links2"
3382 links3=$(stat -c %h .)
3383 [ $(($links1 + 1)) != $links3 ] &&
3384 error "wrong links count $links1 != $links3"
3387 run_test 39p "remote directory cached attributes updated after create ========"
3391 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3392 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3393 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3394 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3395 error "$tfile is not 4096 bytes in size"
3397 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3401 small_write $DIR/f41 18
3403 run_test 41 "test small file write + fstat ====================="
3405 count_ost_writes() {
3406 lctl get_param -n osc.*.stats |
3407 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3408 END { printf("%0.0f", writes) }'
3415 BG_DIRTY_RATIO_SAVE=10
3416 MAX_BG_DIRTY_RATIO=25
3420 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3421 # dirty_ratio, dirty_background_ratio
3422 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3423 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3424 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3425 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3427 # if file not here, we are a 2.4 kernel
3428 kill -CONT `pidof kupdated`
3433 # setup the trap first, so someone cannot exit the test at the
3434 # exact wrong time and mess up a machine
3435 trap start_writeback EXIT
3436 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3437 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3438 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3439 sysctl -w vm.dirty_writeback_centisecs=0
3440 sysctl -w vm.dirty_writeback_centisecs=0
3441 # save and increase /proc/sys/vm/dirty_ratio
3442 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3443 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3444 # save and increase /proc/sys/vm/dirty_background_ratio
3445 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3446 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3448 # if file not here, we are a 2.4 kernel
3449 kill -STOP `pidof kupdated`
3453 # ensure that all stripes have some grant before we test client-side cache
3455 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3456 dd if=/dev/zero of=$i bs=4k count=1
3461 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3462 # file truncation, and file removal.
3464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3466 cancel_lru_locks osc
3468 sync; sleep 1; sync # just to be safe
3469 BEFOREWRITES=`count_ost_writes`
3470 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3471 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3472 AFTERWRITES=`count_ost_writes`
3473 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3474 error "$BEFOREWRITES < $AFTERWRITES"
3477 run_test 42a "ensure that we don't flush on close =============="
3480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3482 cancel_lru_locks osc
3485 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3486 BEFOREWRITES=$(count_ost_writes)
3487 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3488 AFTERWRITES=$(count_ost_writes)
3489 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3490 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3492 BEFOREWRITES=$(count_ost_writes)
3493 sync || error "sync: $?"
3494 AFTERWRITES=$(count_ost_writes)
3495 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3496 error "$BEFOREWRITES < $AFTERWRITES on sync"
3498 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3502 run_test 42b "test destroy of file with cached dirty data ======"
3504 # if these tests just want to test the effect of truncation,
3505 # they have to be very careful. consider:
3506 # - the first open gets a {0,EOF}PR lock
3507 # - the first write conflicts and gets a {0, count-1}PW
3508 # - the rest of the writes are under {count,EOF}PW
3509 # - the open for truncate tries to match a {0,EOF}PR
3510 # for the filesize and cancels the PWs.
3511 # any number of fixes (don't get {0,EOF} on open, match
3512 # composite locks, do smarter file size management) fix
3513 # this, but for now we want these tests to verify that
3514 # the cancellation with truncate intent works, so we
3515 # start the file with a full-file pw lock to match against
3516 # until the truncate.
3521 cancel_lru_locks osc
3523 # prime the file with 0,EOF PW to match
3527 # now the real test..
3528 dd if=/dev/zero of=$file bs=1024 count=100
3529 BEFOREWRITES=`count_ost_writes`
3530 $TRUNCATE $file $offset
3531 cancel_lru_locks osc
3532 AFTERWRITES=`count_ost_writes`
3537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3539 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3540 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3543 run_test 42c "test partial truncate of file with cached dirty data"
3546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3548 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3549 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3552 run_test 42d "test complete truncate of file with cached dirty data"
3554 test_42e() { # bug22074
3555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3556 local TDIR=$DIR/${tdir}e
3557 local pagesz=$(page_size)
3558 local pages=16 # hardcoded 16 pages, don't change it.
3559 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3560 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3564 test_mkdir -p $DIR/${tdir}e
3565 $SETSTRIPE -c 1 $TDIR
3566 createmany -o $TDIR/f $files
3568 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3570 # we assume that with $OSTCOUNT files, at least one of them will
3571 # be allocated on OST0.
3572 warmup_files=$((OSTCOUNT * max_dirty_mb))
3573 createmany -o $TDIR/w $warmup_files
3575 # write a large amount of data into one file and sync, to get good
3576 # avail_grant number from OST.
3577 for ((i=0; i<$warmup_files; i++)); do
3578 idx=$($GETSTRIPE -i $TDIR/w$i)
3579 [ $idx -ne 0 ] && continue
3580 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3583 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3585 $LCTL get_param $proc_osc0/cur_dirty_bytes
3586 $LCTL get_param $proc_osc0/cur_grant_bytes
3588 # create as much dirty pages as we can while not to trigger the actual
3589 # RPCs directly. but depends on the env, VFS may trigger flush during this
3590 # period, hopefully we are good.
3591 for ((i=0; i<$warmup_files; i++)); do
3592 idx=$($GETSTRIPE -i $TDIR/w$i)
3593 [ $idx -ne 0 ] && continue
3594 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3596 $LCTL get_param $proc_osc0/cur_dirty_bytes
3597 $LCTL get_param $proc_osc0/cur_grant_bytes
3599 # perform the real test
3600 $LCTL set_param $proc_osc0/rpc_stats 0
3601 for ((;i<$files; i++)); do
3602 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3603 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3606 $LCTL get_param $proc_osc0/rpc_stats
3609 local have_ppr=false
3610 $LCTL get_param $proc_osc0/rpc_stats |
3611 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3612 # skip lines until we are at the RPC histogram data
3613 [ "$PPR" == "pages" ] && have_ppr=true && continue
3614 $have_ppr || continue
3616 # we only want the percent stat for < 16 pages
3617 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3619 percent=$((percent + WPCT))
3620 if [[ $percent -gt 15 ]]; then
3621 error "less than 16-pages write RPCs" \
3628 run_test 42e "verify sub-RPC writes are not done synchronously"
3631 test_mkdir -p $DIR/$tdir
3632 cp -p /bin/ls $DIR/$tdir/$tfile
3633 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3635 # give multiop a chance to open
3638 $DIR/$tdir/$tfile && error || true
3641 run_test 43 "execution of file opened for write should return -ETXTBSY"
3644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3645 test_mkdir -p $DIR/$tdir
3646 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3647 cp -p multiop $DIR/$tdir/multiop
3648 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3651 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3652 kill -USR1 $MULTIOP_PID || return 2
3653 wait $MULTIOP_PID || return 3
3654 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3656 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3660 test_mkdir -p $DIR/$tdir
3661 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3662 cp -p multiop $DIR/$tdir/multiop
3663 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3666 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3667 kill -USR1 $MULTIOP_PID || return 2
3668 wait $MULTIOP_PID || return 3
3669 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3671 run_test 43b "truncate of file being executed should return -ETXTBSY"
3674 local testdir="$DIR/$tdir"
3675 test_mkdir -p $DIR/$tdir
3677 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3678 ( cd $testdir && md5sum -c)
3680 run_test 43c "md5sum of copy into lustre========================"
3683 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3684 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3685 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3687 run_test 44 "zero length read from a sparse stripe ============="
3690 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3692 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3693 [[ $nstripe -gt $OSTCOUNT ]] &&
3694 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3696 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3698 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3699 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3703 OFFSETS="0 $((stride/2)) $((stride-1))"
3704 for offset in $OFFSETS; do
3705 for i in $(seq 0 $((nstripe-1))); do
3706 local GLOBALOFFSETS=""
3708 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3709 local myfn=$DIR/d44a-$size
3710 echo "--------writing $myfn at $size"
3711 ll_sparseness_write $myfn $size ||
3712 error "ll_sparseness_write"
3713 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3714 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3715 error "ll_sparseness_verify $GLOBALOFFSETS"
3717 for j in $(seq 0 $((nstripe-1))); do
3719 size=$((((j + $nstripe )*$stride + $offset)))
3720 ll_sparseness_write $myfn $size ||
3721 error "ll_sparseness_write"
3722 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3724 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3725 error "ll_sparseness_verify $GLOBALOFFSETS"
3730 run_test 44a "test sparse pwrite ==============================="
3734 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3740 before=`dirty_osc_total`
3741 echo executing "\"$*\""
3743 after=`dirty_osc_total`
3744 echo before $before, after $after
3747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3749 # Obtain grants from OST if it supports it
3750 echo blah > ${f}_grant
3753 do_dirty_record "echo blah > $f"
3754 [[ $before -eq $after ]] && error "write wasn't cached"
3755 do_dirty_record "> $f"
3756 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3757 do_dirty_record "echo blah > $f"
3758 [[ $before -eq $after ]] && error "write wasn't cached"
3759 do_dirty_record "sync"
3760 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3761 do_dirty_record "echo blah > $f"
3762 [[ $before -eq $after ]] && error "write wasn't cached"
3763 do_dirty_record "cancel_lru_locks osc"
3764 [[ $before -gt $after ]] ||
3765 error "lock cancellation didn't lower dirty count"
3768 run_test 45 "osc io page accounting ============================"
3770 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3771 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3772 # objects offset and an assert hit when an rpc was built with 1023's mapped
3773 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3779 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3781 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3782 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3786 run_test 46 "dirtying a previously written page ================"
3788 # test_47 is removed "Device nodes check" is moved to test_28
3790 test_48a() { # bug 2399
3791 check_kernel_version 34 || return 0
3792 test_mkdir -p $DIR/$tdir
3794 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3795 test_mkdir $DIR/$tdir || error "recreate directory failed"
3796 touch foo || error "'touch foo' failed after recreating cwd"
3797 test_mkdir $DIR/$tdir/bar ||
3798 error "'mkdir foo' failed after recreating cwd"
3799 if check_kernel_version 44; then
3800 touch .foo || error "'touch .foo' failed after recreating cwd"
3801 test_mkdir $DIR/$tdir/.bar ||
3802 error "'mkdir .foo' failed after recreating cwd"
3804 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3805 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3806 cd . || error "'cd .' failed after recreating cwd"
3807 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3808 rmdir . && error "'rmdir .' worked after recreating cwd"
3809 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3810 cd .. || error "'cd ..' failed after recreating cwd"
3812 run_test 48a "Access renamed working dir (should return errors)="
3814 test_48b() { # bug 2399
3815 check_kernel_version 34 || return 0
3817 test_mkdir -p $DIR/$tdir
3819 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3820 touch foo && error "'touch foo' worked after removing cwd"
3821 test_mkdir $DIR/$tdir/foo &&
3822 error "'mkdir foo' worked after removing cwd"
3823 if check_kernel_version 44; then
3824 touch .foo && error "'touch .foo' worked after removing cwd"
3825 test_mkdir $DIR/$tdir/.foo &&
3826 error "'mkdir .foo' worked after removing cwd"
3828 ls . > /dev/null && error "'ls .' worked after removing cwd"
3829 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3830 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3831 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3832 rmdir . && error "'rmdir .' worked after removing cwd"
3833 ln -s . foo && error "'ln -s .' worked after removing cwd"
3834 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3836 run_test 48b "Access removed working dir (should return errors)="
3838 test_48c() { # bug 2350
3839 check_kernel_version 36 || return 0
3840 #lctl set_param debug=-1
3843 test_mkdir -p $DIR/$tdir/dir
3845 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3846 $TRACE touch foo && error "touch foo worked after removing cwd"
3847 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3848 if check_kernel_version 44; then
3849 touch .foo && error "touch .foo worked after removing cwd"
3850 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3852 $TRACE ls . && error "'ls .' worked after removing cwd"
3853 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3854 is_patchless || ( $TRACE cd . &&
3855 error "'cd .' worked after removing cwd" )
3856 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3857 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3858 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3859 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3861 run_test 48c "Access removed working subdir (should return errors)"
3863 test_48d() { # bug 2350
3864 check_kernel_version 36 || return 0
3865 #lctl set_param debug=-1
3868 test_mkdir -p $DIR/$tdir/dir
3870 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3871 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3872 $TRACE touch foo && error "'touch foo' worked after removing parent"
3873 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3874 if check_kernel_version 44; then
3875 touch .foo && error "'touch .foo' worked after removing parent"
3877 error "mkdir .foo worked after removing parent"
3879 $TRACE ls . && error "'ls .' worked after removing parent"
3880 $TRACE ls .. && error "'ls ..' worked after removing parent"
3881 is_patchless || ( $TRACE cd . &&
3882 error "'cd .' worked after recreate parent" )
3883 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3884 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3885 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3886 is_patchless || ( $TRACE cd .. &&
3887 error "'cd ..' worked after removing parent" || true )
3889 run_test 48d "Access removed parent subdir (should return errors)"
3891 test_48e() { # bug 4134
3892 check_kernel_version 41 || return 0
3893 #lctl set_param debug=-1
3896 test_mkdir -p $DIR/$tdir/dir
3898 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3899 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3900 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3901 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3902 # On a buggy kernel addition of "touch foo" after cd .. will
3903 # produce kernel oops in lookup_hash_it
3904 touch ../foo && error "'cd ..' worked after recreate parent"
3906 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3908 run_test 48e "Access to recreated parent subdir (should return errors)"
3910 test_49() { # LU-1030
3911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3912 # get ost1 size - lustre-OST0000
3913 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3915 # write 800M at maximum
3916 [[ $ost1_size -lt 2 ]] && ost1_size=2
3917 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3919 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3920 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3923 # change max_pages_per_rpc while writing the file
3924 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3925 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3926 # loop until dd process exits
3927 while ps ax -opid | grep -wq $dd_pid; do
3928 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3929 sleep $((RANDOM % 5 + 1))
3931 # restore original max_pages_per_rpc
3932 $LCTL set_param $osc1_mppc=$orig_mppc
3933 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3935 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3939 test_mkdir $DIR/$tdir
3941 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3943 run_test 50 "special situations: /proc symlinks ==============="
3945 test_51a() { # was test_51
3946 # bug 1516 - create an empty entry right after ".." then split dir
3947 test_mkdir -c1 $DIR/$tdir
3948 touch $DIR/$tdir/foo
3949 $MCREATE $DIR/$tdir/bar
3951 createmany -m $DIR/$tdir/longfile 201
3953 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3954 $MCREATE $DIR/$tdir/longfile$FNUM
3959 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3961 run_test 51a "special situations: split htree with empty entry =="
3963 export NUMTEST=70000
3965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3966 local BASE=$DIR/d${base}.${TESTSUITE}
3968 # cleanup the directory
3971 test_mkdir -p -c1 $BASE
3973 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3974 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3975 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3978 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3979 echo "reduced count to $NUMTEST due to inodes"
3981 # need to check free space for the directories as well
3982 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3983 numfree=$((blkfree / 4))
3984 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3985 echo "reduced count to $NUMTEST due to blocks"
3987 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3988 echo "failed" > $BASE/fnum
3990 run_test 51b "exceed 64k subdirectory nlink limit"
3992 test_51ba() { # LU-993
3993 local BASE=$DIR/d${base}.${TESTSUITE}
3994 # unlink all but 100 subdirectories, then check it still works
3996 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3998 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3999 local DELETE=$((NUMTEST - LEFT))
4001 # continue on to run this test even if 51b didn't finish,
4002 # just to delete the many subdirectories created.
4003 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4005 # for ldiskfs the nlink count should be 1, but this is OSD specific
4006 # and so this is listed for informational purposes only
4007 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4008 unlinkmany -d $BASE/d $DELETE
4011 if [ $RC -ne 0 ]; then
4012 if [ "$NUMPREV" == "failed" ]; then
4013 skip "previous setup failed"
4016 error "unlink of first $DELETE subdirs failed"
4021 echo "nlink between: $(stat -c %h $BASE)"
4022 # trim the first line of ls output
4023 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4024 [ $FOUND -ne $LEFT ] &&
4025 error "can't find subdirs: found only $FOUND/$LEFT"
4027 unlinkmany -d $BASE/d $DELETE $LEFT ||
4028 error "unlink of second $LEFT subdirs failed"
4029 # regardless of whether the backing filesystem tracks nlink accurately
4030 # or not, the nlink count shouldn't be more than "." and ".." here
4031 local AFTER=$(stat -c %h $BASE)
4032 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4033 echo "nlink after: $AFTER"
4035 run_test 51ba "verify nlink for many subdirectory cleanup"
4038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4039 [[ $OSTCOUNT -lt 3 ]] &&
4040 skip_env "skipping test with few OSTs" && return
4041 test_mkdir -p $DIR/$tdir
4042 createmany -o $DIR/$tdir/t- 1000
4043 $GETSTRIPE $DIR/$tdir > $TMP/files
4044 for N in $(seq 0 $((OSTCOUNT - 1))); do
4045 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4046 END { printf("%0.0f", objs) }' $TMP/files)
4047 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4048 '($1 == '$N') { objs += 1 } \
4049 END { printf("%0.0f", objs) }')
4050 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4052 unlinkmany $DIR/$tdir/t- 1000
4055 for N in $(seq 1 $((OSTCOUNT - 1))); do
4056 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4057 error "OST $N has less objects vs OST $NLAST" \
4058 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4059 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4060 error "OST $N has less objects vs OST $NLAST" \
4061 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4063 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4064 error "OST $N has less #0 objects vs OST $NLAST" \
4065 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4066 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4067 error "OST $N has less #0 objects vs OST $NLAST" \
4068 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4072 run_test 51d "check object distribution ===================="
4075 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4076 skip "Only applicable to ldiskfs-based MDTs"
4080 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4081 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4083 touch $DIR/$tdir/d0/foo
4084 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4085 error "file exceed 65000 nlink limit!"
4086 unlinkmany $DIR/$tdir/d0/f- 65001
4089 run_test 51e "check file nlink limit"
4092 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4093 test_mkdir -p $DIR/$tdir
4094 touch $DIR/$tdir/foo
4095 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4096 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4097 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4098 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4099 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4101 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4102 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4103 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4105 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4106 cp -r $DIR/$tdir /tmp/
4107 rm -fr $DIR/$tdir || error "cleanup rm failed"
4109 run_test 52a "append-only flag test (should return errors) ====="
4112 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4113 test_mkdir -p $DIR/$tdir
4114 touch $DIR/$tdir/foo
4115 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4116 cat test > $DIR/$tdir/foo && error "cat test worked"
4117 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4118 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4119 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4121 echo foo >> $DIR/$tdir/foo && error "echo worked"
4122 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4123 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4124 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4125 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4127 chattr -i $DIR/$tdir/foo || error "chattr failed"
4129 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4131 run_test 52b "immutable flag test (should return errors) ======="
4134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4135 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4136 remote_ost_nodsh && skip "remote OST with nodsh" && return
4149 local support_last_seq=true
4151 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4152 support_last_seq=false
4155 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4157 for value in $(do_facet $SINGLEMDS \
4158 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4159 param=$(echo ${value[0]} | cut -d "=" -f1)
4160 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4162 if $support_last_seq; then
4163 param_seq=$(echo $param |
4164 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4165 mds_last_seq=$(do_facet $SINGLEMDS \
4166 $LCTL get_param -n $param_seq)
4168 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4170 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4171 node=$(facet_active_host ost$((ostnum+1)))
4172 param="obdfilter.$ostname.last_id"
4173 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4174 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4175 ost_last_id=$ost_last
4177 if $support_last_seq; then
4178 ost_last_id=$(echo $ost_last |
4179 awk -F':' '{print $2}' |
4181 ost_last_seq=$(echo $ost_last |
4182 awk -F':' '{print $1}')
4183 [[ $ost_last_seq = $mds_last_seq ]] || continue
4186 if [[ $ost_last_id != $mds_last ]]; then
4187 error "$ost_last_id != $mds_last"
4194 $found || error "can not match last_seq/last_id for $mdtosc"
4197 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4200 $SOCKETSERVER $DIR/socket ||
4201 error "$SOCKETSERVER $DIR/socket failed: $?"
4202 $SOCKETCLIENT $DIR/socket ||
4203 error "$SOCKETCLIENT $DIR/socket failed: $?"
4204 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4206 run_test 54a "unix domain socket test =========================="
4212 dd if=/dev/zero of=$f bs=$(page_size) count=1
4214 run_test 54b "char device works in lustre ======================"
4217 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4218 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4219 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4221 for i in $(seq 3 7); do
4222 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4230 loopdev="$DIR/loop54c"
4233 $UMOUNT -d $DIR/$tdir || rc=$?
4234 losetup -d $loopdev || true
4235 losetup -d $LOOPDEV || true
4236 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4242 loopdev="$DIR/loop54c"
4245 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4246 trap cleanup_54c EXIT
4247 mknod $loopdev b 7 $LOOPNUM
4248 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4249 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4250 losetup $loopdev $DIR/$tfile ||
4251 error "can't set up $loopdev for $DIR/$tfile"
4252 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4253 test_mkdir -p $DIR/$tdir
4254 mount -t ext2 $loopdev $DIR/$tdir ||
4255 error "error mounting $loopdev on $DIR/$tdir"
4256 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4259 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4263 run_test 54c "block device works in lustre ====================="
4269 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4271 run_test 54d "fifo device works in lustre ======================"
4274 check_kernel_version 46 || return 0
4277 cp -aL /dev/console $f
4278 echo $string > $f || error "echo $string to $f failed"
4280 run_test 54e "console/tty device works in lustre ======================"
4282 #The test_55 used to be iopen test and it was removed by bz#24037.
4283 #run_test 55 "check iopen_connect_dentry() ======================"
4285 test_56a() { # was test_56
4288 test_mkdir -p $DIR/$tdir/dir
4290 NUMFILESx2=$(($NUMFILES * 2))
4291 for i in $(seq 1 $NUMFILES); do
4292 touch $DIR/$tdir/file$i
4293 touch $DIR/$tdir/dir/file$i
4296 # test lfs getstripe with --recursive
4297 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4298 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4299 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4300 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4301 [[ $FILENUM -eq $NUMFILES ]] ||
4302 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4303 echo "$GETSTRIPE --recursive passed."
4305 # test lfs getstripe with file instead of dir
4306 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4307 [[ $FILENUM -eq 1 ]] ||
4308 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4309 echo "$GETSTRIPE file1 passed."
4311 #test lfs getstripe with --verbose
4312 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4313 grep -c lmm_magic) -eq $NUMFILES ]] ||
4314 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4315 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4316 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4317 echo "$GETSTRIPE --verbose passed."
4319 #test lfs getstripe with --obd
4320 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4321 grep -q "unknown obduuid" ||
4322 error "$GETSTRIPE --obd wrong_uuid should return error message"
4324 [[ $OSTCOUNT -lt 2 ]] &&
4325 skip_env "skipping other $GETSTRIPE --obd test" && return
4328 OBDUUID=$(ostuuid_from_index $OSTIDX)
4329 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4330 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4331 [[ $FOUND -eq $FILENUM ]] ||
4332 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4333 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4334 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4335 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4336 error "$GETSTRIPE --obd: should not show file on other obd"
4337 echo "$GETSTRIPE --obd passed"
4339 run_test 56a "check $GETSTRIPE"
4344 local LOCAL_NUMFILES="$1"
4345 local LOCAL_NUMDIRS="$2"
4346 local MKDIR_PARAMS="$3"
4347 local DIR_STRIPE_PARAMS="$4"
4349 if [ ! -d "$TDIR" ] ; then
4350 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4351 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4352 for i in `seq 1 $LOCAL_NUMFILES` ; do
4355 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4356 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4357 for j in `seq 1 $LOCAL_NUMFILES` ; do
4358 touch $TDIR/dir$i/file$j
4364 setup_56_special() {
4368 if [ ! -e "$TDIR/loop1b" ] ; then
4369 for i in `seq 1 $LOCAL_NUMFILES` ; do
4370 mknod $TDIR/loop${i}b b 7 $i
4371 mknod $TDIR/null${i}c c 1 3
4372 ln -s $TDIR/file1 $TDIR/link${i}l
4374 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4375 mknod $TDIR/dir$i/loop${i}b b 7 $i
4376 mknod $TDIR/dir$i/null${i}c c 1 3
4377 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4386 setup_56 $NUMFILES $NUMDIRS
4388 EXPECTED=$(($NUMDIRS + 2))
4389 # test lfs find with -name
4390 for i in $(seq 1 $NUMFILES) ; do
4391 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4392 [ $NUMS -eq $EXPECTED ] ||
4393 error "lfs find -name \"*$i\" $TDIR wrong: "\
4394 "found $NUMS, expected $EXPECTED"
4397 run_test 56g "check lfs find -name ============================="
4403 setup_56 $NUMFILES $NUMDIRS
4405 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4406 # test lfs find with ! -name
4407 for i in $(seq 1 $NUMFILES) ; do
4408 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4409 [ $NUMS -eq $EXPECTED ] ||
4410 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4411 "found $NUMS, expected $EXPECTED"
4414 run_test 56h "check lfs find ! -name ============================="
4418 test_mkdir -p $DIR/$tdir
4419 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4420 CMD="$LFIND -ost $UUID $DIR/$tdir"
4422 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4424 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4428 setup_56_special $NUMFILES $NUMDIRS
4430 EXPECTED=$((NUMDIRS + 1))
4431 CMD="$LFIND -type d $TDIR"
4432 NUMS=$($CMD | wc -l)
4433 [ $NUMS -eq $EXPECTED ] ||
4434 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4436 run_test 56j "check lfs find -type d ============================="
4440 setup_56_special $NUMFILES $NUMDIRS
4442 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4443 CMD="$LFIND -type f $TDIR"
4444 NUMS=$($CMD | wc -l)
4445 [ $NUMS -eq $EXPECTED ] ||
4446 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4448 run_test 56k "check lfs find -type f ============================="
4452 setup_56_special $NUMFILES $NUMDIRS
4454 EXPECTED=$((NUMDIRS + NUMFILES))
4455 CMD="$LFIND -type b $TDIR"
4456 NUMS=$($CMD | wc -l)
4457 [ $NUMS -eq $EXPECTED ] ||
4458 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4460 run_test 56l "check lfs find -type b ============================="
4464 setup_56_special $NUMFILES $NUMDIRS
4466 EXPECTED=$((NUMDIRS + NUMFILES))
4467 CMD="$LFIND -type c $TDIR"
4468 NUMS=$($CMD | wc -l)
4469 [ $NUMS -eq $EXPECTED ] ||
4470 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4472 run_test 56m "check lfs find -type c ============================="
4476 setup_56_special $NUMFILES $NUMDIRS
4478 EXPECTED=$((NUMDIRS + NUMFILES))
4479 CMD="$LFIND -type l $TDIR"
4480 NUMS=$($CMD | wc -l)
4481 [ $NUMS -eq $EXPECTED ] ||
4482 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4484 run_test 56n "check lfs find -type l ============================="
4488 setup_56 $NUMFILES $NUMDIRS
4489 utime $TDIR/file1 > /dev/null || error "utime (1)"
4490 utime $TDIR/file2 > /dev/null || error "utime (2)"
4491 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4492 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4493 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4494 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4497 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4498 [ $NUMS -eq $EXPECTED ] || \
4499 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4502 CMD="$LFIND -mtime 0 $TDIR"
4503 NUMS=$($CMD | wc -l)
4504 [ $NUMS -eq $EXPECTED ] ||
4505 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4507 run_test 56o "check lfs find -mtime for old files =========================="
4510 [ $RUNAS_ID -eq $UID ] &&
4511 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4514 setup_56 $NUMFILES $NUMDIRS
4516 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4518 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4519 NUMS=$($CMD | wc -l)
4520 [ $NUMS -eq $EXPECTED ] || \
4521 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4523 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4524 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4525 NUMS=$($CMD | wc -l)
4526 [ $NUMS -eq $EXPECTED ] || \
4527 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4529 run_test 56p "check lfs find -uid and ! -uid ==============================="
4532 [ $RUNAS_ID -eq $UID ] &&
4533 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4536 setup_56 $NUMFILES $NUMDIRS
4538 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4541 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4542 NUMS=$($CMD | wc -l)
4543 [ $NUMS -eq $EXPECTED ] ||
4544 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4546 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4547 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4548 NUMS=$($CMD | wc -l)
4549 [ $NUMS -eq $EXPECTED ] ||
4550 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4552 run_test 56q "check lfs find -gid and ! -gid ==============================="
4556 setup_56 $NUMFILES $NUMDIRS
4559 CMD="$LFIND -size 0 -type f $TDIR"
4560 NUMS=$($CMD | wc -l)
4561 [ $NUMS -eq $EXPECTED ] ||
4562 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4564 CMD="$LFIND ! -size 0 -type f $TDIR"
4565 NUMS=$($CMD | wc -l)
4566 [ $NUMS -eq $EXPECTED ] ||
4567 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4568 echo "test" > $TDIR/$tfile
4569 echo "test2" > $TDIR/$tfile.2 && sync
4571 CMD="$LFIND -size 5 -type f $TDIR"
4572 NUMS=$($CMD | wc -l)
4573 [ $NUMS -eq $EXPECTED ] ||
4574 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4576 CMD="$LFIND -size +5 -type f $TDIR"
4577 NUMS=$($CMD | wc -l)
4578 [ $NUMS -eq $EXPECTED ] ||
4579 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4581 CMD="$LFIND -size +0 -type f $TDIR"
4582 NUMS=$($CMD | wc -l)
4583 [ $NUMS -eq $EXPECTED ] ||
4584 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4586 CMD="$LFIND ! -size -5 -type f $TDIR"
4587 NUMS=$($CMD | wc -l)
4588 [ $NUMS -eq $EXPECTED ] ||
4589 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4591 CMD="$LFIND -size -5 -type f $TDIR"
4592 NUMS=$($CMD | wc -l)
4593 [ $NUMS -eq $EXPECTED ] ||
4594 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4596 run_test 56r "check lfs find -size works =========================="
4598 test_56s() { # LU-611
4600 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4602 if [[ $OSTCOUNT -gt 1 ]]; then
4603 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4607 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4611 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4612 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4613 NUMS=$($CMD | wc -l)
4614 [ $NUMS -eq $EXPECTED ] || {
4616 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4619 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4620 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4621 NUMS=$($CMD | wc -l)
4622 [ $NUMS -eq $EXPECTED ] || {
4624 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4628 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4629 NUMS=$($CMD | wc -l)
4630 [ $NUMS -eq $EXPECTED ] || {
4632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4635 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4636 NUMS=$($CMD | wc -l)
4637 [ $NUMS -eq $EXPECTED ] || {
4639 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4643 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4644 NUMS=$($CMD | wc -l)
4645 [ $NUMS -eq $EXPECTED ] || {
4647 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 run_test 56s "check lfs find -stripe-count works"
4652 test_56t() { # LU-611
4654 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4656 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4658 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4659 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4660 NUMS=$($CMD | wc -l)
4661 [ $NUMS -eq $EXPECTED ] ||
4662 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4664 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4665 NUMS=$($CMD | wc -l)
4666 [ $NUMS -eq $EXPECTED ] ||
4667 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4669 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4670 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4671 NUMS=$($CMD | wc -l)
4672 [ $NUMS -eq $EXPECTED ] ||
4673 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4675 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4676 NUMS=$($CMD | wc -l)
4677 [ $NUMS -eq $EXPECTED ] ||
4678 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4681 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4682 NUMS=$($CMD | wc -l)
4683 [ $NUMS -eq $EXPECTED ] ||
4684 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4686 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4687 NUMS=$($CMD | wc -l)
4688 [ $NUMS -eq $EXPECTED ] ||
4689 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4692 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4693 NUMS=$($CMD | wc -l)
4694 [ $NUMS -eq $EXPECTED ] ||
4695 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4697 run_test 56t "check lfs find -stripe-size works"
4699 test_56u() { # LU-611
4701 setup_56 $NUMFILES $NUMDIRS "-i 0"
4703 if [[ $OSTCOUNT -gt 1 ]]; then
4704 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4710 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4711 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4712 NUMS=$($CMD | wc -l)
4713 [ $NUMS -eq $EXPECTED ] ||
4714 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4717 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] ||
4720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4722 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4723 NUMS=$($CMD | wc -l)
4724 [ $NUMS -eq $EXPECTED ] ||
4725 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4728 # This should produce an error and not return any files
4729 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4730 NUMS=$($CMD 2>/dev/null | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 if [[ $OSTCOUNT -gt 1 ]]; then
4735 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4736 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4737 NUMS=$($CMD | wc -l)
4738 [ $NUMS -eq $EXPECTED ] ||
4739 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4742 run_test 56u "check lfs find -stripe-index works"
4749 setup_56 $NUMFILES $NUMDIRS
4751 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4752 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4754 for file in $($LFIND -mdt $UUID $TDIR); do
4755 file_mdt_idx=$($GETSTRIPE -M $file)
4756 [ $file_mdt_idx -eq $MDT_IDX ] ||
4757 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4760 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4762 # Get and check the actual stripe count of one file.
4763 # Usage: check_stripe_count <file> <expected_stripe_count>
4764 check_stripe_count() {
4769 [[ -z "$file" || -z "$expected" ]] &&
4770 error "check_stripe_count: invalid argument!"
4772 local cmd="$GETSTRIPE -c $file"
4773 actual=$($cmd) || error "$cmd failed"
4774 actual=${actual%% *}
4776 if [[ $actual -ne $expected ]]; then
4777 [[ $expected -eq -1 ]] ||
4778 error "$cmd wrong: found $actual, expected $expected"
4779 [[ $actual -eq $OSTCOUNT ]] ||
4780 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4788 rm -rf $TDIR || error "remove $TDIR failed"
4789 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4792 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4793 error "$GETSTRIPE -S -d $TDIR failed"
4794 stripe_size=${stripe_size%% *}
4796 local file_size=$((stripe_size * OSTCOUNT))
4797 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4798 local required_space=$((file_num * file_size))
4799 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4800 [[ $free_space -le $((required_space / 1024)) ]] &&
4801 skip_env "need at least $required_space bytes free space," \
4802 "have $free_space kbytes" && return
4805 local dd_count=$((file_size / dd_bs))
4807 # write data into the files
4811 for i in $(seq 1 $NUMFILES); do
4813 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4814 error "write data into $file failed"
4816 for i in $(seq 1 $NUMDIRS); do
4817 for j in $(seq 1 $NUMFILES); do
4818 file=$TDIR/dir$i/file$j
4819 yes | dd bs=$dd_bs count=$dd_count of=$file \
4821 error "write data into $file failed"
4826 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4829 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4831 eval $cmd || error "$cmd failed"
4833 check_stripe_count $TDIR/file1 $expected
4836 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4838 eval $cmd || error "$cmd failed"
4840 for j in $(seq 1 $NUMFILES); do
4841 check_stripe_count $TDIR/dir1/file$j $expected
4844 # lfs_migrate works with lfs find
4845 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4846 $LFS_MIGRATE -y -c $expected"
4848 eval $cmd || error "$cmd failed"
4850 for i in $(seq 2 $NUMFILES); do
4851 check_stripe_count $TDIR/file$i $expected
4853 for i in $(seq 2 $NUMDIRS); do
4854 for j in $(seq 1 $NUMFILES); do
4855 check_stripe_count $TDIR/dir$i/file$j $expected
4859 run_test 56w "check lfs_migrate -c stripe_count works"
4862 check_swap_layouts_support && return 0
4863 [[ $OSTCOUNT -lt 2 ]] &&
4864 skip_env "need 2 OST, skipping test" && return
4866 local dir0=$DIR/$tdir/$testnum
4867 mkdir -p $dir0 || error "creating dir $dir0"
4869 local ref1=/etc/passwd
4870 local file1=$dir0/file1
4872 $SETSTRIPE -c 2 $file1
4874 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4875 stripe=$($GETSTRIPE -c $file1)
4876 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4877 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4882 run_test 56x "lfs migration support"
4885 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4886 skip "No HSM support on MDS of $(get_lustre_version)," \
4887 "need 2.4.53 at least" && return
4890 local dir0=$DIR/$tdir/$testnum
4891 mkdir -p $dir0 || error "creating dir $dir0"
4892 local f1=$dir0/file1
4893 local f2=$dir0/file2
4895 touch $f1 || error "creating std file $f1"
4896 $MULTIOP $f2 H2c || error "creating released file $f2"
4898 # a directory can be raid0, so ask only for files
4899 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4900 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4902 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4903 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4905 # only files can be released, so no need to force file search
4906 res=$($LFIND $dir0 -L released)
4907 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4909 res=$($LFIND $dir0 \! -L released)
4910 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4913 run_test 56y "lfs find -L raid0|released"
4915 test_56z() { # LU-4824
4916 # This checks to make sure 'lfs find' continues after errors
4917 # There are two classes of errors that should be caught:
4918 # - If multiple paths are provided, all should be searched even if one
4920 # - If errors are encountered during the search, it should not terminate
4923 test_mkdir $DIR/$tdir
4924 for i in d{0..9}; do
4925 test_mkdir $DIR/$tdir/$i
4927 touch $DIR/$tdir/d{0..9}/$tfile
4928 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4929 error "$LFS find did not return an error"
4930 # Make a directory unsearchable. This should NOT be the last entry in
4931 # directory order. Arbitrarily pick the 6th entry
4932 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
4933 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4934 # The user should be able to see 10 directories and 9 files
4935 [ $count == 19 ] || error "$LFS find did not continue after error"
4937 run_test 56z "lfs find should continue after an error"
4940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4941 # note test will not do anything if MDS is not local
4942 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4943 skip "Only applicable to ldiskfs-based MDTs"
4947 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4948 local MNTDEV="osd*.*MDT*.mntdev"
4949 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4950 [ -z "$DEV" ] && error "can't access $MNTDEV"
4951 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4952 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4953 error "can't access $DEV"
4954 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4955 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4959 run_test 57a "verify MDS filesystem created with large inodes =="
4962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4963 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4964 skip "Only applicable to ldiskfs-based MDTs"
4968 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4973 local FILEN=$dir/f$FILECOUNT
4975 rm -rf $dir || error "removing $dir"
4976 test_mkdir -p $dir || error "creating $dir"
4977 local num=$(get_mds_dir $dir)
4980 echo "mcreating $FILECOUNT files"
4981 createmany -m $dir/f 1 $FILECOUNT || \
4982 error "creating files in $dir"
4984 # verify that files do not have EAs yet
4985 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4986 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4990 df $dir #make sure we get new statfs data
4991 local MDSFREE=$(do_facet $mymds \
4992 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4993 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4994 echo "opening files to create objects/EAs"
4996 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4997 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5000 # verify that files have EAs now
5001 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5002 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5004 sleep 1 #make sure we get new statfs data
5006 local MDSFREE2=$(do_facet $mymds \
5007 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
5008 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5009 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5010 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5011 error "MDC before $MDCFREE != after $MDCFREE2"
5013 echo "MDC before $MDCFREE != after $MDCFREE2"
5014 echo "unable to confirm if MDS has large inodes"
5019 run_test 57b "default LOV EAs are stored inside large inodes ==="
5022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5023 [ -z "$(which wiretest 2>/dev/null)" ] &&
5024 skip_env "could not find wiretest" && return
5027 run_test 58 "verify cross-platform wire constants =============="
5030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5031 echo "touch 130 files"
5032 createmany -o $DIR/f59- 130
5034 unlinkmany $DIR/f59- 130
5036 # wait for commitment of removal
5037 wait_delete_completed
5039 run_test 59 "verify cancellation of llog records async ========="
5041 TEST60_HEAD="test_60 run $RANDOM"
5043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5044 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5045 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5046 skip_env "missing subtest run-llog.sh" && return
5047 log "$TEST60_HEAD - from kernel mode"
5048 do_facet mgs sh run-llog.sh
5050 run_test 60a "llog sanity tests run from kernel module =========="
5052 test_60b() { # bug 6411
5053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5055 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5067 [[ $LLOG_COUNT -gt 50 ]] &&
5068 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5070 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5074 echo "create 5000 files"
5075 createmany -o $DIR/f60c- 5000
5076 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5077 lctl set_param fail_loc=0x80000137
5078 unlinkmany $DIR/f60c- 5000
5079 lctl set_param fail_loc=0
5081 run_test 60c "unlink file when mds full"
5084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5085 SAVEPRINTK=$(lctl get_param -n printk)
5087 # verify "lctl mark" is even working"
5088 MESSAGE="test message ID $RANDOM $$"
5089 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5090 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5092 lctl set_param printk=0 || error "set lnet.printk failed"
5093 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5094 MESSAGE="new test message ID $RANDOM $$"
5095 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5096 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5097 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5099 lctl set_param -n printk="$SAVEPRINTK"
5101 run_test 60d "test printk console message masking"
5104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5106 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5107 cancel_lru_locks osc
5108 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5111 run_test 61 "mmap() writes don't make sync hang ================"
5113 # bug 2330 - insufficient obd_match error checking causes LBUG
5115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5118 cancel_lru_locks osc
5119 lctl set_param fail_loc=0x405
5120 cat $f && error "cat succeeded, expect -EIO"
5121 lctl set_param fail_loc=0
5123 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5124 # match every page all of the time.
5125 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5127 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5128 # Though this test is irrelevant anymore, it helped to reveal some
5129 # other grant bugs (LU-4482), let's keep it.
5130 test_63a() { # was test_63
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5133 for i in `seq 10` ; do
5134 dd if=/dev/zero of=$DIR/f63 bs=8k &
5140 rm -f $DIR/f63 || true
5142 run_test 63a "Verify oig_wait interruption does not crash ======="
5144 # bug 2248 - async write errors didn't return to application on sync
5145 # bug 3677 - async write errors left page locked
5147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5149 lctl set_param debug=-1
5151 # ensure we have a grant to do async writes
5152 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5155 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5156 lctl set_param fail_loc=0x80000406
5157 $MULTIOP $DIR/$tfile Owy && \
5158 error "sync didn't return ENOMEM"
5159 sync; sleep 2; sync # do a real sync this time to flush page
5160 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5161 error "locked page left in cache after async error" || true
5164 run_test 63b "async write errors should be returned to fsync ==="
5167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5169 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5171 run_test 64a "verify filter grant calculations (in kernel) ====="
5174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5175 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5177 run_test 64b "check out-of-space detection on client ==========="
5180 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5182 run_test 64c "verify grant shrink ========================------"
5184 # bug 1414 - set/get directories' stripe info
5186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5187 test_mkdir -p $DIR/$tdir
5189 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5191 run_test 65a "directory with no stripe info ===================="
5194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5195 test_mkdir -p $DIR/$tdir
5196 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5199 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5201 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5205 if [[ $OSTCOUNT -gt 1 ]]; then
5206 test_mkdir -p $DIR/$tdir
5207 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5208 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5210 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5213 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5217 test_mkdir -p $DIR/$tdir
5218 if [[ $STRIPECOUNT -le 0 ]]; then
5220 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5221 #LOV_MAX_STRIPE_COUNT is 2000
5222 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5224 sc=$(($STRIPECOUNT - 1))
5226 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5227 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5228 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5229 error "lverify failed"
5231 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5235 test_mkdir -p $DIR/$tdir
5237 $SETSTRIPE $DIR/$tdir || error "setstripe"
5238 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5239 error "no stripe info failed"
5241 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5243 run_test 65e "directory setstripe defaults ======================="
5246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5247 test_mkdir -p $DIR/${tdir}f
5248 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5250 run_test 65f "dir setstripe permission (should return error) ==="
5253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5254 test_mkdir -p $DIR/$tdir
5255 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5257 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5258 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5259 error "delete default stripe failed"
5261 run_test 65g "directory setstripe -d ==========================="
5264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5265 test_mkdir -p $DIR/$tdir
5266 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5268 test_mkdir -p $DIR/$tdir/dd1
5269 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5270 error "stripe info inherit failed"
5272 run_test 65h "directory stripe info inherit ===================="
5274 test_65i() { # bug6367
5275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5276 $SETSTRIPE -S 65536 -c -1 $MOUNT
5278 run_test 65i "set non-default striping on root directory (bug 6367)="
5280 test_65ia() { # bug12836
5281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5282 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5284 run_test 65ia "getstripe on -1 default directory striping"
5286 test_65ib() { # bug12836
5287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5288 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5290 run_test 65ib "getstripe -v on -1 default directory striping"
5292 test_65ic() { # bug12836
5293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5294 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5296 run_test 65ic "new find on -1 default directory striping"
5298 test_65j() { # bug6367
5299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5301 # if we aren't already remounting for each test, do so for this test
5302 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5303 cleanup || error "failed to unmount"
5306 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5308 run_test 65j "set default striping on root directory (bug 6367)="
5310 test_65k() { # bug11679
5311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5312 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5313 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5315 echo "Check OST status: "
5316 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5317 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5319 for OSC in $MDS_OSCS; do
5320 echo $OSC "is activate"
5321 do_facet $SINGLEMDS lctl --device %$OSC activate
5325 for INACTIVE_OSC in $MDS_OSCS; do
5326 echo "Deactivate: " $INACTIVE_OSC
5327 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5328 for STRIPE_OSC in $MDS_OSCS; do
5329 OST=`osc_to_ost $STRIPE_OSC`
5330 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5331 awk -F: /$OST/'{ print $1 }' | head -n 1`
5333 [ -f $DIR/$tdir/$IDX ] && continue
5334 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5335 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5337 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5340 echo $INACTIVE_OSC "is Activate."
5341 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5344 run_test 65k "validate manual striping works properly with deactivated OSCs"
5346 test_65l() { # bug 12836
5347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5348 test_mkdir -p $DIR/$tdir/test_dir
5349 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5350 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5352 run_test 65l "lfs find on -1 stripe dir ========================"
5354 # bug 2543 - update blocks count on client
5356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5358 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5359 sync; sync_all_data; sync; sync_all_data
5360 cancel_lru_locks osc
5361 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5362 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5364 run_test 66 "update inode blocks count on client ==============="
5369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5371 if [ ! -z "$LLOOP" ]; then
5372 if swapon -s | grep -q $LLOOP; then
5373 swapoff $LLOOP || error "swapoff failed"
5376 $LCTL blockdev_detach $LLOOP || error "detach failed"
5380 if [ ! -z "$LLITELOOPLOAD" ]; then
5388 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5392 swapon -s | awk '($1 == "'$1'") { print $4 }'
5395 # test case for lloop driver, basic function
5397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5398 [ "$UID" != 0 ] && skip_env "must run as root" && return
5399 llite_lloop_enabled || \
5400 { skip_env "llite_lloop module disabled" && return; }
5402 trap cleanup_68 EXIT
5404 if ! module_loaded llite_lloop; then
5405 if load_module llite/llite_lloop; then
5408 skip_env "can't find module llite_lloop"
5413 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5414 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5415 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5417 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5418 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5422 run_test 68a "lloop driver - basic test ========================"
5424 # excercise swapping to lustre by adding a high priority swapfile entry
5425 # and then consuming memory until it is used.
5426 test_68b() { # was test_68
5427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5428 [ "$UID" != 0 ] && skip_env "must run as root" && return
5429 lctl get_param -n devices | grep -q obdfilter && \
5430 skip "local OST" && return
5432 grep -q llite_lloop /proc/modules
5433 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5435 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5436 skip "can't reliably test swap with TCP" && return
5438 MEMTOTAL=`meminfo MemTotal`
5439 NR_BLOCKS=$((MEMTOTAL>>8))
5440 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5442 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5443 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5446 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5448 trap cleanup_68 EXIT
5450 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5452 echo "before: `swapon -s | grep $LLOOP`"
5453 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5454 echo "after: `swapon -s | grep $LLOOP`"
5455 SWAPUSED=`swap_used $LLOOP`
5459 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5461 run_test 68b "support swapping to Lustre ========================"
5463 # bug5265, obdfilter oa2dentry return -ENOENT
5464 # #define OBD_FAIL_OST_ENOENT 0x217
5466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5467 remote_ost_nodsh && skip "remote OST with nodsh" && return
5470 $SETSTRIPE -c 1 -i 0 $f
5472 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5474 do_facet ost1 lctl set_param fail_loc=0x217
5475 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5476 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5478 do_facet ost1 lctl set_param fail_loc=0
5479 $DIRECTIO write $f 0 2 || error "write error"
5481 cancel_lru_locks osc
5482 $DIRECTIO read $f 0 1 || error "read error"
5484 do_facet ost1 lctl set_param fail_loc=0x217
5485 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5487 do_facet ost1 lctl set_param fail_loc=0
5490 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5493 test_mkdir -p $DIR/$tdir
5494 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5496 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5498 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5500 [ "$RUNAS_ID" = "$UID" ] &&
5501 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5503 # Check that testing environment is properly set up. Skip if not
5504 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5505 skip_env "User $RUNAS_ID does not exist - skipping"
5509 chmod 777 $DIR/$tfile
5510 chmod ug+s $DIR/$tfile
5511 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5512 error "$RUNAS dd $DIR/$tfile failed"
5513 # See if we are still setuid/sgid
5514 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5515 error "S/gid is not dropped on write"
5516 # Now test that MDS is updated too
5517 cancel_lru_locks mdc
5518 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5519 error "S/gid is not dropped on MDS"
5522 run_test 72a "Test that remove suid works properly (bug5695) ===="
5524 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5527 [ "$RUNAS_ID" = "$UID" ] && \
5528 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5529 [ "$RUNAS_ID" -eq 0 ] && \
5530 skip_env "RUNAS_ID = 0 -- skipping" && return
5532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5533 # Check that testing environment is properly set up. Skip if not
5534 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5535 skip_env "User $RUNAS_ID does not exist - skipping"
5538 touch $DIR/${tfile}-f{g,u}
5539 test_mkdir $DIR/${tfile}-dg
5540 test_mkdir $DIR/${tfile}-du
5541 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5542 chmod g+s $DIR/${tfile}-{f,d}g
5543 chmod u+s $DIR/${tfile}-{f,d}u
5544 for perm in 777 2777 4777; do
5545 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5546 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5547 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5548 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5552 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5554 # bug 3462 - multiple simultaneous MDC requests
5556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5557 test_mkdir $DIR/d73-1
5558 test_mkdir $DIR/d73-2
5559 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5562 lctl set_param fail_loc=0x80000129
5563 $MULTIOP $DIR/d73-1/f73-2 Oc &
5565 lctl set_param fail_loc=0
5567 $MULTIOP $DIR/d73-2/f73-3 Oc &
5571 wait $pid1 || return 1
5575 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5576 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5577 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5581 run_test 73 "multiple MDC requests (should not deadlock)"
5583 test_74a() { # bug 6149, 6184
5584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5585 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5587 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5588 # will spin in a tight reconnection loop
5590 $LCTL set_param fail_loc=0x8000030e
5591 # get any lock that won't be difficult - lookup works.
5593 $LCTL set_param fail_loc=0
5597 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5599 test_74b() { # bug 13310
5600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5601 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5603 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5604 # will spin in a tight reconnection loop
5605 $LCTL set_param fail_loc=0x8000030e
5606 # get a "difficult" lock
5608 $LCTL set_param fail_loc=0
5612 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5616 #define OBD_FAIL_LDLM_NEW_LOCK
5617 $LCTL set_param fail_loc=0x319
5618 touch $DIR/$tfile && error "touch successful"
5619 $LCTL set_param fail_loc=0
5622 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5625 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5628 get_inode_slab_tunables() {
5629 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5632 set_inode_slab_tunables() {
5633 echo "lustre_inode_cache $1" > /proc/slabinfo
5636 test_76() { # Now for bug 20433, added originally in bug 1443
5637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5638 local SLAB_SETTINGS=`get_inode_slab_tunables`
5639 local CPUS=`getconf _NPROCESSORS_ONLN`
5640 # we cannot set limit below 1 which means 1 inode in each
5641 # per-cpu cache is still allowed
5642 set_inode_slab_tunables "1 1 0"
5643 cancel_lru_locks osc
5644 BEFORE_INODES=$(num_inodes)
5645 echo "before inodes: $BEFORE_INODES"
5647 [ "$SLOW" = "no" ] && COUNT=100
5648 for i in $(seq $COUNT); do
5652 cancel_lru_locks osc
5653 AFTER_INODES=$(num_inodes)
5654 echo "after inodes: $AFTER_INODES"
5656 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5658 AFTER_INODES=$(num_inodes)
5660 echo "wait $wait seconds inodes: $AFTER_INODES"
5661 if [ $wait -gt 30 ]; then
5662 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5665 set_inode_slab_tunables "$SLAB_SETTINGS"
5667 run_test 76 "confirm clients recycle inodes properly ===="
5673 # Note: in sptlrpc modes which enable its own bulk checksum, the
5674 # original crc32_le bulk checksum will be automatically disabled,
5675 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5676 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5677 # In this case set_checksums() will not be no-op, because sptlrpc
5678 # bulk checksum will be enabled all through the test.
5680 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5681 lctl set_param -n osc.*.checksums $1
5685 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5686 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5687 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5688 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5691 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5692 log "set checksum type to $1"
5695 F77_TMP=$TMP/f77-temp
5698 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5699 error "error writing to $F77_TMP"
5702 test_77a() { # bug 10889
5703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5704 $GSS && skip "could not run with gss" && return
5705 [ ! -f $F77_TMP ] && setup_f77
5707 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5711 run_test 77a "normal checksum read/write operation"
5713 test_77b() { # bug 10889
5714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5715 $GSS && skip "could not run with gss" && return
5716 [ ! -f $F77_TMP ] && setup_f77
5717 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5718 $LCTL set_param fail_loc=0x80000409
5721 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5722 error "dd error: $?"
5723 $LCTL set_param fail_loc=0
5725 for algo in $CKSUM_TYPES; do
5726 cancel_lru_locks osc
5727 set_checksum_type $algo
5728 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5729 $LCTL set_param fail_loc=0x80000408
5730 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5731 $LCTL set_param fail_loc=0
5734 set_checksum_type $ORIG_CSUM_TYPE
5737 run_test 77b "checksum error on client write, read"
5739 test_77d() { # bug 10889
5740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5741 $GSS && skip "could not run with gss" && return
5742 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5743 $LCTL set_param fail_loc=0x80000409
5745 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5746 error "direct write: rc=$?"
5747 $LCTL set_param fail_loc=0
5750 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5751 $LCTL set_param fail_loc=0x80000408
5753 cancel_lru_locks osc
5754 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5755 error "direct read: rc=$?"
5756 $LCTL set_param fail_loc=0
5759 run_test 77d "checksum error on OST direct write, read"
5761 test_77f() { # bug 10889
5762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5763 $GSS && skip "could not run with gss" && return
5765 for algo in $CKSUM_TYPES; do
5766 cancel_lru_locks osc
5767 set_checksum_type $algo
5768 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5769 $LCTL set_param fail_loc=0x409
5770 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5771 error "direct write succeeded"
5772 $LCTL set_param fail_loc=0
5774 set_checksum_type $ORIG_CSUM_TYPE
5777 run_test 77f "repeat checksum error on write (expect error)"
5779 test_77g() { # bug 10889
5780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5781 $GSS && skip "could not run with gss" && return
5782 remote_ost_nodsh && skip "remote OST with nodsh" && return
5784 [ ! -f $F77_TMP ] && setup_f77
5786 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5787 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5788 do_facet ost1 lctl set_param fail_loc=0x8000021a
5790 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5791 error "write error: rc=$?"
5792 do_facet ost1 lctl set_param fail_loc=0
5795 cancel_lru_locks osc
5796 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5797 do_facet ost1 lctl set_param fail_loc=0x8000021b
5799 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5800 do_facet ost1 lctl set_param fail_loc=0
5803 run_test 77g "checksum error on OST write, read"
5805 test_77i() { # bug 13805
5806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5807 $GSS && skip "could not run with gss" && return
5808 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5809 lctl set_param fail_loc=0x40b
5810 remount_client $MOUNT
5811 lctl set_param fail_loc=0
5812 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5813 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5814 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5815 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5817 remount_client $MOUNT
5819 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5821 test_77j() { # bug 13805
5822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5823 $GSS && skip "could not run with gss" && return
5824 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5825 lctl set_param fail_loc=0x40c
5826 remount_client $MOUNT
5827 lctl set_param fail_loc=0
5828 sleep 2 # wait async osc connect to finish
5829 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5830 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5831 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5832 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5834 remount_client $MOUNT
5836 run_test 77j "client only supporting ADLER32"
5838 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5842 test_78() { # bug 10901
5843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5844 remote_ost || { skip_env "local OST" && return; }
5847 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5848 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5849 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5850 echo "MemTotal: $MEMTOTAL"
5852 # reserve 256MB of memory for the kernel and other running processes,
5853 # and then take 1/2 of the remaining memory for the read/write buffers.
5854 if [ $MEMTOTAL -gt 512 ] ;then
5855 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5857 # for those poor memory-starved high-end clusters...
5858 MEMTOTAL=$((MEMTOTAL / 2))
5860 echo "Mem to use for directio: $MEMTOTAL"
5862 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5863 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5864 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5865 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5867 echo "Smallest OST: $SMALLESTOST"
5868 [[ $SMALLESTOST -lt 10240 ]] &&
5869 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5871 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5872 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5874 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5875 echo "File size: $F78SIZE"
5876 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5877 for i in $(seq 1 $NSEQ); do
5878 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5879 echo directIO rdwr round $i of $NSEQ
5880 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5885 run_test 78 "handle large O_DIRECT writes correctly ============"
5887 test_79() { # bug 12743
5888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5889 wait_delete_completed
5891 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5892 BKFREE=$(calc_osc_kbytes kbytesfree)
5893 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5895 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5896 DFTOTAL=`echo $STRING | cut -d, -f1`
5897 DFUSED=`echo $STRING | cut -d, -f2`
5898 DFAVAIL=`echo $STRING | cut -d, -f3`
5899 DFFREE=$(($DFTOTAL - $DFUSED))
5901 ALLOWANCE=$((64 * $OSTCOUNT))
5903 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5904 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5905 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5907 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5908 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5909 error "df free($DFFREE) mismatch OST free($BKFREE)"
5911 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5912 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5913 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5916 run_test 79 "df report consistency check ======================="
5918 test_80() { # bug 10718
5919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5920 # relax strong synchronous semantics for slow backends like ZFS
5921 local soc="obdfilter.*.sync_on_lock_cancel"
5922 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5924 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5925 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5926 facet_active_host $host; done | sort -u)
5927 do_nodes $hosts lctl set_param $soc=never
5930 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5932 local BEFORE=`date +%s`
5933 cancel_lru_locks osc
5934 local AFTER=`date +%s`
5935 local DIFF=$((AFTER-BEFORE))
5936 if [ $DIFF -gt 1 ] ; then
5937 error "elapsed for 1M@1T = $DIFF"
5940 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5944 run_test 80 "Page eviction is equally fast at high offsets too ===="
5946 test_81a() { # LU-456
5947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5948 remote_ost_nodsh && skip "remote OST with nodsh" && return
5949 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5950 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5951 do_facet ost1 lctl set_param fail_loc=0x80000228
5953 # write should trigger a retry and success
5954 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5955 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5957 if [ $RC -ne 0 ] ; then
5958 error "write should success, but failed for $RC"
5961 run_test 81a "OST should retry write when get -ENOSPC ==============="
5963 test_81b() { # LU-456
5964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5965 remote_ost_nodsh && skip "remote OST with nodsh" && return
5966 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5967 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5968 do_facet ost1 lctl set_param fail_loc=0x228
5970 # write should retry several times and return -ENOSPC finally
5971 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5972 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5975 if [ $RC -ne $ENOSPC ] ; then
5976 error "dd should fail for -ENOSPC, but succeed."
5979 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5981 test_82() { # LU-1031
5982 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5986 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5988 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5990 kill -USR1 $MULTIPID2
5992 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5993 error "First grouplock does not block second one"
5995 echo "Second grouplock blocks first one"
5997 kill -USR1 $MULTIPID1
6001 run_test 82 "Basic grouplock test ==============================="
6004 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6006 test_mkdir -p $DIR/d99cvsroot
6007 chown $RUNAS_ID $DIR/d99cvsroot
6008 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6011 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6014 run_test 99a "cvs init ========================================="
6017 [ -z "$(which cvs 2>/dev/null)" ] &&
6018 skip_env "could not find cvs" && return
6019 [ ! -d $DIR/d99cvsroot ] && test_99a
6021 # some versions of cvs import exit(1) when asked to import links or
6022 # files they can't read. ignore those files.
6023 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6024 ! -perm +4 -printf '-I %f\n')
6025 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6026 d99reposname vtag rtag
6028 run_test 99b "cvs import ======================================="
6031 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6032 [ ! -d $DIR/d99cvsroot ] && test_99b
6034 test_mkdir -p $DIR/d99reposname
6035 chown $RUNAS_ID $DIR/d99reposname
6036 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6038 run_test 99c "cvs checkout ====================================="
6041 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6042 [ ! -d $DIR/d99cvsroot ] && test_99c
6043 cd $DIR/d99reposname
6045 $RUNAS cvs add -m 'addmsg' foo99
6047 run_test 99d "cvs add =========================================="
6050 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6051 [ ! -d $DIR/d99cvsroot ] && test_99c
6052 cd $DIR/d99reposname
6055 run_test 99e "cvs update ======================================="
6058 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6059 [ ! -d $DIR/d99cvsroot ] && test_99d
6060 cd $DIR/d99reposname
6061 $RUNAS cvs commit -m 'nomsg' foo99
6062 rm -fr $DIR/d99cvsroot
6064 run_test 99f "cvs commit ======================================="
6067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6068 [ "$NETTYPE" = tcp ] || \
6069 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6072 remote_ost_nodsh && skip "remote OST with nodsh" && return
6073 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6075 { skip "useless for local single node setup" && return; }
6077 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6078 [ "$PROT" != "tcp" ] && continue
6079 RPORT=$(echo $REMOTE | cut -d: -f2)
6080 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6083 LPORT=`echo $LOCAL | cut -d: -f2`
6084 if [ $LPORT -ge 1024 ]; then
6085 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6087 error_exit "local: $LPORT > 1024, remote: $RPORT"
6090 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6092 run_test 100 "check local port using privileged port ==========="
6094 function get_named_value()
6103 echo $line | sed "s/^$tag[ ]*//"
6110 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6111 awk '/^max_cached_mb/ { print $2 }')
6114 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6120 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6124 local cache_limit=32
6126 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6127 trap cleanup_101a EXIT
6128 $LCTL set_param -n llite.*.read_ahead_stats 0
6129 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6132 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6134 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6135 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6138 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6139 get_named_value 'read but discarded' | cut -d" " -f1); do
6140 discard=$(($discard + $s))
6144 if [[ $(($discard * 10)) -gt $nreads ]]; then
6145 $LCTL get_param osc.*-osc*.rpc_stats
6146 $LCTL get_param llite.*.read_ahead_stats
6147 error "too many ($discard) discarded pages"
6149 rm -f $DIR/$tfile || true
6151 run_test 101a "check read-ahead for random reads ================"
6154 test_mkdir -p $DIR/$tdir
6155 local STRIPE_SIZE=$1
6156 local FILE_LENGTH=$2
6159 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6161 local list=$(comma_list $(osts_nodes))
6162 set_osd_param $list '' read_cache_enable 0
6163 set_osd_param $list '' writethrough_cache_enable 0
6165 trap cleanup_test101bc EXIT
6166 # prepare the read-ahead file
6167 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6169 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6170 count=$FILE_SIZE_MB 2> /dev/null
6174 cleanup_test101bc() {
6179 local list=$(comma_list $(osts_nodes))
6180 set_osd_param $list '' read_cache_enable 1
6181 set_osd_param $list '' writethrough_cache_enable 1
6185 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6190 local STRIPE_SIZE=$2
6191 local FILE_LENGTH=$3
6192 local RA_INC=1048576
6193 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6194 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6195 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6196 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6197 get_named_value 'read but discarded' |
6198 cut -d" " -f1 | calc_total)
6199 if [[ $DISCARD -gt $discard_limit ]]; then
6200 $LCTL get_param llite.*.read_ahead_stats
6201 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6203 echo "Read-ahead success for size ${READ_SIZE}"
6208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6209 [[ $OSTCOUNT -lt 2 ]] &&
6210 skip_env "skipping stride IO stride-ahead test" && return
6211 local STRIPE_SIZE=1048576
6212 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6213 if [ $SLOW == "yes" ]; then
6214 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6216 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6219 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6221 # prepare the read-ahead file
6222 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6223 cancel_lru_locks osc
6224 for BIDX in 2 4 8 16 32 64 128 256
6226 local BSIZE=$((BIDX*4096))
6227 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6228 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6229 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6230 $LCTL set_param -n llite.*.read_ahead_stats 0
6231 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6232 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6233 cancel_lru_locks osc
6234 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6239 run_test 101b "check stride-io mode read-ahead ================="
6242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6243 local STRIPE_SIZE=1048576
6244 local FILE_LENGTH=$((STRIPE_SIZE*100))
6248 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6250 cancel_lru_locks osc
6251 $LCTL set_param osc.*.rpc_stats 0
6252 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6253 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6254 local stats=$($LCTL get_param -n $osc_rpc_stats)
6255 local lines=$(echo "$stats" | awk 'END {print NR;}')
6258 if [ $lines -le 20 ]; then
6261 for size in 1 2 4 8; do
6262 local rpc=$(echo "$stats" |
6263 awk '($1 == "'$size':") {print $2; exit; }')
6265 error "Small $((size*4))k read IO $rpc !"
6267 echo "$osc_rpc_stats check passed!"
6272 run_test 101c "check stripe_size aligned read-ahead ================="
6275 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6276 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6281 local file=$DIR/$tfile
6282 local sz_MB=${FILESIZE_101d:-500}
6283 local ra_MB=${READAHEAD_MB:-40}
6285 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6286 [ $free_MB -lt $sz_MB ] &&
6287 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6289 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6290 $SETSTRIPE -c -1 $file || error "setstripe failed"
6292 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6293 echo Cancel LRU locks on lustre client to flush the client cache
6294 cancel_lru_locks osc
6296 echo Disable read-ahead
6297 local old_READAHEAD=$(set_read_ahead 0)
6299 echo Reading the test file $file with read-ahead disabled
6300 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6302 echo Cancel LRU locks on lustre client to flush the client cache
6303 cancel_lru_locks osc
6304 echo Enable read-ahead with ${ra_MB}MB
6305 set_read_ahead $ra_MB
6307 echo Reading the test file $file with read-ahead enabled
6308 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6310 echo "read-ahead disabled time read $raOFF"
6311 echo "read-ahead enabled time read $raON"
6313 set_read_ahead $old_READAHEAD
6315 wait_delete_completed
6317 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6318 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6320 run_test 101d "file read with and without read-ahead enabled"
6323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6324 local file=$DIR/$tfile
6325 local size_KB=500 #KB
6329 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6330 local need_KB=$((count * size_KB))
6331 [[ $free_KB -le $need_KB ]] &&
6332 skip_env "Need free space $need_KB, have $free_KB" && return
6334 echo "Creating $count ${size_KB}K test files"
6335 for ((i = 0; i < $count; i++)); do
6336 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6339 echo "Cancel LRU locks on lustre client to flush the client cache"
6340 cancel_lru_locks osc
6342 echo "Reset readahead stats"
6343 $LCTL set_param -n llite.*.read_ahead_stats 0
6345 for ((i = 0; i < $count; i++)); do
6346 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6349 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6350 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6352 for ((i = 0; i < $count; i++)); do
6353 rm -rf $file.$i 2>/dev/null
6356 #10000 means 20% reads are missing in readahead
6357 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6359 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6361 cleanup_test101f() {
6363 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6364 rm -rf $DIR/$tfile 2>/dev/null
6368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6369 local file=$DIR/$tfile
6372 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6373 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6374 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6375 trap cleanup_test101f EXIT
6377 echo Cancel LRU locks on lustre client to flush the client cache
6378 cancel_lru_locks osc
6380 echo Reset readahead stats
6381 $LCTL set_param -n llite.*.read_ahead_stats 0
6382 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6383 # readahead should read in 2M file on second read, so only miss
6385 echo Random 4K reads on 2M file for 1000 times
6386 $READS -f $file -s 2097152 -b 4096 -n $nreads
6388 echo checking missing pages
6389 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6390 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6392 [ $miss -lt 3 ] || error "misses too much pages!"
6395 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6398 test_mkdir -p $DIR/$tdir
6399 chown $RUNAS_ID $DIR/$tdir
6402 STRIPE_COUNT=$OSTCOUNT
6403 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6405 trap cleanup_test102 EXIT
6407 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6409 for num in 1 2 3 4; do
6410 for count in $(seq 1 $STRIPE_COUNT); do
6411 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6412 local size=`expr $STRIPE_SIZE \* $num`
6413 local file=file"$num-$idx-$count"
6414 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6420 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6426 rm -rf $DIR/d0.sanity/d102
6430 local testfile=$DIR/$tfile
6434 [ "$UID" != 0 ] && skip_env "must run as root" && return
6435 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6436 skip_env "must have user_xattr" && return
6438 [ -z "$(which setfattr 2>/dev/null)" ] &&
6439 skip_env "could not find setfattr" && return
6441 echo "set/get xattr..."
6442 setfattr -n trusted.name1 -v value1 $testfile ||
6443 error "setfattr -n trusted.name1=value1 $testfile failed"
6444 getfattr -n trusted.name1 $testfile 2> /dev/null |
6445 grep "trusted.name1=.value1" ||
6446 error "$testfile missing trusted.name1=value1"
6448 setfattr -n user.author1 -v author1 $testfile ||
6449 error "setfattr -n user.author1=author1 $testfile failed"
6450 getfattr -n user.author1 $testfile 2> /dev/null |
6451 grep "user.author1=.author1" ||
6452 error "$testfile missing trusted.author1=author1"
6455 setfattr -n trusted.name2 -v value2 $testfile ||
6456 error "$testfile unable to set trusted.name2"
6457 setfattr -n trusted.name3 -v value3 $testfile ||
6458 error "$testfile unable to set trusted.name3"
6459 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6460 grep "trusted.name" | wc -l) -eq 3 ] ||
6461 error "$testfile missing 3 trusted.name xattrs"
6463 setfattr -n user.author2 -v author2 $testfile ||
6464 error "$testfile unable to set user.author2"
6465 setfattr -n user.author3 -v author3 $testfile ||
6466 error "$testfile unable to set user.author3"
6467 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6468 grep "user.author" | wc -l) -eq 3 ] ||
6469 error "$testfile missing 3 user.author xattrs"
6471 echo "remove xattr..."
6472 setfattr -x trusted.name1 $testfile ||
6473 error "$testfile error deleting trusted.name1"
6474 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6475 error "$testfile did not delete trusted.name1 xattr"
6477 setfattr -x user.author1 $testfile ||
6478 error "$testfile error deleting user.author1"
6479 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6480 error "$testfile did not delete trusted.name1 xattr"
6482 # b10667: setting lustre special xattr be silently discarded
6483 echo "set lustre special xattr ..."
6484 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6485 error "$testfile allowed setting trusted.lov"
6487 run_test 102a "user xattr test =================================="
6490 [ -z "$(which setfattr 2>/dev/null)" ] &&
6491 skip_env "could not find setfattr" && return
6493 # b10930: get/set/list trusted.lov xattr
6494 echo "get/set/list trusted.lov xattr ..."
6495 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6496 local testfile=$DIR/$tfile
6497 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6498 error "setstripe failed"
6499 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6500 error "getstripe failed"
6501 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6502 error "can't get trusted.lov from $testfile"
6504 local testfile2=${testfile}2
6505 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6506 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6509 setfattr -n trusted.lov -v $value $testfile2
6510 local stripe_size=$($GETSTRIPE -S $testfile2)
6511 local stripe_count=$($GETSTRIPE -c $testfile2)
6512 [[ $stripe_size -eq 65536 ]] ||
6513 error "stripe size $stripe_size != 65536"
6514 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6515 error "stripe count $stripe_count != $STRIPECOUNT"
6518 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6521 [ -z "$(which setfattr 2>/dev/null)" ] &&
6522 skip_env "could not find setfattr" && return
6524 # b10930: get/set/list lustre.lov xattr
6525 echo "get/set/list lustre.lov xattr ..."
6526 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6527 test_mkdir -p $DIR/$tdir
6528 chown $RUNAS_ID $DIR/$tdir
6529 local testfile=$DIR/$tdir/$tfile
6530 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6531 error "setstripe failed"
6532 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6533 error "getstripe failed"
6534 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6535 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6537 local testfile2=${testfile}2
6538 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6539 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6541 $RUNAS $MCREATE $testfile2
6542 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6543 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6544 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6545 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6546 [ $stripe_count -eq $STRIPECOUNT ] ||
6547 error "stripe count $stripe_count != $STRIPECOUNT"
6549 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6551 compare_stripe_info1() {
6552 local stripe_index_all_zero=true
6554 for num in 1 2 3 4; do
6555 for count in $(seq 1 $STRIPE_COUNT); do
6556 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6557 local size=$((STRIPE_SIZE * num))
6558 local file=file"$num-$offset-$count"
6559 stripe_size=$(lfs getstripe -S $PWD/$file)
6560 [[ $stripe_size -ne $size ]] &&
6561 error "$file: size $stripe_size != $size"
6562 stripe_count=$(lfs getstripe -c $PWD/$file)
6563 # allow fewer stripes to be created, ORI-601
6564 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6565 error "$file: count $stripe_count != $count"
6566 stripe_index=$(lfs getstripe -i $PWD/$file)
6567 [[ $stripe_index -ne 0 ]] &&
6568 stripe_index_all_zero=false
6572 $stripe_index_all_zero &&
6573 error "all files are being extracted starting from OST index 0"
6578 [ -n "$(which tar 2>/dev/null)" ] &&
6579 strings $(which tar) | grep -q "lustre" && echo tar
6583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6584 # b10930: tar test for trusted.lov xattr
6585 TAR=$(find_lustre_tar)
6586 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6587 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6589 test_mkdir -p $DIR/d102d
6590 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6592 compare_stripe_info1
6594 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6598 # b10930: tar test for trusted.lov xattr
6599 TAR=$(find_lustre_tar)
6600 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6601 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6603 test_mkdir -p $DIR/d102f
6605 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6607 compare_stripe_info1
6609 run_test 102f "tar copy files, not keep osts ==========="
6612 local xsize=${1:-1024} # in bytes
6613 local file=$DIR/$tfile
6615 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6616 skip "must have user_xattr" && return 0
6617 [ -z "$(which setfattr 2>/dev/null)" ] &&
6618 skip_env "could not find setfattr" && return 0
6619 [ -z "$(which getfattr 2>/dev/null)" ] &&
6620 skip_env "could not find getfattr" && return 0
6624 local value="$(generate_string $xsize)"
6626 local xbig=trusted.big
6627 log "save $xbig on $file"
6628 setfattr -n $xbig -v $value $file ||
6629 error "saving $xbig on $file failed"
6631 local orig=$(get_xattr_value $xbig $file)
6632 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6634 local xsml=trusted.sml
6635 log "save $xsml on $file"
6636 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6638 local new=$(get_xattr_value $xbig $file)
6639 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6641 log "grow $xsml on $file"
6642 setfattr -n $xsml -v "$value" $file ||
6643 error "growing $xsml on $file failed"
6645 new=$(get_xattr_value $xbig $file)
6646 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6647 log "$xbig still valid after growing $xsml"
6652 test_102h() { # bug 15777
6655 run_test 102h "grow xattr from inside inode to external block"
6658 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6659 grow_xattr $(max_xattr_size)
6661 run_test 102ha "grow xattr from inside inode to external inode"
6663 test_102i() { # bug 17038
6664 [ -z "$(which getfattr 2>/dev/null)" ] &&
6665 skip "could not find getfattr" && return
6667 ln -s $DIR/$tfile $DIR/${tfile}link
6668 getfattr -n trusted.lov $DIR/$tfile ||
6669 error "lgetxattr on $DIR/$tfile failed"
6670 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6671 grep -i "no such attr" ||
6672 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6673 rm -f $DIR/$tfile $DIR/${tfile}link
6675 run_test 102i "lgetxattr test on symbolic link ============"
6678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6679 TAR=$(find_lustre_tar)
6680 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6681 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6682 setup_test102 "$RUNAS"
6683 test_mkdir -p $DIR/d102j
6684 chown $RUNAS_ID $DIR/d102j
6685 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6687 compare_stripe_info1 "$RUNAS"
6689 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6692 [ -z "$(which setfattr 2>/dev/null)" ] &&
6693 skip "could not find setfattr" && return
6695 # b22187 just check that does not crash for regular file.
6696 setfattr -n trusted.lov $DIR/$tfile
6697 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6698 local test_kdir=$DIR/d102k
6699 test_mkdir $test_kdir
6700 local default_size=`$GETSTRIPE -S $test_kdir`
6701 local default_count=`$GETSTRIPE -c $test_kdir`
6702 local default_offset=`$GETSTRIPE -i $test_kdir`
6703 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6704 error 'dir setstripe failed'
6705 setfattr -n trusted.lov $test_kdir
6706 local stripe_size=`$GETSTRIPE -S $test_kdir`
6707 local stripe_count=`$GETSTRIPE -c $test_kdir`
6708 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6709 [ $stripe_size -eq $default_size ] ||
6710 error "stripe size $stripe_size != $default_size"
6711 [ $stripe_count -eq $default_count ] ||
6712 error "stripe count $stripe_count != $default_count"
6713 [ $stripe_offset -eq $default_offset ] ||
6714 error "stripe offset $stripe_offset != $default_offset"
6715 rm -rf $DIR/$tfile $test_kdir
6717 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6720 [ -z "$(which getfattr 2>/dev/null)" ] &&
6721 skip "could not find getfattr" && return
6723 # LU-532 trusted. xattr is invisible to non-root
6724 local testfile=$DIR/$tfile
6728 echo "listxattr as user..."
6729 chown $RUNAS_ID $testfile
6730 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6731 grep -q "trusted" &&
6732 error "$testfile trusted xattrs are user visible"
6736 run_test 102l "listxattr size test =================================="
6738 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6739 local path=$DIR/$tfile
6742 listxattr_size_check $path || error "listattr_size_check $path failed"
6744 run_test 102m "Ensure listxattr fails on small bufffer ========"
6748 getxattr() { # getxattr path name
6749 # Return the base64 encoding of the value of xattr name on path.
6753 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6755 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6757 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6759 getfattr --absolute-names --encoding=base64 --name=$name $path |
6760 awk -F= -v name=$name '$1 == name {
6761 print substr($0, index($0, "=") + 1);
6765 test_102n() { # LU-4101 mdt: protect internal xattrs
6766 local file0=$DIR/$tfile.0
6767 local file1=$DIR/$tfile.1
6768 local xattr0=$TMP/$tfile.0
6769 local xattr1=$TMP/$tfile.1
6773 [ -z "$(which setfattr 2>/dev/null)" ] &&
6774 skip "could not find setfattr" && return
6776 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6778 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6782 rm -rf $file0 $file1 $xattr0 $xattr1
6785 # Get 'before' xattrs of $file1.
6786 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6788 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6789 # Try to copy xattr from $file0 to $file1.
6790 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6792 setfattr --name=trusted.$name --value="$value" $file1 ||
6793 error "setxattr 'trusted.$name' failed"
6795 # Try to set a garbage xattr.
6796 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6798 setfattr --name=trusted.$name --value="$value" $file1 ||
6799 error "setxattr 'trusted.$name' failed"
6801 # Try to remove the xattr from $file1. We don't care if this
6802 # appears to succeed or fail, we just don't want there to be
6803 # any changes or crashes.
6804 setfattr --remove=$trusted.$name $file1 2> /dev/null
6807 # Get 'after' xattrs of file1.
6808 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6810 if ! diff $xattr0 $xattr1; then
6811 error "before and after xattrs of '$file1' differ"
6814 rm -rf $file0 $file1 $xattr0 $xattr1
6818 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6820 test_102p() { # LU-4703 setxattr did not check ownership
6821 local testfile=$DIR/$tfile
6823 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6824 skip "MDS needs to be at least 2.5.56" && return
6828 echo "setfacl as user..."
6829 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6830 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6832 echo "setfattr as user..."
6833 setfacl -m "u:$RUNAS_ID:---" $testfile
6834 $RUNAS setfattr -x system.posix_acl_access $testfile
6835 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6837 run_test 102p "check setxattr(2) correctly fails without permission"
6841 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6846 [ "$UID" != 0 ] && skip_env "must run as root" && return
6847 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6848 skip "must have acl enabled" && return
6849 [ -z "$(which setfacl 2>/dev/null)" ] &&
6850 skip_env "could not find setfacl" && return
6851 $GSS && skip "could not run under gss" && return
6853 declare -a identity_old
6855 for num in $(seq $MDSCOUNT); do
6856 switch_identity $num true || identity_old[$num]=$?
6863 echo "performing cp ..."
6864 run_acl_subtest cp || error "run_acl_subtest cp failed"
6865 echo "performing getfacl-noacl..."
6866 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6867 echo "performing misc..."
6868 run_acl_subtest misc || error "misc test failed"
6869 echo "performing permissions..."
6870 run_acl_subtest permissions || error "permissions failed"
6871 echo "performing setfacl..."
6872 run_acl_subtest setfacl || error "setfacl test failed"
6874 # inheritance test got from HP
6875 echo "performing inheritance..."
6876 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6877 chmod +x make-tree || error "chmod +x failed"
6878 run_acl_subtest inheritance || error "inheritance test failed"
6881 echo "LU-974 ignore umask when acl is enabled..."
6882 run_acl_subtest 974 || error "LU-974 umask test failed"
6883 if [ $MDSCOUNT -ge 2 ]; then
6884 run_acl_subtest 974_remote ||
6885 error "LU-974 umask test failed under remote dir"
6888 echo "LU-2561 newly created file is same size as directory..."
6889 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6890 run_acl_subtest 2561 || error "LU-2561 test failed"
6892 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6895 run_acl_subtest 4924 || error "LU-4924 test failed"
6900 for num in $(seq $MDSCOUNT); do
6901 if [ "${identity_old[$num]}" = 1 ]; then
6902 switch_identity $num false || identity_old[$num]=$?
6906 run_test 103 "acl test ========================================="
6909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6911 lfs df || error "lfs df failed"
6912 lfs df -ih || error "lfs df -ih failed"
6913 lfs df -h $DIR || error "lfs df -h $DIR failed"
6914 lfs df -i $DIR || error "lfs df -i $DIR failed"
6915 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6916 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6918 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6919 lctl --device %$OSC deactivate
6920 lfs df || error "lfs df with deactivated OSC failed"
6921 lctl --device %$OSC activate
6922 # wait the osc back to normal
6923 wait_osc_import_state client ost FULL
6925 lfs df || error "lfs df with reactivated OSC failed"
6928 run_test 104a "lfs df [-ih] [path] test ========================="
6931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6932 [ $RUNAS_ID -eq $UID ] &&
6933 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6935 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6936 grep "Permission denied" | wc -l)))
6937 if [ $denied_cnt -ne 0 ]; then
6938 error "lfs check servers test failed"
6941 run_test 104b "$RUNAS lfs check servers test ===================="
6944 # doesn't work on 2.4 kernels
6946 if $(flock_is_enabled); then
6947 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6949 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6953 run_test 105a "flock when mounted without -o flock test ========"
6957 if $(flock_is_enabled); then
6958 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6960 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6964 run_test 105b "fcntl when mounted without -o flock test ========"
6968 if $(flock_is_enabled); then
6969 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6971 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6975 run_test 105c "lockf when mounted without -o flock test ========"
6977 test_105d() { # bug 15924
6978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6979 test_mkdir -p $DIR/$tdir
6980 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6981 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6982 $LCTL set_param fail_loc=0x80000315
6983 flocks_test 2 $DIR/$tdir
6985 run_test 105d "flock race (should not freeze) ========"
6987 test_105e() { # bug 22660 && 22040
6988 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6990 flocks_test 3 $DIR/$tfile
6992 run_test 105e "Two conflicting flocks from same process ======="
6994 test_106() { #bug 10921
6995 test_mkdir -p $DIR/$tdir
6996 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6997 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6999 run_test 106 "attempt exec of dir followed by chown of that dir"
7002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7009 local save_pattern=$(sysctl -n kernel.core_pattern)
7010 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7011 sysctl -w kernel.core_pattern=$file
7012 sysctl -w kernel.core_uses_pid=0
7020 kill -s 11 $SLEEPPID
7022 if [ -e $file ]; then
7023 size=`stat -c%s $file`
7024 [ $size -eq 0 ] && error "Fail to create core file $file"
7026 error "Fail to create core file $file"
7029 sysctl -w kernel.core_pattern=$save_pattern
7030 sysctl -w kernel.core_uses_pid=$save_uses_pid
7033 run_test 107 "Coredump on SIG"
7036 test_mkdir -p $DIR/$tdir
7037 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7038 error "mkdir with 255 char failed"
7039 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7040 error "mkdir with 256 char should fail, but did not"
7041 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7042 error "create with 255 char failed"
7043 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7044 error "create with 256 char should fail, but did not"
7049 run_test 110 "filename length checking"
7052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7053 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7054 tail -1 | cut -c11-20)
7055 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7056 echo "Starting with $OSTIO_pre threads"
7059 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7060 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7061 echo "$NUMTEST creates/unlinks"
7062 test_mkdir -p $DIR/$tdir
7063 createmany -o $DIR/$tdir/$tfile $NUMTEST
7064 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7066 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7067 tail -1 | cut -c11-20)
7069 # don't return an error
7070 [ $OSTIO_post == $OSTIO_pre ] && echo \
7071 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7072 echo "This may be fine, depending on what ran before this test" &&
7073 echo "and how fast this system is." && return
7075 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7077 run_test 115 "verify dynamic thread creation===================="
7080 wait_delete_completed
7081 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7082 echo OST kbytes available: ${AVAIL[@]}
7083 MAXI=0; MAXV=${AVAIL[0]}
7084 MINI=0; MINV=${AVAIL[0]}
7085 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7086 #echo OST $i: ${AVAIL[i]}kb
7087 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7088 MAXV=${AVAIL[i]}; MAXI=$i
7090 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7091 MINV=${AVAIL[i]}; MINI=$i
7094 echo Min free space: OST $MINI: $MINV
7095 echo Max free space: OST $MAXI: $MAXV
7098 test_116a() { # was previously test_116()
7099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7100 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7102 echo -n "Free space priority "
7103 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7108 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7109 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7111 trap simple_cleanup_common EXIT
7114 # Check if we need to generate uneven OSTs
7115 test_mkdir -p $DIR/$tdir/OST${MINI}
7116 local FILL=$(($MINV / 4))
7117 local DIFF=$(($MAXV - $MINV))
7118 local DIFF2=$(($DIFF * 100 / $MINV))
7120 local threshold=$(do_facet $SINGLEMDS \
7121 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7122 threshold=${threshold%%%}
7123 echo -n "Check for uneven OSTs: "
7124 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7126 if [[ $DIFF2 -gt $threshold ]]; then
7128 echo "Don't need to fill OST$MINI"
7130 # generate uneven OSTs. Write 2% over the QOS threshold value
7132 DIFF=$(($threshold - $DIFF2 + 2))
7133 DIFF2=$(( ($MINV * $DIFF)/100 ))
7134 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7135 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7136 error "setstripe failed"
7137 DIFF=$(($DIFF2 / 2048))
7139 while [ $i -lt $DIFF ]; do
7141 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7142 bs=2M count=1 2>/dev/null
7151 DIFF=$(($MAXV - $MINV))
7152 DIFF2=$(($DIFF * 100 / $MINV))
7153 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7154 if [[ $DIFF2 -gt $threshold ]]; then
7157 echo "failed - QOS mode won't be used"
7158 skip "QOS imbalance criteria not met"
7159 simple_cleanup_common
7163 MINI1=$MINI; MINV1=$MINV
7164 MAXI1=$MAXI; MAXV1=$MAXV
7166 # now fill using QOS
7167 $SETSTRIPE -c 1 $DIR/$tdir
7168 FILL=$(($FILL / 200))
7169 if [ $FILL -gt 600 ]; then
7172 echo "writing $FILL files to QOS-assigned OSTs"
7174 while [ $i -lt $FILL ]; do
7176 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7180 echo "wrote $i 200k files"
7184 echo "Note: free space may not be updated, so measurements might be off"
7186 DIFF2=$(($MAXV - $MINV))
7187 echo "free space delta: orig $DIFF final $DIFF2"
7188 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7189 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7190 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7191 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7192 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7193 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7195 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7197 # Figure out which files were written where
7198 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7199 awk '/'$MINI1': / {print $2; exit}')
7201 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7202 echo "$MINC files created on smaller OST $MINI1"
7203 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7204 awk '/'$MAXI1': / {print $2; exit}')
7206 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7207 echo "$MAXC files created on larger OST $MAXI1"
7208 FILL=$(($MAXC * 100 / $MINC - 100))
7209 [[ $MINC -gt 0 ]] &&
7210 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7211 [[ $MAXC -gt $MINC ]] ||
7212 error_ignore LU-9 "stripe QOS didn't balance free space"
7213 simple_cleanup_common
7215 run_test 116a "stripe QOS: free space balance ==================="
7217 test_116b() { # LU-2093
7218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7219 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7220 head -1 2>/dev/null)" ] && skip "no QOS" && return
7221 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7223 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7224 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7225 do_facet $SINGLEMDS lctl set_param \
7226 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7228 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7229 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7230 do_facet $SINGLEMDS lctl set_param fail_loc=0
7232 do_facet $SINGLEMDS lctl set_param \
7233 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7235 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7237 test_117() # bug 10891
7239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7240 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7241 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7242 lctl set_param fail_loc=0x21e
7243 > $DIR/$tfile || error "truncate failed"
7244 lctl set_param fail_loc=0
7245 echo "Truncate succeeded."
7248 run_test 117 "verify osd extend =========="
7250 NO_SLOW_RESENDCOUNT=4
7251 export OLD_RESENDCOUNT=""
7252 set_resend_count () {
7253 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7254 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7255 lctl set_param -n $PROC_RESENDCOUNT $1
7256 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7259 # for reduce test_118* time (b=14842)
7260 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7262 # Reset async IO behavior after error case
7264 FILE=$DIR/reset_async
7266 # Ensure all OSCs are cleared
7267 $SETSTRIPE -c -1 $FILE
7268 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7273 test_118a() #bug 11710
7275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7278 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7279 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7280 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7282 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7283 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7288 run_test 118a "verify O_SYNC works =========="
7292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7293 remote_ost_nodsh && skip "remote OST with nodsh" && return
7297 #define OBD_FAIL_OST_ENOENT 0x217
7298 set_nodes_failloc "$(osts_nodes)" 0x217
7299 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7301 set_nodes_failloc "$(osts_nodes)" 0
7302 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7303 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7306 if [[ $RC -eq 0 ]]; then
7307 error "Must return error due to dropped pages, rc=$RC"
7311 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7312 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7316 echo "Dirty pages not leaked on ENOENT"
7318 # Due to the above error the OSC will issue all RPCs syncronously
7319 # until a subsequent RPC completes successfully without error.
7320 $MULTIOP $DIR/$tfile Ow4096yc
7325 run_test 118b "Reclaim dirty pages on fatal error =========="
7329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7331 # for 118c, restore the original resend count, LU-1940
7332 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7333 set_resend_count $OLD_RESENDCOUNT
7334 remote_ost_nodsh && skip "remote OST with nodsh" && return
7338 #define OBD_FAIL_OST_EROFS 0x216
7339 set_nodes_failloc "$(osts_nodes)" 0x216
7341 # multiop should block due to fsync until pages are written
7342 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7346 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7347 error "Multiop failed to block on fsync, pid=$MULTIPID"
7350 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7352 if [[ $WRITEBACK -eq 0 ]]; then
7353 error "No page in writeback, writeback=$WRITEBACK"
7356 set_nodes_failloc "$(osts_nodes)" 0
7359 if [[ $RC -ne 0 ]]; then
7360 error "Multiop fsync failed, rc=$RC"
7363 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7364 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7366 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7367 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7371 echo "Dirty pages flushed via fsync on EROFS"
7374 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7376 # continue to use small resend count to reduce test_118* time (b=14842)
7377 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7382 remote_ost_nodsh && skip "remote OST with nodsh" && return
7386 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7387 set_nodes_failloc "$(osts_nodes)" 0x214
7388 # multiop should block due to fsync until pages are written
7389 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7393 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7394 error "Multiop failed to block on fsync, pid=$MULTIPID"
7397 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7399 if [[ $WRITEBACK -eq 0 ]]; then
7400 error "No page in writeback, writeback=$WRITEBACK"
7403 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7404 set_nodes_failloc "$(osts_nodes)" 0
7406 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7407 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7409 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7410 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7414 echo "Dirty pages gaurenteed flushed via fsync"
7417 run_test 118d "Fsync validation inject a delay of the bulk =========="
7420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7423 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7424 lctl set_param fail_loc=0x8000040a
7426 # Should simulate EINVAL error which is fatal
7427 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7429 if [[ $RC -eq 0 ]]; then
7430 error "Must return error due to dropped pages, rc=$RC"
7433 lctl set_param fail_loc=0x0
7435 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7436 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7437 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7439 if [[ $LOCKED -ne 0 ]]; then
7440 error "Locked pages remain in cache, locked=$LOCKED"
7443 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7444 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7448 echo "No pages locked after fsync"
7453 run_test 118f "Simulate unrecoverable OSC side error =========="
7456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7459 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7460 lctl set_param fail_loc=0x406
7462 # simulate local -ENOMEM
7463 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7466 lctl set_param fail_loc=0
7467 if [[ $RC -eq 0 ]]; then
7468 error "Must return error due to dropped pages, rc=$RC"
7471 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7472 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7473 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7475 if [[ $LOCKED -ne 0 ]]; then
7476 error "Locked pages remain in cache, locked=$LOCKED"
7479 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7480 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7484 echo "No pages locked after fsync"
7489 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7493 remote_ost_nodsh && skip "remote OST with nodsh" && return
7497 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7498 set_nodes_failloc "$(osts_nodes)" 0x20e
7499 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7500 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7503 set_nodes_failloc "$(osts_nodes)" 0
7504 if [[ $RC -eq 0 ]]; then
7505 error "Must return error due to dropped pages, rc=$RC"
7508 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7509 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7510 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7512 if [[ $LOCKED -ne 0 ]]; then
7513 error "Locked pages remain in cache, locked=$LOCKED"
7516 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7517 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7521 echo "No pages locked after fsync"
7525 run_test 118h "Verify timeout in handling recoverables errors =========="
7527 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7531 remote_ost_nodsh && skip "remote OST with nodsh" && return
7535 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7536 set_nodes_failloc "$(osts_nodes)" 0x20e
7538 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7539 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7542 set_nodes_failloc "$(osts_nodes)" 0
7546 if [[ $RC -ne 0 ]]; then
7547 error "got error, but should be not, rc=$RC"
7550 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7551 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7552 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7553 if [[ $LOCKED -ne 0 ]]; then
7554 error "Locked pages remain in cache, locked=$LOCKED"
7557 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7558 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7562 echo "No pages locked after fsync"
7566 run_test 118i "Fix error before timeout in recoverable error =========="
7568 [ "$SLOW" = "no" ] && set_resend_count 4
7571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7572 remote_ost_nodsh && skip "remote OST with nodsh" && return
7576 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7577 set_nodes_failloc "$(osts_nodes)" 0x220
7579 # return -EIO from OST
7580 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7582 set_nodes_failloc "$(osts_nodes)" 0x0
7583 if [[ $RC -eq 0 ]]; then
7584 error "Must return error due to dropped pages, rc=$RC"
7587 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7588 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7589 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7590 if [[ $LOCKED -ne 0 ]]; then
7591 error "Locked pages remain in cache, locked=$LOCKED"
7594 # in recoverable error on OST we want resend and stay until it finished
7595 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7596 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7600 echo "No pages locked after fsync"
7604 run_test 118j "Simulate unrecoverable OST side error =========="
7608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7609 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7611 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7612 set_nodes_failloc "$(osts_nodes)" 0x20e
7613 test_mkdir -p $DIR/$tdir
7615 for ((i=0;i<10;i++)); do
7616 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7617 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7624 set_nodes_failloc "$(osts_nodes)" 0
7627 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7633 test_mkdir -p $DIR/$tdir
7634 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7637 run_test 118l "fsync dir ========="
7639 test_118m() # LU-3066
7641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7642 test_mkdir -p $DIR/$tdir
7643 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7646 run_test 118m "fdatasync dir ========="
7648 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7650 test_119a() # bug 11737
7652 BSIZE=$((512 * 1024))
7653 directio write $DIR/$tfile 0 1 $BSIZE
7654 # We ask to read two blocks, which is more than a file size.
7655 # directio will indicate an error when requested and actual
7656 # sizes aren't equeal (a normal situation in this case) and
7657 # print actual read amount.
7658 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7659 if [ "$NOB" != "$BSIZE" ]; then
7660 error "read $NOB bytes instead of $BSIZE"
7664 run_test 119a "Short directIO read must return actual read amount"
7666 test_119b() # bug 11737
7668 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7670 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7671 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7673 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7674 error "direct read failed"
7677 run_test 119b "Sparse directIO read must return actual read amount"
7679 test_119c() # bug 13099
7682 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7683 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7686 run_test 119c "Testing for direct read hitting hole"
7688 test_119d() # bug 15950
7690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7691 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7692 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7694 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7695 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7696 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7697 lctl set_param fail_loc=0x40d
7698 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7701 cat $DIR/$tfile > /dev/null &
7702 lctl set_param fail_loc=0
7705 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7707 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7708 error "the read rpcs have not completed in 2s"
7710 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7712 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7716 test_mkdir -p $DIR/$tdir
7717 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7718 skip "no early lock cancel on server" && return 0
7720 lru_resize_disable mdc
7721 lru_resize_disable osc
7722 cancel_lru_locks mdc
7723 # asynchronous object destroy at MDT could cause bl ast to client
7724 cancel_lru_locks osc
7726 stat $DIR/$tdir > /dev/null
7727 can1=$(do_facet $SINGLEMDS \
7728 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7729 awk '/ldlm_cancel/ {print $2}')
7730 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7731 awk '/ldlm_bl_callback/ {print $2}')
7732 test_mkdir -c1 $DIR/$tdir/d1
7733 can2=$(do_facet $SINGLEMDS \
7734 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7735 awk '/ldlm_cancel/ {print $2}')
7736 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7737 awk '/ldlm_bl_callback/ {print $2}')
7738 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7739 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7740 lru_resize_enable mdc
7741 lru_resize_enable osc
7743 run_test 120a "Early Lock Cancel: mkdir test"
7746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7747 test_mkdir $DIR/$tdir
7748 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7749 skip "no early lock cancel on server" && return 0
7750 lru_resize_disable mdc
7751 lru_resize_disable osc
7752 cancel_lru_locks mdc
7753 stat $DIR/$tdir > /dev/null
7754 can1=$(do_facet $SINGLEMDS \
7755 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7756 awk '/ldlm_cancel/ {print $2}')
7757 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7758 awk '/ldlm_bl_callback/ {print $2}')
7760 can2=$(do_facet $SINGLEMDS \
7761 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7762 awk '/ldlm_cancel/ {print $2}')
7763 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7764 awk '/ldlm_bl_callback/ {print $2}')
7765 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7766 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7767 lru_resize_enable mdc
7768 lru_resize_enable osc
7770 run_test 120b "Early Lock Cancel: create test"
7773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7774 test_mkdir -c1 $DIR/$tdir
7775 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7776 skip "no early lock cancel on server" && return 0
7777 lru_resize_disable mdc
7778 lru_resize_disable osc
7779 test_mkdir -p -c1 $DIR/$tdir/d1
7780 test_mkdir -p -c1 $DIR/$tdir/d2
7781 touch $DIR/$tdir/d1/f1
7782 cancel_lru_locks mdc
7783 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7784 can1=$(do_facet $SINGLEMDS \
7785 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7786 awk '/ldlm_cancel/ {print $2}')
7787 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7788 awk '/ldlm_bl_callback/ {print $2}')
7789 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7790 can2=$(do_facet $SINGLEMDS \
7791 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7792 awk '/ldlm_cancel/ {print $2}')
7793 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7794 awk '/ldlm_bl_callback/ {print $2}')
7795 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7796 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7797 lru_resize_enable mdc
7798 lru_resize_enable osc
7800 run_test 120c "Early Lock Cancel: link test"
7803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7804 test_mkdir -p -c1 $DIR/$tdir
7805 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7806 skip "no early lock cancel on server" && return 0
7807 lru_resize_disable mdc
7808 lru_resize_disable osc
7810 cancel_lru_locks mdc
7811 stat $DIR/$tdir > /dev/null
7812 can1=$(do_facet $SINGLEMDS \
7813 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7814 awk '/ldlm_cancel/ {print $2}')
7815 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7816 awk '/ldlm_bl_callback/ {print $2}')
7817 chmod a+x $DIR/$tdir
7818 can2=$(do_facet $SINGLEMDS \
7819 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7820 awk '/ldlm_cancel/ {print $2}')
7821 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7822 awk '/ldlm_bl_callback/ {print $2}')
7823 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7824 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7825 lru_resize_enable mdc
7826 lru_resize_enable osc
7828 run_test 120d "Early Lock Cancel: setattr test"
7831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7832 test_mkdir -p -c1 $DIR/$tdir
7833 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7834 skip "no early lock cancel on server" && return 0
7835 lru_resize_disable mdc
7836 lru_resize_disable osc
7837 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7838 cancel_lru_locks mdc
7839 cancel_lru_locks osc
7840 dd if=$DIR/$tdir/f1 of=/dev/null
7841 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7842 # XXX client can not do early lock cancel of OST lock
7843 # during unlink (LU-4206), so cancel osc lock now.
7844 cancel_lru_locks osc
7845 can1=$(do_facet $SINGLEMDS \
7846 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7847 awk '/ldlm_cancel/ {print $2}')
7848 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7849 awk '/ldlm_bl_callback/ {print $2}')
7850 unlink $DIR/$tdir/f1
7852 can2=$(do_facet $SINGLEMDS \
7853 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7854 awk '/ldlm_cancel/ {print $2}')
7855 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7856 awk '/ldlm_bl_callback/ {print $2}')
7857 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7858 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7859 lru_resize_enable mdc
7860 lru_resize_enable osc
7862 run_test 120e "Early Lock Cancel: unlink test"
7865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7866 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7867 skip "no early lock cancel on server" && return 0
7868 test_mkdir -p -c1 $DIR/$tdir
7869 lru_resize_disable mdc
7870 lru_resize_disable osc
7871 test_mkdir -p -c1 $DIR/$tdir/d1
7872 test_mkdir -p -c1 $DIR/$tdir/d2
7873 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7874 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7875 cancel_lru_locks mdc
7876 cancel_lru_locks osc
7877 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7878 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7879 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7880 # XXX client can not do early lock cancel of OST lock
7881 # during rename (LU-4206), so cancel osc lock now.
7882 cancel_lru_locks osc
7883 can1=$(do_facet $SINGLEMDS \
7884 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7885 awk '/ldlm_cancel/ {print $2}')
7886 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7887 awk '/ldlm_bl_callback/ {print $2}')
7888 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7890 can2=$(do_facet $SINGLEMDS \
7891 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7892 awk '/ldlm_cancel/ {print $2}')
7893 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7894 awk '/ldlm_bl_callback/ {print $2}')
7895 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7896 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7897 lru_resize_enable mdc
7898 lru_resize_enable osc
7900 run_test 120f "Early Lock Cancel: rename test"
7903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7904 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7905 skip "no early lock cancel on server" && return 0
7906 lru_resize_disable mdc
7907 lru_resize_disable osc
7909 echo create $count files
7910 test_mkdir -p $DIR/$tdir
7911 cancel_lru_locks mdc
7912 cancel_lru_locks osc
7915 can0=$(do_facet $SINGLEMDS \
7916 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7917 awk '/ldlm_cancel/ {print $2}')
7918 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7919 awk '/ldlm_bl_callback/ {print $2}')
7920 createmany -o $DIR/$tdir/f $count
7922 can1=$(do_facet $SINGLEMDS \
7923 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7924 awk '/ldlm_cancel/ {print $2}')
7925 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7926 awk '/ldlm_bl_callback/ {print $2}')
7928 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7929 echo rm $count files
7932 can2=$(do_facet $SINGLEMDS \
7933 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7934 awk '/ldlm_cancel/ {print $2}')
7935 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7936 awk '/ldlm_bl_callback/ {print $2}')
7938 echo total: $count removes in $((t2-t1))
7939 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7941 # wait for commitment of removal
7942 lru_resize_enable mdc
7943 lru_resize_enable osc
7945 run_test 120g "Early Lock Cancel: performance test"
7947 test_121() { #bug #10589
7948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7950 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7951 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7952 lctl set_param fail_loc=0x310
7953 cancel_lru_locks osc > /dev/null
7954 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7955 lctl set_param fail_loc=0
7956 [[ $reads -eq $writes ]] ||
7957 error "read $reads blocks, must be $writes blocks"
7959 run_test 121 "read cancel race ========="
7961 test_123a() { # was test 123, statahead(bug 11401)
7962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7964 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7965 log "testing on UP system. Performance may be not as good as expected."
7970 test_mkdir -p $DIR/$tdir
7971 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7972 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7974 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7975 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7977 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7978 lctl set_param -n llite.*.statahead_max 0
7979 lctl get_param llite.*.statahead_max
7980 cancel_lru_locks mdc
7981 cancel_lru_locks osc
7983 time ls -l $DIR/$tdir | wc -l
7985 delta=$((etime - stime))
7986 log "ls $i files without statahead: $delta sec"
7987 lctl set_param llite.*.statahead_max=$max
7989 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7990 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7991 cancel_lru_locks mdc
7992 cancel_lru_locks osc
7994 time ls -l $DIR/$tdir | wc -l
7996 delta_sa=$((etime - stime))
7997 log "ls $i files with statahead: $delta_sa sec"
7998 lctl get_param -n llite.*.statahead_stats
7999 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8001 [[ $swrong -lt $ewrong ]] &&
8002 log "statahead was stopped, maybe too many locks held!"
8003 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8005 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8006 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8007 lctl set_param -n llite.*.statahead_max 0
8008 lctl get_param llite.*.statahead_max
8009 cancel_lru_locks mdc
8010 cancel_lru_locks osc
8012 time ls -l $DIR/$tdir | wc -l
8014 delta=$((etime - stime))
8015 log "ls $i files again without statahead: $delta sec"
8016 lctl set_param llite.*.statahead_max=$max
8017 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8018 if [ $SLOWOK -eq 0 ]; then
8019 error "ls $i files is slower with statahead!"
8021 log "ls $i files is slower with statahead!"
8027 [ $delta -gt 20 ] && break
8028 [ $delta -gt 8 ] && MULT=$((50 / delta))
8029 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8037 delta=$((etime - stime))
8038 log "rm -r $DIR/$tdir/: $delta seconds"
8040 lctl get_param -n llite.*.statahead_stats
8042 run_test 123a "verify statahead work"
8044 test_123b () { # statahead(bug 15027)
8045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8046 test_mkdir -p $DIR/$tdir
8047 createmany -o $DIR/$tdir/$tfile-%d 1000
8049 cancel_lru_locks mdc
8050 cancel_lru_locks osc
8052 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8053 lctl set_param fail_loc=0x80000803
8054 ls -lR $DIR/$tdir > /dev/null
8056 lctl set_param fail_loc=0x0
8057 lctl get_param -n llite.*.statahead_stats
8062 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8066 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8067 skip "no lru resize on server" && return 0
8069 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8071 log "create $NR files at $DIR/$tdir"
8072 createmany -o $DIR/$tdir/f $NR ||
8073 error "failed to create $NR files in $DIR/$tdir"
8075 cancel_lru_locks mdc
8076 ls -l $DIR/$tdir > /dev/null
8080 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8081 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8082 LRU_SIZE=$($LCTL get_param -n $PARAM)
8083 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8084 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8086 log "NS=$(basename $NSDIR)"
8091 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8092 skip "Not enough cached locks created!"
8099 # We know that lru resize allows one client to hold $LIMIT locks
8100 # for 10h. After that locks begin to be killed by client.
8102 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8105 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8106 # killing locks. Some time was spent for creating locks. This means
8107 # that up to the moment of sleep finish we must have killed some of
8108 # them (10-100 locks). This depends on how fast ther were created.
8109 # Many of them were touched in almost the same moment and thus will
8110 # be killed in groups.
8111 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8113 # Use $LRU_SIZE_B here to take into account real number of locks
8114 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8115 local LRU_SIZE_B=$LRU_SIZE
8117 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8118 log "OLD_LVF=$OLD_LVF"
8119 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8121 # Let's make sure that we really have some margin. Client checks
8122 # cached locks every 10 sec.
8124 log "Sleep ${SLEEP} sec"
8126 while ((SEC<$SLEEP)); do
8130 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8134 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8135 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8137 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8138 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8139 unlinkmany $DIR/$tdir/f $NR
8143 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8144 log "unlink $NR files at $DIR/$tdir"
8145 unlinkmany $DIR/$tdir/f $NR
8147 run_test 124a "lru resize ======================================="
8149 get_max_pool_limit()
8151 local limit=$($LCTL get_param \
8152 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8155 if [[ $l -gt $max ]]; then
8163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8164 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8165 skip "no lru resize on server" && return 0
8167 LIMIT=$(get_max_pool_limit)
8169 NR=$(($(default_lru_size)*20))
8170 if [[ $NR -gt $LIMIT ]]; then
8171 log "Limit lock number by $LIMIT locks"
8174 lru_resize_disable mdc
8175 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8176 error "failed to create $DIR/$tdir/disable_lru_resize"
8178 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8179 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8180 cancel_lru_locks mdc
8183 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8186 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8189 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8193 nolruresize_delta=$((etime-stime))
8194 log "ls -la time: $nolruresize_delta seconds"
8195 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8196 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8198 lru_resize_enable mdc
8199 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8200 error "failed to create $DIR/$tdir/enable_lru_resize"
8202 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8203 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8204 cancel_lru_locks mdc
8207 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8210 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8213 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8217 lruresize_delta=$((etime-stime))
8218 log "ls -la time: $lruresize_delta seconds"
8219 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8221 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8222 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8223 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8224 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8226 log "lru resize performs the same with no lru resize"
8228 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8230 run_test 124b "lru resize (performance test) ======================="
8232 test_125() { # 13358
8233 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8234 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8235 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8236 test_mkdir -p $DIR/d125 || error "mkdir failed"
8237 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8238 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8239 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8241 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8243 test_126() { # bug 12829/13455
8244 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8245 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8246 $GSS && skip "must run as gss disabled" && return
8248 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8249 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8251 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8253 run_test 126 "check that the fsgid provided by the client is taken into account"
8255 test_127a() { # bug 15521
8256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8257 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8258 $LCTL set_param osc.*.stats=0
8259 FSIZE=$((2048 * 1024))
8260 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8261 cancel_lru_locks osc
8262 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8264 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8265 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8266 echo "got $COUNT $NAME"
8267 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8268 eval $NAME=$COUNT || error "Wrong proc format"
8271 read_bytes|write_bytes)
8272 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8273 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8274 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8275 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8276 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8277 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8278 error "sumsquare is too small: $SUMSQ"
8279 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8280 error "sumsquare is too big: $SUMSQ"
8284 done < $DIR/${tfile}.tmp
8286 #check that we actually got some stats
8287 [ "$read_bytes" ] || error "Missing read_bytes stats"
8288 [ "$write_bytes" ] || error "Missing write_bytes stats"
8289 [ "$read_bytes" != 0 ] || error "no read done"
8290 [ "$write_bytes" != 0 ] || error "no write done"
8292 run_test 127a "verify the client stats are sane"
8294 test_127b() { # bug LU-333
8295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8296 $LCTL set_param llite.*.stats=0
8297 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8298 # perform 2 reads and writes so MAX is different from SUM.
8299 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8300 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8301 cancel_lru_locks osc
8302 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8303 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8305 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8306 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8307 echo "got $COUNT $NAME"
8308 eval $NAME=$COUNT || error "Wrong proc format"
8312 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8313 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8314 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8315 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8318 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8319 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8320 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8321 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8325 done < $TMP/${tfile}.tmp
8327 #check that we actually got some stats
8328 [ "$read_bytes" ] || error "Missing read_bytes stats"
8329 [ "$write_bytes" ] || error "Missing write_bytes stats"
8330 [ "$read_bytes" != 0 ] || error "no read done"
8331 [ "$write_bytes" != 0 ] || error "no write done"
8333 run_test 127b "verify the llite client stats are sane"
8335 test_128() { # bug 15212
8337 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8342 result=$(grep error $TMP/$tfile.log)
8344 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8346 run_test 128 "interactive lfs for 2 consecutive find's"
8353 local LDPROC=/proc/fs/ldiskfs
8354 local facets=$(get_facets MDS)
8356 for facet in ${facets//,/ }; do
8357 canondev=$(ldiskfs_canon \
8358 *.$(convert_facet2label $facet).mntdev $facet)
8359 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8360 LDPROC=/sys/fs/ldiskfs
8361 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8367 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8368 skip "Only applicable to ldiskfs-based MDTs"
8371 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8376 test_mkdir -p $DIR/$tdir
8378 # block size of mds1
8379 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8380 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8381 local MAX=$((MDSBLOCKSIZE * 3))
8383 local I=$(stat -c%s "$DIR/$tdir")
8385 local STRIPE_COUNT=1
8386 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8387 MAX=$((MAX*STRIPE_COUNT))
8388 while [[ $I -le $MAX ]]; do
8389 $MULTIOP $DIR/$tdir/$J Oc
8391 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8392 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8393 #and EFBIG for previous versions
8394 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8396 echo "return code $rc received as expected"
8397 multiop $DIR/$tdir/$J Oc ||
8398 error_exit "multiop failed w/o dir size limit"
8400 I=$(stat -c%s "$DIR/$tdir")
8402 if [ $(lustre_version_code $SINGLEMDS) -lt \
8403 $(version_code 2.4.51) ]
8405 [[ $I -eq $MAX ]] && return 0
8407 [[ $I -gt $MAX ]] && return 0
8409 error_exit "current dir size $I, previous limit $MAX"
8410 elif [ $rc -ne 0 ]; then
8412 error_exit "return code $rc received instead of expected " \
8413 "$EFBIG or $ENOSPC, files in dir $I"
8416 I=$(stat -c%s "$DIR/$tdir")
8420 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8422 run_test 129 "test directory size limit ========================"
8431 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8432 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8435 trap cleanup_130 EXIT RETURN
8437 local fm_file=$DIR/$tfile
8438 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8439 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8440 error "dd failed for $fm_file"
8442 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8443 filefrag -ves $fm_file
8445 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8446 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8447 [ $RC != 0 ] && error "filefrag $fm_file failed"
8449 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8450 grep -v "ext:" | grep -v "found")
8451 lun=$($GETSTRIPE -i $fm_file)
8453 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8456 for line in $filefrag_op
8458 frag_lun=`echo $line | cut -d: -f5`
8459 ext_len=`echo $line | cut -d: -f4`
8460 if (( $frag_lun != $lun )); then
8462 error "FIEMAP on 1-stripe file($fm_file) failed"
8465 (( tot_len += ext_len ))
8468 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8470 error "FIEMAP on 1-stripe file($fm_file) failed;"
8476 echo "FIEMAP on single striped file succeeded"
8478 run_test 130a "FIEMAP (1-stripe file)"
8481 [ "$OSTCOUNT" -lt "2" ] &&
8482 skip_env "skipping FIEMAP on 2-stripe file test" && return
8484 [ "$OSTCOUNT" -ge "10" ] &&
8485 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8487 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8488 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8491 trap cleanup_130 EXIT RETURN
8493 local fm_file=$DIR/$tfile
8494 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8495 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8496 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8498 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8499 error "dd failed on $fm_file"
8501 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8502 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8503 grep -v "ext:" | grep -v "found")
8505 last_lun=$(echo $filefrag_op | cut -d: -f5)
8510 for line in $filefrag_op
8512 frag_lun=`echo $line | cut -d: -f5`
8513 ext_len=`echo $line | cut -d: -f4`
8514 if (( $frag_lun != $last_lun )); then
8515 if (( tot_len != 1024 )); then
8517 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8524 (( tot_len += ext_len ))
8527 if (( num_luns != 2 || tot_len != 1024 )); then
8529 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8535 echo "FIEMAP on 2-stripe file succeeded"
8537 run_test 130b "FIEMAP (2-stripe file)"
8540 [ "$OSTCOUNT" -lt "2" ] &&
8541 skip_env "skipping FIEMAP on 2-stripe file" && return
8543 [ "$OSTCOUNT" -ge "10" ] &&
8544 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8546 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8547 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8550 trap cleanup_130 EXIT RETURN
8552 local fm_file=$DIR/$tfile
8553 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8554 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8555 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8557 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8559 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8560 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8562 last_lun=`echo $filefrag_op | cut -d: -f5`
8567 for line in $filefrag_op
8569 frag_lun=`echo $line | cut -d: -f5`
8570 ext_len=`echo $line | cut -d: -f4`
8571 if (( $frag_lun != $last_lun )); then
8572 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8573 if (( logical != 512 )); then
8575 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8578 if (( tot_len != 512 )); then
8580 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8587 (( tot_len += ext_len ))
8590 if (( num_luns != 2 || tot_len != 512 )); then
8592 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8598 echo "FIEMAP on 2-stripe file with hole succeeded"
8600 run_test 130c "FIEMAP (2-stripe file with hole)"
8603 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8605 [ "$OSTCOUNT" -ge "10" ] &&
8606 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8608 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8609 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8611 trap cleanup_130 EXIT RETURN
8613 local fm_file=$DIR/$tfile
8614 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8615 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8616 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8618 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8619 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8620 error "dd failed on $fm_file"
8622 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8623 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8624 grep -v "ext:" | grep -v "found"`
8626 last_lun=`echo $filefrag_op | cut -d: -f5`
8631 for line in $filefrag_op
8633 frag_lun=`echo $line | cut -d: -f5`
8634 ext_len=`echo $line | cut -d: -f4`
8635 if (( $frag_lun != $last_lun )); then
8636 if (( tot_len != 1024 )); then
8638 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8645 (( tot_len += ext_len ))
8648 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8650 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8656 echo "FIEMAP on N-stripe file succeeded"
8658 run_test 130d "FIEMAP (N-stripe file)"
8661 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8663 [ "$OSTCOUNT" -ge "10" ] &&
8664 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8666 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8667 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8669 trap cleanup_130 EXIT RETURN
8671 local fm_file=$DIR/$tfile
8672 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8673 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8674 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8677 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8678 for ((i = 0; i < $NUM_BLKS; i++))
8680 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8683 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8684 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8686 last_lun=`echo $filefrag_op | cut -d: -f5`
8691 for line in $filefrag_op
8693 frag_lun=`echo $line | cut -d: -f5`
8694 ext_len=`echo $line | cut -d: -f4`
8695 if (( $frag_lun != $last_lun )); then
8696 if (( tot_len != $EXPECTED_LEN )); then
8698 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8705 (( tot_len += ext_len ))
8708 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8710 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8716 echo "FIEMAP with continuation calls succeeded"
8718 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8720 # Test for writev/readv
8722 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8723 error "writev test failed"
8724 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8725 error "readv failed"
8728 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8731 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8732 error "append writev test failed"
8733 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8734 error "append writev test failed"
8737 run_test 131b "test append writev"
8740 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8743 run_test 131c "test read/write on file w/o objects"
8746 rwv -f $DIR/$tfile -w -n 1 1572864
8747 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8748 if [ "$NOB" != 1572864 ]; then
8749 error "Short read filed: read $NOB bytes instead of 1572864"
8753 run_test 131d "test short read"
8756 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8757 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8758 error "read hitting hole failed"
8761 run_test 131e "test read hitting hole"
8766 for node in $(osts_nodes); do
8767 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8768 [ x$gl = x"" ] && gl=0
8769 gl_sum=$((gl_sum + gl))
8779 if [ x$som = x"enabled" ]; then
8780 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8781 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8782 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8784 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8785 MOUNTOPT="$MOUNTOPT,som_preview"
8786 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8789 # do remount to make new mount-conf parameters actual
8796 test_132() { #1028, SOM
8797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8798 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8799 local num=$(get_mds_dir $DIR)
8800 local mymds=mds${num}
8801 local MOUNTOPT_SAVE=$MOUNTOPT
8803 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8804 cancel_lru_locks osc
8806 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8808 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8809 stat $DIR/$tfile >/dev/null
8810 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8811 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8813 som_mode_switch $som1 $gl1 $gl2
8815 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8816 cancel_lru_locks osc
8818 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8819 if [ $som1 == $som2 ]; then
8820 error "som is still "$som2
8821 if [ x$som2 = x"enabled" ]; then
8828 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8829 stat $DIR/$tfile >/dev/null
8830 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8831 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8832 som_mode_switch $som2 $gl1 $gl2
8833 MOUNTOPT=$MOUNTOPT_SAVE
8835 run_test 132 "som avoids glimpse rpc"
8841 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8843 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8845 *) error "Wrong argument $1" ;;
8848 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8849 # if the argument $3 is zero, it means any stat increment is ok.
8850 if [[ $3 -gt 0 ]]; then
8851 count=$(echo $res | awk '{ print $2 }')
8852 [[ $count -ne $3 ]] &&
8853 error "The $2 counter on $1 is wrong - expected $3"
8858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8859 remote_ost_nodsh && skip "remote OST with nodsh" && return
8860 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8862 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8863 { skip "MDS doesn't support rename stats"; return; }
8864 local testdir=$DIR/${tdir}/stats_testdir
8865 mkdir -p $DIR/${tdir}
8868 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8869 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8871 # verify mdt stats first.
8872 mkdir ${testdir} || error "mkdir failed"
8873 check_stats $SINGLEMDS "mkdir" 1
8874 touch ${testdir}/${tfile} || "touch failed"
8875 check_stats $SINGLEMDS "open" 1
8876 check_stats $SINGLEMDS "close" 1
8877 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8878 check_stats $SINGLEMDS "mknod" 1
8879 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8880 check_stats $SINGLEMDS "unlink" 1
8881 rm -f ${testdir}/${tfile} || error "file remove failed"
8882 check_stats $SINGLEMDS "unlink" 2
8884 # remove working dir and check mdt stats again.
8885 rmdir ${testdir} || error "rmdir failed"
8886 check_stats $SINGLEMDS "rmdir" 1
8888 local testdir1=$DIR/${tdir}/stats_testdir1
8890 mkdir -p ${testdir1}
8891 touch ${testdir1}/test1
8892 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8893 check_stats $SINGLEMDS "crossdir_rename" 1
8895 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8896 check_stats $SINGLEMDS "samedir_rename" 1
8900 run_test 133a "Verifying MDT stats ========================================"
8903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8904 remote_ost_nodsh && skip "remote OST with nodsh" && return
8905 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8906 local testdir=$DIR/${tdir}/stats_testdir
8907 mkdir -p ${testdir} || error "mkdir failed"
8908 touch ${testdir}/${tfile} || "touch failed"
8909 cancel_lru_locks mdc
8912 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8913 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8915 # extra mdt stats verification.
8916 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8917 check_stats $SINGLEMDS "setattr" 1
8918 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8919 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8921 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8922 check_stats $SINGLEMDS "getattr" 1
8924 $LFS df || error "lfs failed"
8925 check_stats $SINGLEMDS "statfs" 1
8929 run_test 133b "Verifying extra MDT stats =================================="
8932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8933 remote_ost_nodsh && skip "remote OST with nodsh" && return
8934 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8935 local testdir=$DIR/${tdir}/stats_testdir
8936 test_mkdir -p ${testdir} || error "mkdir failed"
8938 # verify obdfilter stats.
8939 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8941 cancel_lru_locks osc
8942 wait_delete_completed
8945 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8946 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8948 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8950 cancel_lru_locks osc
8951 check_stats ost "write" 1
8953 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8954 check_stats ost "read" 1
8956 > ${testdir}/${tfile} || error "truncate failed"
8957 check_stats ost "punch" 1
8959 rm -f ${testdir}/${tfile} || error "file remove failed"
8960 wait_delete_completed
8961 check_stats ost "destroy" 1
8965 run_test 133c "Verifying OST stats ========================================"
8972 while [ $value -ge 2 ]; do
8977 if [ $orig -gt $order ]; then
8985 local size=('K' 'M' 'G' 'T');
8987 local size_string=$value
8989 while [ $value -ge 1024 ]; do
8990 if [ $i -gt 3 ]; then
8991 #T is the biggest unit we get here, if that is bigger,
8993 size_string=${value}T
8996 value=$((value >> 10))
8997 if [ $value -lt 1024 ]; then
8998 size_string=${value}${size[$i]}
9009 local context=${2:-.}
9010 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9012 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9018 remote_ost_nodsh && skip "remote OST with nodsh" && return
9019 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9020 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9021 { skip "MDS doesn't support rename stats"; return; }
9023 local testdir1=$DIR/${tdir}/stats_testdir1
9024 local testdir2=$DIR/${tdir}/stats_testdir2
9026 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9028 mkdir -p ${testdir1} || error "mkdir failed"
9029 mkdir -p ${testdir2} || error "mkdir failed"
9031 createmany -o $testdir1/test 512 || error "createmany failed"
9033 # check samedir rename size
9034 mv ${testdir1}/test0 ${testdir1}/test_0
9036 local testdir1_size=$(ls -l $DIR/${tdir} |
9037 awk '/stats_testdir1/ {print $5}')
9038 local testdir2_size=$(ls -l $DIR/${tdir} |
9039 awk '/stats_testdir2/ {print $5}')
9041 testdir1_size=$(order_2 $testdir1_size)
9042 testdir2_size=$(order_2 $testdir2_size)
9044 testdir1_size=$(size_in_KMGT $testdir1_size)
9045 testdir2_size=$(size_in_KMGT $testdir2_size)
9047 echo "source rename dir size: ${testdir1_size}"
9048 echo "target rename dir size: ${testdir2_size}"
9050 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9051 eval $cmd || error "$cmd failed"
9052 local samedir=$($cmd | grep 'same_dir')
9053 local same_sample=$(get_rename_size $testdir1_size)
9054 [ -z "$samedir" ] && error "samedir_rename_size count error"
9055 [[ $same_sample -eq 1 ]] ||
9056 error "samedir_rename_size error $same_sample"
9057 echo "Check same dir rename stats success"
9059 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9061 # check crossdir rename size
9062 mv ${testdir1}/test_0 ${testdir2}/test_0
9064 testdir1_size=$(ls -l $DIR/${tdir} |
9065 awk '/stats_testdir1/ {print $5}')
9066 testdir2_size=$(ls -l $DIR/${tdir} |
9067 awk '/stats_testdir2/ {print $5}')
9069 testdir1_size=$(order_2 $testdir1_size)
9070 testdir2_size=$(order_2 $testdir2_size)
9072 testdir1_size=$(size_in_KMGT $testdir1_size)
9073 testdir2_size=$(size_in_KMGT $testdir2_size)
9075 echo "source rename dir size: ${testdir1_size}"
9076 echo "target rename dir size: ${testdir2_size}"
9078 eval $cmd || error "$cmd failed"
9079 local crossdir=$($cmd | grep 'crossdir')
9080 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9081 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9082 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9083 [[ $src_sample -eq 1 ]] ||
9084 error "crossdir_rename_size error $src_sample"
9085 [[ $tgt_sample -eq 1 ]] ||
9086 error "crossdir_rename_size error $tgt_sample"
9087 echo "Check cross dir rename stats success"
9090 run_test 133d "Verifying rename_stats ========================================"
9093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9094 local testdir=$DIR/${tdir}/stats_testdir
9095 local ctr f0 f1 bs=32768 count=42 sum
9097 remote_ost_nodsh && skip "remote OST with nodsh" && return
9098 mkdir -p ${testdir} || error "mkdir failed"
9100 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9102 for ctr in {write,read}_bytes; do
9104 cancel_lru_locks osc
9106 do_facet ost1 $LCTL set_param -n \
9107 "obdfilter.*.exports.clear=clear"
9109 if [ $ctr = write_bytes ]; then
9111 f1=${testdir}/${tfile}
9113 f0=${testdir}/${tfile}
9117 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9120 cancel_lru_locks osc
9122 sum=$(do_facet ost1 $LCTL get_param \
9123 "obdfilter.*.exports.*.stats" |
9124 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9125 $1 == ctr { sum += $7 }
9126 END { printf("%0.0f", sum) }')
9128 if ((sum != bs * count)); then
9129 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9135 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9138 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9141 # First without trusting modes.
9142 find $proc_dirs -exec cat '{}' \; &> /dev/null
9144 # Second verifying readability.
9147 -exec cat '{}' \; &> /dev/null ||
9148 error "proc file read failed"
9150 for facet in $SINGLEMDS ost1; do
9151 do_facet $facet find $proc_dirs \
9152 ! -name req_history \
9153 -exec cat '{}' \\\; &> /dev/null
9155 do_facet $facet find $proc_dirs \
9156 ! -name req_history \
9158 -exec cat '{}' \\\; &> /dev/null ||
9159 error "proc file read failed"
9162 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9165 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9168 # Second verifying readability.
9171 -not -name force_lbug \
9172 -not -name changelog_mask \
9173 -exec badarea_io '{}' \; &> /dev/null ||
9174 error "find $proc_dirs failed"
9176 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9177 skip "Too old lustre on MDS"
9179 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9180 skip "Too old lustre on ost1"
9182 for facet in $SINGLEMDS ost1; do
9183 do_facet $facet find $proc_dirs \
9185 -not -name force_lbug \
9186 -not -name changelog_mask \
9187 -exec badarea_io '{}' \\\; &> /dev/null ||
9188 error "$facet find $proc_dirs failed"
9192 # remount the FS in case writes/reads /proc break the FS
9193 cleanup || error "failed to unmount"
9194 setup || error "failed to setup"
9197 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9199 test_140() { #bug-17379
9200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9201 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9202 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9203 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9205 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9206 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9208 while i=`expr $i + 1`; do
9209 test_mkdir -p $i || error "Creating dir $i"
9210 cd $i || error "Changing to $i"
9211 ln -s ../stat stat || error "Creating stat symlink"
9212 # Read the symlink until ELOOP present,
9213 # not LBUGing the system is considered success,
9214 # we didn't overrun the stack.
9215 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9217 if [ $ret -eq 40 ]; then
9220 error "Open stat symlink"
9226 echo "The symlink depth = $i"
9227 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9228 error "Invalid symlink depth"
9230 # Test recursive symlink
9231 ln -s symlink_self symlink_self
9232 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9233 echo "open symlink_self returns $ret"
9234 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9236 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9240 local TF="$TMP/$tfile"
9242 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9244 cancel_lru_locks osc
9245 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9246 remount_client $MOUNT
9248 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9251 $TRUNCATE $DIR/$tfile 6000
9252 cancel_lru_locks osc
9253 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9256 echo "12345" >>$DIR/$tfile
9257 cancel_lru_locks osc
9258 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9261 echo "12345" >>$DIR/$tfile
9262 cancel_lru_locks osc
9263 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9268 run_test 150 "truncate/append tests"
9270 #LU-2902 roc_hit was not able to read all values from lproc
9271 function roc_hit_init() {
9272 local list=$(comma_list $(osts_nodes))
9273 local dir=$DIR/$tdir-check
9274 local file=$dir/file
9280 #use setstripe to do a write to every ost
9281 for i in $(seq 0 $((OSTCOUNT-1))); do
9282 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9283 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9284 idx=$(printf %04x $i)
9285 BEFORE=$(get_osd_param $list *OST*$idx stats |
9286 awk '$1 == "cache_access" {sum += $7}
9287 END { printf("%0.0f", sum) }')
9289 cancel_lru_locks osc
9290 cat $file >/dev/null
9292 AFTER=$(get_osd_param $list *OST*$idx stats |
9293 awk '$1 == "cache_access" {sum += $7}
9294 END { printf("%0.0f", sum) }')
9296 echo BEFORE:$BEFORE AFTER:$AFTER
9297 if ! let "AFTER - BEFORE == 4"; then
9299 error "roc_hit is not safe to use"
9307 function roc_hit() {
9308 local list=$(comma_list $(osts_nodes))
9309 echo $(get_osd_param $list '' stats |
9310 awk '$1 == "cache_hit" {sum += $7}
9311 END { printf("%0.0f", sum) }')
9314 function set_cache() {
9317 if [ "$2" == "off" ]; then
9320 local list=$(comma_list $(osts_nodes))
9321 set_osd_param $list '' $1_cache_enable $on
9323 cancel_lru_locks osc
9327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9328 remote_ost_nodsh && skip "remote OST with nodsh" && return
9331 local list=$(comma_list $(osts_nodes))
9333 # check whether obdfilter is cache capable at all
9334 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9335 echo "not cache-capable obdfilter"
9339 # check cache is enabled on all obdfilters
9340 if get_osd_param $list '' read_cache_enable | grep 0; then
9341 echo "oss cache is disabled"
9345 set_osd_param $list '' writethrough_cache_enable 1
9347 # check write cache is enabled on all obdfilters
9348 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9349 echo "oss write cache is NOT enabled"
9355 #define OBD_FAIL_OBD_NO_LRU 0x609
9356 do_nodes $list $LCTL set_param fail_loc=0x609
9358 # pages should be in the case right after write
9359 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9362 local BEFORE=$(roc_hit)
9363 cancel_lru_locks osc
9364 cat $DIR/$tfile >/dev/null
9365 local AFTER=$(roc_hit)
9367 do_nodes $list $LCTL set_param fail_loc=0
9369 if ! let "AFTER - BEFORE == CPAGES"; then
9370 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9373 # the following read invalidates the cache
9374 cancel_lru_locks osc
9375 set_osd_param $list '' read_cache_enable 0
9376 cat $DIR/$tfile >/dev/null
9378 # now data shouldn't be found in the cache
9380 cancel_lru_locks osc
9381 cat $DIR/$tfile >/dev/null
9383 if let "AFTER - BEFORE != 0"; then
9384 error "IN CACHE: before: $BEFORE, after: $AFTER"
9387 set_osd_param $list '' read_cache_enable 1
9390 run_test 151 "test cache on oss and controls ==============================="
9393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9394 local TF="$TMP/$tfile"
9396 # simulate ENOMEM during write
9397 #define OBD_FAIL_OST_NOMEM 0x226
9398 lctl set_param fail_loc=0x80000226
9399 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9401 sync || error "sync failed"
9402 lctl set_param fail_loc=0
9404 # discard client's cache
9405 cancel_lru_locks osc
9407 # simulate ENOMEM during read
9408 lctl set_param fail_loc=0x80000226
9409 cmp $TF $DIR/$tfile || error "cmp failed"
9410 lctl set_param fail_loc=0
9414 run_test 152 "test read/write with enomem ============================"
9417 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9419 run_test 153 "test if fdatasync does not crash ======================="
9421 dot_lustre_fid_permission_check() {
9423 local ffid=$MOUNT/.lustre/fid/$fid
9426 echo "stat fid $fid"
9427 stat $ffid > /dev/null || error "stat $ffid failed."
9428 echo "touch fid $fid"
9429 touch $ffid || error "touch $ffid failed."
9430 echo "write to fid $fid"
9431 cat /etc/hosts > $ffid || error "write $ffid failed."
9432 echo "read fid $fid"
9433 diff /etc/hosts $ffid || error "read $ffid failed."
9434 echo "append write to fid $fid"
9435 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9436 echo "rename fid $fid"
9437 mv $ffid $test_dir/$tfile.1 &&
9438 error "rename $ffid to $tfile.1 should fail."
9439 touch $test_dir/$tfile.1
9440 mv $test_dir/$tfile.1 $ffid &&
9441 error "rename $tfile.1 to $ffid should fail."
9442 rm -f $test_dir/$tfile.1
9443 echo "truncate fid $fid"
9444 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9445 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9446 echo "link fid $fid"
9447 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9449 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9450 echo "setfacl fid $fid"
9451 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9452 echo "getfacl fid $fid"
9453 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9455 echo "unlink fid $fid"
9456 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9457 echo "mknod fid $fid"
9458 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9460 fid=[0xf00000400:0x1:0x0]
9461 ffid=$MOUNT/.lustre/fid/$fid
9463 echo "stat non-exist fid $fid"
9464 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9465 echo "write to non-exist fid $fid"
9466 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9467 echo "link new fid $fid"
9468 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9470 mkdir -p $test_dir/$tdir
9471 touch $test_dir/$tdir/$tfile
9472 fid=$($LFS path2fid $test_dir/$tdir)
9475 error "error: could not get fid for $test_dir/$dir/$tfile."
9477 ffid=$MOUNT/.lustre/fid/$fid
9480 ls $ffid > /dev/null || error "ls $ffid failed."
9481 echo "touch $fid/$tfile.1"
9482 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9484 echo "touch $MOUNT/.lustre/fid/$tfile"
9485 touch $MOUNT/.lustre/fid/$tfile && \
9486 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9488 echo "setxattr to $MOUNT/.lustre/fid"
9489 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9491 echo "listxattr for $MOUNT/.lustre/fid"
9492 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9494 echo "delxattr from $MOUNT/.lustre/fid"
9495 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9497 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9498 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9499 error "touch invalid fid should fail."
9501 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9502 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9503 error "touch non-normal fid should fail."
9505 echo "rename $tdir to $MOUNT/.lustre/fid"
9506 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9507 error "rename to $MOUNT/.lustre/fid should fail."
9509 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9511 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9512 local new_obf_mode=777
9514 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9515 chmod $new_obf_mode $DIR/.lustre/fid ||
9516 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9518 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9519 [ $obf_mode -eq $new_obf_mode ] ||
9520 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9522 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9523 chmod $old_obf_mode $DIR/.lustre/fid ||
9524 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9527 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9528 fid=$($LFS path2fid $test_dir/$tfile-2)
9529 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9530 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9531 error "create lov data thru .lustre should fail."
9532 echo "cp /etc/passwd $test_dir/$tfile-2"
9533 cp /etc/passwd $test_dir/$tfile-2 ||
9534 error "copy to $test_dir/$tfile-2 failed."
9535 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9536 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9537 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9539 rm -rf $test_dir/tfile.lnk
9540 rm -rf $test_dir/$tfile-2
9544 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9545 skip "Need MDS version at least 2.4.1" && return
9548 local FID=$($LFS path2fid $DIR/$tfile)
9549 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9551 # check that we get the same pathname back
9552 local FOUND=$($LFS fid2path $MOUNT $FID)
9553 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9554 [ "$FOUND" != "$DIR/$tfile" ] &&
9555 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9559 run_test 154A "lfs path2fid and fid2path basic checks"
9562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9563 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9564 { skip "Need MDS version at least 2.2.51"; return 0; }
9565 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9567 cp /etc/hosts $DIR/$tfile
9569 fid=$($LFS path2fid $DIR/$tfile)
9571 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9573 dot_lustre_fid_permission_check "$fid" $DIR ||
9574 error "dot lustre permission check $fid failed"
9576 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9578 touch $MOUNT/.lustre/file &&
9579 error "creation is not allowed under .lustre"
9581 mkdir $MOUNT/.lustre/dir &&
9582 error "mkdir is not allowed under .lustre"
9586 run_test 154a "Open-by-FID"
9589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9590 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9591 { skip "Need MDS version at least 2.2.51"; return 0; }
9593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9595 local remote_dir=$DIR/$tdir/remote_dir
9600 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9601 error "create remote directory failed"
9603 cp /etc/hosts $remote_dir/$tfile
9605 fid=$($LFS path2fid $remote_dir/$tfile)
9607 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9609 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9610 error "dot lustre permission check $fid failed"
9613 run_test 154b "Open-by-FID for remote directory"
9616 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9617 skip "Need MDS version at least 2.4.1" && return
9619 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9620 local FID1=$($LFS path2fid $DIR/$tfile.1)
9621 local FID2=$($LFS path2fid $DIR/$tfile.2)
9622 local FID3=$($LFS path2fid $DIR/$tfile.3)
9625 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9626 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9627 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9629 [ "$FID" = "${!want}" ] ||
9630 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9634 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9635 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9636 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9640 run_test 154c "lfs path2fid and fid2path multiple arguments"
9643 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9644 skip "Need MDS version at least 2.5.53" && return
9647 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9651 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9658 fid=$($LFS path2fid $DIR/$tfile)
9661 cmd="exec $fd<$DIR/$tfile"
9663 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9664 echo $fid_list | grep $fid
9667 cmd="exec $fd>/dev/null"
9669 if [ $rc -ne 0 ]; then
9670 error "FID $fid not found in open files list $fid_list"
9673 run_test 154d "Verify open file fid"
9675 test_155_small_load() {
9676 local temp=$TMP/$tfile
9677 local file=$DIR/$tfile
9679 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9680 error "dd of=$temp bs=6096 count=1 failed"
9682 cancel_lru_locks osc
9683 cmp $temp $file || error "$temp $file differ"
9685 $TRUNCATE $temp 6000
9686 $TRUNCATE $file 6000
9687 cmp $temp $file || error "$temp $file differ (truncate1)"
9689 echo "12345" >>$temp
9690 echo "12345" >>$file
9691 cmp $temp $file || error "$temp $file differ (append1)"
9693 echo "12345" >>$temp
9694 echo "12345" >>$file
9695 cmp $temp $file || error "$temp $file differ (append2)"
9701 test_155_big_load() {
9702 remote_ost_nodsh && skip "remote OST with nodsh" && return
9703 local temp=$TMP/$tfile
9704 local file=$DIR/$tfile
9707 local cache_size=$(do_facet ost$((MAXI+1)) \
9708 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9709 local large_file_size=$((cache_size * 2))
9711 echo "OSS cache size: $cache_size KB"
9712 echo "Large file size: $large_file_size KB"
9714 [ $MAXV -le $large_file_size ] && \
9715 skip_env "max available OST size needs > $large_file_size KB" && \
9718 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9720 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9721 error "dd of=$temp bs=$large_file_size count=1k failed"
9724 cancel_lru_locks osc
9725 cmp $temp $file || error "$temp $file differ"
9732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9734 set_cache writethrough on
9737 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9742 set_cache writethrough off
9745 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9750 set_cache writethrough on
9753 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9758 set_cache writethrough off
9761 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9766 set_cache writethrough on
9769 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9774 set_cache writethrough off
9777 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9782 set_cache writethrough on
9785 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9790 set_cache writethrough off
9793 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9800 local file="$DIR/$tfile"
9802 [ "$(facet_fstype ost1)" = "zfs" ] &&
9803 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9808 log "Turn on read and write cache"
9810 set_cache writethrough on
9812 log "Write data and read it back."
9813 log "Read should be satisfied from the cache."
9814 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9816 cancel_lru_locks osc
9817 cat $file >/dev/null
9819 if ! let "AFTER - BEFORE == CPAGES"; then
9820 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9822 log "cache hits:: before: $BEFORE, after: $AFTER"
9825 log "Read again; it should be satisfied from the cache."
9827 cancel_lru_locks osc
9828 cat $file >/dev/null
9830 if ! let "AFTER - BEFORE == CPAGES"; then
9831 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9833 log "cache hits:: before: $BEFORE, after: $AFTER"
9837 log "Turn off the read cache and turn on the write cache"
9839 set_cache writethrough on
9841 log "Read again; it should be satisfied from the cache."
9843 cancel_lru_locks osc
9844 cat $file >/dev/null
9846 if ! let "AFTER - BEFORE == CPAGES"; then
9847 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9849 log "cache hits:: before: $BEFORE, after: $AFTER"
9852 log "Read again; it should not be satisfied from the cache."
9854 cancel_lru_locks osc
9855 cat $file >/dev/null
9857 if ! let "AFTER - BEFORE == 0"; then
9858 error "IN CACHE: before: $BEFORE, after: $AFTER"
9860 log "cache hits:: before: $BEFORE, after: $AFTER"
9863 log "Write data and read it back."
9864 log "Read should be satisfied from the cache."
9865 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9867 cancel_lru_locks osc
9868 cat $file >/dev/null
9870 if ! let "AFTER - BEFORE == CPAGES"; then
9871 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9873 log "cache hits:: before: $BEFORE, after: $AFTER"
9876 log "Read again; it should not be satisfied from the cache."
9878 cancel_lru_locks osc
9879 cat $file >/dev/null
9881 if ! let "AFTER - BEFORE == 0"; then
9882 error "IN CACHE: before: $BEFORE, after: $AFTER"
9884 log "cache hits:: before: $BEFORE, after: $AFTER"
9888 log "Turn off read and write cache"
9890 set_cache writethrough off
9892 log "Write data and read it back"
9893 log "It should not be satisfied from the cache."
9895 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9896 cancel_lru_locks osc
9898 cat $file >/dev/null
9900 if ! let "AFTER - BEFORE == 0"; then
9901 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9903 log "cache hits:: before: $BEFORE, after: $AFTER"
9906 log "Turn on the read cache and turn off the write cache"
9908 set_cache writethrough off
9910 log "Write data and read it back"
9911 log "It should not be satisfied from the cache."
9913 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9915 cancel_lru_locks osc
9916 cat $file >/dev/null
9918 if ! let "AFTER - BEFORE == 0"; then
9919 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9921 log "cache hits:: before: $BEFORE, after: $AFTER"
9924 log "Read again; it should be satisfied from the cache."
9926 cancel_lru_locks osc
9927 cat $file >/dev/null
9929 if ! let "AFTER - BEFORE == CPAGES"; then
9930 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9932 log "cache hits:: before: $BEFORE, after: $AFTER"
9937 run_test 156 "Verification of tunables ============================"
9941 if [[ $MDSCOUNT -gt 1 ]]; then
9942 error_ignore bz17935 $*
9950 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9952 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9954 if [ $MASK -eq 1 ]; then
9955 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9957 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9961 changelog_extract_field() {
9967 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9968 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9974 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9975 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9976 { skip "Need MDS version at least 2.2.0"; return; }
9978 local CL_USERS="mdd.$MDT0.changelog_users"
9979 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9980 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9981 echo "Registered as changelog user $USER"
9982 $GET_CL_USERS | grep -q $USER ||
9983 error "User $USER not found in changelog_users"
9986 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9987 touch $DIR/$tdir/pics/2008/zachy/timestamp
9988 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9989 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9990 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9991 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9992 rm $DIR/$tdir/pics/desktop.jpg
9994 $LFS changelog $MDT0 | tail -5
9996 echo "verifying changelog mask"
9997 changelog_chmask "MKDIR"
9998 changelog_chmask "CLOSE"
10000 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10001 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10003 changelog_chmask "MKDIR"
10004 changelog_chmask "CLOSE"
10006 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10007 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10009 $LFS changelog $MDT0
10010 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10011 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10012 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10013 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10016 echo "verifying target fid"
10017 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10018 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10019 [ "$fidc" == "$fidf" ] ||
10020 err17935 "fid in changelog $fidc != file fid $fidf"
10021 echo "verifying parent fid"
10022 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10023 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10024 [ "$fidc" == "$fidf" ] ||
10025 err17935 "pfid in changelog $fidc != dir fid $fidf"
10027 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10028 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10029 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10030 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10031 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10032 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10034 MIN_REC=$($GET_CL_USERS |
10035 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10036 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10037 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10038 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10039 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10041 # LU-3446 changelog index reset on MDT restart
10042 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10043 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10044 $LFS changelog_clear $MDT0 $USER 0
10045 stop $SINGLEMDS || error "Fail to stop MDT."
10046 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10047 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10048 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10049 [ $CUR_REC1 == $CUR_REC2 ] ||
10050 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10052 echo "verifying user deregister"
10053 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10054 $GET_CL_USERS | grep -q $USER &&
10055 error "User $USER still in changelog_users"
10057 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10058 if [ $USERS -eq 0 ]; then
10059 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10060 touch $DIR/$tdir/chloe
10061 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10062 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10063 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10065 echo "$USERS other changelog users; can't verify off"
10068 run_test 160a "changelog sanity"
10070 test_160b() { # LU-3587
10071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10072 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10073 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10074 { skip "Need MDS version at least 2.2.0"; return; }
10076 local CL_USERS="mdd.$MDT0.changelog_users"
10077 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10078 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10079 echo "Registered as changelog user $USER"
10080 $GET_CL_USERS | grep -q $USER ||
10081 error "User $USER not found in changelog_users"
10083 local LONGNAME1=$(str_repeat a 255)
10084 local LONGNAME2=$(str_repeat b 255)
10087 echo "creating very long named file"
10088 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10089 echo "moving very long named file"
10090 mv $LONGNAME1 $LONGNAME2
10092 $LFS changelog $MDT0 | grep RENME
10094 echo "deregistering $USER"
10095 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10099 run_test 160b "Verify that very long rename doesn't crash in changelog"
10103 local server_version=$(lustre_version_code $SINGLEMDS)
10105 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10106 [[ $server_version -gt $(version_code 2.5.1) &&
10107 $server_version -lt $(version_code 2.5.50) ]] ||
10108 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10111 # Registration step
10112 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10113 changelog_register -n)
10116 mkdir -p $DIR/$tdir
10117 $MCREATE $DIR/$tdir/foo_160c
10118 changelog_chmask "TRUNC"
10119 $TRUNCATE $DIR/$tdir/foo_160c 200
10120 changelog_chmask "TRUNC"
10121 $TRUNCATE $DIR/$tdir/foo_160c 199
10122 $LFS changelog $MDT0
10123 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10124 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10125 $LFS changelog_clear $MDT0 $USER 0
10127 # Deregistration step
10128 echo "deregistering $USER"
10129 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10131 run_test 160c "verify that changelog log catch the truncate event"
10134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10135 test_mkdir -p -c1 $DIR/$tdir
10136 cp /etc/hosts $DIR/$tdir/$tfile
10137 test_mkdir -c1 $DIR/$tdir/foo1
10138 test_mkdir -c1 $DIR/$tdir/foo2
10139 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10140 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10141 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10142 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10143 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10144 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10145 $LFS fid2path $DIR $FID
10146 err17935 "bad link ea"
10149 rm $DIR/$tdir/foo2/zachary
10151 rm $DIR/$tdir/foo2/thor
10153 rm $DIR/$tdir/$tfile
10155 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10156 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10158 $LFS fid2path $DIR $FID
10159 err17935 "bad link rename"
10161 rm $DIR/$tdir/foo2/maggie
10164 local longname=filename_avg_len_is_thirty_two_
10165 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10166 error "failed to hardlink many files"
10167 links=$($LFS fid2path $DIR $FID | wc -l)
10168 echo -n "${links}/1000 links in link EA"
10169 [[ $links -gt 60 ]] ||
10170 err17935 "expected at least 60 links in link EA"
10171 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10172 error "failed to unlink many hardlinks"
10174 run_test 161a "link ea sanity"
10177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10178 [ $MDSCOUNT -lt 2 ] &&
10179 skip "skipping remote directory test" && return
10181 local remote_dir=$DIR/$tdir/remote_dir
10183 mkdir -p $DIR/$tdir
10184 $LFS mkdir -i $MDTIDX $remote_dir ||
10185 error "create remote directory failed"
10187 cp /etc/hosts $remote_dir/$tfile
10188 mkdir -p $remote_dir/foo1
10189 mkdir -p $remote_dir/foo2
10190 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10191 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10192 ln $remote_dir/$tfile $remote_dir/foo1/luna
10193 ln $remote_dir/$tfile $remote_dir/foo2/thor
10195 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10197 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10198 $LFS fid2path $DIR $FID
10199 err17935 "bad link ea"
10202 rm $remote_dir/foo2/zachary
10204 rm $remote_dir/foo2/thor
10206 rm $remote_dir/$tfile
10208 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10209 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10210 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10211 $LFS fid2path $DIR $FID
10212 err17935 "bad link rename"
10214 rm $remote_dir/foo2/maggie
10217 local longname=filename_avg_len_is_thirty_two_
10218 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10219 error "failed to hardlink many files"
10220 links=$($LFS fid2path $DIR $FID | wc -l)
10221 echo -n "${links}/1000 links in link EA"
10222 [[ ${links} -gt 60 ]] ||
10223 err17935 "expected at least 60 links in link EA"
10224 unlinkmany $remote_dir/foo2/$longname 1000 ||
10225 error "failed to unlink many hardlinks"
10227 run_test 161b "link ea sanity under remote directory"
10230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10231 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10232 skip "Need MDS version at least 2.1.5" && return
10234 # define CLF_RENAME_LAST 0x0001
10235 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10236 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10237 changelog_register -n)
10239 mkdir -p $DIR/$tdir
10240 touch $DIR/$tdir/foo_161c
10241 touch $DIR/$tdir/bar_161c
10242 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10243 $LFS changelog $MDT0 | grep RENME
10244 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10246 $LFS changelog_clear $MDT0 $USER 0
10247 if [ x$flags != "x0x1" ]; then
10248 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10250 error "flag $flags is not 0x1"
10252 echo "rename overwrite a target having nlink = 1," \
10253 "changelog record has flags of $flags"
10255 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10256 touch $DIR/$tdir/foo_161c
10257 touch $DIR/$tdir/bar_161c
10258 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10259 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10260 $LFS changelog $MDT0 | grep RENME
10261 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10262 $LFS changelog_clear $MDT0 $USER 0
10263 if [ x$flags != "x0x0" ]; then
10264 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10266 error "flag $flags is not 0x0"
10268 echo "rename overwrite a target having nlink > 1," \
10269 "changelog record has flags of $flags"
10271 # rename doesn't overwrite a target (changelog flag 0x0)
10272 touch $DIR/$tdir/foo_161c
10273 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10274 $LFS changelog $MDT0 | grep RENME
10275 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10276 $LFS changelog_clear $MDT0 $USER 0
10277 if [ x$flags != "x0x0" ]; then
10278 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10280 error "flag $flags is not 0x0"
10282 echo "rename doesn't overwrite a target," \
10283 "changelog record has flags of $flags"
10285 # define CLF_UNLINK_LAST 0x0001
10286 # unlink a file having nlink = 1 (changelog flag 0x1)
10287 rm -f $DIR/$tdir/foo2_161c
10288 $LFS changelog $MDT0 | grep UNLNK
10289 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10290 $LFS changelog_clear $MDT0 $USER 0
10291 if [ x$flags != "x0x1" ]; then
10292 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10294 error "flag $flags is not 0x1"
10296 echo "unlink a file having nlink = 1," \
10297 "changelog record has flags of $flags"
10299 # unlink a file having nlink > 1 (changelog flag 0x0)
10300 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10301 rm -f $DIR/$tdir/foobar_161c
10302 $LFS changelog $MDT0 | grep UNLNK
10303 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10304 $LFS changelog_clear $MDT0 $USER 0
10305 if [ x$flags != "x0x0" ]; then
10306 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10308 error "flag $flags is not 0x0"
10310 echo "unlink a file having nlink > 1," \
10311 "changelog record has flags of $flags"
10312 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10314 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10321 local path=$(${LFS} fid2path $*)
10324 if [ $RC -ne 0 ]; then
10325 err17935 "path looked up of $expected failed. Error $RC"
10327 elif [ "${path}" != "${expected}" ]; then
10328 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10331 echo "fid $fid resolves to path $path (expected $expected)"
10335 # Make changes to filesystem
10336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10337 test_mkdir -p -c1 $DIR/$tdir/d2
10338 touch $DIR/$tdir/d2/$tfile
10339 touch $DIR/$tdir/d2/x1
10340 touch $DIR/$tdir/d2/x2
10341 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10342 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10344 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10345 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10348 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10349 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10350 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10352 # softlink to wrong file
10353 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10354 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10355 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10358 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10359 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10360 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10361 # fid2path dir/fsname should both work
10362 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10363 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10365 # hardlink count: check that there are 2 links
10366 # Doesnt work with CMD yet: 17935
10367 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10368 err17935 "expected 2 links"
10370 # hardlink indexing: remove the first link
10371 rm $DIR/$tdir/d2/p/q/r/hlink
10372 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10376 run_test 162 "path lookup sanity"
10379 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10380 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10383 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10384 error "create striped dir failed"
10386 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10387 tail -n 1 | awk '{print $2}')
10388 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10390 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10391 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10394 for ((i=0;i<5;i++)); do
10395 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10396 error "get fid for f$i failed"
10397 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
10399 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10400 error "get fid for d$i failed"
10401 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
10406 run_test 162b "striped directory path lookup sanity"
10409 # do directio so as not to populate the page cache
10410 log "creating a 10 Mb file"
10411 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10412 log "starting reads"
10413 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10414 log "truncating the file"
10415 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10417 kill %+ || true # reads might have finished
10418 echo "wait until dd is finished"
10420 log "removing the temporary file"
10421 rm -rf $DIR/$tfile || error "tmp file removal failed"
10423 run_test 169 "parallel read and truncate should not deadlock"
10426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10427 $LCTL clear # bug 18514
10428 $LCTL debug_daemon start $TMP/${tfile}_log_good
10430 $LCTL debug_daemon stop
10431 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10432 error "sed failed to read log_good"
10434 $LCTL debug_daemon start $TMP/${tfile}_log_good
10436 $LCTL debug_daemon stop
10438 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10439 error "lctl df log_bad failed"
10441 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10442 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10444 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10445 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10447 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10448 error "bad_line good_line1 good_line2 are empty"
10450 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10451 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10452 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10454 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10455 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10456 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10458 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10459 error "bad_line_new good_line_new are empty"
10461 local expected_good=$((good_line1 + good_line2*2))
10463 rm -f $TMP/${tfile}*
10464 # LU-231, short malformed line may not be counted into bad lines
10465 if [ $bad_line -ne $bad_line_new ] &&
10466 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10467 error "expected $bad_line bad lines, but got $bad_line_new"
10471 if [ $expected_good -ne $good_line_new ]; then
10472 error "expected $expected_good good lines, but got $good_line_new"
10477 run_test 170 "test lctl df to handle corrupted log ====================="
10479 test_171() { # bug20592
10480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10481 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10482 $LCTL set_param fail_loc=0x50e
10483 $LCTL set_param fail_val=3000
10484 multiop_bg_pause $DIR/$tfile O_s || true
10486 kill -USR1 $MULTIPID
10490 if dmesg | grep "recursive fault"; then
10491 error "caught a recursive fault"
10493 $LCTL set_param fail_loc=0
10496 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10498 # it would be good to share it with obdfilter-survey/iokit-libecho code
10499 setup_obdecho_osc () {
10502 local obdfilter_name=$2
10503 echo "Creating new osc for $obdfilter_name on $ost_nid"
10504 # make sure we can find loopback nid
10505 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10507 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10508 ${obdfilter_name}_osc_UUID || rc=2; }
10509 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10510 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10514 cleanup_obdecho_osc () {
10515 local obdfilter_name=$1
10516 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10517 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10524 local pages=${3:-64}
10529 local obd_size=$(get_obd_size $node $OBD)
10530 local page_size=$(get_page_size $node)
10531 if [[ -n "$obd_size" ]]; then
10532 local new_count=$((obd_size / (pages * page_size / 1024)))
10533 [[ $new_count -ge $count ]] || count=$new_count
10536 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10537 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10539 if [ $rc -eq 0 ]; then
10540 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10541 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10543 echo "New object id is $id"
10544 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10546 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10547 "test_brw $count w v $pages $id" || rc=4; }
10548 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10550 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10551 "cleanup" || rc=5; }
10552 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10553 "detach" || rc=6; }
10554 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10560 remote_ost_nodsh && skip "remote OST with nodsh" && return
10562 local rmmod_local=0
10564 if ! module_loaded obdecho; then
10565 load_module obdecho/obdecho
10569 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10570 local host=$(lctl get_param -n osc.$osc.import |
10571 awk '/current_connection:/ {print $2}' )
10572 local target=$(lctl get_param -n osc.$osc.import |
10573 awk '/target:/ {print $2}' )
10574 target=${target%_UUID}
10576 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10577 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10578 [[ -n $target ]] && cleanup_obdecho_osc $target
10579 [ $rmmod_local -eq 1 ] && rmmod obdecho
10582 run_test 180a "test obdecho on osc"
10585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10586 remote_ost_nodsh && skip "remote OST with nodsh" && return
10588 local rmmod_remote=0
10590 do_facet ost1 "lsmod | grep -q obdecho || " \
10591 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10592 "modprobe obdecho; }" && rmmod_remote=1
10593 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10594 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10595 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10598 run_test 180b "test obdecho directly on obdfilter"
10600 test_180c() { # LU-2598
10601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10602 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10603 skip "Need MDS version at least 2.4.0" && return
10606 local rmmod_remote=false
10607 local pages=16384 # 64MB bulk I/O RPC size
10610 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10611 rmmod_remote=true || error "failed to load module obdecho"
10613 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10615 if [ -n "$target" ]; then
10616 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10618 echo "there is no obdfilter target on ost1"
10621 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10624 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10626 test_181() { # bug 22177
10627 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10628 # create enough files to index the directory
10629 createmany -o $DIR/$tdir/foobar 4000
10630 # print attributes for debug purpose
10633 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10635 # remove the files & current working dir
10636 unlinkmany $DIR/$tdir/foobar 4000
10638 kill -USR1 $MULTIPID
10640 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10643 run_test 181 "Test open-unlinked dir ========================"
10646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10647 # disable MDC RPC lock wouldn't crash client
10651 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10652 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10653 $LCTL set_param fail_loc=0x804
10655 for (( i=0; i < $tcount; i++ )) ; do
10656 mkdir $DIR/$tdir/$i
10657 createmany -o $DIR/$tdir/$i/f- $fcount &
10661 for (( i=0; i < $tcount; i++ )) ; do
10662 unlinkmany $DIR/$tdir/$i/f- $fcount &
10668 $LCTL set_param fail_loc=0
10670 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10672 test_183() { # LU-2275
10673 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10674 skip "Need MDS version at least 2.3.56" && return
10676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10677 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10678 echo aaa > $DIR/$tdir/$tfile
10680 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10681 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10683 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10684 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10686 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10688 # Flush negative dentry cache
10689 touch $DIR/$tdir/$tfile
10691 # We are not checking for any leaked references here, they'll
10692 # become evident next time we do cleanup with module unload.
10695 run_test 183 "No crash or request leak in case of strange dispositions ========"
10697 # test suite 184 is for LU-2016, LU-2017
10699 check_swap_layouts_support && return 0
10701 dir0=$DIR/$tdir/$testnum
10702 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10707 $SETSTRIPE -c1 $file1
10709 $SETSTRIPE -c2 $file2
10711 gen1=$($GETSTRIPE -g $file1)
10712 gen2=$($GETSTRIPE -g $file2)
10714 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10715 gen=$($GETSTRIPE -g $file1)
10716 [[ $gen1 != $gen ]] ||
10717 "Layout generation on $file1 does not change"
10718 gen=$($GETSTRIPE -g $file2)
10719 [[ $gen2 != $gen ]] ||
10720 "Layout generation on $file2 does not change"
10722 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10723 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10725 run_test 184a "Basic layout swap"
10728 check_swap_layouts_support && return 0
10730 dir0=$DIR/$tdir/$testnum
10731 mkdir -p $dir0 || error "creating dir $dir0"
10738 $SETSTRIPE -c1 $file1
10739 $SETSTRIPE -c2 $file2
10740 $SETSTRIPE -c1 $file3
10741 chown $RUNAS_ID $file3
10742 gen1=$($GETSTRIPE -g $file1)
10743 gen2=$($GETSTRIPE -g $file2)
10745 $LFS swap_layouts $dir1 $dir2 &&
10746 error "swap of directories layouts should fail"
10747 $LFS swap_layouts $dir1 $file1 &&
10748 error "swap of directory and file layouts should fail"
10749 $RUNAS $LFS swap_layouts $file1 $file2 &&
10750 error "swap of file we cannot write should fail"
10751 $LFS swap_layouts $file1 $file3 &&
10752 error "swap of file with different owner should fail"
10753 /bin/true # to clear error code
10755 run_test 184b "Forbidden layout swap (will generate errors)"
10758 check_swap_layouts_support && return 0
10760 local dir0=$DIR/$tdir/$testnum
10761 mkdir -p $dir0 || error "creating dir $dir0"
10763 local ref1=$dir0/ref1
10764 local ref2=$dir0/ref2
10765 local file1=$dir0/file1
10766 local file2=$dir0/file2
10767 # create a file large enough for the concurent test
10768 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10769 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10770 echo "ref file size: ref1($(stat -c %s $ref1))," \
10771 "ref2($(stat -c %s $ref2))"
10774 dd if=$ref1 of=$file1 bs=16k &
10777 # Make sure dd starts to copy file
10778 while [ ! -f $file1 ]; do sleep 0.1; done
10780 $LFS swap_layouts $file1 $file2
10783 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10784 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10786 # how many bytes copied before swapping layout
10787 local copied=$(stat -c %s $file2)
10788 local remaining=$(stat -c %s $ref1)
10789 remaining=$((remaining - copied))
10790 echo "Copied $copied bytes before swapping layout..."
10792 cmp -n $copied $file1 $ref2 | grep differ &&
10793 error "Content mismatch [0, $copied) of ref2 and file1"
10794 cmp -n $copied $file2 $ref1 ||
10795 error "Content mismatch [0, $copied) of ref1 and file2"
10796 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10797 error "Content mismatch [$copied, EOF) of ref1 and file1"
10800 rm -f $ref1 $ref2 $file1 $file2
10802 run_test 184c "Concurrent write and layout swap"
10805 check_swap_layouts_support && return 0
10806 [ -z "$(which getfattr 2>/dev/null)" ] &&
10807 skip "no getfattr command" && return 0
10809 local file1=$DIR/$tdir/$tfile-1
10810 local file2=$DIR/$tdir/$tfile-2
10811 local file3=$DIR/$tdir/$tfile-3
10815 mkdir -p $DIR/$tdir
10816 touch $file1 || error "create $file1 failed"
10817 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10818 error "create $file2 failed"
10819 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10820 error "create $file3 failed"
10821 lovea1=$($LFS getstripe $file1 | sed 1d)
10823 $LFS swap_layouts $file2 $file3 ||
10824 error "swap $file2 $file3 layouts failed"
10825 $LFS swap_layouts $file1 $file2 ||
10826 error "swap $file1 $file2 layouts failed"
10828 lovea2=$($LFS getstripe $file2 | sed 1d)
10829 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10831 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10832 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10834 run_test 184d "allow stripeless layouts swap"
10837 test_185() { # LU-2441
10838 # LU-3553 - no volatile file support in old servers
10839 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10840 { skip "Need MDS version at least 2.3.60"; return 0; }
10842 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10843 touch $DIR/$tdir/spoo
10844 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10845 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10846 error "cannot create/write a volatile file"
10847 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10848 error "FID is still valid after close"
10850 multiop_bg_pause $DIR/$tdir vVw4096_c
10857 # assume that the next FID for this client is sequential, since stdout
10858 # is unfortunately eaten by multiop_bg_pause
10859 local n=$((${fidv[1]} + 1))
10860 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10861 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10862 error "FID is missing before close"
10863 kill -USR1 $multi_pid
10864 # 1 second delay, so if mtime change we will see it
10866 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10867 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10869 run_test 185 "Volatile file support"
10872 local dir0=$DIR/$tdir/$testnum
10873 mkdir -p $dir0 || error "creating dir $dir0"
10875 local file=$dir0/file1
10876 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10877 local dv1=$($LFS data_version $file)
10878 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10879 local dv2=$($LFS data_version $file)
10880 [[ $dv1 != $dv2 ]] ||
10881 error "data version did not change on write $dv1 == $dv2"
10886 run_test 187a "Test data version change"
10889 local dir0=$DIR/$tdir/$testnum
10890 mkdir -p $dir0 || error "creating dir $dir0"
10892 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10893 [[ ${DV[0]} != ${DV[1]} ]] ||
10894 error "data version did not change on write"\
10895 " ${DV[0]} == ${DV[1]}"
10900 run_test 187b "Test data version change on volatile file"
10903 check_file_in_pool()
10908 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10911 for t in $tlist ; do
10912 [ "$i" -eq "$t" ] && continue 2
10915 echo "pool list: $tlist"
10916 echo "striping: $res"
10917 error_noexit "$file not allocated in $pool"
10924 echo "Creating new pool"
10927 create_pool $FSNAME.$pool ||
10928 { error_noexit "No pool created, result code $?"; return 1; }
10929 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10930 { error_noexit "$pool not in lfs pool_list"; return 2; }
10933 pool_add_targets() {
10934 echo "Adding targets to pool"
10940 local list=$(seq $first $step $last)
10942 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10943 do_facet mgs $LCTL pool_add \
10944 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10945 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10946 | sort -u | tr '\n' ' ' " "$t" || {
10947 error_noexit "Add to pool failed"
10950 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10951 local addcount=$(((last - first) / step + 1))
10952 [ $lfscount -eq $addcount ] || {
10953 error_noexit "lfs pool_list bad ost count" \
10954 "$lfscount != $addcount"
10962 echo "Setting pool on directory $tdir"
10964 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10966 error_noexit "Cannot set pool $pool to $tdir"
10973 echo "Checking pool on directory $tdir"
10975 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10976 [ "$res" = "$pool" ] && return 0
10978 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10982 pool_dir_rel_path() {
10983 echo "Testing relative path works well"
10988 mkdir -p $root/$tdir/$tdir
10990 pool_set_dir $pool $tdir || return 1
10991 pool_set_dir $pool ./$tdir || return 2
10992 pool_set_dir $pool ../$tdir || return 3
10993 pool_set_dir $pool ../$tdir/$tdir || return 4
10994 rm -rf $tdir; cd - > /dev/null
10997 pool_alloc_files() {
10998 echo "Checking files allocation from directory pool"
11005 for i in $(seq -w 1 $count)
11007 local file=$tdir/file-$i
11009 check_file_in_pool $file $pool "$tlist" || \
11010 failed=$((failed + 1))
11012 [ "$failed" = 0 ] && return 0
11014 error_noexit "$failed files not allocated in $pool"
11018 pool_create_files() {
11019 echo "Creating files in pool"
11027 for i in $(seq -w 1 $count)
11029 local file=$tdir/spoo-$i
11030 $SETSTRIPE -p $pool $file
11031 check_file_in_pool $file $pool "$tlist" || \
11032 failed=$((failed + 1))
11034 [ "$failed" = 0 ] && return 0
11036 error_noexit "$failed files not allocated in $pool"
11041 echo "Checking 'lfs df' output"
11044 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
11046 local res=$($LFS df --pool $FSNAME.$pool |
11048 grep "$FSNAME-OST" |
11050 [ "$res" = "$t" ] && return 0
11052 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
11056 pool_file_rel_path() {
11057 echo "Creating files in a pool with relative pathname"
11062 { error_noexit "unable to create $tdir"; return 1 ; }
11063 local file="/..$tdir/$tfile-1"
11064 $SETSTRIPE -p $pool $file ||
11065 { error_noexit "unable to create $file" ; return 2 ; }
11068 $SETSTRIPE -p $pool $tfile-2 || {
11069 error_noexit "unable to create $tfile-2 in $tdir"
11074 pool_remove_first_target() {
11075 echo "Removing first target from a pool"
11078 local pname="lov.$FSNAME-*.pools.$pool"
11079 local t=$($LCTL get_param -n $pname | head -n1)
11080 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11081 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
11082 error_noexit "$t not removed from $FSNAME.$pool"
11087 pool_remove_all_targets() {
11088 echo "Removing all targets from pool"
11091 local pname="lov.$FSNAME-*.pools.$pool"
11092 for t in $($LCTL get_param -n $pname | sort -u)
11094 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11096 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
11097 error_noexit "Pool $FSNAME.$pool cannot be drained"
11100 # striping on an empty/nonexistant pool should fall back
11101 # to "pool of everything"
11103 error_noexit "failed to use fallback striping for empty pool"
11106 # setstripe on an empty pool should fail
11107 $SETSTRIPE -p $pool $file 2>/dev/null && {
11108 error_noexit "expected failure when creating file" \
11116 echo "Destroying pool"
11120 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
11123 # striping on an empty/nonexistant pool should fall back
11124 # to "pool of everything"
11126 error_noexit "failed to use fallback striping for missing pool"
11129 # setstripe on an empty pool should fail
11130 $SETSTRIPE -p $pool $file 2>/dev/null && {
11131 error_noexit "expected failure when creating file" \
11132 "with missing pool"
11136 # get param should return err once pool is gone
11137 if wait_update $HOSTNAME "lctl get_param -n \
11138 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
11140 remove_pool_from_list $FSNAME.$pool
11143 error_noexit "Pool $FSNAME.$pool is not destroyed"
11148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11149 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11151 local POOL=${POOL:-cea1}
11152 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11153 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11156 local last_ost=$(($OSTCOUNT - 1))
11158 local ost_list=$(seq $first_ost $ost_step $last_ost)
11159 local ost_range="$first_ost $last_ost $ost_step"
11160 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11161 local file_dir=$POOL_ROOT/file_tst
11165 # former test_200a test_200b
11166 pool_add $POOL || { rc=$? ; break; }
11167 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11168 # former test_200c test_200d
11169 mkdir -p $test_path
11170 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11171 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11172 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11173 || { rc=$? ; break; }
11174 # former test_200e test_200f
11175 local files=$((OSTCOUNT*3))
11176 pool_alloc_files $POOL $test_path $files "$ost_list" \
11177 || { rc=$? ; break; }
11178 pool_create_files $POOL $file_dir $files "$ost_list" \
11179 || { rc=$? ; break; }
11180 # former test_200g test_200h
11181 pool_lfs_df $POOL || { rc=$? ; break; }
11182 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11184 # former test_201a test_201b test_201c
11185 pool_remove_first_target $POOL || { rc=$? ; break; }
11187 local f=$test_path/$tfile
11188 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11189 pool_remove $POOL $f || { rc=$? ; break; }
11196 run_test 200 "OST pools"
11198 # usage: default_attr <count | size | offset>
11200 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11203 # usage: check_default_stripe_attr
11204 check_default_stripe_attr() {
11205 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11207 --stripe-count|--count)
11208 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11209 --stripe-size|--size)
11210 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11211 --stripe-index|--index)
11214 error "unknown getstripe attr '$1'"
11217 [ $ACTUAL != $EXPECTED ] &&
11218 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11222 test_mkdir -p $DIR/$tdir
11223 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11225 check_default_stripe_attr --stripe-count
11226 check_default_stripe_attr --stripe-size
11227 check_default_stripe_attr --stripe-index
11231 run_test 204a "Print default stripe attributes ================="
11234 test_mkdir -p $DIR/$tdir
11235 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11237 check_default_stripe_attr --stripe-size
11238 check_default_stripe_attr --stripe-index
11242 run_test 204b "Print default stripe size and offset ==========="
11245 test_mkdir -p $DIR/$tdir
11246 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11248 check_default_stripe_attr --stripe-count
11249 check_default_stripe_attr --stripe-index
11253 run_test 204c "Print default stripe count and offset ==========="
11256 test_mkdir -p $DIR/$tdir
11257 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11259 check_default_stripe_attr --stripe-count
11260 check_default_stripe_attr --stripe-size
11264 run_test 204d "Print default stripe count and size ============="
11267 test_mkdir -p $DIR/$tdir
11268 $SETSTRIPE -d $DIR/$tdir
11270 check_default_stripe_attr --stripe-count --raw
11271 check_default_stripe_attr --stripe-size --raw
11272 check_default_stripe_attr --stripe-index --raw
11276 run_test 204e "Print raw stripe attributes ================="
11279 test_mkdir -p $DIR/$tdir
11280 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11282 check_default_stripe_attr --stripe-size --raw
11283 check_default_stripe_attr --stripe-index --raw
11287 run_test 204f "Print raw stripe size and offset ==========="
11290 test_mkdir -p $DIR/$tdir
11291 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11293 check_default_stripe_attr --stripe-count --raw
11294 check_default_stripe_attr --stripe-index --raw
11298 run_test 204g "Print raw stripe count and offset ==========="
11301 test_mkdir -p $DIR/$tdir
11302 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11304 check_default_stripe_attr --stripe-count --raw
11305 check_default_stripe_attr --stripe-size --raw
11309 run_test 204h "Print raw stripe count and size ============="
11311 # Figure out which job scheduler is being used, if any,
11312 # or use a fake one
11313 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11314 JOBENV=SLURM_JOB_ID
11315 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11317 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11319 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11320 JOBENV=LOADL_STEP_ID
11321 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11327 verify_jobstats() {
11331 # clear old jobstats
11332 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11333 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11335 # use a new JobID for this test, or we might see an old one
11336 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11340 log "Using JobID environment variable $JOBENV=$JOBVAL"
11342 if [ $JOBENV = "FAKE_JOBID" ]; then
11343 FAKE_JOBID=$JOBVAL $cmd
11348 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11349 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11350 do_facet $FACET lctl get_param mdt.*.job_stats |
11351 grep $JOBVAL || error "No job stats found on MDT $FACET"
11353 if [ "$target" = "ost" -o "$target" = "both" ]; then
11355 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11356 grep $JOBVAL || error "No job stats found on OST $FACET"
11362 NEW_JOBENV=${1:-$OLD_JOBENV}
11363 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11364 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11367 test_205() { # Job stats
11368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11369 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11370 skip "Server doesn't support jobstats" && return 0
11371 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11374 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11375 if [ $OLD_JOBENV != $JOBENV ]; then
11376 jobstats_set $JOBENV
11377 trap jobstats_set EXIT
11381 cmd="mkdir $DIR/$tfile"
11382 verify_jobstats "$cmd" "mdt"
11384 cmd="rm -fr $DIR/$tfile"
11385 verify_jobstats "$cmd" "mdt"
11387 cmd="mknod $DIR/$tfile c 1 3"
11388 verify_jobstats "$cmd" "mdt"
11390 cmd="rm -f $DIR/$tfile"
11391 verify_jobstats "$cmd" "mdt"
11393 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11394 verify_jobstats "$cmd" "mdt"
11396 cmd="touch $DIR/$tfile"
11397 verify_jobstats "$cmd" "both"
11399 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11400 verify_jobstats "$cmd" "ost"
11402 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11403 verify_jobstats "$cmd" "ost"
11405 cmd="$TRUNCATE $DIR/$tfile 0"
11406 verify_jobstats "$cmd" "both"
11408 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11409 verify_jobstats "$cmd" "mdt"
11412 rm -f $DIR/jobstats_test_rename
11414 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11416 run_test 205 "Verify job stats"
11418 # LU-1480, LU-1773 and LU-1657
11420 mkdir -p $DIR/$tdir
11421 $SETSTRIPE -c -1 $DIR/$tdir
11422 #define OBD_FAIL_LOV_INIT 0x1403
11423 $LCTL set_param fail_loc=0xa0001403
11424 $LCTL set_param fail_val=1
11425 touch $DIR/$tdir/$tfile || true
11427 run_test 206 "fail lov_init_raid0() doesn't lbug"
11430 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11431 local fsz=`stat -c %s $DIR/$tfile`
11432 cancel_lru_locks mdc
11434 # do not return layout in getattr intent
11435 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11436 $LCTL set_param fail_loc=0x170
11437 local sz=`stat -c %s $DIR/$tfile`
11439 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11443 run_test 207a "can refresh layout at glimpse"
11446 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11447 local cksum=`md5sum $DIR/$tfile`
11448 local fsz=`stat -c %s $DIR/$tfile`
11449 cancel_lru_locks mdc
11450 cancel_lru_locks osc
11452 # do not return layout in getattr intent
11453 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11454 $LCTL set_param fail_loc=0x171
11456 # it will refresh layout after the file is opened but before read issues
11457 echo checksum is "$cksum"
11458 echo "$cksum" |md5sum -c --quiet || error "file differs"
11462 run_test 207b "can refresh layout at open"
11465 # FIXME: in this test suite, only RD lease is used. This is okay
11466 # for now as only exclusive open is supported. After generic lease
11467 # is done, this test suite should be revised. - Jinshan
11469 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11470 { skip "Need MDS version at least 2.4.52"; return 0; }
11472 echo "==== test 1: verify get lease work"
11473 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11475 echo "==== test 2: verify lease can be broken by upcoming open"
11476 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11480 $MULTIOP $DIR/$tfile oO_RDONLY:c
11481 kill -USR1 $PID && wait $PID || error "break lease error"
11483 echo "==== test 3: verify lease can't be granted if an open already exists"
11484 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11488 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11489 kill -USR1 $PID && wait $PID || error "open file error"
11491 echo "==== test 4: lease can sustain over recovery"
11492 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11498 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11500 echo "==== test 5: lease broken can't be regained by replay"
11501 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11505 # open file to break lease and then recovery
11506 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11509 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11513 run_test 208 "Exclusive open"
11516 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11517 skip_env "must have disp_stripe" && return
11520 sync; sleep 5; sync;
11522 echo 3 > /proc/sys/vm/drop_caches
11523 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11525 # open/close 500 times
11526 for i in $(seq 500); do
11530 echo 3 > /proc/sys/vm/drop_caches
11531 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11533 echo "before: $req_before, after: $req_after"
11534 [ $((req_after - req_before)) -ge 300 ] &&
11535 error "open/close requests are not freed"
11538 run_test 209 "read-only open/close requests should be freed promptly"
11542 size=$((size % 8192 + 1))
11543 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11544 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11545 rm -f $DIR/f212 $DIR/f212.xyz
11547 run_test 212 "Sendfile test ============================================"
11550 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11551 cancel_lru_locks osc
11552 lctl set_param fail_loc=0x8000040f
11553 # generate a read lock
11554 cat $DIR/$tfile > /dev/null
11555 # write to the file, it will try to cancel the above read lock.
11556 cat /etc/hosts >> $DIR/$tfile
11558 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11560 test_214() { # for bug 20133
11561 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11562 for (( i=0; i < 340; i++ )) ; do
11563 touch $DIR/$tdir/d214c/a$i
11566 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11567 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11568 ls $DIR/d214c || error "ls $DIR/d214c failed"
11569 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11570 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11572 run_test 214 "hash-indexed directory test - bug 20133"
11574 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11575 create_lnet_proc_files() {
11576 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11577 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11579 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11580 rm -f "$TMP/lnet_$1.sys_tmp"
11583 # counterpart of create_lnet_proc_files
11584 remove_lnet_proc_files() {
11585 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11588 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11589 # 3rd arg as regexp for body
11590 check_lnet_proc_stats() {
11591 local l=$(cat "$TMP/lnet_$1" |wc -l)
11592 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11594 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11597 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11598 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11599 # optional and can be regexp for 2nd line (lnet.routes case)
11600 check_lnet_proc_entry() {
11601 local blp=2 # blp stands for 'position of 1st line of body'
11602 [ -z "$5" ] || blp=3 # lnet.routes case
11604 local l=$(cat "$TMP/lnet_$1" |wc -l)
11605 # subtracting one from $blp because the body can be empty
11606 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11608 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11609 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11611 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11612 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11614 # bail out if any unexpected line happened
11615 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11616 [ "$?" != 0 ] || error "$2 misformatted"
11619 test_215() { # for bugs 18102, 21079, 21517
11620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11621 local N='(0|[1-9][0-9]*)' # non-negative numeric
11622 local P='[1-9][0-9]*' # positive numeric
11623 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11624 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11625 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11626 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11628 local L1 # regexp for 1st line
11629 local L2 # regexp for 2nd line (optional)
11630 local BR # regexp for the rest (body)
11632 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11633 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11634 create_lnet_proc_files "stats"
11635 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11636 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11637 remove_lnet_proc_files "stats"
11639 # /proc/sys/lnet/routes should look like this:
11640 # Routing disabled/enabled
11641 # net hops priority state router
11642 # where net is a string like tcp0, hops > 0, priority >= 0,
11643 # state is up/down,
11644 # router is a string like 192.168.1.1@tcp2
11645 L1="^Routing (disabled|enabled)$"
11646 L2="^net +hops +priority +state +router$"
11647 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11648 create_lnet_proc_files "routes"
11649 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11650 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11651 remove_lnet_proc_files "routes"
11653 # /proc/sys/lnet/routers should look like this:
11654 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11655 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11656 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11657 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11658 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11659 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11660 create_lnet_proc_files "routers"
11661 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11662 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11663 remove_lnet_proc_files "routers"
11665 # /proc/sys/lnet/peers should look like this:
11666 # nid refs state last max rtr min tx min queue
11667 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11668 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11669 # numeric (0 or >0 or <0), queue >= 0.
11670 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11671 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11672 create_lnet_proc_files "peers"
11673 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11674 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11675 remove_lnet_proc_files "peers"
11677 # /proc/sys/lnet/buffers should look like this:
11678 # pages count credits min
11679 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11680 L1="^pages +count +credits +min$"
11681 BR="^ +$N +$N +$I +$I$"
11682 create_lnet_proc_files "buffers"
11683 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11684 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11685 remove_lnet_proc_files "buffers"
11687 # /proc/sys/lnet/nis should look like this:
11688 # nid status alive refs peer rtr max tx min
11689 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11690 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11691 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11692 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11693 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11694 create_lnet_proc_files "nis"
11695 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11696 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11697 remove_lnet_proc_files "nis"
11699 # can we successfully write to /proc/sys/lnet/stats?
11700 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11701 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11703 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11705 test_216() { # bug 20317
11706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11707 remote_ost_nodsh && skip "remote OST with nodsh" && return
11710 local facets=$(get_facets OST)
11711 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11713 save_lustre_params client "osc.*.contention_seconds" > $p
11714 save_lustre_params $facets \
11715 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11716 save_lustre_params $facets \
11717 "ldlm.namespaces.filter-*.contended_locks" >> $p
11718 save_lustre_params $facets \
11719 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11722 # agressive lockless i/o settings
11723 for node in $(osts_nodes); do
11724 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'
11726 lctl set_param -n osc.*.contention_seconds 60
11728 $DIRECTIO write $DIR/$tfile 0 10 4096
11729 $CHECKSTAT -s 40960 $DIR/$tfile
11731 # disable lockless i/o
11732 for node in $(osts_nodes); do
11733 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'
11735 lctl set_param -n osc.*.contention_seconds 0
11738 dd if=/dev/zero of=$DIR/$tfile count=0
11739 $CHECKSTAT -s 0 $DIR/$tfile
11741 restore_lustre_params <$p
11745 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11747 test_217() { # bug 22430
11748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11752 for node in $(nodes_list); do
11753 nid=$(host_nids_address $node $NETTYPE)
11754 if [[ $nid = *-* ]] ; then
11755 echo "lctl ping $nid@$NETTYPE"
11756 lctl ping $nid@$NETTYPE
11758 echo "skipping $node (no hyphen detected)"
11762 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11765 # do directio so as not to populate the page cache
11766 log "creating a 10 Mb file"
11767 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11768 log "starting reads"
11769 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11770 log "truncating the file"
11771 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11773 kill %+ || true # reads might have finished
11774 echo "wait until dd is finished"
11776 log "removing the temporary file"
11777 rm -rf $DIR/$tfile || error "tmp file removal failed"
11779 run_test 218 "parallel read and truncate should not deadlock ======================="
11782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11783 # write one partial page
11784 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11785 # set no grant so vvp_io_commit_write will do sync write
11786 $LCTL set_param fail_loc=0x411
11787 # write a full page at the end of file
11788 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11790 $LCTL set_param fail_loc=0
11791 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11792 $LCTL set_param fail_loc=0x411
11793 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11796 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11797 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11799 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11801 test_220() { #LU-325
11802 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11803 remote_ost_nodsh && skip "remote OST with nodsh" && return
11806 test_mkdir -p $DIR/$tdir
11807 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11808 awk '{print $2}' | sed -e 's/_UUID$//')
11811 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11812 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11813 osc.$mdtosc_proc1.prealloc_last_id)
11814 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11815 osc.$mdtosc_proc1.prealloc_next_id)
11819 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11820 #define OBD_FAIL_OST_ENOINO 0x229
11821 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11822 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11823 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11825 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11827 MDSOBJS=$((last_id - next_id))
11828 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11830 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11831 echo "OST still has $count kbytes free"
11833 echo "create $MDSOBJS files @next_id..."
11834 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11836 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11837 osc.$mdtosc_proc1.prealloc_last_id)
11838 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11839 osc.$mdtosc_proc1.prealloc_next_id)
11841 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11846 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11847 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11849 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11850 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11851 echo "unlink $MDSOBJS files @$next_id..."
11852 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11854 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11858 dd if=`which date` of=$MOUNT/date oflag=sync
11859 chmod +x $MOUNT/date
11861 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11862 $LCTL set_param fail_loc=0x80001401
11864 $MOUNT/date > /dev/null
11867 run_test 221 "make sure fault and truncate race to not cause OOM"
11870 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11872 test_mkdir -p $DIR/$tdir
11873 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11874 createmany -o $DIR/$tdir/$tfile 10
11875 cancel_lru_locks mdc
11876 cancel_lru_locks osc
11877 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11878 $LCTL set_param fail_loc=0x31a
11879 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11880 $LCTL set_param fail_loc=0
11883 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11888 test_mkdir -p $DIR/$tdir
11889 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11890 createmany -o $DIR/$tdir/$tfile 10
11891 cancel_lru_locks mdc
11892 cancel_lru_locks osc
11893 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11894 $LCTL set_param fail_loc=0x31a
11895 rm -r $DIR/$tdir || "AGL for rmdir failed"
11896 $LCTL set_param fail_loc=0
11898 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11903 test_mkdir -p $DIR/$tdir
11904 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11905 createmany -o $DIR/$tdir/$tfile 10
11906 cancel_lru_locks mdc
11907 cancel_lru_locks osc
11908 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11909 $LCTL set_param fail_loc=0x31b
11910 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11911 $LCTL set_param fail_loc=0
11914 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11916 test_224a() { # LU-1039, MRP-303
11917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11918 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11919 $LCTL set_param fail_loc=0x508
11920 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11921 $LCTL set_param fail_loc=0
11924 run_test 224a "Don't panic on bulk IO failure"
11926 test_224b() { # LU-1039, MRP-303
11927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11928 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11929 cancel_lru_locks osc
11930 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11931 $LCTL set_param fail_loc=0x515
11932 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11933 $LCTL set_param fail_loc=0
11936 run_test 224b "Don't panic on bulk IO failure"
11938 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11941 if [ -z ${MDSSURVEY} ]; then
11942 skip_env "mds-survey not found" && return
11945 [ $MDSCOUNT -ge 2 ] &&
11946 skip "skipping now for more than one MDT" && return
11948 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11949 { skip "Need MDS version at least 2.2.51"; return; }
11951 local mds=$(facet_host $SINGLEMDS)
11952 local target=$(do_nodes $mds 'lctl dl' | \
11953 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11955 local cmd1="file_count=1000 thrhi=4"
11956 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11957 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11958 local cmd="$cmd1 $cmd2 $cmd3"
11960 rm -f ${TMP}/mds_survey*
11962 eval $cmd || error "mds-survey with zero-stripe failed"
11963 cat ${TMP}/mds_survey*
11964 rm -f ${TMP}/mds_survey*
11966 run_test 225a "Metadata survey sanity with zero-stripe"
11969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11971 if [ -z ${MDSSURVEY} ]; then
11972 skip_env "mds-survey not found" && return
11974 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11975 { skip "Need MDS version at least 2.2.51"; return; }
11977 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11978 skip_env "Need to mount OST to test" && return
11981 [ $MDSCOUNT -ge 2 ] &&
11982 skip "skipping now for more than one MDT" && return
11983 local mds=$(facet_host $SINGLEMDS)
11984 local target=$(do_nodes $mds 'lctl dl' | \
11985 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11987 local cmd1="file_count=1000 thrhi=4"
11988 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11989 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11990 local cmd="$cmd1 $cmd2 $cmd3"
11992 rm -f ${TMP}/mds_survey*
11994 eval $cmd || error "mds-survey with stripe_count failed"
11995 cat ${TMP}/mds_survey*
11996 rm -f ${TMP}/mds_survey*
11998 run_test 225b "Metadata survey sanity with stripe_count = 1"
12000 mcreate_path2fid () {
12006 local path=$DIR/$tdir/$name
12011 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12012 error "cannot create $desc"
12014 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12016 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12018 fid_path=$($LFS fid2path $MOUNT $fid)
12020 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12022 [ "$path" == "$fid_path" ] ||
12023 error "fid2path returned $fid_path, expected $path"
12025 echo "pass with $path and $fid"
12030 mkdir -p $DIR/$tdir
12032 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12033 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12034 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12035 mcreate_path2fid 0040666 0 0 dir "directory"
12036 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12037 mcreate_path2fid 0100666 0 0 file "regular file"
12038 mcreate_path2fid 0120666 0 0 link "symbolic link"
12039 mcreate_path2fid 0140666 0 0 sock "socket"
12041 run_test 226a "call path2fid and fid2path on files of all type"
12044 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12048 mkdir -p $DIR/$tdir
12049 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12050 error "create remote directory failed"
12051 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12052 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12053 "character special file (null)"
12054 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12055 "character special file (no device)"
12056 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12057 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12058 "block special file (loop)"
12059 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12060 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12061 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12063 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12065 # LU-1299 Executing or running ldd on a truncated executable does not
12066 # cause an out-of-memory condition.
12068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12069 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12070 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12071 chmod +x $MOUNT/date
12073 $MOUNT/date > /dev/null
12074 ldd $MOUNT/date > /dev/null
12077 run_test 227 "running truncated executable does not cause OOM"
12079 # LU-1512 try to reuse idle OI blocks
12081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12082 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12083 skip "non-ldiskfs backend" && return
12085 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12086 local myDIR=$DIR/$tdir
12089 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12090 $LCTL set_param fail_loc=0x80001002
12091 createmany -o $myDIR/t- 10000
12092 $LCTL set_param fail_loc=0
12093 # The guard is current the largest FID holder
12095 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12097 local IDX=$(($SEQ % 64))
12099 do_facet $SINGLEMDS sync
12100 # Make sure journal flushed.
12102 local blk1=$(do_facet $SINGLEMDS \
12103 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12104 grep Blockcount | awk '{print $4}')
12106 # Remove old files, some OI blocks will become idle.
12107 unlinkmany $myDIR/t- 10000
12108 # Create new files, idle OI blocks should be reused.
12109 createmany -o $myDIR/t- 2000
12110 do_facet $SINGLEMDS sync
12111 # Make sure journal flushed.
12113 local blk2=$(do_facet $SINGLEMDS \
12114 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12115 grep Blockcount | awk '{print $4}')
12117 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12119 run_test 228a "try to reuse idle OI blocks"
12122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12123 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12124 skip "non-ldiskfs backend" && return
12126 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12127 local myDIR=$DIR/$tdir
12130 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12131 $LCTL set_param fail_loc=0x80001002
12132 createmany -o $myDIR/t- 10000
12133 $LCTL set_param fail_loc=0
12134 # The guard is current the largest FID holder
12136 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12138 local IDX=$(($SEQ % 64))
12140 do_facet $SINGLEMDS sync
12141 # Make sure journal flushed.
12143 local blk1=$(do_facet $SINGLEMDS \
12144 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12145 grep Blockcount | awk '{print $4}')
12147 # Remove old files, some OI blocks will become idle.
12148 unlinkmany $myDIR/t- 10000
12151 stop $SINGLEMDS || error "Fail to stop MDT."
12153 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12155 df $MOUNT || error "Fail to df."
12156 # Create new files, idle OI blocks should be reused.
12157 createmany -o $myDIR/t- 2000
12158 do_facet $SINGLEMDS sync
12159 # Make sure journal flushed.
12161 local blk2=$(do_facet $SINGLEMDS \
12162 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12163 grep Blockcount | awk '{print $4}')
12165 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12167 run_test 228b "idle OI blocks can be reused after MDT restart"
12171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12172 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12173 skip "non-ldiskfs backend" && return
12175 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12176 local myDIR=$DIR/$tdir
12179 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12180 $LCTL set_param fail_loc=0x80001002
12181 # 20000 files can guarantee there are index nodes in the OI file
12182 createmany -o $myDIR/t- 20000
12183 $LCTL set_param fail_loc=0
12184 # The guard is current the largest FID holder
12186 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12188 local IDX=$(($SEQ % 64))
12190 do_facet $SINGLEMDS sync
12191 # Make sure journal flushed.
12193 local blk1=$(do_facet $SINGLEMDS \
12194 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12195 grep Blockcount | awk '{print $4}')
12197 # Remove old files, some OI blocks will become idle.
12198 unlinkmany $myDIR/t- 20000
12200 # The OI file should become empty now
12202 # Create new files, idle OI blocks should be reused.
12203 createmany -o $myDIR/t- 2000
12204 do_facet $SINGLEMDS sync
12205 # Make sure journal flushed.
12207 local blk2=$(do_facet $SINGLEMDS \
12208 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12209 grep Blockcount | awk '{print $4}')
12211 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12213 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12215 test_229() { # LU-2482, LU-3448
12216 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12217 skip "No HSM support on MDS of $(get_lustre_version)," \
12218 "need 2.4.53 at least" && return
12219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12220 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12224 # Create a file with a released layout and stripe count 2.
12225 $MULTIOP $DIR/$tfile H2c ||
12226 error "failed to create file with released layout"
12228 $GETSTRIPE -v $DIR/$tfile
12230 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12231 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12233 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12234 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12235 stat $DIR/$tfile || error "failed to stat released file"
12237 chown $RUNAS_ID $DIR/$tfile ||
12238 error "chown $RUNAS_ID $DIR/$tfile failed"
12240 chgrp $RUNAS_ID $DIR/$tfile ||
12241 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12243 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12244 rm $DIR/$tfile || error "failed to remove released file"
12246 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12250 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12253 mkdir -p $DIR/$tdir/test_230_local
12254 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12255 [ $mdt_idx -ne 0 ] &&
12256 error "create local directory on wrong MDT $mdt_idx"
12258 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12259 error "create remote directory failed"
12260 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12261 [ $mdt_idx -ne $MDTIDX ] &&
12262 error "create remote directory on wrong MDT $mdt_idx"
12264 createmany -o $DIR/$tdir/test_230/t- 10 ||
12265 error "create files on remote directory failed"
12266 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12267 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12268 rm -r $DIR/$tdir || error "unlink remote directory failed"
12270 run_test 230a "Create remote directory and files under the remote directory"
12273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12274 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12281 local migrate_dir=$DIR/$tdir/migrate_dir
12282 local other_dir=$DIR/$tdir/other_dir
12284 mkdir -p $migrate_dir
12285 mkdir -p $other_dir
12286 for ((i=0; i<10; i++)); do
12287 mkdir -p $migrate_dir/dir_${i}
12288 createmany -o $migrate_dir/dir_${i}/f 10 ||
12289 error "create files under remote dir failed $i"
12292 cp /etc/passwd $migrate_dir/$tfile
12293 cp /etc/passwd $other_dir/$tfile
12294 chattr +SAD $migrate_dir
12295 chattr +SAD $migrate_dir/$tfile
12297 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12298 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12299 local old_dir_mode=$(stat -c%f $migrate_dir)
12300 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12302 mkdir -p $migrate_dir/dir_default_stripe2
12303 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12304 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12306 mkdir -p $other_dir
12307 ln $migrate_dir/$tfile $other_dir/luna
12308 ln $migrate_dir/$tfile $migrate_dir/sofia
12309 ln $other_dir/$tfile $migrate_dir/david
12310 ln -s $migrate_dir/$tfile $other_dir/zachary
12311 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12312 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12314 $LFS mv -v -M $MDTIDX $migrate_dir ||
12315 error "migrate remote dir error"
12317 echo "migratate to MDT1, then checking.."
12318 for ((i=0; i<10; i++)); do
12319 for file in $(find $migrate_dir/dir_${i}); do
12320 mdt_index=$($LFS getstripe -M $file)
12321 [ $mdt_index == $MDTIDX ] ||
12322 error "$file is not on MDT${MDTIDX}"
12326 # the multiple link file should still in MDT0
12327 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12328 [ $mdt_index == 0 ] ||
12329 error "$file is not on MDT${MDTIDX}"
12331 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12332 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12333 error " expect $old_dir_flag get $new_dir_flag"
12335 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12336 [ "$old_file_flag" = "$new_file_flag" ] ||
12337 error " expect $old_file_flag get $new_file_flag"
12339 local new_dir_mode=$(stat -c%f $migrate_dir)
12340 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12341 error "expect mode $old_dir_mode get $new_dir_mode"
12343 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12344 [ "$old_file_mode" = "$new_file_mode" ] ||
12345 error "expect mode $old_file_mode get $new_file_mode"
12347 diff /etc/passwd $migrate_dir/$tfile ||
12348 error "$tfile different after migration"
12350 diff /etc/passwd $other_dir/luna ||
12351 error "luna different after migration"
12353 diff /etc/passwd $migrate_dir/sofia ||
12354 error "sofia different after migration"
12356 diff /etc/passwd $migrate_dir/david ||
12357 error "david different after migration"
12359 diff /etc/passwd $other_dir/zachary ||
12360 error "zachary different after migration"
12362 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12363 error "${tfile}_ln different after migration"
12365 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12366 error "${tfile}_ln_other different after migration"
12368 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12369 [ $stripe_count = 2 ] ||
12370 error "dir strpe_count $d != 2 after migration."
12372 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12373 [ $stripe_count = 2 ] ||
12374 error "file strpe_count $d != 2 after migration."
12376 #migrate back to MDT0
12378 $LFS mv -v -M $MDTIDX $migrate_dir ||
12379 error "migrate remote dir error"
12381 echo "migrate back to MDT0, checking.."
12382 for file in $(find $migrate_dir); do
12383 mdt_index=$($LFS getstripe -M $file)
12384 [ $mdt_index == $MDTIDX ] ||
12385 error "$file is not on MDT${MDTIDX}"
12388 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12389 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12390 error " expect $old_dir_flag get $new_dir_flag"
12392 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12393 [ "$old_file_flag" = "$new_file_flag" ] ||
12394 error " expect $old_file_flag get $new_file_flag"
12396 local new_dir_mode=$(stat -c%f $migrate_dir)
12397 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12398 error "expect mode $old_dir_mode get $new_dir_mode"
12400 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12401 [ "$old_file_mode" = "$new_file_mode" ] ||
12402 error "expect mode $old_file_mode get $new_file_mode"
12404 diff /etc/passwd ${migrate_dir}/$tfile ||
12405 error "$tfile different after migration"
12407 diff /etc/passwd ${other_dir}/luna ||
12408 error "luna different after migration"
12410 diff /etc/passwd ${migrate_dir}/sofia ||
12411 error "sofia different after migration"
12413 diff /etc/passwd ${other_dir}/zachary ||
12414 error "zachary different after migration"
12416 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12417 error "${tfile}_ln different after migration"
12419 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12420 error "${tfile}_ln_other different after migration"
12422 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12423 [ $stripe_count = 2 ] ||
12424 error "dir strpe_count $d != 2 after migration."
12426 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12427 [ $stripe_count = 2 ] ||
12428 error "file strpe_count $d != 2 after migration."
12430 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12432 run_test 230b "migrate directory"
12435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12436 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12441 #If migrating directory fails in the middle, all entries of
12442 #the directory is still accessiable.
12443 mkdir -p $DIR/$tdir
12445 createmany -o $DIR/$tdir/f 10 ||
12446 error "create files under ${tdir} failed"
12448 #failed after migrating 5 entries
12449 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12450 do_facet mds1 lctl set_param fail_loc=0x20001801
12451 do_facet mds1 lctl set_param fail_val=5
12452 local t=`ls $DIR/$tdir | wc -l`
12453 $LFS mv -M $MDTIDX $DIR/$tdir &&
12454 error "migrate should failed after 5 entries"
12455 local u=`ls $DIR/$tdir | wc -l`
12456 [ "$u" == "$t" ] || error "$u != $t during migration"
12458 for file in $(find $DIR/$tdir); do
12459 stat $file || error "stat $file failed"
12462 do_facet mds1 lctl set_param fail_loc=0
12463 do_facet mds1 lctl set_param fail_val=0
12465 $LFS mv -M $MDTIDX $DIR/$tdir ||
12466 error "migrate open files should failed with open files"
12468 echo "Finish migration, then checking.."
12469 for file in $(find $DIR/$tdir); do
12470 mdt_index=$($LFS getstripe -M $file)
12471 [ $mdt_index == $MDTIDX ] ||
12472 error "$file is not on MDT${MDTIDX}"
12475 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12477 run_test 230c "check directory accessiblity if migration is failed"
12480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12481 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12487 mkdir -p $DIR/$tdir
12489 for ((i=0; i<100; i++)); do
12490 mkdir -p $DIR/$tdir/dir_${i}
12491 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12492 error "create files under remote dir failed $i"
12495 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12497 echo "Finish migration, then checking.."
12498 for file in $(find $DIR/$tdir); do
12499 mdt_index=$($LFS getstripe -M $file)
12500 [ $mdt_index == $MDTIDX ] ||
12501 error "$file is not on MDT${MDTIDX}"
12504 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12506 run_test 230d "check migrate big directory"
12510 # For simplicity this test assumes that max_pages_per_rpc
12511 # is the same across all OSCs
12512 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12513 local bulk_size=$((max_pages * 4096))
12515 mkdir -p $DIR/$tdir
12517 # clear the OSC stats
12518 $LCTL set_param osc.*.stats=0 &>/dev/null
12520 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12521 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12522 oflag=direct &>/dev/null || error "dd failed"
12524 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12525 if [ x$nrpcs != "x1" ]; then
12526 error "found $nrpc ost_write RPCs, not 1 as expected"
12529 # Drop the OSC cache, otherwise we will read from it
12530 cancel_lru_locks osc
12532 # clear the OSC stats
12533 $LCTL set_param osc.*.stats=0 &>/dev/null
12535 # Client reads $bulk_size.
12536 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12537 iflag=direct &>/dev/null || error "dd failed"
12539 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12540 if [ x$nrpcs != "x1" ]; then
12541 error "found $nrpc ost_read RPCs, not 1 as expected"
12544 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12547 mkdir -p $DIR/$tdir
12549 for i in {0..1023}; do
12550 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12551 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12552 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12556 run_test 231b "must not assert on fully utilized OST request buffer"
12559 mkdir -p $DIR/$tdir
12560 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12561 $LCTL set_param fail_loc=0x31c
12563 # ignore dd failure
12564 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12566 $LCTL set_param fail_loc=0
12567 umount_client $MOUNT || error "umount failed"
12568 mount_client $MOUNT || error "mount failed"
12570 run_test 232 "failed lock should not block umount"
12573 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12574 { skip "Need MDS version at least 2.3.64"; return; }
12576 local fid=$($LFS path2fid $MOUNT)
12577 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12578 error "cannot access $MOUNT using its FID '$fid'"
12580 run_test 233a "checking that OBF of the FS root succeeds"
12583 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12584 { skip "Need MDS version at least 2.5.90"; return; }
12586 local fid=$($LFS path2fid $MOUNT/.lustre)
12587 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12588 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12590 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12591 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12592 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12594 run_test 233b "checking that OBF of the FS .lustre succeeds"
12597 local p="$TMP/sanityN-$TESTNAME.parameters"
12598 save_lustre_params client "llite.*.xattr_cache" > $p
12599 lctl set_param llite.*.xattr_cache 1 ||
12600 { skip "xattr cache is not supported"; return 0; }
12602 mkdir -p $DIR/$tdir || error "mkdir failed"
12603 touch $DIR/$tdir/$tfile || error "touch failed"
12604 # OBD_FAIL_LLITE_XATTR_ENOMEM
12605 $LCTL set_param fail_loc=0x1405
12606 if [ ! -f /etc/SuSE-release ]; then
12607 # attr pre-2.4.44-7 had a bug with rc
12608 # LU-3703 - SLES clients have older attr
12609 getfattr -n user.attr $DIR/$tdir/$tfile &&
12610 error "getfattr should have failed with ENOMEM"
12612 $LCTL set_param fail_loc=0x0
12615 restore_lustre_params < $p
12618 run_test 234 "xattr cache should not crash on ENOMEM"
12621 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12622 skip "Need MDS version at least 2.4.52" && return
12623 flock_deadlock $DIR/$tfile
12628 124) error "process hangs on a deadlock"
12630 *) error "error executing flock_deadlock $DIR/$tfile"
12634 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12638 check_swap_layouts_support && return 0
12639 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12641 local ref1=/etc/passwd
12642 local ref2=/etc/group
12643 local file1=$DIR/$tdir/f1
12644 local file2=$DIR/$tdir/f2
12646 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12647 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12648 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12649 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12650 local fd=$(free_fd)
12651 local cmd="exec $fd<>$file2"
12654 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12655 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12658 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12663 run_test 236 "Layout swap on open unlinked file"
12665 # test to verify file handle related system calls
12666 # (name_to_handle_at/open_by_handle_at)
12667 # The new system calls are supported in glibc >= 2.14.
12670 echo "Test file_handle syscalls" > $DIR/$tfile ||
12671 error "write failed"
12672 check_fhandle_syscalls $DIR/$tfile ||
12673 error "check_fhandle_syscalls failed"
12675 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12677 # LU-4659 linkea consistency
12679 local server_version=$(lustre_version_code $SINGLEMDS)
12681 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12682 [[ $server_version -gt $(version_code 2.5.1) &&
12683 $server_version -lt $(version_code 2.5.50) ]] ||
12684 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12687 ln $DIR/$tfile $DIR/$tfile.lnk
12688 touch $DIR/$tfile.new
12689 mv $DIR/$tfile.new $DIR/$tfile
12690 local fid1=$(lfs path2fid $DIR/$tfile)
12691 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12692 local path1=$(lfs fid2path $FSNAME $fid1)
12693 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12694 local path2=$(lfs fid2path $FSNAME $fid2)
12695 [ $tfile.lnk == $path2 ] ||
12696 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12699 run_test 238 "Verify linkea consistency"
12702 local list=$(comma_list $(mdts_nodes))
12704 mkdir -p $DIR/$tdir
12705 createmany -o $DIR/$tdir/f- 5000
12706 unlinkmany $DIR/$tdir/f- 5000
12707 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12708 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12709 osc.*MDT*.sync_in_flight" | calc_sum)
12710 [ "$changes" -eq 0 ] || error "$changes not synced"
12712 run_test 239 "osp_sync test"
12714 cleanup_test_300() {
12718 test_striped_dir() {
12723 mkdir -p $DIR/$tdir
12725 SAVE_UMASK=$(umask)
12726 trap cleanup_test_300 RETURN EXIT
12728 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12729 $DIR/$tdir/striped_dir ||
12730 error "set striped dir error"
12732 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12733 [ "$mode" = "755" ] || error "expect 755 got $mode"
12735 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12736 if [ "$stripe_count" != "2" ]; then
12737 error "stripe_count is $stripe_count, expect 2"
12740 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12741 if [ "$stripe_index" != "$mdt_index" ]; then
12742 error "stripe_index is $stripe_index, expect $mdt_index"
12745 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12746 error "nlink error after create striped dir"
12748 mkdir $DIR/$tdir/striped_dir/a
12749 mkdir $DIR/$tdir/striped_dir/b
12751 stat $DIR/$tdir/striped_dir/a ||
12752 error "create dir under striped dir failed"
12753 stat $DIR/$tdir/striped_dir/b ||
12754 error "create dir under striped dir failed"
12756 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12757 error "nlink error after mkdir"
12759 rmdir $DIR/$tdir/striped_dir/a
12760 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12761 error "nlink error after rmdir"
12763 rmdir $DIR/$tdir/striped_dir/b
12764 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12765 error "nlink error after rmdir"
12767 rmdir $DIR/$tdir/striped_dir ||
12768 error "rmdir striped dir error"
12776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12777 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12779 test_striped_dir 0 || error "failed on striped dir on MDT0"
12780 test_striped_dir 1 || error "failed on striped dir on MDT0"
12782 run_test 300a "basic striped dir sanity test"
12785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12786 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12792 test_mkdir $DIR/$tdir || error "mkdir fail"
12793 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12794 error "set striped dir error"
12795 for ((i=0; i<10; i++)); do
12796 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12798 touch $DIR/$tdir/striped_dir/file_$i ||
12799 error "touch error $i"
12800 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12801 [ $mtime1 -eq $mtime2 ] &&
12802 error "mtime not change after create"
12804 rm -f $DIR/$tdir/striped_dir/file_$i ||
12805 error "unlink error $i"
12806 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12807 [ $mtime2 -eq $mtime3 ] &&
12808 error "mtime did not change after unlink"
12812 run_test 300b "check ctime/mtime for striped dir"
12815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12816 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12819 mkdir -p $DIR/$tdir
12820 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12821 error "set striped dir error"
12823 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12824 error "chown striped dir failed"
12826 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12827 error "create 5k files failed"
12829 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12831 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12835 run_test 300c "chown && check ls under striped directory"
12838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12839 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12843 mkdir -p $DIR/$tdir
12844 $SETSTRIPE -c 2 $DIR/$tdir
12846 #local striped directory
12847 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12848 error "set striped dir error"
12849 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12850 error "create 10 files failed"
12852 #remote striped directory
12853 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12854 error "set striped dir error"
12855 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12856 error "create 10 files failed"
12858 for file in $(find $DIR/$tdir); do
12859 stripe_count=$($GETSTRIPE -c $file)
12860 [ $stripe_count -eq 2 ] ||
12861 error "wrong stripe $stripe_count for $file"
12866 run_test 300d "check default stripe under striped directory"
12869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12870 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12874 mkdir -p $DIR/$tdir
12876 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12877 error "set striped dir error"
12879 touch $DIR/$tdir/striped_dir/a
12880 touch $DIR/$tdir/striped_dir/b
12881 touch $DIR/$tdir/striped_dir/c
12883 mkdir $DIR/$tdir/striped_dir/dir_a
12884 mkdir $DIR/$tdir/striped_dir/dir_b
12885 mkdir $DIR/$tdir/striped_dir/dir_c
12887 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12888 error "set striped dir under striped dir error"
12890 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12891 error "set striped dir under striped dir error"
12893 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12894 error "set striped dir under striped dir error"
12896 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12897 error "rename file under striped dir should fail"
12899 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12900 error "rename dir under striped dir should fail"
12902 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12903 error "rename dir under different stripes should fail"
12905 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12906 error "rename file under striped dir should succeed"
12908 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12909 error "rename dir under striped dir should succeed"
12913 run_test 300e "check rename under striped directory"
12916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12922 mkdir -p $DIR/$tdir
12924 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12925 error "set striped dir error"
12927 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12928 error "set striped dir error"
12930 touch $DIR/$tdir/striped_dir/a
12931 mkdir $DIR/$tdir/striped_dir/dir_a
12932 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12933 error "create striped dir under striped dir fails"
12935 touch $DIR/$tdir/striped_dir1/b
12936 mkdir $DIR/$tdir/striped_dir1/dir_b
12937 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12938 error "create striped dir under striped dir fails"
12940 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12941 error "rename file under different striped dir should fail"
12943 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12944 error "rename dir under different striped dir should fail"
12946 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12947 error "rename striped dir under diff striped dir should fail"
12949 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12950 error "rename file under diff striped dirs fails"
12952 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12953 error "rename dir under diff striped dirs fails"
12957 run_test 300f "check rename cross striped directory"
12960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12965 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12966 $DIR/$tdir/striped_dir ||
12967 error "set striped dir error"
12969 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12970 error "set default stripe on striped dir error"
12972 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
12973 [ $stripe_count -eq $MDSCOUNT ] ||
12974 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
12976 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12978 for dir in $(find $DIR/$tdir/striped_dir/*); do
12979 stripe_count=$($LFS getdirstripe -c $dir)
12980 [ $stripe_count -eq $MDSCOUNT ] ||
12981 error "expect $MDSCOUNT get $stripe_count for $dir"
12984 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12985 #change default stripe count to 2
12986 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12987 error "set default stripe on striped dir error"
12989 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12991 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12993 #change default stripe count to 1
12994 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12995 error "set default stripe on striped dir error"
12997 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12998 for dir in $(find $DIR/$tdir/striped_dir/*); do
12999 stripe_count=$($LFS getdirstripe -c $dir)
13000 [ $stripe_count -eq 1 ] ||
13001 error "expect 1 get $stripe_count for $dir"
13003 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
13005 run_test 300g "check default striped directory for striped directory"
13008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13009 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13015 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13016 error "set striped dir error"
13018 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13019 error "create files under striped dir failed"
13021 # unfortunately, we need to umount to clear dir layout cache for now
13022 # once we fully implement dir layout, we can drop this
13023 umount_client $MOUNT || error "umount failed"
13024 mount_client $MOUNT || error "mount failed"
13026 #set the stripe to be unknown hash type
13027 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13028 $LCTL set_param fail_loc=0x1901
13029 for ((i = 0; i < 10; i++)); do
13030 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13031 error "stat f-$i failed"
13032 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13035 touch $DIR/$tdir/striped_dir/f0 &&
13036 error "create under striped dir with unknown hash should fail"
13038 $LCTL set_param fail_loc=0
13040 umount_client $MOUNT || error "umount failed"
13041 mount_client $MOUNT || error "mount failed"
13045 run_test 300h "client handle unknown hash type striped directory"
13047 test_400a() { # LU-1606, was conf-sanity test_74
13048 local extra_flags=''
13049 local out=$TMP/$tfile
13050 local prefix=/usr/include/lustre
13053 if ! which $CC > /dev/null 2>&1; then
13054 skip_env "$CC is not installed"
13058 if ! [[ -d $prefix ]]; then
13059 # Assume we're running in tree and fixup the include path.
13060 extra_flags+=" -I$LUSTRE/../libcfs/include"
13061 extra_flags+=" -I$LUSTRE/include"
13062 extra_flags+=" -L$LUSTRE/utils"
13065 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13066 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13067 error "client api broken"
13070 run_test 400a "Lustre client api program can compile and link"
13072 test_400b() { # LU-1606, LU-5011
13074 local out=$TMP/$tfile
13075 local prefix=/usr/include/lustre
13077 # We use a hard coded prefix so that this test will not fail
13078 # when run in tree. There are headers in lustre/include/lustre/
13079 # that are not packaged (like lustre_idl.h) and have more
13080 # complicated include dependencies (like config.h and lnet/types.h).
13081 # Since this test about correct packaging we just skip them when
13082 # they don't exist (see below) rather than try to fixup cppflags.
13084 if ! which $CC > /dev/null 2>&1; then
13085 skip_env "$CC is not installed"
13089 for header in $prefix/*.h; do
13090 if ! [[ -f "$header" ]]; then
13094 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13095 continue # liblustreapi.h is deprecated.
13098 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13099 error "cannot compile '$header'"
13102 run_test 400b "packaged headers can be compiled"
13105 # tests that do cleanup/setup should be run at the end
13109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13111 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13112 $LCTL set_param fail_loc=0x903
13113 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
13114 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
13117 FAIL_ON_ERROR=true cleanup
13118 FAIL_ON_ERROR=true setup
13120 run_test 900 "umount should not race with any mgc requeue thread"
13123 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13124 check_and_cleanup_lustre
13125 if [ "$I_MOUNTED" != "yes" ]; then
13126 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true