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
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 df $MOUNT > /dev/null 2>&1
650 [ $rc -ne 0 ] && break
658 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
659 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
660 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
662 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
663 skip "only for ldiskfs MDT" && return 0
665 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
670 for ((i=0; i<10; i++)); do
671 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
672 error "create remote dir error $i"
673 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
674 error "create files under remote dir failed $i"
677 check_fs_consistency_17n ||
678 error "e2fsck report error after create files under remote dir"
680 for ((i=0;i<10;i++)); do
681 rm -rf $DIR/$tdir/remote_dir_${i} ||
682 error "destroy remote dir error $i"
685 check_fs_consistency_17n ||
686 error "e2fsck report error after unlink files under remote dir"
688 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
689 skip "lustre < 2.4.50 does not support migrate mv " && return
691 for ((i=0; i<10; i++)); do
692 mkdir -p $DIR/$tdir/remote_dir_${i}
693 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
694 error "create files under remote dir failed $i"
695 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
696 error "migrate remote dir error $i"
698 check_fs_consistency_17n || error "e2fsck report error after migration"
700 for ((i=0;i<10;i++)); do
701 rm -rf $DIR/$tdir/remote_dir_${i} ||
702 error "destroy remote dir error $i"
705 check_fs_consistency_17n || error "e2fsck report error after unlink"
707 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
710 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
711 skip "Need MDS version at least 2.3.64" && return
713 local WDIR=$DIR/${tdir}o
719 mdt_index=$($LFS getstripe -M $WDIR)
720 mdt_index=$((mdt_index+1))
721 mdtdevname=$(mdsdevname $mdt_index)
725 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
727 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
728 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
729 ls -l $WDIR/$tfile && rc=1
730 do_facet mds${mdt_index} lctl set_param fail_loc=0
731 [[ $rc -ne 0 ]] && error "stat file should fail"
734 run_test 17o "stat file with incompat LMA feature"
737 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
738 ls $DIR || error "Failed to ls $DIR: $?"
740 run_test 18 "touch .../f ; ls ... =============================="
746 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
748 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
751 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
753 run_test 19b "ls -l .../f19 (should return error) =============="
756 [ $RUNAS_ID -eq $UID ] &&
757 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
758 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
760 run_test 19c "$RUNAS touch .../f19 (should return error) =="
763 cat $DIR/f19 && error || true
765 run_test 19d "cat .../f19 (should return error) =============="
777 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
779 run_test 20 "touch .../f ; ls -l ... ==========================="
782 test_mkdir -p $DIR/$tdir
783 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
784 ln -s dangle $DIR/$tdir/link
785 echo foo >> $DIR/$tdir/link
786 cat $DIR/$tdir/dangle
787 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
788 $CHECKSTAT -f -t file $DIR/$tdir/link ||
789 error "$tdir/link not linked to a file"
791 run_test 21 "write to dangling link ============================"
795 test_mkdir -p $DIR/$tdir
796 chown $RUNAS_ID:$RUNAS_GID $WDIR
797 (cd $WDIR || error "cd $WDIR failed";
798 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
800 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
801 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
802 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
804 run_test 22 "unpack tar archive as non-root user ==============="
808 test_mkdir -p $DIR/$tdir
809 local file=$DIR/$tdir/$tfile
811 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
812 openfile -f O_CREAT:O_EXCL $file &&
813 error "$file recreate succeeded" || true
815 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
817 test_23b() { # bug 18988
818 test_mkdir -p $DIR/$tdir
819 local file=$DIR/$tdir/$tfile
822 echo foo > $file || error "write filed"
823 echo bar >> $file || error "append filed"
824 $CHECKSTAT -s 8 $file || error "wrong size"
827 run_test 23b "O_APPEND check =========================="
831 echo '-- same directory rename'
832 test_mkdir $DIR/$tdir
833 touch $DIR/$tdir/$tfile.1
834 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
835 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
837 run_test 24a "rename file to non-existent target"
840 test_mkdir $DIR/$tdir
841 touch $DIR/$tdir/$tfile.{1,2}
842 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
843 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
844 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
846 run_test 24b "rename file to existing target"
849 test_mkdir $DIR/$tdir
850 test_mkdir $DIR/$tdir/d$testnum.1
851 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
852 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
853 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
855 run_test 24c "rename directory to non-existent target"
858 test_mkdir -c1 $DIR/$tdir
859 test_mkdir -c1 $DIR/$tdir/d$testnum.1
860 test_mkdir -c1 $DIR/$tdir/d$testnum.2
861 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
862 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
863 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
865 run_test 24d "rename directory to existing target"
868 echo '-- cross directory renames --'
872 mv $DIR/R5a/f $DIR/R5b/g
873 $CHECKSTAT -a $DIR/R5a/f || error
874 $CHECKSTAT -t file $DIR/R5b/g || error
876 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
881 touch $DIR/R6a/f $DIR/R6b/g
882 mv $DIR/R6a/f $DIR/R6b/g
883 $CHECKSTAT -a $DIR/R6a/f || error
884 $CHECKSTAT -t file $DIR/R6b/g || error
886 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
891 test_mkdir $DIR/R7a/d
892 mv $DIR/R7a/d $DIR/R7b/e
893 $CHECKSTAT -a $DIR/R7a/d || error
894 $CHECKSTAT -t dir $DIR/R7b/e || error
896 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
899 test_mkdir -c1 $DIR/R8a
900 test_mkdir -c1 $DIR/R8b
901 test_mkdir -c1 $DIR/R8a/d
902 test_mkdir -c1 $DIR/R8b/e
903 mrename $DIR/R8a/d $DIR/R8b/e
904 $CHECKSTAT -a $DIR/R8a/d || error
905 $CHECKSTAT -t dir $DIR/R8b/e || error
907 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
910 echo "-- rename error cases"
914 mrename $DIR/R9/f $DIR/R9/a
915 $CHECKSTAT -t file $DIR/R9/f || error
916 $CHECKSTAT -t dir $DIR/R9/a || error
917 $CHECKSTAT -a $DIR/R9/a/f || error
919 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
923 mrename $DIR/R10/f $DIR/R10/g
924 $CHECKSTAT -t dir $DIR/R10 || error
925 $CHECKSTAT -a $DIR/R10/f || error
926 $CHECKSTAT -a $DIR/R10/g || error
928 run_test 24j "source does not exist ============================"
932 test_mkdir $DIR/R11a/d
934 mv $DIR/R11a/f $DIR/R11a/d
935 $CHECKSTAT -a $DIR/R11a/f || error
936 $CHECKSTAT -t file $DIR/R11a/d/f || error
938 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
940 # bug 2429 - rename foo foo foo creates invalid file
943 $MULTIOP $f OcNs || error
945 run_test 24l "Renaming a file to itself ========================"
949 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
950 # on ext3 this does not remove either the source or target files
951 # though the "expected" operation would be to remove the source
952 $CHECKSTAT -t file ${f} || error "${f} missing"
953 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
955 run_test 24m "Renaming a file to a hard link to itself ========="
959 # this stats the old file after it was renamed, so it should fail
963 $CHECKSTAT ${f}.rename
966 run_test 24n "Statting the old file after renaming (Posix rename 2)"
969 check_kernel_version 37 || return 0
970 test_mkdir -p $DIR/d24o
971 rename_many -s random -v -n 10 $DIR/d24o
973 run_test 24o "rename of files during htree split ==============="
978 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
979 mrename $DIR/R12a $DIR/R12b
980 $CHECKSTAT -a $DIR/R12a || error
981 $CHECKSTAT -t dir $DIR/R12b || error
982 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
983 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
985 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
987 cleanup_multiop_pause() {
993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
996 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
997 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1000 trap cleanup_multiop_pause EXIT
1001 mrename $DIR/R13a $DIR/R13b
1002 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1003 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1004 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1005 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1006 cleanup_multiop_pause
1007 wait $MULTIPID || error "multiop close failed"
1009 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1011 test_24r() { #bug 3789
1012 test_mkdir $DIR/R14a
1013 test_mkdir $DIR/R14a/b
1014 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1015 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1016 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1018 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1021 test_mkdir $DIR/R15a
1022 test_mkdir $DIR/R15a/b
1023 test_mkdir $DIR/R15a/b/c
1024 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1025 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1026 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1028 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1030 test_mkdir $DIR/R16a
1031 test_mkdir $DIR/R16a/b
1032 test_mkdir $DIR/R16a/b/c
1033 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1034 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1035 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1037 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1039 test_24u() { # bug12192
1040 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1041 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1043 run_test 24u "create stripe file"
1049 simple_cleanup_common() {
1052 wait_delete_completed
1055 max_pages_per_rpc() {
1056 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1060 local NRFILES=100000
1061 local FREE_INODES=$(mdt_free_inodes 0)
1062 [[ $FREE_INODES -lt $NRFILES ]] &&
1063 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1067 trap simple_cleanup_common EXIT
1069 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1070 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1073 createmany -m $DIR/$tdir/$tfile $NRFILES
1075 cancel_lru_locks mdc
1076 lctl set_param mdc.*.stats clear
1078 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1080 # LU-5 large readdir
1081 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1082 # 8 bytes for name(filename is mostly 5 in this test) +
1083 # 8 bytes for luda_type
1084 # take into account of overhead in lu_dirpage header and end mark in
1085 # each page, plus one in RPC_NUM calculation.
1087 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1088 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1089 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1090 awk '/^mds_readpage/ {print $2}')
1091 [[ $mds_readpage -gt $RPC_NUM ]] &&
1092 error "large readdir doesn't take effect"
1094 simple_cleanup_common
1096 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1098 test_24w() { # bug21506
1100 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1101 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1102 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1103 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1104 [[ "$SZ1" -eq "$SZ2" ]] ||
1105 error "Error reading at the end of the file $tfile"
1107 run_test 24w "Reading a file larger than 4Gb"
1110 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1113 local remote_dir=$DIR/$tdir/remote_dir
1116 $LFS mkdir -i $MDTIDX $remote_dir ||
1117 error "create remote directory failed"
1119 mkdir -p $DIR/$tdir/src_dir
1120 touch $DIR/$tdir/src_file
1121 mkdir -p $remote_dir/tgt_dir
1122 touch $remote_dir/tgt_file
1124 mrename $remote_dir $DIR/ &&
1125 error "rename dir cross MDT works!"
1127 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1128 error "rename dir cross MDT works!"
1130 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1131 error "rename file cross MDT works!"
1133 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1134 error "ln file cross MDT should not work!"
1136 rm -rf $DIR/$tdir || error "Can not delete directories"
1138 run_test 24x "cross rename/link should be failed"
1141 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1144 local remote_dir=$DIR/$tdir/remote_dir
1147 $LFS mkdir -i $MDTIDX $remote_dir ||
1148 error "create remote directory failed"
1150 mkdir -p $remote_dir/src_dir
1151 touch $remote_dir/src_file
1152 mkdir -p $remote_dir/tgt_dir
1153 touch $remote_dir/tgt_file
1155 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1156 error "rename subdir in the same remote dir failed!"
1158 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1159 error "rename files in the same remote dir failed!"
1161 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1162 error "link files in the same remote dir failed!"
1164 rm -rf $DIR/$tdir || error "Can not delete directories"
1166 run_test 24y "rename/link on the same dir should succeed"
1169 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1172 local remote_src=$DIR/$tdir/remote_dir
1173 local remote_tgt=$DIR/$tdir/remote_tgt
1176 $LFS mkdir -i $MDTIDX $remote_src ||
1177 error "create remote directory failed"
1179 $LFS mkdir -i $MDTIDX $remote_tgt ||
1180 error "create remote directory failed"
1182 mrename $remote_src $remote_tgt &&
1183 error "rename remote dirs should not work!"
1185 # If target dir does not exists, it should succeed
1187 mrename $remote_src $remote_tgt ||
1188 error "rename remote dirs(tgt dir does not exists) failed!"
1190 rm -rf $DIR/$tdir || error "Can not delete directories"
1192 run_test 24z "rename one remote dir to another remote dir should fail"
1194 test_24A() { # LU-3182
1199 createmany -m $DIR/$tdir/$tfile $NFILES
1200 local t=$(ls $DIR/$tdir | wc -l)
1201 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1202 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1203 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1204 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1207 rm -rf $DIR/$tdir || error "Can not delete directories"
1209 run_test 24A "readdir() returns correct number of entries."
1211 test_24B() { # LU-4805
1212 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1216 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1217 error "create striped dir failed"
1219 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1220 [ $count -eq 2 ] || error "Expected 2, got $count"
1222 touch $DIR/$tdir/striped_dir/a
1224 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1225 [ $count -eq 3 ] || error "Expected 3, got $count"
1227 touch $DIR/$tdir/striped_dir/.f
1229 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1230 [ $count -eq 4 ] || error "Expected 4, got $count"
1232 rm -rf $DIR/$tdir || error "Can not delete directories"
1234 run_test 24B "readdir for striped dir return correct number of entries"
1237 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1243 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1244 error "create striped dir failed"
1246 cd $DIR/$tdir/d0/striped_dir
1248 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1249 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1250 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1252 [ "$d0_ino" = "$parent_ino" ] ||
1253 error ".. wrong, expect $d0_ino, get $parent_ino"
1255 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1256 error "mv striped dir failed"
1258 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1260 [ "$d1_ino" = "$parent_ino" ] ||
1261 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1263 run_test 24C "check .. in striped dir"
1266 echo '== symlink sanity ============================================='
1270 touch $DIR/s25/foo || error
1272 run_test 25a "create file in symlinked directory ==============="
1275 [ ! -d $DIR/d25 ] && test_25a
1276 $CHECKSTAT -t file $DIR/s25/foo || error
1278 run_test 25b "lookup file in symlinked directory ==============="
1282 test_mkdir $DIR/d26/d26-2
1283 ln -s d26/d26-2 $DIR/s26
1284 touch $DIR/s26/foo || error
1286 run_test 26a "multiple component symlink ======================="
1289 test_mkdir -p $DIR/d26b/d26-2
1290 ln -s d26b/d26-2/foo $DIR/s26-2
1291 touch $DIR/s26-2 || error
1293 run_test 26b "multiple component symlink at end of lookup ======"
1296 test_mkdir $DIR/d26.2
1297 touch $DIR/d26.2/foo
1298 ln -s d26.2 $DIR/s26.2-1
1299 ln -s s26.2-1 $DIR/s26.2-2
1300 ln -s s26.2-2 $DIR/s26.2-3
1301 chmod 0666 $DIR/s26.2-3/foo
1303 run_test 26c "chain of symlinks ================================"
1305 # recursive symlinks (bug 439)
1307 ln -s d26-3/foo $DIR/d26-3
1309 run_test 26d "create multiple component recursive symlink ======"
1312 [ ! -h $DIR/d26-3 ] && test_26d
1315 run_test 26e "unlink multiple component recursive symlink ======"
1317 # recursive symlinks (bug 7022)
1319 test_mkdir -p $DIR/$tdir
1320 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1321 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1322 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1323 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1324 cd $tfile || error "cd $tfile failed"
1325 ln -s .. dotdot || error "ln dotdot failed"
1326 ln -s dotdot/lndir lndir || error "ln lndir failed"
1327 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1328 output=`ls $tfile/$tfile/lndir/bar1`
1329 [ "$output" = bar1 ] && error "unexpected output"
1330 rm -r $tfile || error "rm $tfile failed"
1331 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1333 run_test 26f "rm -r of a directory which has recursive symlink ="
1336 echo '== stripe sanity =============================================='
1337 test_mkdir -p $DIR/d27 || error "mkdir failed"
1339 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1340 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1341 log "== test_27a: write to one stripe file ========================="
1342 cp /etc/hosts $DIR/d27/f0 || error
1344 run_test 27a "one stripe file =================================="
1347 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1348 test_mkdir -p $DIR/d27
1349 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1350 $GETSTRIPE -c $DIR/d27/f01
1351 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1352 error "two-stripe file doesn't have two stripes"
1354 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1356 run_test 27b "create and write to two stripe file"
1359 test_mkdir -p $DIR/d27
1360 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1361 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1362 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1364 run_test 27d "create file with default settings ================"
1367 test_mkdir -p $DIR/d27
1368 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1369 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1370 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1372 run_test 27e "setstripe existing file (should return error) ======"
1375 test_mkdir -p $DIR/d27
1376 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1377 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1378 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1380 run_test 27f "setstripe with bad stripe size (should return error)"
1383 test_mkdir -p $DIR/d27
1384 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1385 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1386 error "$DIR/d27/fnone has object"
1388 run_test 27g "$GETSTRIPE with no objects"
1391 touch $DIR/d27/fsome || error "touch failed"
1392 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1394 run_test 27i "$GETSTRIPE with some objects"
1397 test_mkdir -p $DIR/d27
1398 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1400 run_test 27j "setstripe with bad stripe offset (should return error)"
1402 test_27k() { # bug 2844
1403 test_mkdir -p $DIR/d27
1405 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1406 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1407 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1408 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1409 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1410 dd if=/dev/zero of=$FILE bs=4k count=1
1411 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1412 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1414 run_test 27k "limit i_blksize for broken user apps ============="
1417 test_mkdir -p $DIR/d27
1418 mcreate $DIR/f27l || error "creating file"
1419 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1420 error "setstripe should have failed" || true
1422 run_test 27l "check setstripe permissions (should return error)"
1425 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1427 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1428 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1431 trap simple_cleanup_common EXIT
1432 test_mkdir -p $DIR/$tdir
1433 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1434 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1435 error "dd should fill OST0"
1437 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1439 [ $i -gt 256 ] && break
1442 touch $DIR/$tdir/f27m_$i
1443 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1444 error "OST0 was full but new created file still use it"
1446 touch $DIR/$tdir/f27m_$i
1447 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1448 error "OST0 was full but new created file still use it"
1449 simple_cleanup_common
1451 run_test 27m "create file while OST0 was full =================="
1454 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1458 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1459 # if the OST isn't full anymore.
1461 local OSTIDX=${1:-""}
1463 local list=$(comma_list $(osts_nodes))
1464 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1466 do_nodes $list lctl set_param fail_loc=0
1467 sync # initiate all OST_DESTROYs from MDS to OST
1471 exhaust_precreations() {
1474 local FAILIDX=${3:-$OSTIDX}
1476 test_mkdir -p $DIR/$tdir
1477 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1478 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1480 local OST=$(ostname_from_index $OSTIDX)
1481 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1482 sed -e 's/_UUID$//;s/^.*-//')
1485 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1486 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1487 osc.$mdtosc_proc1.prealloc_last_id)
1488 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1489 osc.$mdtosc_proc1.prealloc_next_id)
1491 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1492 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1494 test_mkdir -p $DIR/$tdir/${OST}
1495 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1496 #define OBD_FAIL_OST_ENOSPC 0x215
1497 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1498 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1499 echo "Creating to objid $last_id on ost $OST..."
1500 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1501 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1502 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1506 exhaust_all_precreations() {
1508 for (( i=0; i < OSTCOUNT; i++ )) ; do
1509 exhaust_precreations $i $1 -1
1514 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1517 remote_ost_nodsh && skip "remote OST with nodsh" && return
1520 rm -f $DIR/$tdir/$tfile
1521 exhaust_precreations 0 0x80000215
1522 $SETSTRIPE -c -1 $DIR/$tdir
1523 touch $DIR/$tdir/$tfile || error
1524 $GETSTRIPE $DIR/$tdir/$tfile
1527 run_test 27n "create file with some full OSTs =================="
1530 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 remote_ost_nodsh && skip "remote OST with nodsh" && return
1536 rm -f $DIR/$tdir/$tfile
1537 exhaust_all_precreations 0x215
1539 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1544 run_test 27o "create file with all full OSTs (should error) ===="
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 test_mkdir -p $DIR/$tdir
1556 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1557 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1558 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1560 exhaust_precreations 0 0x80000215
1561 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1562 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1563 $GETSTRIPE $DIR/$tdir/$tfile
1567 run_test 27p "append to a truncated file with some full OSTs ==="
1570 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 remote_ost_nodsh && skip "remote OST with nodsh" && return
1576 rm -f $DIR/$tdir/$tfile
1578 test_mkdir -p $DIR/$tdir
1579 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1580 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1581 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1583 exhaust_all_precreations 0x215
1585 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1586 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1590 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1593 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1595 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1596 remote_ost_nodsh && skip "remote OST with nodsh" && return
1599 rm -f $DIR/$tdir/$tfile
1600 exhaust_precreations 0 0x80000215
1602 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1606 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1608 test_27s() { # bug 10725
1609 test_mkdir -p $DIR/$tdir
1610 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1611 local stripe_count=0
1612 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1613 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1614 error "stripe width >= 2^32 succeeded" || true
1617 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1619 test_27t() { # bug 10864
1624 $WLFS getstripe $tfile
1627 run_test 27t "check that utils parse path correctly"
1629 test_27u() { # bug 4900
1630 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1633 local list=$(comma_list $(mdts_nodes))
1635 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1636 do_nodes $list $LCTL set_param fail_loc=0x139
1637 test_mkdir -p $DIR/$tdir
1639 createmany -o $DIR/$tdir/t- 1000
1640 do_nodes $list $LCTL set_param fail_loc=0
1642 TLOG=$DIR/$tfile.getstripe
1643 $GETSTRIPE $DIR/$tdir > $TLOG
1644 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1645 unlinkmany $DIR/$tdir/t- 1000
1646 [[ $OBJS -gt 0 ]] &&
1647 error "$OBJS objects created on OST-0. See $TLOG" || pass
1649 run_test 27u "skip object creation on OSC w/o objects =========="
1651 test_27v() { # bug 4900
1652 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1654 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return
1657 exhaust_all_precreations 0x215
1660 test_mkdir -p $DIR/$tdir
1661 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1663 touch $DIR/$tdir/$tfile
1664 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1666 for (( i=1; i < OSTCOUNT; i++ )); do
1667 do_facet ost$i lctl set_param fail_loc=0x705
1669 local START=`date +%s`
1670 createmany -o $DIR/$tdir/$tfile 32
1672 local FINISH=`date +%s`
1673 local TIMEOUT=`lctl get_param -n timeout`
1674 local PROCESS=$((FINISH - START))
1675 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1676 error "$FINISH - $START >= $TIMEOUT / 2"
1677 sleep $((TIMEOUT / 2 - PROCESS))
1680 run_test 27v "skip object creation on slow OST ================="
1682 test_27w() { # bug 10997
1683 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1684 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1685 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1686 error "stripe size $size != 65536" || true
1687 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1688 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1690 run_test 27w "check $SETSTRIPE -S option"
1693 [[ $OSTCOUNT -lt 2 ]] &&
1694 skip_env "skipping multiple stripe count/offset test" && return
1696 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1697 for i in $(seq 1 $OSTCOUNT); do
1699 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1700 error "setstripe -c $i -i $offset failed"
1701 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1702 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1703 [ $count -ne $i ] && error "stripe count $count != $i" || true
1704 [ $index -ne $offset ] &&
1705 error "stripe offset $index != $offset" || true
1708 run_test 27wa "check $SETSTRIPE -c -i options"
1711 remote_ost_nodsh && skip "remote OST with nodsh" && return
1712 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1714 OFFSET=$(($OSTCOUNT - 1))
1716 local OST=$(ostname_from_index $OSTIDX)
1718 test_mkdir -p $DIR/$tdir
1719 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1720 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1722 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1723 for i in `seq 0 $OFFSET`; do
1724 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1725 error "OST0 was degraded but new created file still use it"
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1729 run_test 27x "create files while OST0 is degraded"
1732 [[ $OSTCOUNT -lt 2 ]] &&
1733 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1735 remote_ost_nodsh && skip "remote OST with nodsh" && return
1736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1738 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1739 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1740 osc.$mdtosc.prealloc_last_id)
1741 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1742 osc.$mdtosc.prealloc_next_id)
1743 local fcount=$((last_id - next_id))
1744 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1745 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1747 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1748 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1749 local OST_DEACTIVE_IDX=-1
1754 for OSC in $MDS_OSCS; do
1755 OST=$(osc_to_ost $OSC)
1756 OSTIDX=$(index_from_ostuuid $OST)
1757 if [ $OST_DEACTIVE_IDX == -1 ]; then
1758 OST_DEACTIVE_IDX=$OSTIDX
1760 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1761 echo $OSC "is Deactivated:"
1762 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1766 OSTIDX=$(index_from_ostuuid $OST)
1768 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1770 for OSC in $MDS_OSCS; do
1771 OST=$(osc_to_ost $OSC)
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1774 echo $OST "is degraded:"
1775 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1776 obdfilter.$OST.degraded=1
1781 createmany -o $DIR/$tdir/$tfile $fcount
1783 for OSC in $MDS_OSCS; do
1784 OST=$(osc_to_ost $OSC)
1785 OSTIDX=$(index_from_ostuuid $OST)
1786 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1787 echo $OST "is recovered from degraded:"
1788 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1789 obdfilter.$OST.degraded=0
1791 do_facet $SINGLEMDS lctl --device %$OSC activate
1795 # all osp devices get activated, hence -1 stripe count restored
1798 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1799 # devices get activated.
1801 $SETSTRIPE -c -1 $DIR/$tfile
1802 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1804 [ $stripecnt -ne $OSTCOUNT ] &&
1805 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1808 run_test 27y "create files while OST0 is degraded and the rest inactive"
1814 lmm_count=$($GETSTRIPE -c $1)
1815 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1816 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1818 local old_ifs="$IFS"
1820 fid=($($LFS path2fid $1))
1823 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1824 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1826 # compare lmm_seq and lu_fid->f_seq
1827 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1828 # compare lmm_object_id and lu_fid->oid
1829 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1831 # check the trusted.fid attribute of the OST objects of the file
1832 local have_obdidx=false
1834 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1835 # skip lines up to and including "obdidx"
1836 [ -z "$obdidx" ] && break
1837 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1838 $have_obdidx || continue
1840 local ost=$((obdidx + 1))
1841 local dev=$(ostdevname $ost)
1844 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1846 seq=$(echo $seq | sed -e "s/^0x//g")
1847 if [ $seq == 0 ]; then
1848 oid_hex=$(echo $oid)
1850 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1852 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1856 # Don't unmount/remount the OSTs if we don't need to do that.
1857 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1858 # update too, until that use mount/ll_decode_filter_fid/mount.
1859 # Re-enable when debugfs will understand new filter_fid.
1861 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1862 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1863 $dev 2>/dev/null" | grep "parent=")
1866 mount_fstype ost$ost
1867 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1868 $(facet_mntpt ost$ost)/$obj_file)
1869 unmount_fstype ost$ost
1870 start ost$ost $dev $OST_MOUNT_OPTS
1873 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1875 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1877 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1878 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1879 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1880 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1881 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1883 if echo $ff_parent | grep -q 'stripe='; then
1884 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1887 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1888 # into f_ver in this case. See the comment on
1891 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1895 # compare lmm_seq and filter_fid->ff_parent.f_seq
1896 [ $ff_pseq = $lmm_seq ] ||
1897 error "FF parent SEQ $ff_pseq != $lmm_seq"
1898 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1899 [ $ff_poid = $lmm_oid ] ||
1900 error "FF parent OID $ff_poid != $lmm_oid"
1901 (($ff_pstripe == $stripe_nr)) ||
1902 error "FF stripe $ff_pstripe != $stripe_nr"
1904 stripe_nr=$((stripe_nr + 1))
1909 remote_ost_nodsh && skip "remote OST with nodsh" && return
1910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1911 test_mkdir -p $DIR/$tdir
1913 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1914 { error "setstripe -c -1 failed"; return 1; }
1915 # We need to send a write to every object to get parent FID info set.
1916 # This _should_ also work for setattr, but does not currently.
1917 # touch $DIR/$tdir/$tfile-1 ||
1918 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1919 { error "dd $tfile-1 failed"; return 2; }
1920 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1921 { error "setstripe -c -1 failed"; return 3; }
1922 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1923 { error "dd $tfile-2 failed"; return 4; }
1925 # make sure write RPCs have been sent to OSTs
1928 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1929 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1931 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1933 test_27A() { # b=19102
1934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1935 local restore_size=$($GETSTRIPE -S $MOUNT)
1936 local restore_count=$($GETSTRIPE -c $MOUNT)
1937 local restore_offset=$($GETSTRIPE -i $MOUNT)
1938 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1939 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1940 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1941 local default_size=$($GETSTRIPE -S $MOUNT)
1942 local default_offset=$($GETSTRIPE -i $MOUNT)
1943 local dsize=$((1024 * 1024))
1944 [ $default_size -eq $dsize ] ||
1945 error "stripe size $default_size != $dsize"
1946 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1947 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1949 run_test 27A "check filesystem-wide default LOV EA values"
1951 test_27B() { # LU-2523
1952 test_mkdir -p $DIR/$tdir
1953 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1969 # Allow multiop to fail in imitation of NFS's busted semantics.
1972 run_test 27B "call setstripe on open unlinked file/rename victim"
1974 test_27C() { #LU-2871
1975 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1983 test_mkdir -p $DIR/$tdir
1985 for i in $(seq 0 $((OSTCOUNT - 1))); do
1986 # set stripe across all OSTs starting from OST$i
1987 $SETSTRIPE -i $i -c -1 $tfile$i
1988 # get striping information
1989 ost_idx=($($GETSTRIPE $tfile$i |
1990 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1994 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1995 error "${#ost_idx[@]} != $OSTCOUNT"
1997 for index in $(seq 0 $((OSTCOUNT - 1))); do
1999 for j in $(echo ${ost_idx[@]}); do
2000 if [ $index -eq $j ]; then
2006 error "Can not find $index in ${ost_idx[@]}"
2010 run_test 27C "check full striping across all OSTs"
2012 # createtest also checks that device nodes are created and
2013 # then visible correctly (#2091)
2014 test_28() { # bug 2091
2016 $CREATETEST $DIR/d28/ct || error
2018 run_test 28 "create/mknod/mkdir with bad file types ============"
2021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2022 cancel_lru_locks mdc
2028 declare -i LOCKCOUNTORIG=0
2029 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2030 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2032 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2034 declare -i LOCKUNUSEDCOUNTORIG=0
2035 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2036 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2043 declare -i LOCKCOUNTCURRENT=0
2044 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2045 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2048 declare -i LOCKUNUSEDCOUNTCURRENT=0
2049 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2050 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2053 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2054 $LCTL set_param -n ldlm.dump_namespaces ""
2055 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2056 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2057 log "dumped log to $TMP/test_29.dk (bug 5793)"
2060 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2061 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2062 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2063 log "dumped log to $TMP/test_29.dk (bug 5793)"
2067 run_test 29 "IT_GETATTR regression ============================"
2069 test_30a() { # was test_30
2070 cp $(which ls) $DIR || cp /bin/ls $DIR
2074 run_test 30a "execute binary from Lustre (execve) =============="
2077 cp `which ls` $DIR || cp /bin/ls $DIR
2079 $RUNAS $DIR/ls / || error
2082 run_test 30b "execute binary from Lustre as non-root ==========="
2084 test_30c() { # b=22376
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2086 cp `which ls` $DIR || cp /bin/ls $DIR
2088 cancel_lru_locks mdc
2089 cancel_lru_locks osc
2090 $RUNAS $DIR/ls / || error
2093 run_test 30c "execute binary from Lustre without read perms ===="
2096 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2097 $CHECKSTAT -a $DIR/f31 || error
2099 run_test 31a "open-unlink file =================================="
2102 touch $DIR/f31 || error
2103 ln $DIR/f31 $DIR/f31b || error
2104 $MULTIOP $DIR/f31b Ouc || error
2105 $CHECKSTAT -t file $DIR/f31 || error
2107 run_test 31b "unlink file with multiple links while open ======="
2110 touch $DIR/f31 || error
2111 ln $DIR/f31 $DIR/f31c || error
2112 multiop_bg_pause $DIR/f31 O_uc || return 1
2114 $MULTIOP $DIR/f31c Ouc
2115 kill -USR1 $MULTIPID
2118 run_test 31c "open-unlink file with multiple links ============="
2121 opendirunlink $DIR/d31d $DIR/d31d || error
2122 $CHECKSTAT -a $DIR/d31d || error
2124 run_test 31d "remove of open directory ========================="
2126 test_31e() { # bug 2904
2127 check_kernel_version 34 || return 0
2128 openfilleddirunlink $DIR/d31e || error
2130 run_test 31e "remove of open non-empty directory ==============="
2132 test_31f() { # bug 4554
2133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2135 test_mkdir $DIR/d31f
2136 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2137 cp /etc/hosts $DIR/d31f
2139 $GETSTRIPE $DIR/d31f/hosts
2140 multiop_bg_pause $DIR/d31f D_c || return 1
2143 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2144 test_mkdir $DIR/d31f
2145 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2146 cp /etc/hosts $DIR/d31f
2148 $GETSTRIPE $DIR/d31f/hosts
2149 multiop_bg_pause $DIR/d31f D_c || return 1
2152 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2153 wait $MULTIPID || error "first opendir $MULTIPID failed"
2157 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2158 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2161 run_test 31f "remove of open directory with open-unlink file ==="
2164 echo "-- cross directory link --"
2165 test_mkdir -c1 $DIR/${tdir}ga
2166 test_mkdir -c1 $DIR/${tdir}gb
2167 touch $DIR/${tdir}ga/f
2168 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2169 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2170 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2171 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2172 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2174 run_test 31g "cross directory link==============="
2177 echo "-- cross directory link --"
2178 test_mkdir -c1 $DIR/${tdir}
2179 test_mkdir -c1 $DIR/${tdir}/dir
2180 touch $DIR/${tdir}/f
2181 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2182 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2183 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2184 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2185 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2187 run_test 31h "cross directory link under child==============="
2190 echo "-- cross directory link --"
2191 test_mkdir -c1 $DIR/$tdir
2192 test_mkdir -c1 $DIR/$tdir/dir
2193 touch $DIR/$tdir/dir/f
2194 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2195 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2196 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2197 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2198 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2200 run_test 31i "cross directory link under parent==============="
2203 test_mkdir -c1 -p $DIR/$tdir
2204 test_mkdir -c1 -p $DIR/$tdir/dir1
2205 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2206 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2207 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2208 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2211 run_test 31j "link for directory==============="
2214 test_mkdir -c1 -p $DIR/$tdir
2216 touch $DIR/$tdir/exist
2217 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2218 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2219 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2220 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2221 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2222 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2223 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2226 run_test 31k "link to file: the same, non-existing, dir==============="
2232 touch $DIR/d31m2/exist
2233 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2234 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2235 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2236 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2237 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2238 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2241 run_test 31m "link to file: the same, non-existing, dir==============="
2244 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2245 nlink=$(stat --format=%h $DIR/$tfile)
2246 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2248 local cmd="exec $fd<$DIR/$tfile"
2251 trap "eval $cmd" EXIT
2252 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2253 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2254 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2255 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2256 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2259 run_test 31n "check link count of unlinked file"
2262 local TEMPNAME=$(mktemp $1_XXXXXX)
2263 mlink $TEMPNAME $1 2> /dev/null &&
2264 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2268 test_31o() { # LU-2901
2270 for LOOP in $(seq 100); do
2271 rm -f $DIR/$tdir/$tfile*
2272 for THREAD in $(seq 8); do
2273 link_one $DIR/$tdir/$tfile.$LOOP &
2276 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2277 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2278 error "$LINKS duplicate links to $tfile.$LOOP" &&
2282 run_test 31o "duplicate hard links with same filename"
2285 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2288 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2289 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2291 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2292 error "open unlink test1 failed"
2293 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2294 error "open unlink test2 failed"
2296 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2297 error "test1 still exists"
2298 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2299 error "test2 still exists"
2301 run_test 31p "remove of open striped directory"
2303 cleanup_test32_mount() {
2305 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2310 echo "== more mountpoints and symlinks ================="
2311 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2312 trap cleanup_test32_mount EXIT
2313 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2314 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2315 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2316 cleanup_test32_mount
2318 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2322 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2323 trap cleanup_test32_mount EXIT
2324 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2325 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2326 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2327 cleanup_test32_mount
2329 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2333 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2334 trap cleanup_test32_mount EXIT
2335 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2336 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2337 test_mkdir -p $DIR/$tdir/d2/test_dir
2338 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2339 cleanup_test32_mount
2341 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2345 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2346 trap cleanup_test32_mount EXIT
2347 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2348 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2349 test_mkdir -p $DIR/$tdir/d2/test_dir
2350 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2351 cleanup_test32_mount
2353 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2356 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2357 test_mkdir -p $DIR/d32e/tmp
2358 TMP_DIR=$DIR/d32e/tmp
2359 ln -s $DIR/d32e $TMP_DIR/symlink11
2360 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2361 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2362 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2364 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2367 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2368 test_mkdir -p $DIR/d32f/tmp
2369 TMP_DIR=$DIR/d32f/tmp
2370 ln -s $DIR/d32f $TMP_DIR/symlink11
2371 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2372 ls $DIR/d32f/tmp/symlink11 || error
2373 ls $DIR/d32f/symlink01 || error
2375 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2378 TMP_DIR=$DIR/$tdir/tmp
2379 test_mkdir -p $DIR/$tdir/tmp
2380 test_mkdir $DIR/${tdir}2
2381 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2382 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2383 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2384 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2385 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2386 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2388 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2391 rm -fr $DIR/$tdir $DIR/${tdir}2
2392 TMP_DIR=$DIR/$tdir/tmp
2393 test_mkdir -p $DIR/$tdir/tmp
2394 test_mkdir $DIR/${tdir}2
2395 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2396 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2397 ls $TMP_DIR/symlink12 || error
2398 ls $DIR/$tdir/symlink02 || error
2400 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2404 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2405 trap cleanup_test32_mount EXIT
2406 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2407 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2408 touch $DIR/$tdir/test_file
2409 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2410 cleanup_test32_mount
2412 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2416 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2417 trap cleanup_test32_mount EXIT
2418 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2419 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2420 touch $DIR/$tdir/test_file
2421 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2422 cleanup_test32_mount
2424 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2429 trap cleanup_test32_mount EXIT
2430 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2431 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2432 test_mkdir -p $DIR/$tdir/d2
2433 touch $DIR/$tdir/d2/test_file || error
2434 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2435 cleanup_test32_mount
2437 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2440 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2442 trap cleanup_test32_mount EXIT
2443 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2444 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2445 test_mkdir -p $DIR/$tdir/d2
2446 touch $DIR/$tdir/d2/test_file
2447 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2448 cleanup_test32_mount
2450 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2454 test_mkdir -p $DIR/d32m/tmp
2455 TMP_DIR=$DIR/d32m/tmp
2456 ln -s $DIR $TMP_DIR/symlink11
2457 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2458 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2459 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2461 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2465 test_mkdir -p $DIR/d32n/tmp
2466 TMP_DIR=$DIR/d32n/tmp
2467 ln -s $DIR $TMP_DIR/symlink11
2468 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2469 ls -l $DIR/d32n/tmp/symlink11 || error
2470 ls -l $DIR/d32n/symlink01 || error
2472 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2476 test_mkdir -p $DIR/d32o/tmp
2477 TMP_DIR=$DIR/d32o/tmp
2478 ln -s $DIR/$tfile $TMP_DIR/symlink12
2479 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2480 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2481 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2482 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2483 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2485 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2495 test_mkdir -p $DIR/d32p/tmp
2497 TMP_DIR=$DIR/d32p/tmp
2499 ln -s $DIR/$tfile $TMP_DIR/symlink12
2501 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2503 cat $DIR/d32p/tmp/symlink12 || error
2505 cat $DIR/d32p/symlink02 || error
2508 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2510 cleanup_testdir_mount() {
2512 $UMOUNT -d $DIR/$tdir
2516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2517 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2518 trap cleanup_testdir_mount EXIT
2519 test_mkdir -p $DIR/$tdir
2520 touch $DIR/$tdir/under_the_mount
2521 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2522 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2523 cleanup_testdir_mount
2525 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2529 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2530 trap cleanup_testdir_mount EXIT
2531 test_mkdir -p $DIR/$tdir
2532 touch $DIR/$tdir/under_the_mount
2533 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2534 ls $DIR/$tdir | grep -q under_the_mount && error || true
2535 cleanup_testdir_mount
2537 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2542 chmod 444 $DIR/$tfile
2543 chown $RUNAS_ID $DIR/$tfile
2545 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2548 run_test 33aa "write file with mode 444 (should return error) ===="
2552 test_mkdir -p $DIR/d33
2553 chown $RUNAS_ID $DIR/d33
2554 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2555 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2556 error "open RDWR" || true
2558 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2562 test_mkdir -p $DIR/d33
2563 chown $RUNAS_ID $DIR/d33
2564 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2566 run_test 33b "test open file with malformed flags (No panic and return error)"
2569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2575 remote_ost_nodsh && skip "remote OST with nodsh" && return
2578 test_mkdir -p $DIR/d33
2579 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2582 for ostnum in $(seq $OSTCOUNT); do
2583 # test-framework's OST numbering is one-based, while Lustre's
2585 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2586 # Parsing llobdstat's output sucks; we could grep the /proc
2587 # path, but that's likely to not be as portable as using the
2588 # llobdstat utility. So we parse lctl output instead.
2589 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2590 obdfilter/$ostname/stats |
2591 awk '/^write_bytes/ {print $7}' )
2592 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2593 if (( ${write_bytes:-0} > 0 ))
2600 $all_zeros || return 0
2603 echo foo > $DIR/d33/bar
2607 # Total up write_bytes after writing. We'd better find non-zeros.
2608 for ostnum in $(seq $OSTCOUNT); do
2609 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2610 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2611 obdfilter/$ostname/stats |
2612 awk '/^write_bytes/ {print $7}' )
2613 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2614 if (( ${write_bytes:-0} > 0 ))
2623 for ostnum in $(seq $OSTCOUNT); do
2624 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2625 echo "Check that write_bytes is present in obdfilter/*/stats:"
2626 do_facet ost$ostnum lctl get_param -n \
2627 obdfilter/$ostname/stats
2629 error "OST not keeping write_bytes stats (b22312)"
2632 run_test 33c "test llobdstat and write_bytes"
2635 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2638 local remote_dir=$DIR/$tdir/remote_dir
2641 $LFS mkdir -i $MDTIDX $remote_dir ||
2642 error "create remote directory failed"
2644 touch $remote_dir/$tfile
2645 chmod 444 $remote_dir/$tfile
2646 chown $RUNAS_ID $remote_dir/$tfile
2648 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2650 chown $RUNAS_ID $remote_dir
2651 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2652 error "create" || true
2653 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2654 error "open RDWR" || true
2655 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2656 error "create" || true
2658 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2661 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2665 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2666 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2667 mkdir $DIR/$tdir/local_dir
2669 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2670 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2671 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2673 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2674 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2676 rmdir $DIR/$tdir/* || error "rmdir failed"
2679 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2680 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2681 mkdir $DIR/$tdir/local_dir
2683 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2684 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2685 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2687 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2688 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2690 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2693 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2694 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2695 mkdir $DIR/$tdir/local_dir
2697 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2698 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2699 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2701 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2702 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2704 run_test 33e "mkdir and striped directory should have same mode"
2706 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2709 $MCREATE $DIR/f34 || error
2710 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2711 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2712 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2713 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2715 run_test 34a "truncate file that has not been opened ==========="
2718 [ ! -f $DIR/f34 ] && test_34a
2719 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2720 $OPENFILE -f O_RDONLY $DIR/f34
2721 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2722 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2724 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2727 [ ! -f $DIR/f34 ] && test_34a
2728 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2729 $OPENFILE -f O_RDWR $DIR/f34
2730 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2731 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2733 run_test 34c "O_RDWR opening file-with-size works =============="
2736 [ ! -f $DIR/f34 ] && test_34a
2737 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2738 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2741 run_test 34d "write to sparse file ============================="
2745 $MCREATE $DIR/f34e || error
2746 $TRUNCATE $DIR/f34e 1000 || error
2747 $CHECKSTAT -s 1000 $DIR/f34e || error
2748 $OPENFILE -f O_RDWR $DIR/f34e
2749 $CHECKSTAT -s 1000 $DIR/f34e || error
2751 run_test 34e "create objects, some with size and some without =="
2753 test_34f() { # bug 6242, 6243
2754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2757 $MCREATE $DIR/f34f || error
2758 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2759 dd if=$DIR/f34f of=$TMP/f34f
2760 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2761 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2762 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2763 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2764 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2766 run_test 34f "read from a file with no objects until EOF ======="
2769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2770 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2771 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2772 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2773 cancel_lru_locks osc
2774 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2775 error "wrong size after lock cancel"
2777 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2778 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2779 error "expanding truncate failed"
2780 cancel_lru_locks osc
2781 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2782 error "wrong expanded size after lock cancel"
2784 run_test 34g "truncate long file ==============================="
2787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2791 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2792 sync # Flush the cache so that multiop below does not block on cache
2793 # flush when getting the group lock
2794 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2797 # Since just timed wait is not good enough, let's do a sync write
2798 # that way we are sure enough time for a roundtrip + processing
2799 # passed + 2 seconds of extra margin.
2800 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2804 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2805 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2809 local nsz=`stat -c %s $DIR/$tfile`
2810 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2812 run_test 34h "ftruncate file under grouplock should not block"
2815 cp /bin/sh $DIR/f35a
2817 chown $RUNAS_ID $DIR/f35a
2818 $RUNAS $DIR/f35a && error || true
2821 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2825 utime $DIR/f36 || error
2827 run_test 36a "MDS utime check (mknod, utime) ==================="
2831 utime $DIR/f36 || error
2833 run_test 36b "OST utime check (open, utime) ===================="
2838 chown $RUNAS_ID $DIR/d36
2839 $RUNAS utime $DIR/d36/f36 || error
2841 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2844 [ ! -d $DIR/d36 ] && test_36c
2845 echo "" > $DIR/d36/f36
2846 $RUNAS utime $DIR/d36/f36 || error
2848 run_test 36d "non-root OST utime check (open, utime) ==========="
2851 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2852 test_mkdir -p $DIR/$tdir
2853 touch $DIR/$tdir/$tfile
2854 $RUNAS utime $DIR/$tdir/$tfile && \
2855 error "utime worked, expected failure" || true
2857 run_test 36e "utime on non-owned file (should return error) ===="
2861 local LANG_SAVE=$LANG
2862 local LC_LANG_SAVE=$LC_LANG
2863 export LANG=C LC_LANG=C # for date language
2865 DATESTR="Dec 20 2000"
2866 test_mkdir -p $DIR/$tdir
2867 lctl set_param fail_loc=$fl
2869 cp /etc/hosts $DIR/$tdir/$tfile
2870 sync & # write RPC generated with "current" inode timestamp, but delayed
2872 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2873 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2874 cancel_lru_locks osc
2875 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2877 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2878 echo "BEFORE: $LS_BEFORE" && \
2879 echo "AFTER : $LS_AFTER" && \
2880 echo "WANT : $DATESTR" && \
2881 error "$DIR/$tdir/$tfile timestamps changed" || true
2883 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2888 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2889 subr_36fh "0x80000214"
2891 run_test 36f "utime on file racing with OST BRW write =========="
2894 remote_ost_nodsh && skip "remote OST with nodsh" && return
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2900 test_mkdir -p $DIR/$tdir
2901 fmd_max_age=$(do_facet ost1 \
2902 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2905 fmd_before=$(do_facet ost1 \
2906 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2907 touch $DIR/$tdir/$tfile
2908 sleep $((fmd_max_age + 12))
2909 fmd_after=$(do_facet ost1 \
2910 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2912 echo "fmd_before: $fmd_before"
2913 echo "fmd_after: $fmd_after"
2914 [[ $fmd_after -gt $fmd_before ]] &&
2915 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2916 error "fmd didn't expire after ping" || true
2918 run_test 36g "filter mod data cache expiry ====================="
2921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2922 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2923 subr_36fh "0x80000227"
2925 run_test 36h "utime on file racing with OST BRW write =========="
2928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2931 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2933 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2934 local new_mtime=$((mtime + 200))
2936 #change Modify time of striped dir
2937 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2938 error "change mtime failed"
2940 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2942 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2944 run_test 36i "change mtime on striped directory"
2946 # test_37 - duplicate with tests 32q 32r
2949 local file=$DIR/$tfile
2951 openfile -f O_DIRECTORY $file
2954 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2955 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2957 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2961 touch $DIR/${tfile}2
2962 # ls -l $DIR/$tfile $DIR/${tfile}2
2963 # ls -lu $DIR/$tfile $DIR/${tfile}2
2964 # ls -lc $DIR/$tfile $DIR/${tfile}2
2966 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2967 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2969 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2971 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2973 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2974 error "O_TRUNC didn't change timestamps"
2977 run_test 39 "mtime changed on create ==========================="
2980 test_mkdir -p -c1 $DIR/$tdir
2981 cp -p /etc/passwd $DIR/$tdir/fopen
2982 cp -p /etc/passwd $DIR/$tdir/flink
2983 cp -p /etc/passwd $DIR/$tdir/funlink
2984 cp -p /etc/passwd $DIR/$tdir/frename
2985 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2988 echo "aaaaaa" >> $DIR/$tdir/fopen
2989 echo "aaaaaa" >> $DIR/$tdir/flink
2990 echo "aaaaaa" >> $DIR/$tdir/funlink
2991 echo "aaaaaa" >> $DIR/$tdir/frename
2993 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2994 local link_new=`stat -c %Y $DIR/$tdir/flink`
2995 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2996 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2998 cat $DIR/$tdir/fopen > /dev/null
2999 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3000 rm -f $DIR/$tdir/funlink2
3001 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3003 for (( i=0; i < 2; i++ )) ; do
3004 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3005 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3006 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3007 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3009 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3010 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3011 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3012 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3014 cancel_lru_locks osc
3015 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3018 run_test 39b "mtime change on open, link, unlink, rename ======"
3020 # this should be set to past
3021 TEST_39_MTIME=`date -d "1 year ago" +%s`
3027 local mtime0=`stat -c %Y $DIR1/$tfile`
3029 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3030 local mtime1=`stat -c %Y $DIR1/$tfile`
3031 [ "$mtime1" = $TEST_39_MTIME ] || \
3032 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3035 echo hello >> $DIR1/$tfile
3037 local mtime2=`stat -c %Y $DIR1/$tfile`
3038 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3039 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3041 mv $DIR1/$tfile $DIR1/$tfile-1
3043 for (( i=0; i < 2; i++ )) ; do
3044 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3045 [ "$mtime2" = "$mtime3" ] || \
3046 error "mtime ($mtime2) changed (to $mtime3) on rename"
3048 cancel_lru_locks osc
3049 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3052 run_test 39c "mtime change on rename ==========================="
3056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3059 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3061 for (( i=0; i < 2; i++ )) ; do
3062 local mtime=`stat -c %Y $DIR1/$tfile`
3063 [ $mtime = $TEST_39_MTIME ] || \
3064 error "mtime($mtime) is not set to $TEST_39_MTIME"
3066 cancel_lru_locks osc
3067 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3070 run_test 39d "create, utime, stat =============================="
3074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3076 local mtime1=`stat -c %Y $DIR1/$tfile`
3078 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3080 for (( i=0; i < 2; i++ )) ; do
3081 local mtime2=`stat -c %Y $DIR1/$tfile`
3082 [ $mtime2 = $TEST_39_MTIME ] || \
3083 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3085 cancel_lru_locks osc
3086 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3089 run_test 39e "create, stat, utime, stat ========================"
3093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3095 mtime1=`stat -c %Y $DIR1/$tfile`
3098 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3100 for (( i=0; i < 2; i++ )) ; do
3101 local mtime2=`stat -c %Y $DIR1/$tfile`
3102 [ $mtime2 = $TEST_39_MTIME ] || \
3103 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3105 cancel_lru_locks osc
3106 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3109 run_test 39f "create, stat, sleep, utime, stat ================="
3113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3114 echo hello >> $DIR1/$tfile
3115 local mtime1=`stat -c %Y $DIR1/$tfile`
3118 chmod o+r $DIR1/$tfile
3120 for (( i=0; i < 2; i++ )) ; do
3121 local mtime2=`stat -c %Y $DIR1/$tfile`
3122 [ "$mtime1" = "$mtime2" ] || \
3123 error "lost mtime: $mtime2, should be $mtime1"
3125 cancel_lru_locks osc
3126 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3129 run_test 39g "write, chmod, stat ==============================="
3133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3138 echo hello >> $DIR1/$tfile
3139 local mtime1=`stat -c %Y $DIR1/$tfile`
3141 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3143 if [ "$d1" != "$d2" ]; then
3144 echo "write and touch not within one second"
3146 for (( i=0; i < 2; i++ )) ; do
3147 local mtime2=`stat -c %Y $DIR1/$tfile`
3148 [ "$mtime2" = $TEST_39_MTIME ] || \
3149 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3151 cancel_lru_locks osc
3152 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3156 run_test 39h "write, utime within one second, stat ============="
3159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3163 echo hello >> $DIR1/$tfile
3164 local mtime1=`stat -c %Y $DIR1/$tfile`
3166 mv $DIR1/$tfile $DIR1/$tfile-1
3168 for (( i=0; i < 2; i++ )) ; do
3169 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3171 [ "$mtime1" = "$mtime2" ] || \
3172 error "lost mtime: $mtime2, should be $mtime1"
3174 cancel_lru_locks osc
3175 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3178 run_test 39i "write, rename, stat =============================="
3181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3182 start_full_debug_logging
3186 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3187 lctl set_param fail_loc=0x80000412
3188 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3189 error "multiop failed"
3191 local mtime1=`stat -c %Y $DIR1/$tfile`
3193 mv $DIR1/$tfile $DIR1/$tfile-1
3195 kill -USR1 $multipid
3196 wait $multipid || error "multiop close failed"
3198 for (( i=0; i < 2; i++ )) ; do
3199 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3200 [ "$mtime1" = "$mtime2" ] ||
3201 error "mtime is lost on close: $mtime2, " \
3204 cancel_lru_locks osc
3205 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3207 lctl set_param fail_loc=0
3208 stop_full_debug_logging
3210 run_test 39j "write, rename, close, stat ======================="
3213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3217 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3219 local mtime1=`stat -c %Y $DIR1/$tfile`
3221 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3223 kill -USR1 $multipid
3224 wait $multipid || error "multiop close failed"
3226 for (( i=0; i < 2; i++ )) ; do
3227 local mtime2=`stat -c %Y $DIR1/$tfile`
3229 [ "$mtime2" = $TEST_39_MTIME ] || \
3230 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3232 cancel_lru_locks osc
3233 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3236 run_test 39k "write, utime, close, stat ========================"
3238 # this should be set to future
3239 TEST_39_ATIME=`date -d "1 year" +%s`
3242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3243 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3244 local atime_diff=$(do_facet $SINGLEMDS \
3245 lctl get_param -n mdd.*MDT0000*.atime_diff)
3249 # test setting directory atime to future
3250 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3251 local atime=$(stat -c %X $DIR/$tdir)
3252 [ "$atime" = $TEST_39_ATIME ] || \
3253 error "atime is not set to future: $atime, $TEST_39_ATIME"
3255 # test setting directory atime from future to now
3256 local d1=$(date +%s)
3258 local d2=$(date +%s)
3260 cancel_lru_locks mdc
3261 atime=$(stat -c %X $DIR/$tdir)
3262 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3263 error "atime is not updated from future: $atime, $d1<atime<$d2"
3265 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3268 # test setting directory atime when now > dir atime + atime_diff
3272 cancel_lru_locks mdc
3273 atime=$(stat -c %X $DIR/$tdir)
3274 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3275 error "atime is not updated : $atime, should be $d2"
3277 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3280 # test not setting directory atime when now < dir atime + atime_diff
3282 cancel_lru_locks mdc
3283 atime=$(stat -c %X $DIR/$tdir)
3284 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3285 error "atime is updated to $atime, should remain $d1<atime<$d2"
3287 do_facet $SINGLEMDS \
3288 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3290 run_test 39l "directory atime update ==========================="
3293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3296 local far_past_mtime=$(date -d "May 29 1953" +%s)
3297 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3299 touch -m -d @$far_past_mtime $DIR1/$tfile
3300 touch -a -d @$far_past_atime $DIR1/$tfile
3302 for (( i=0; i < 2; i++ )) ; do
3303 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3304 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3305 error "atime or mtime set incorrectly"
3307 cancel_lru_locks osc
3308 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3311 run_test 39m "test atime and mtime before 1970"
3313 test_39n() { # LU-3832
3314 local atime_diff=$(do_facet $SINGLEMDS \
3315 lctl get_param -n mdd.*MDT0000*.atime_diff)
3320 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3323 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3324 atime0=$(stat -c %X $DIR/$tfile)
3327 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3328 atime1=$(stat -c %X $DIR/$tfile)
3331 cancel_lru_locks mdc
3332 cancel_lru_locks osc
3333 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3334 atime2=$(stat -c %X $DIR/$tfile)
3336 do_facet $SINGLEMDS \
3337 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3339 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3340 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3342 run_test 39n "check that O_NOATIME is honored"
3345 TESTDIR=$DIR/$tdir/$tfile
3346 [ -e $TESTDIR ] && rm -rf $TESTDIR
3347 test_mkdir -p $TESTDIR
3353 links2=$(stat -c %h .)
3354 [ $(($links1 + 2)) != $links2 ] &&
3355 error "wrong links count $(($links1 + 2)) != $links2"
3357 links3=$(stat -c %h .)
3358 [ $(($links1 + 1)) != $links3 ] &&
3359 error "wrong links count $links1 != $links3"
3362 run_test 39o "directory cached attributes updated after create ========"
3365 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3367 TESTDIR=$DIR/$tdir/$tfile
3368 [ -e $TESTDIR ] && rm -rf $TESTDIR
3373 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3374 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3376 links2=$(stat -c %h .)
3377 [ $(($links1 + 2)) != $links2 ] &&
3378 error "wrong links count $(($links1 + 2)) != $links2"
3380 links3=$(stat -c %h .)
3381 [ $(($links1 + 1)) != $links3 ] &&
3382 error "wrong links count $links1 != $links3"
3385 run_test 39p "remote directory cached attributes updated after create ========"
3389 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3390 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3391 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3392 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3393 error "$tfile is not 4096 bytes in size"
3395 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3399 small_write $DIR/f41 18
3401 run_test 41 "test small file write + fstat ====================="
3403 count_ost_writes() {
3404 lctl get_param -n osc.*.stats |
3405 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3406 END { printf("%0.0f", writes) }'
3413 BG_DIRTY_RATIO_SAVE=10
3414 MAX_BG_DIRTY_RATIO=25
3418 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3419 # dirty_ratio, dirty_background_ratio
3420 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3421 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3422 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3423 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3425 # if file not here, we are a 2.4 kernel
3426 kill -CONT `pidof kupdated`
3431 # setup the trap first, so someone cannot exit the test at the
3432 # exact wrong time and mess up a machine
3433 trap start_writeback EXIT
3434 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3435 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3436 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3437 sysctl -w vm.dirty_writeback_centisecs=0
3438 sysctl -w vm.dirty_writeback_centisecs=0
3439 # save and increase /proc/sys/vm/dirty_ratio
3440 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3441 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3442 # save and increase /proc/sys/vm/dirty_background_ratio
3443 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3444 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3446 # if file not here, we are a 2.4 kernel
3447 kill -STOP `pidof kupdated`
3451 # ensure that all stripes have some grant before we test client-side cache
3453 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3454 dd if=/dev/zero of=$i bs=4k count=1
3459 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3460 # file truncation, and file removal.
3462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3464 cancel_lru_locks osc
3466 sync; sleep 1; sync # just to be safe
3467 BEFOREWRITES=`count_ost_writes`
3468 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3469 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3470 AFTERWRITES=`count_ost_writes`
3471 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3472 error "$BEFOREWRITES < $AFTERWRITES"
3475 run_test 42a "ensure that we don't flush on close =============="
3478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3480 cancel_lru_locks osc
3483 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3484 BEFOREWRITES=$(count_ost_writes)
3485 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3486 AFTERWRITES=$(count_ost_writes)
3487 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3488 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3490 BEFOREWRITES=$(count_ost_writes)
3491 sync || error "sync: $?"
3492 AFTERWRITES=$(count_ost_writes)
3493 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3494 error "$BEFOREWRITES < $AFTERWRITES on sync"
3496 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3500 run_test 42b "test destroy of file with cached dirty data ======"
3502 # if these tests just want to test the effect of truncation,
3503 # they have to be very careful. consider:
3504 # - the first open gets a {0,EOF}PR lock
3505 # - the first write conflicts and gets a {0, count-1}PW
3506 # - the rest of the writes are under {count,EOF}PW
3507 # - the open for truncate tries to match a {0,EOF}PR
3508 # for the filesize and cancels the PWs.
3509 # any number of fixes (don't get {0,EOF} on open, match
3510 # composite locks, do smarter file size management) fix
3511 # this, but for now we want these tests to verify that
3512 # the cancellation with truncate intent works, so we
3513 # start the file with a full-file pw lock to match against
3514 # until the truncate.
3519 cancel_lru_locks osc
3521 # prime the file with 0,EOF PW to match
3525 # now the real test..
3526 dd if=/dev/zero of=$file bs=1024 count=100
3527 BEFOREWRITES=`count_ost_writes`
3528 $TRUNCATE $file $offset
3529 cancel_lru_locks osc
3530 AFTERWRITES=`count_ost_writes`
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3537 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3538 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3541 run_test 42c "test partial truncate of file with cached dirty data"
3544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3546 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3547 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3550 run_test 42d "test complete truncate of file with cached dirty data"
3552 test_42e() { # bug22074
3553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3554 local TDIR=$DIR/${tdir}e
3555 local pagesz=$(page_size)
3556 local pages=16 # hardcoded 16 pages, don't change it.
3557 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3558 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3562 test_mkdir -p $DIR/${tdir}e
3563 $SETSTRIPE -c 1 $TDIR
3564 createmany -o $TDIR/f $files
3566 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3568 # we assume that with $OSTCOUNT files, at least one of them will
3569 # be allocated on OST0.
3570 warmup_files=$((OSTCOUNT * max_dirty_mb))
3571 createmany -o $TDIR/w $warmup_files
3573 # write a large amount of data into one file and sync, to get good
3574 # avail_grant number from OST.
3575 for ((i=0; i<$warmup_files; i++)); do
3576 idx=$($GETSTRIPE -i $TDIR/w$i)
3577 [ $idx -ne 0 ] && continue
3578 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3581 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3583 $LCTL get_param $proc_osc0/cur_dirty_bytes
3584 $LCTL get_param $proc_osc0/cur_grant_bytes
3586 # create as much dirty pages as we can while not to trigger the actual
3587 # RPCs directly. but depends on the env, VFS may trigger flush during this
3588 # period, hopefully we are good.
3589 for ((i=0; i<$warmup_files; i++)); do
3590 idx=$($GETSTRIPE -i $TDIR/w$i)
3591 [ $idx -ne 0 ] && continue
3592 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3594 $LCTL get_param $proc_osc0/cur_dirty_bytes
3595 $LCTL get_param $proc_osc0/cur_grant_bytes
3597 # perform the real test
3598 $LCTL set_param $proc_osc0/rpc_stats 0
3599 for ((;i<$files; i++)); do
3600 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3601 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3604 $LCTL get_param $proc_osc0/rpc_stats
3607 local have_ppr=false
3608 $LCTL get_param $proc_osc0/rpc_stats |
3609 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3610 # skip lines until we are at the RPC histogram data
3611 [ "$PPR" == "pages" ] && have_ppr=true && continue
3612 $have_ppr || continue
3614 # we only want the percent stat for < 16 pages
3615 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3617 percent=$((percent + WPCT))
3618 if [[ $percent -gt 15 ]]; then
3619 error "less than 16-pages write RPCs" \
3626 run_test 42e "verify sub-RPC writes are not done synchronously"
3629 test_mkdir -p $DIR/$tdir
3630 cp -p /bin/ls $DIR/$tdir/$tfile
3631 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3633 # give multiop a chance to open
3636 $DIR/$tdir/$tfile && error || true
3639 run_test 43 "execution of file opened for write should return -ETXTBSY"
3642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3643 test_mkdir -p $DIR/$tdir
3644 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3645 cp -p multiop $DIR/$tdir/multiop
3646 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3649 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3650 kill -USR1 $MULTIOP_PID || return 2
3651 wait $MULTIOP_PID || return 3
3652 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3654 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3658 test_mkdir -p $DIR/$tdir
3659 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3660 cp -p multiop $DIR/$tdir/multiop
3661 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3664 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3665 kill -USR1 $MULTIOP_PID || return 2
3666 wait $MULTIOP_PID || return 3
3667 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3669 run_test 43b "truncate of file being executed should return -ETXTBSY"
3672 local testdir="$DIR/$tdir"
3673 test_mkdir -p $DIR/$tdir
3675 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3676 ( cd $testdir && md5sum -c)
3678 run_test 43c "md5sum of copy into lustre========================"
3681 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3682 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3683 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3685 run_test 44 "zero length read from a sparse stripe ============="
3688 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3690 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3691 [[ $nstripe -gt $OSTCOUNT ]] &&
3692 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3694 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3696 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3697 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3701 OFFSETS="0 $((stride/2)) $((stride-1))"
3702 for offset in $OFFSETS; do
3703 for i in $(seq 0 $((nstripe-1))); do
3704 local GLOBALOFFSETS=""
3706 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3707 local myfn=$DIR/d44a-$size
3708 echo "--------writing $myfn at $size"
3709 ll_sparseness_write $myfn $size ||
3710 error "ll_sparseness_write"
3711 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3712 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3713 error "ll_sparseness_verify $GLOBALOFFSETS"
3715 for j in $(seq 0 $((nstripe-1))); do
3717 size=$((((j + $nstripe )*$stride + $offset)))
3718 ll_sparseness_write $myfn $size ||
3719 error "ll_sparseness_write"
3720 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3722 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3723 error "ll_sparseness_verify $GLOBALOFFSETS"
3728 run_test 44a "test sparse pwrite ==============================="
3732 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3738 before=`dirty_osc_total`
3739 echo executing "\"$*\""
3741 after=`dirty_osc_total`
3742 echo before $before, after $after
3745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3747 # Obtain grants from OST if it supports it
3748 echo blah > ${f}_grant
3751 do_dirty_record "echo blah > $f"
3752 [[ $before -eq $after ]] && error "write wasn't cached"
3753 do_dirty_record "> $f"
3754 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3755 do_dirty_record "echo blah > $f"
3756 [[ $before -eq $after ]] && error "write wasn't cached"
3757 do_dirty_record "sync"
3758 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3759 do_dirty_record "echo blah > $f"
3760 [[ $before -eq $after ]] && error "write wasn't cached"
3761 do_dirty_record "cancel_lru_locks osc"
3762 [[ $before -gt $after ]] ||
3763 error "lock cancellation didn't lower dirty count"
3766 run_test 45 "osc io page accounting ============================"
3768 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3769 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3770 # objects offset and an assert hit when an rpc was built with 1023's mapped
3771 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3777 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3779 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3780 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3784 run_test 46 "dirtying a previously written page ================"
3786 # test_47 is removed "Device nodes check" is moved to test_28
3788 test_48a() { # bug 2399
3789 check_kernel_version 34 || return 0
3790 test_mkdir -p $DIR/$tdir
3792 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3793 test_mkdir $DIR/$tdir || error "recreate directory failed"
3794 touch foo || error "'touch foo' failed after recreating cwd"
3795 test_mkdir $DIR/$tdir/bar ||
3796 error "'mkdir foo' failed after recreating cwd"
3797 if check_kernel_version 44; then
3798 touch .foo || error "'touch .foo' failed after recreating cwd"
3799 test_mkdir $DIR/$tdir/.bar ||
3800 error "'mkdir .foo' failed after recreating cwd"
3802 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3803 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3804 cd . || error "'cd .' failed after recreating cwd"
3805 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3806 rmdir . && error "'rmdir .' worked after recreating cwd"
3807 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3808 cd .. || error "'cd ..' failed after recreating cwd"
3810 run_test 48a "Access renamed working dir (should return errors)="
3812 test_48b() { # bug 2399
3813 check_kernel_version 34 || return 0
3815 test_mkdir -p $DIR/$tdir
3817 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3818 touch foo && error "'touch foo' worked after removing cwd"
3819 test_mkdir $DIR/$tdir/foo &&
3820 error "'mkdir foo' worked after removing cwd"
3821 if check_kernel_version 44; then
3822 touch .foo && error "'touch .foo' worked after removing cwd"
3823 test_mkdir $DIR/$tdir/.foo &&
3824 error "'mkdir .foo' worked after removing cwd"
3826 ls . > /dev/null && error "'ls .' worked after removing cwd"
3827 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3828 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3829 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3830 rmdir . && error "'rmdir .' worked after removing cwd"
3831 ln -s . foo && error "'ln -s .' worked after removing cwd"
3832 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3834 run_test 48b "Access removed working dir (should return errors)="
3836 test_48c() { # bug 2350
3837 check_kernel_version 36 || return 0
3838 #lctl set_param debug=-1
3841 test_mkdir -p $DIR/$tdir/dir
3843 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3844 $TRACE touch foo && error "touch foo worked after removing cwd"
3845 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3846 if check_kernel_version 44; then
3847 touch .foo && error "touch .foo worked after removing cwd"
3848 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3850 $TRACE ls . && error "'ls .' worked after removing cwd"
3851 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3852 is_patchless || ( $TRACE cd . &&
3853 error "'cd .' worked after removing cwd" )
3854 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3855 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3856 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3857 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3859 run_test 48c "Access removed working subdir (should return errors)"
3861 test_48d() { # bug 2350
3862 check_kernel_version 36 || return 0
3863 #lctl set_param debug=-1
3866 test_mkdir -p $DIR/$tdir/dir
3868 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3869 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3870 $TRACE touch foo && error "'touch foo' worked after removing parent"
3871 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3872 if check_kernel_version 44; then
3873 touch .foo && error "'touch .foo' worked after removing parent"
3875 error "mkdir .foo worked after removing parent"
3877 $TRACE ls . && error "'ls .' worked after removing parent"
3878 $TRACE ls .. && error "'ls ..' worked after removing parent"
3879 is_patchless || ( $TRACE cd . &&
3880 error "'cd .' worked after recreate parent" )
3881 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3882 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3883 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3884 is_patchless || ( $TRACE cd .. &&
3885 error "'cd ..' worked after removing parent" || true )
3887 run_test 48d "Access removed parent subdir (should return errors)"
3889 test_48e() { # bug 4134
3890 check_kernel_version 41 || return 0
3891 #lctl set_param debug=-1
3894 test_mkdir -p $DIR/$tdir/dir
3896 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3897 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3898 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3899 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3900 # On a buggy kernel addition of "touch foo" after cd .. will
3901 # produce kernel oops in lookup_hash_it
3902 touch ../foo && error "'cd ..' worked after recreate parent"
3904 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3906 run_test 48e "Access to recreated parent subdir (should return errors)"
3908 test_49() { # LU-1030
3909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3910 # get ost1 size - lustre-OST0000
3911 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3913 # write 800M at maximum
3914 [[ $ost1_size -lt 2 ]] && ost1_size=2
3915 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3917 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3918 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3921 # change max_pages_per_rpc while writing the file
3922 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3923 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3924 # loop until dd process exits
3925 while ps ax -opid | grep -wq $dd_pid; do
3926 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3927 sleep $((RANDOM % 5 + 1))
3929 # restore original max_pages_per_rpc
3930 $LCTL set_param $osc1_mppc=$orig_mppc
3931 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3933 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3937 test_mkdir $DIR/$tdir
3939 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3941 run_test 50 "special situations: /proc symlinks ==============="
3943 test_51a() { # was test_51
3944 # bug 1516 - create an empty entry right after ".." then split dir
3945 test_mkdir -c1 $DIR/$tdir
3946 touch $DIR/$tdir/foo
3947 $MCREATE $DIR/$tdir/bar
3949 createmany -m $DIR/$tdir/longfile 201
3951 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3952 $MCREATE $DIR/$tdir/longfile$FNUM
3957 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3959 run_test 51a "special situations: split htree with empty entry =="
3961 export NUMTEST=70000
3963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3964 local BASE=$DIR/d${base}.${TESTSUITE}
3966 # cleanup the directory
3969 test_mkdir -p -c1 $BASE
3971 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3972 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3973 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3976 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3977 echo "reduced count to $NUMTEST due to inodes"
3979 # need to check free space for the directories as well
3980 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3981 numfree=$((blkfree / 4))
3982 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3983 echo "reduced count to $NUMTEST due to blocks"
3985 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3986 echo "failed" > $BASE/fnum
3988 run_test 51b "exceed 64k subdirectory nlink limit"
3990 test_51ba() { # LU-993
3991 local BASE=$DIR/d${base}.${TESTSUITE}
3992 # unlink all but 100 subdirectories, then check it still works
3994 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3996 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3997 local DELETE=$((NUMTEST - LEFT))
3999 # continue on to run this test even if 51b didn't finish,
4000 # just to delete the many subdirectories created.
4001 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4003 # for ldiskfs the nlink count should be 1, but this is OSD specific
4004 # and so this is listed for informational purposes only
4005 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4006 unlinkmany -d $BASE/d $DELETE
4009 if [ $RC -ne 0 ]; then
4010 if [ "$NUMPREV" == "failed" ]; then
4011 skip "previous setup failed"
4014 error "unlink of first $DELETE subdirs failed"
4019 echo "nlink between: $(stat -c %h $BASE)"
4020 # trim the first line of ls output
4021 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4022 [ $FOUND -ne $LEFT ] &&
4023 error "can't find subdirs: found only $FOUND/$LEFT"
4025 unlinkmany -d $BASE/d $DELETE $LEFT ||
4026 error "unlink of second $LEFT subdirs failed"
4027 # regardless of whether the backing filesystem tracks nlink accurately
4028 # or not, the nlink count shouldn't be more than "." and ".." here
4029 local AFTER=$(stat -c %h $BASE)
4030 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4031 echo "nlink after: $AFTER"
4033 run_test 51ba "verify nlink for many subdirectory cleanup"
4036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4037 [[ $OSTCOUNT -lt 3 ]] &&
4038 skip_env "skipping test with few OSTs" && return
4039 test_mkdir -p $DIR/$tdir
4040 createmany -o $DIR/$tdir/t- 1000
4041 $GETSTRIPE $DIR/$tdir > $TMP/files
4042 for N in $(seq 0 $((OSTCOUNT - 1))); do
4043 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4044 END { printf("%0.0f", objs) }' $TMP/files)
4045 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4046 '($1 == '$N') { objs += 1 } \
4047 END { printf("%0.0f", objs) }')
4048 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4050 unlinkmany $DIR/$tdir/t- 1000
4053 for N in $(seq 1 $((OSTCOUNT - 1))); do
4054 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4055 error "OST $N has less objects vs OST $NLAST" \
4056 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4057 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4058 error "OST $N has less objects vs OST $NLAST" \
4059 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4061 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4062 error "OST $N has less #0 objects vs OST $NLAST" \
4063 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4064 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4065 error "OST $N has less #0 objects vs OST $NLAST" \
4066 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4070 run_test 51d "check object distribution ===================="
4073 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4074 test_mkdir -p $DIR/$tdir
4075 touch $DIR/$tdir/foo
4076 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4077 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4078 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4079 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4080 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4082 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4083 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4084 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4086 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4087 cp -r $DIR/$tdir /tmp/
4088 rm -fr $DIR/$tdir || error "cleanup rm failed"
4090 run_test 52a "append-only flag test (should return errors) ====="
4093 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4094 test_mkdir -p $DIR/$tdir
4095 touch $DIR/$tdir/foo
4096 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4097 cat test > $DIR/$tdir/foo && error "cat test worked"
4098 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4099 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4100 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4102 echo foo >> $DIR/$tdir/foo && error "echo worked"
4103 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4104 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4105 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4106 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4108 chattr -i $DIR/$tdir/foo || error "chattr failed"
4110 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4112 run_test 52b "immutable flag test (should return errors) ======="
4115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4117 remote_ost_nodsh && skip "remote OST with nodsh" && return
4130 local support_last_seq=true
4132 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4133 support_last_seq=false
4136 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4138 for value in $(do_facet $SINGLEMDS \
4139 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4140 param=$(echo ${value[0]} | cut -d "=" -f1)
4141 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4143 if $support_last_seq; then
4144 param_seq=$(echo $param |
4145 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4146 mds_last_seq=$(do_facet $SINGLEMDS \
4147 $LCTL get_param -n $param_seq)
4149 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4151 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4152 node=$(facet_active_host ost$((ostnum+1)))
4153 param="obdfilter.$ostname.last_id"
4154 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4155 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4156 ost_last_id=$ost_last
4158 if $support_last_seq; then
4159 ost_last_id=$(echo $ost_last |
4160 awk -F':' '{print $2}' |
4162 ost_last_seq=$(echo $ost_last |
4163 awk -F':' '{print $1}')
4164 [[ $ost_last_seq = $mds_last_seq ]] || continue
4167 if [[ $ost_last_id != $mds_last ]]; then
4168 error "$ost_last_id != $mds_last"
4175 $found || error "can not match last_seq/last_id for $mdtosc"
4178 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4181 $SOCKETSERVER $DIR/socket ||
4182 error "$SOCKETSERVER $DIR/socket failed: $?"
4183 $SOCKETCLIENT $DIR/socket ||
4184 error "$SOCKETCLIENT $DIR/socket failed: $?"
4185 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4187 run_test 54a "unix domain socket test =========================="
4193 dd if=/dev/zero of=$f bs=$(page_size) count=1
4195 run_test 54b "char device works in lustre ======================"
4198 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4199 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4200 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4202 for i in $(seq 3 7); do
4203 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4211 loopdev="$DIR/loop54c"
4214 $UMOUNT -d $DIR/$tdir || rc=$?
4215 losetup -d $loopdev || true
4216 losetup -d $LOOPDEV || true
4217 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4223 loopdev="$DIR/loop54c"
4226 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4227 trap cleanup_54c EXIT
4228 mknod $loopdev b 7 $LOOPNUM
4229 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4230 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4231 losetup $loopdev $DIR/$tfile ||
4232 error "can't set up $loopdev for $DIR/$tfile"
4233 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4234 test_mkdir -p $DIR/$tdir
4235 mount -t ext2 $loopdev $DIR/$tdir ||
4236 error "error mounting $loopdev on $DIR/$tdir"
4237 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4240 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4244 run_test 54c "block device works in lustre ====================="
4250 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4252 run_test 54d "fifo device works in lustre ======================"
4255 check_kernel_version 46 || return 0
4258 cp -aL /dev/console $f
4259 echo $string > $f || error "echo $string to $f failed"
4261 run_test 54e "console/tty device works in lustre ======================"
4263 #The test_55 used to be iopen test and it was removed by bz#24037.
4264 #run_test 55 "check iopen_connect_dentry() ======================"
4266 test_56a() { # was test_56
4269 test_mkdir -p $DIR/$tdir/dir
4271 NUMFILESx2=$(($NUMFILES * 2))
4272 for i in $(seq 1 $NUMFILES); do
4273 touch $DIR/$tdir/file$i
4274 touch $DIR/$tdir/dir/file$i
4277 # test lfs getstripe with --recursive
4278 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4279 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4280 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4281 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4282 [[ $FILENUM -eq $NUMFILES ]] ||
4283 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4284 echo "$GETSTRIPE --recursive passed."
4286 # test lfs getstripe with file instead of dir
4287 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4288 [[ $FILENUM -eq 1 ]] ||
4289 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4290 echo "$GETSTRIPE file1 passed."
4292 #test lfs getstripe with --verbose
4293 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4294 grep -c lmm_magic) -eq $NUMFILES ]] ||
4295 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4296 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4297 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4298 echo "$GETSTRIPE --verbose passed."
4300 #test lfs getstripe with --obd
4301 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4302 grep -q "unknown obduuid" ||
4303 error "$GETSTRIPE --obd wrong_uuid should return error message"
4305 [[ $OSTCOUNT -lt 2 ]] &&
4306 skip_env "skipping other $GETSTRIPE --obd test" && return
4309 OBDUUID=$(ostuuid_from_index $OSTIDX)
4310 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4311 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4312 [[ $FOUND -eq $FILENUM ]] ||
4313 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4314 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4315 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4316 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4317 error "$GETSTRIPE --obd: should not show file on other obd"
4318 echo "$GETSTRIPE --obd passed"
4320 run_test 56a "check $GETSTRIPE"
4325 local LOCAL_NUMFILES="$1"
4326 local LOCAL_NUMDIRS="$2"
4327 local MKDIR_PARAMS="$3"
4328 local DIR_STRIPE_PARAMS="$4"
4330 if [ ! -d "$TDIR" ] ; then
4331 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4332 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4333 for i in `seq 1 $LOCAL_NUMFILES` ; do
4336 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4337 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4338 for j in `seq 1 $LOCAL_NUMFILES` ; do
4339 touch $TDIR/dir$i/file$j
4345 setup_56_special() {
4349 if [ ! -e "$TDIR/loop1b" ] ; then
4350 for i in `seq 1 $LOCAL_NUMFILES` ; do
4351 mknod $TDIR/loop${i}b b 7 $i
4352 mknod $TDIR/null${i}c c 1 3
4353 ln -s $TDIR/file1 $TDIR/link${i}l
4355 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4356 mknod $TDIR/dir$i/loop${i}b b 7 $i
4357 mknod $TDIR/dir$i/null${i}c c 1 3
4358 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4367 setup_56 $NUMFILES $NUMDIRS
4369 EXPECTED=$(($NUMDIRS + 2))
4370 # test lfs find with -name
4371 for i in $(seq 1 $NUMFILES) ; do
4372 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4373 [ $NUMS -eq $EXPECTED ] ||
4374 error "lfs find -name \"*$i\" $TDIR wrong: "\
4375 "found $NUMS, expected $EXPECTED"
4378 run_test 56g "check lfs find -name ============================="
4384 setup_56 $NUMFILES $NUMDIRS
4386 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4387 # test lfs find with ! -name
4388 for i in $(seq 1 $NUMFILES) ; do
4389 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4390 [ $NUMS -eq $EXPECTED ] ||
4391 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4392 "found $NUMS, expected $EXPECTED"
4395 run_test 56h "check lfs find ! -name ============================="
4399 test_mkdir -p $DIR/$tdir
4400 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4401 CMD="$LFIND -ost $UUID $DIR/$tdir"
4403 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4405 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4409 setup_56_special $NUMFILES $NUMDIRS
4411 EXPECTED=$((NUMDIRS + 1))
4412 CMD="$LFIND -type d $TDIR"
4413 NUMS=$($CMD | wc -l)
4414 [ $NUMS -eq $EXPECTED ] ||
4415 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4417 run_test 56j "check lfs find -type d ============================="
4421 setup_56_special $NUMFILES $NUMDIRS
4423 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4424 CMD="$LFIND -type f $TDIR"
4425 NUMS=$($CMD | wc -l)
4426 [ $NUMS -eq $EXPECTED ] ||
4427 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4429 run_test 56k "check lfs find -type f ============================="
4433 setup_56_special $NUMFILES $NUMDIRS
4435 EXPECTED=$((NUMDIRS + NUMFILES))
4436 CMD="$LFIND -type b $TDIR"
4437 NUMS=$($CMD | wc -l)
4438 [ $NUMS -eq $EXPECTED ] ||
4439 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4441 run_test 56l "check lfs find -type b ============================="
4445 setup_56_special $NUMFILES $NUMDIRS
4447 EXPECTED=$((NUMDIRS + NUMFILES))
4448 CMD="$LFIND -type c $TDIR"
4449 NUMS=$($CMD | wc -l)
4450 [ $NUMS -eq $EXPECTED ] ||
4451 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4453 run_test 56m "check lfs find -type c ============================="
4457 setup_56_special $NUMFILES $NUMDIRS
4459 EXPECTED=$((NUMDIRS + NUMFILES))
4460 CMD="$LFIND -type l $TDIR"
4461 NUMS=$($CMD | wc -l)
4462 [ $NUMS -eq $EXPECTED ] ||
4463 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4465 run_test 56n "check lfs find -type l ============================="
4469 setup_56 $NUMFILES $NUMDIRS
4470 utime $TDIR/file1 > /dev/null || error "utime (1)"
4471 utime $TDIR/file2 > /dev/null || error "utime (2)"
4472 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4473 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4474 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4475 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4478 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4479 [ $NUMS -eq $EXPECTED ] || \
4480 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4483 CMD="$LFIND -mtime 0 $TDIR"
4484 NUMS=$($CMD | wc -l)
4485 [ $NUMS -eq $EXPECTED ] ||
4486 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4488 run_test 56o "check lfs find -mtime for old files =========================="
4491 [ $RUNAS_ID -eq $UID ] &&
4492 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4495 setup_56 $NUMFILES $NUMDIRS
4497 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4499 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4500 NUMS=$($CMD | wc -l)
4501 [ $NUMS -eq $EXPECTED ] || \
4502 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4504 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4505 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4506 NUMS=$($CMD | wc -l)
4507 [ $NUMS -eq $EXPECTED ] || \
4508 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4510 run_test 56p "check lfs find -uid and ! -uid ==============================="
4513 [ $RUNAS_ID -eq $UID ] &&
4514 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4517 setup_56 $NUMFILES $NUMDIRS
4519 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4522 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4523 NUMS=$($CMD | wc -l)
4524 [ $NUMS -eq $EXPECTED ] ||
4525 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4527 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4528 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4529 NUMS=$($CMD | wc -l)
4530 [ $NUMS -eq $EXPECTED ] ||
4531 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4533 run_test 56q "check lfs find -gid and ! -gid ==============================="
4537 setup_56 $NUMFILES $NUMDIRS
4540 CMD="$LFIND -size 0 -type f $TDIR"
4541 NUMS=$($CMD | wc -l)
4542 [ $NUMS -eq $EXPECTED ] ||
4543 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4545 CMD="$LFIND ! -size 0 -type f $TDIR"
4546 NUMS=$($CMD | wc -l)
4547 [ $NUMS -eq $EXPECTED ] ||
4548 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 echo "test" > $TDIR/$tfile
4550 echo "test2" > $TDIR/$tfile.2 && sync
4552 CMD="$LFIND -size 5 -type f $TDIR"
4553 NUMS=$($CMD | wc -l)
4554 [ $NUMS -eq $EXPECTED ] ||
4555 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4557 CMD="$LFIND -size +5 -type f $TDIR"
4558 NUMS=$($CMD | wc -l)
4559 [ $NUMS -eq $EXPECTED ] ||
4560 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4562 CMD="$LFIND -size +0 -type f $TDIR"
4563 NUMS=$($CMD | wc -l)
4564 [ $NUMS -eq $EXPECTED ] ||
4565 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4567 CMD="$LFIND ! -size -5 -type f $TDIR"
4568 NUMS=$($CMD | wc -l)
4569 [ $NUMS -eq $EXPECTED ] ||
4570 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4572 CMD="$LFIND -size -5 -type f $TDIR"
4573 NUMS=$($CMD | wc -l)
4574 [ $NUMS -eq $EXPECTED ] ||
4575 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4577 run_test 56r "check lfs find -size works =========================="
4579 test_56s() { # LU-611
4581 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4583 if [[ $OSTCOUNT -gt 1 ]]; then
4584 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4588 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4592 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4593 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4594 NUMS=$($CMD | wc -l)
4595 [ $NUMS -eq $EXPECTED ] || {
4597 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4600 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4601 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4602 NUMS=$($CMD | wc -l)
4603 [ $NUMS -eq $EXPECTED ] || {
4605 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4609 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4610 NUMS=$($CMD | wc -l)
4611 [ $NUMS -eq $EXPECTED ] || {
4613 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4616 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4617 NUMS=$($CMD | wc -l)
4618 [ $NUMS -eq $EXPECTED ] || {
4620 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4624 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4625 NUMS=$($CMD | wc -l)
4626 [ $NUMS -eq $EXPECTED ] || {
4628 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4631 run_test 56s "check lfs find -stripe-count works"
4633 test_56t() { # LU-611
4635 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4637 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4639 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4640 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4641 NUMS=$($CMD | wc -l)
4642 [ $NUMS -eq $EXPECTED ] ||
4643 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4645 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4646 NUMS=$($CMD | wc -l)
4647 [ $NUMS -eq $EXPECTED ] ||
4648 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4651 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4652 NUMS=$($CMD | wc -l)
4653 [ $NUMS -eq $EXPECTED ] ||
4654 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4656 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4657 NUMS=$($CMD | wc -l)
4658 [ $NUMS -eq $EXPECTED ] ||
4659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4662 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4663 NUMS=$($CMD | wc -l)
4664 [ $NUMS -eq $EXPECTED ] ||
4665 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4667 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4668 NUMS=$($CMD | wc -l)
4669 [ $NUMS -eq $EXPECTED ] ||
4670 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4673 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4674 NUMS=$($CMD | wc -l)
4675 [ $NUMS -eq $EXPECTED ] ||
4676 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4678 run_test 56t "check lfs find -stripe-size works"
4680 test_56u() { # LU-611
4682 setup_56 $NUMFILES $NUMDIRS "-i 0"
4684 if [[ $OSTCOUNT -gt 1 ]]; then
4685 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4691 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4692 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4693 NUMS=$($CMD | wc -l)
4694 [ $NUMS -eq $EXPECTED ] ||
4695 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4698 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4699 NUMS=$($CMD | wc -l)
4700 [ $NUMS -eq $EXPECTED ] ||
4701 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4703 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4704 NUMS=$($CMD | wc -l)
4705 [ $NUMS -eq $EXPECTED ] ||
4706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4709 # This should produce an error and not return any files
4710 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4711 NUMS=$($CMD 2>/dev/null | wc -l)
4712 [ $NUMS -eq $EXPECTED ] ||
4713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4715 if [[ $OSTCOUNT -gt 1 ]]; then
4716 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4717 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] ||
4720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4723 run_test 56u "check lfs find -stripe-index works"
4730 setup_56 $NUMFILES $NUMDIRS
4732 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4733 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4735 for file in $($LFIND -mdt $UUID $TDIR); do
4736 file_mdt_idx=$($GETSTRIPE -M $file)
4737 [ $file_mdt_idx -eq $MDT_IDX ] ||
4738 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4741 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4743 # Get and check the actual stripe count of one file.
4744 # Usage: check_stripe_count <file> <expected_stripe_count>
4745 check_stripe_count() {
4750 [[ -z "$file" || -z "$expected" ]] &&
4751 error "check_stripe_count: invalid argument!"
4753 local cmd="$GETSTRIPE -c $file"
4754 actual=$($cmd) || error "$cmd failed"
4755 actual=${actual%% *}
4757 if [[ $actual -ne $expected ]]; then
4758 [[ $expected -eq -1 ]] ||
4759 error "$cmd wrong: found $actual, expected $expected"
4760 [[ $actual -eq $OSTCOUNT ]] ||
4761 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4769 rm -rf $TDIR || error "remove $TDIR failed"
4770 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4773 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4774 error "$GETSTRIPE -S -d $TDIR failed"
4775 stripe_size=${stripe_size%% *}
4777 local file_size=$((stripe_size * OSTCOUNT))
4778 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4779 local required_space=$((file_num * file_size))
4780 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4781 [[ $free_space -le $((required_space / 1024)) ]] &&
4782 skip_env "need at least $required_space bytes free space," \
4783 "have $free_space kbytes" && return
4786 local dd_count=$((file_size / dd_bs))
4788 # write data into the files
4792 for i in $(seq 1 $NUMFILES); do
4794 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4795 error "write data into $file failed"
4797 for i in $(seq 1 $NUMDIRS); do
4798 for j in $(seq 1 $NUMFILES); do
4799 file=$TDIR/dir$i/file$j
4800 yes | dd bs=$dd_bs count=$dd_count of=$file \
4802 error "write data into $file failed"
4807 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4810 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4812 eval $cmd || error "$cmd failed"
4814 check_stripe_count $TDIR/file1 $expected
4817 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4819 eval $cmd || error "$cmd failed"
4821 for j in $(seq 1 $NUMFILES); do
4822 check_stripe_count $TDIR/dir1/file$j $expected
4825 # lfs_migrate works with lfs find
4826 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4827 $LFS_MIGRATE -y -c $expected"
4829 eval $cmd || error "$cmd failed"
4831 for i in $(seq 2 $NUMFILES); do
4832 check_stripe_count $TDIR/file$i $expected
4834 for i in $(seq 2 $NUMDIRS); do
4835 for j in $(seq 1 $NUMFILES); do
4836 check_stripe_count $TDIR/dir$i/file$j $expected
4840 run_test 56w "check lfs_migrate -c stripe_count works"
4843 check_swap_layouts_support && return 0
4844 [[ $OSTCOUNT -lt 2 ]] &&
4845 skip_env "need 2 OST, skipping test" && return
4847 local dir0=$DIR/$tdir/$testnum
4848 mkdir -p $dir0 || error "creating dir $dir0"
4850 local ref1=/etc/passwd
4851 local file1=$dir0/file1
4853 $SETSTRIPE -c 2 $file1
4855 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4856 stripe=$($GETSTRIPE -c $file1)
4857 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4858 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4863 run_test 56x "lfs migration support"
4866 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4867 skip "No HSM support on MDS of $(get_lustre_version)," \
4868 "need 2.4.53 at least" && return
4871 local dir0=$DIR/$tdir/$testnum
4872 mkdir -p $dir0 || error "creating dir $dir0"
4873 local f1=$dir0/file1
4874 local f2=$dir0/file2
4876 touch $f1 || error "creating std file $f1"
4877 $MULTIOP $f2 H2c || error "creating released file $f2"
4879 # a directory can be raid0, so ask only for files
4880 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4881 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4883 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4884 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4886 # only files can be released, so no need to force file search
4887 res=$($LFIND $dir0 -L released)
4888 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4890 res=$($LFIND $dir0 \! -L released)
4891 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4894 run_test 56y "lfs find -L raid0|released"
4897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4898 # note test will not do anything if MDS is not local
4899 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4900 skip "Only applicable to ldiskfs-based MDTs"
4904 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4905 local MNTDEV="osd*.*MDT*.mntdev"
4906 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4907 [ -z "$DEV" ] && error "can't access $MNTDEV"
4908 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4909 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4910 error "can't access $DEV"
4911 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4912 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4916 run_test 57a "verify MDS filesystem created with large inodes =="
4919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4920 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4921 skip "Only applicable to ldiskfs-based MDTs"
4925 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4930 local FILEN=$dir/f$FILECOUNT
4932 rm -rf $dir || error "removing $dir"
4933 test_mkdir -p $dir || error "creating $dir"
4934 local num=$(get_mds_dir $dir)
4937 echo "mcreating $FILECOUNT files"
4938 createmany -m $dir/f 1 $FILECOUNT || \
4939 error "creating files in $dir"
4941 # verify that files do not have EAs yet
4942 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4943 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4947 df $dir #make sure we get new statfs data
4948 local MDSFREE=$(do_facet $mymds \
4949 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4950 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4951 echo "opening files to create objects/EAs"
4953 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4954 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4957 # verify that files have EAs now
4958 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4959 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4961 sleep 1 #make sure we get new statfs data
4963 local MDSFREE2=$(do_facet $mymds \
4964 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4965 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4966 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4967 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4968 error "MDC before $MDCFREE != after $MDCFREE2"
4970 echo "MDC before $MDCFREE != after $MDCFREE2"
4971 echo "unable to confirm if MDS has large inodes"
4976 run_test 57b "default LOV EAs are stored inside large inodes ==="
4979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4980 [ -z "$(which wiretest 2>/dev/null)" ] &&
4981 skip_env "could not find wiretest" && return
4984 run_test 58 "verify cross-platform wire constants =============="
4987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4988 echo "touch 130 files"
4989 createmany -o $DIR/f59- 130
4991 unlinkmany $DIR/f59- 130
4993 # wait for commitment of removal
4994 wait_delete_completed
4996 run_test 59 "verify cancellation of llog records async ========="
4998 TEST60_HEAD="test_60 run $RANDOM"
5000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5001 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5002 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5003 skip_env "missing subtest run-llog.sh" && return
5004 log "$TEST60_HEAD - from kernel mode"
5005 do_facet mgs sh run-llog.sh
5007 run_test 60a "llog sanity tests run from kernel module =========="
5009 test_60b() { # bug 6411
5010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5012 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5024 [[ $LLOG_COUNT -gt 50 ]] &&
5025 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5027 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5031 echo "create 5000 files"
5032 createmany -o $DIR/f60c- 5000
5033 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5034 lctl set_param fail_loc=0x80000137
5035 unlinkmany $DIR/f60c- 5000
5036 lctl set_param fail_loc=0
5038 run_test 60c "unlink file when mds full"
5041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5042 SAVEPRINTK=$(lctl get_param -n printk)
5044 # verify "lctl mark" is even working"
5045 MESSAGE="test message ID $RANDOM $$"
5046 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5047 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5049 lctl set_param printk=0 || error "set lnet.printk failed"
5050 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5051 MESSAGE="new test message ID $RANDOM $$"
5052 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5053 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5054 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5056 lctl set_param -n printk="$SAVEPRINTK"
5058 run_test 60d "test printk console message masking"
5061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5063 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5064 cancel_lru_locks osc
5065 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5068 run_test 61 "mmap() writes don't make sync hang ================"
5070 # bug 2330 - insufficient obd_match error checking causes LBUG
5072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5075 cancel_lru_locks osc
5076 lctl set_param fail_loc=0x405
5077 cat $f && error "cat succeeded, expect -EIO"
5078 lctl set_param fail_loc=0
5080 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5081 # match every page all of the time.
5082 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5084 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5085 # Though this test is irrelevant anymore, it helped to reveal some
5086 # other grant bugs (LU-4482), let's keep it.
5087 test_63a() { # was test_63
5088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5089 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5090 for i in `seq 10` ; do
5091 dd if=/dev/zero of=$DIR/f63 bs=8k &
5097 rm -f $DIR/f63 || true
5099 run_test 63a "Verify oig_wait interruption does not crash ======="
5101 # bug 2248 - async write errors didn't return to application on sync
5102 # bug 3677 - async write errors left page locked
5104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5106 lctl set_param debug=-1
5108 # ensure we have a grant to do async writes
5109 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5112 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5113 lctl set_param fail_loc=0x80000406
5114 $MULTIOP $DIR/$tfile Owy && \
5115 error "sync didn't return ENOMEM"
5116 sync; sleep 2; sync # do a real sync this time to flush page
5117 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5118 error "locked page left in cache after async error" || true
5121 run_test 63b "async write errors should be returned to fsync ==="
5124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5126 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5128 run_test 64a "verify filter grant calculations (in kernel) ====="
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5134 run_test 64b "check out-of-space detection on client ==========="
5137 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5139 run_test 64c "verify grant shrink ========================------"
5141 # bug 1414 - set/get directories' stripe info
5143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5144 test_mkdir -p $DIR/$tdir
5146 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5148 run_test 65a "directory with no stripe info ===================="
5151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5152 test_mkdir -p $DIR/$tdir
5153 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5156 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5158 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5162 if [[ $OSTCOUNT -gt 1 ]]; then
5163 test_mkdir -p $DIR/$tdir
5164 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5165 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5167 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5170 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5174 test_mkdir -p $DIR/$tdir
5175 if [[ $STRIPECOUNT -le 0 ]]; then
5177 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5178 #LOV_MAX_STRIPE_COUNT is 2000
5179 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5181 sc=$(($STRIPECOUNT - 1))
5183 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5184 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5185 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5186 error "lverify failed"
5188 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5192 test_mkdir -p $DIR/$tdir
5194 $SETSTRIPE $DIR/$tdir || error "setstripe"
5195 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5196 error "no stripe info failed"
5198 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5200 run_test 65e "directory setstripe defaults ======================="
5203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5204 test_mkdir -p $DIR/${tdir}f
5205 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5207 run_test 65f "dir setstripe permission (should return error) ==="
5210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5211 test_mkdir -p $DIR/$tdir
5212 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5214 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5215 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5216 error "delete default stripe failed"
5218 run_test 65g "directory setstripe -d ==========================="
5221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5222 test_mkdir -p $DIR/$tdir
5223 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5225 test_mkdir -p $DIR/$tdir/dd1
5226 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5227 error "stripe info inherit failed"
5229 run_test 65h "directory stripe info inherit ===================="
5231 test_65i() { # bug6367
5232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5233 $SETSTRIPE -S 65536 -c -1 $MOUNT
5235 run_test 65i "set non-default striping on root directory (bug 6367)="
5237 test_65ia() { # bug12836
5238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5239 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5241 run_test 65ia "getstripe on -1 default directory striping"
5243 test_65ib() { # bug12836
5244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5245 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5247 run_test 65ib "getstripe -v on -1 default directory striping"
5249 test_65ic() { # bug12836
5250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5251 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5253 run_test 65ic "new find on -1 default directory striping"
5255 test_65j() { # bug6367
5256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5258 # if we aren't already remounting for each test, do so for this test
5259 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5260 cleanup || error "failed to unmount"
5263 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5265 run_test 65j "set default striping on root directory (bug 6367)="
5267 test_65k() { # bug11679
5268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5269 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5270 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5272 echo "Check OST status: "
5273 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5274 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5276 for OSC in $MDS_OSCS; do
5277 echo $OSC "is activate"
5278 do_facet $SINGLEMDS lctl --device %$OSC activate
5282 for INACTIVE_OSC in $MDS_OSCS; do
5283 echo "Deactivate: " $INACTIVE_OSC
5284 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5285 for STRIPE_OSC in $MDS_OSCS; do
5286 OST=`osc_to_ost $STRIPE_OSC`
5287 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5288 awk -F: /$OST/'{ print $1 }' | head -n 1`
5290 [ -f $DIR/$tdir/$IDX ] && continue
5291 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5292 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5294 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5297 echo $INACTIVE_OSC "is Activate."
5298 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5301 run_test 65k "validate manual striping works properly with deactivated OSCs"
5303 test_65l() { # bug 12836
5304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5305 test_mkdir -p $DIR/$tdir/test_dir
5306 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5307 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5309 run_test 65l "lfs find on -1 stripe dir ========================"
5311 # bug 2543 - update blocks count on client
5313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5315 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5316 sync; sync_all_data; sync; sync_all_data
5317 cancel_lru_locks osc
5318 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5319 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5321 run_test 66 "update inode blocks count on client ==============="
5326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5328 if [ ! -z "$LLOOP" ]; then
5329 if swapon -s | grep -q $LLOOP; then
5330 swapoff $LLOOP || error "swapoff failed"
5333 $LCTL blockdev_detach $LLOOP || error "detach failed"
5337 if [ ! -z "$LLITELOOPLOAD" ]; then
5345 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5349 swapon -s | awk '($1 == "'$1'") { print $4 }'
5352 # test case for lloop driver, basic function
5354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5355 [ "$UID" != 0 ] && skip_env "must run as root" && return
5356 llite_lloop_enabled || \
5357 { skip_env "llite_lloop module disabled" && return; }
5359 trap cleanup_68 EXIT
5361 if ! module_loaded llite_lloop; then
5362 if load_module llite/llite_lloop; then
5365 skip_env "can't find module llite_lloop"
5370 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5371 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5372 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5374 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5375 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5379 run_test 68a "lloop driver - basic test ========================"
5381 # excercise swapping to lustre by adding a high priority swapfile entry
5382 # and then consuming memory until it is used.
5383 test_68b() { # was test_68
5384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5385 [ "$UID" != 0 ] && skip_env "must run as root" && return
5386 lctl get_param -n devices | grep -q obdfilter && \
5387 skip "local OST" && return
5389 grep -q llite_lloop /proc/modules
5390 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5392 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5393 skip "can't reliably test swap with TCP" && return
5395 MEMTOTAL=`meminfo MemTotal`
5396 NR_BLOCKS=$((MEMTOTAL>>8))
5397 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5399 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5400 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5403 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5405 trap cleanup_68 EXIT
5407 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5409 echo "before: `swapon -s | grep $LLOOP`"
5410 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5411 echo "after: `swapon -s | grep $LLOOP`"
5412 SWAPUSED=`swap_used $LLOOP`
5416 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5418 run_test 68b "support swapping to Lustre ========================"
5420 # bug5265, obdfilter oa2dentry return -ENOENT
5421 # #define OBD_FAIL_OST_ENOENT 0x217
5423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5424 remote_ost_nodsh && skip "remote OST with nodsh" && return
5427 $SETSTRIPE -c 1 -i 0 $f
5429 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5431 do_facet ost1 lctl set_param fail_loc=0x217
5432 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5433 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5435 do_facet ost1 lctl set_param fail_loc=0
5436 $DIRECTIO write $f 0 2 || error "write error"
5438 cancel_lru_locks osc
5439 $DIRECTIO read $f 0 1 || error "read error"
5441 do_facet ost1 lctl set_param fail_loc=0x217
5442 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5444 do_facet ost1 lctl set_param fail_loc=0
5447 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5450 test_mkdir -p $DIR/$tdir
5451 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5453 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5455 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5457 [ "$RUNAS_ID" = "$UID" ] &&
5458 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5460 # Check that testing environment is properly set up. Skip if not
5461 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5462 skip_env "User $RUNAS_ID does not exist - skipping"
5466 chmod 777 $DIR/$tfile
5467 chmod ug+s $DIR/$tfile
5468 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5469 error "$RUNAS dd $DIR/$tfile failed"
5470 # See if we are still setuid/sgid
5471 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5472 error "S/gid is not dropped on write"
5473 # Now test that MDS is updated too
5474 cancel_lru_locks mdc
5475 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5476 error "S/gid is not dropped on MDS"
5479 run_test 72a "Test that remove suid works properly (bug5695) ===="
5481 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5484 [ "$RUNAS_ID" = "$UID" ] && \
5485 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5486 [ "$RUNAS_ID" -eq 0 ] && \
5487 skip_env "RUNAS_ID = 0 -- skipping" && return
5489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5490 # Check that testing environment is properly set up. Skip if not
5491 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5492 skip_env "User $RUNAS_ID does not exist - skipping"
5495 touch $DIR/${tfile}-f{g,u}
5496 test_mkdir $DIR/${tfile}-dg
5497 test_mkdir $DIR/${tfile}-du
5498 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5499 chmod g+s $DIR/${tfile}-{f,d}g
5500 chmod u+s $DIR/${tfile}-{f,d}u
5501 for perm in 777 2777 4777; do
5502 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5503 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5504 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5505 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5509 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5511 # bug 3462 - multiple simultaneous MDC requests
5513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5514 test_mkdir $DIR/d73-1
5515 test_mkdir $DIR/d73-2
5516 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5519 lctl set_param fail_loc=0x80000129
5520 $MULTIOP $DIR/d73-1/f73-2 Oc &
5522 lctl set_param fail_loc=0
5524 $MULTIOP $DIR/d73-2/f73-3 Oc &
5528 wait $pid1 || return 1
5532 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5533 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5534 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5538 run_test 73 "multiple MDC requests (should not deadlock)"
5540 test_74a() { # bug 6149, 6184
5541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5542 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5544 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5545 # will spin in a tight reconnection loop
5547 $LCTL set_param fail_loc=0x8000030e
5548 # get any lock that won't be difficult - lookup works.
5550 $LCTL set_param fail_loc=0
5554 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5556 test_74b() { # bug 13310
5557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5558 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5560 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5561 # will spin in a tight reconnection loop
5562 $LCTL set_param fail_loc=0x8000030e
5563 # get a "difficult" lock
5565 $LCTL set_param fail_loc=0
5569 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5573 #define OBD_FAIL_LDLM_NEW_LOCK
5574 $LCTL set_param fail_loc=0x319
5575 touch $DIR/$tfile && error "touch successful"
5576 $LCTL set_param fail_loc=0
5579 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5582 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5585 get_inode_slab_tunables() {
5586 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5589 set_inode_slab_tunables() {
5590 echo "lustre_inode_cache $1" > /proc/slabinfo
5593 test_76() { # Now for bug 20433, added originally in bug 1443
5594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5595 local SLAB_SETTINGS=`get_inode_slab_tunables`
5596 local CPUS=`getconf _NPROCESSORS_ONLN`
5597 # we cannot set limit below 1 which means 1 inode in each
5598 # per-cpu cache is still allowed
5599 set_inode_slab_tunables "1 1 0"
5600 cancel_lru_locks osc
5601 BEFORE_INODES=$(num_inodes)
5602 echo "before inodes: $BEFORE_INODES"
5604 [ "$SLOW" = "no" ] && COUNT=100
5605 for i in $(seq $COUNT); do
5609 cancel_lru_locks osc
5610 AFTER_INODES=$(num_inodes)
5611 echo "after inodes: $AFTER_INODES"
5613 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5615 AFTER_INODES=$(num_inodes)
5617 echo "wait $wait seconds inodes: $AFTER_INODES"
5618 if [ $wait -gt 30 ]; then
5619 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5622 set_inode_slab_tunables "$SLAB_SETTINGS"
5624 run_test 76 "confirm clients recycle inodes properly ===="
5630 # Note: in sptlrpc modes which enable its own bulk checksum, the
5631 # original crc32_le bulk checksum will be automatically disabled,
5632 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5633 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5634 # In this case set_checksums() will not be no-op, because sptlrpc
5635 # bulk checksum will be enabled all through the test.
5637 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5638 lctl set_param -n osc.*.checksums $1
5642 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5643 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5644 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5645 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5648 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5649 log "set checksum type to $1"
5652 F77_TMP=$TMP/f77-temp
5655 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5656 error "error writing to $F77_TMP"
5659 test_77a() { # bug 10889
5660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5661 $GSS && skip "could not run with gss" && return
5662 [ ! -f $F77_TMP ] && setup_f77
5664 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5668 run_test 77a "normal checksum read/write operation"
5670 test_77b() { # bug 10889
5671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5672 $GSS && skip "could not run with gss" && return
5673 [ ! -f $F77_TMP ] && setup_f77
5674 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5675 $LCTL set_param fail_loc=0x80000409
5678 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5679 error "dd error: $?"
5680 $LCTL set_param fail_loc=0
5682 for algo in $CKSUM_TYPES; do
5683 cancel_lru_locks osc
5684 set_checksum_type $algo
5685 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5686 $LCTL set_param fail_loc=0x80000408
5687 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5688 $LCTL set_param fail_loc=0
5691 set_checksum_type $ORIG_CSUM_TYPE
5694 run_test 77b "checksum error on client write, read"
5696 test_77d() { # bug 10889
5697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5698 $GSS && skip "could not run with gss" && return
5699 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5700 $LCTL set_param fail_loc=0x80000409
5702 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5703 error "direct write: rc=$?"
5704 $LCTL set_param fail_loc=0
5707 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5708 $LCTL set_param fail_loc=0x80000408
5710 cancel_lru_locks osc
5711 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5712 error "direct read: rc=$?"
5713 $LCTL set_param fail_loc=0
5716 run_test 77d "checksum error on OST direct write, read"
5718 test_77f() { # bug 10889
5719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5720 $GSS && skip "could not run with gss" && return
5722 for algo in $CKSUM_TYPES; do
5723 cancel_lru_locks osc
5724 set_checksum_type $algo
5725 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5726 $LCTL set_param fail_loc=0x409
5727 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5728 error "direct write succeeded"
5729 $LCTL set_param fail_loc=0
5731 set_checksum_type $ORIG_CSUM_TYPE
5734 run_test 77f "repeat checksum error on write (expect error)"
5736 test_77g() { # bug 10889
5737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5738 $GSS && skip "could not run with gss" && return
5739 remote_ost_nodsh && skip "remote OST with nodsh" && return
5741 [ ! -f $F77_TMP ] && setup_f77
5743 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5744 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5745 do_facet ost1 lctl set_param fail_loc=0x8000021a
5747 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5748 error "write error: rc=$?"
5749 do_facet ost1 lctl set_param fail_loc=0
5752 cancel_lru_locks osc
5753 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5754 do_facet ost1 lctl set_param fail_loc=0x8000021b
5756 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5757 do_facet ost1 lctl set_param fail_loc=0
5760 run_test 77g "checksum error on OST write, read"
5762 test_77i() { # bug 13805
5763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5764 $GSS && skip "could not run with gss" && return
5765 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5766 lctl set_param fail_loc=0x40b
5767 remount_client $MOUNT
5768 lctl set_param fail_loc=0
5769 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5770 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5771 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5772 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5774 remount_client $MOUNT
5776 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5778 test_77j() { # bug 13805
5779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5780 $GSS && skip "could not run with gss" && return
5781 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5782 lctl set_param fail_loc=0x40c
5783 remount_client $MOUNT
5784 lctl set_param fail_loc=0
5785 sleep 2 # wait async osc connect to finish
5786 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5787 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5788 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5789 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5791 remount_client $MOUNT
5793 run_test 77j "client only supporting ADLER32"
5795 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5799 test_78() { # bug 10901
5800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5801 remote_ost || { skip_env "local OST" && return; }
5804 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5805 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5806 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5807 echo "MemTotal: $MEMTOTAL"
5809 # reserve 256MB of memory for the kernel and other running processes,
5810 # and then take 1/2 of the remaining memory for the read/write buffers.
5811 if [ $MEMTOTAL -gt 512 ] ;then
5812 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5814 # for those poor memory-starved high-end clusters...
5815 MEMTOTAL=$((MEMTOTAL / 2))
5817 echo "Mem to use for directio: $MEMTOTAL"
5819 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5820 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5821 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5822 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5824 echo "Smallest OST: $SMALLESTOST"
5825 [[ $SMALLESTOST -lt 10240 ]] &&
5826 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5828 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5829 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5831 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5832 echo "File size: $F78SIZE"
5833 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5834 for i in $(seq 1 $NSEQ); do
5835 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5836 echo directIO rdwr round $i of $NSEQ
5837 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5842 run_test 78 "handle large O_DIRECT writes correctly ============"
5844 test_79() { # bug 12743
5845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5846 wait_delete_completed
5848 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5849 BKFREE=$(calc_osc_kbytes kbytesfree)
5850 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5852 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5853 DFTOTAL=`echo $STRING | cut -d, -f1`
5854 DFUSED=`echo $STRING | cut -d, -f2`
5855 DFAVAIL=`echo $STRING | cut -d, -f3`
5856 DFFREE=$(($DFTOTAL - $DFUSED))
5858 ALLOWANCE=$((64 * $OSTCOUNT))
5860 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5861 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5862 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5864 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5865 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5866 error "df free($DFFREE) mismatch OST free($BKFREE)"
5868 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5869 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5870 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5873 run_test 79 "df report consistency check ======================="
5875 test_80() { # bug 10718
5876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5877 # relax strong synchronous semantics for slow backends like ZFS
5878 local soc="obdfilter.*.sync_on_lock_cancel"
5879 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5881 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5882 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5883 facet_active_host $host; done | sort -u)
5884 do_nodes $hosts lctl set_param $soc=never
5887 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5889 local BEFORE=`date +%s`
5890 cancel_lru_locks osc
5891 local AFTER=`date +%s`
5892 local DIFF=$((AFTER-BEFORE))
5893 if [ $DIFF -gt 1 ] ; then
5894 error "elapsed for 1M@1T = $DIFF"
5897 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5901 run_test 80 "Page eviction is equally fast at high offsets too ===="
5903 test_81a() { # LU-456
5904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5905 remote_ost_nodsh && skip "remote OST with nodsh" && return
5906 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5907 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5908 do_facet ost1 lctl set_param fail_loc=0x80000228
5910 # write should trigger a retry and success
5911 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5912 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5914 if [ $RC -ne 0 ] ; then
5915 error "write should success, but failed for $RC"
5918 run_test 81a "OST should retry write when get -ENOSPC ==============="
5920 test_81b() { # LU-456
5921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5922 remote_ost_nodsh && skip "remote OST with nodsh" && return
5923 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5924 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5925 do_facet ost1 lctl set_param fail_loc=0x228
5927 # write should retry several times and return -ENOSPC finally
5928 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5929 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5932 if [ $RC -ne $ENOSPC ] ; then
5933 error "dd should fail for -ENOSPC, but succeed."
5936 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5938 test_82() { # LU-1031
5939 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5943 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5945 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5947 kill -USR1 $MULTIPID2
5949 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5950 error "First grouplock does not block second one"
5952 echo "Second grouplock blocks first one"
5954 kill -USR1 $MULTIPID1
5958 run_test 82 "Basic grouplock test ==============================="
5961 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5963 test_mkdir -p $DIR/d99cvsroot
5964 chown $RUNAS_ID $DIR/d99cvsroot
5965 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5968 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5971 run_test 99a "cvs init ========================================="
5974 [ -z "$(which cvs 2>/dev/null)" ] &&
5975 skip_env "could not find cvs" && return
5976 [ ! -d $DIR/d99cvsroot ] && test_99a
5978 # some versions of cvs import exit(1) when asked to import links or
5979 # files they can't read. ignore those files.
5980 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5981 ! -perm +4 -printf '-I %f\n')
5982 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5983 d99reposname vtag rtag
5985 run_test 99b "cvs import ======================================="
5988 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5989 [ ! -d $DIR/d99cvsroot ] && test_99b
5991 test_mkdir -p $DIR/d99reposname
5992 chown $RUNAS_ID $DIR/d99reposname
5993 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5995 run_test 99c "cvs checkout ====================================="
5998 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5999 [ ! -d $DIR/d99cvsroot ] && test_99c
6000 cd $DIR/d99reposname
6002 $RUNAS cvs add -m 'addmsg' foo99
6004 run_test 99d "cvs add =========================================="
6007 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6008 [ ! -d $DIR/d99cvsroot ] && test_99c
6009 cd $DIR/d99reposname
6012 run_test 99e "cvs update ======================================="
6015 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6016 [ ! -d $DIR/d99cvsroot ] && test_99d
6017 cd $DIR/d99reposname
6018 $RUNAS cvs commit -m 'nomsg' foo99
6019 rm -fr $DIR/d99cvsroot
6021 run_test 99f "cvs commit ======================================="
6024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6025 [ "$NETTYPE" = tcp ] || \
6026 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6029 remote_ost_nodsh && skip "remote OST with nodsh" && return
6030 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6032 { skip "useless for local single node setup" && return; }
6034 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6035 [ "$PROT" != "tcp" ] && continue
6036 RPORT=$(echo $REMOTE | cut -d: -f2)
6037 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6040 LPORT=`echo $LOCAL | cut -d: -f2`
6041 if [ $LPORT -ge 1024 ]; then
6042 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6044 error_exit "local: $LPORT > 1024, remote: $RPORT"
6047 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6049 run_test 100 "check local port using privileged port ==========="
6051 function get_named_value()
6060 echo $line | sed "s/^$tag[ ]*//"
6067 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6068 awk '/^max_cached_mb/ { print $2 }')
6071 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6077 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6081 local cache_limit=32
6083 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6084 trap cleanup_101a EXIT
6085 $LCTL set_param -n llite.*.read_ahead_stats 0
6086 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6089 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6091 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6092 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6095 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6096 get_named_value 'read but discarded' | cut -d" " -f1); do
6097 discard=$(($discard + $s))
6101 if [[ $(($discard * 10)) -gt $nreads ]]; then
6102 $LCTL get_param osc.*-osc*.rpc_stats
6103 $LCTL get_param llite.*.read_ahead_stats
6104 error "too many ($discard) discarded pages"
6106 rm -f $DIR/$tfile || true
6108 run_test 101a "check read-ahead for random reads ================"
6111 test_mkdir -p $DIR/$tdir
6112 local STRIPE_SIZE=$1
6113 local FILE_LENGTH=$2
6116 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6118 local list=$(comma_list $(osts_nodes))
6119 set_osd_param $list '' read_cache_enable 0
6120 set_osd_param $list '' writethrough_cache_enable 0
6122 trap cleanup_test101bc EXIT
6123 # prepare the read-ahead file
6124 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6126 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6127 count=$FILE_SIZE_MB 2> /dev/null
6131 cleanup_test101bc() {
6136 local list=$(comma_list $(osts_nodes))
6137 set_osd_param $list '' read_cache_enable 1
6138 set_osd_param $list '' writethrough_cache_enable 1
6142 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6147 local STRIPE_SIZE=$2
6148 local FILE_LENGTH=$3
6149 local RA_INC=1048576
6150 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6151 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6152 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6153 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6154 get_named_value 'read but discarded' |
6155 cut -d" " -f1 | calc_total)
6156 if [[ $DISCARD -gt $discard_limit ]]; then
6157 $LCTL get_param llite.*.read_ahead_stats
6158 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6160 echo "Read-ahead success for size ${READ_SIZE}"
6165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6166 [[ $OSTCOUNT -lt 2 ]] &&
6167 skip_env "skipping stride IO stride-ahead test" && return
6168 local STRIPE_SIZE=1048576
6169 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6170 if [ $SLOW == "yes" ]; then
6171 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6173 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6176 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6178 # prepare the read-ahead file
6179 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6180 cancel_lru_locks osc
6181 for BIDX in 2 4 8 16 32 64 128 256
6183 local BSIZE=$((BIDX*4096))
6184 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6185 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6186 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6187 $LCTL set_param -n llite.*.read_ahead_stats 0
6188 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6189 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6190 cancel_lru_locks osc
6191 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6196 run_test 101b "check stride-io mode read-ahead ================="
6199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6200 local STRIPE_SIZE=1048576
6201 local FILE_LENGTH=$((STRIPE_SIZE*100))
6205 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6207 cancel_lru_locks osc
6208 $LCTL set_param osc.*.rpc_stats 0
6209 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6210 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6211 local stats=$($LCTL get_param -n $osc_rpc_stats)
6212 local lines=$(echo "$stats" | awk 'END {print NR;}')
6215 if [ $lines -le 20 ]; then
6218 for size in 1 2 4 8; do
6219 local rpc=$(echo "$stats" |
6220 awk '($1 == "'$size':") {print $2; exit; }')
6222 error "Small $((size*4))k read IO $rpc !"
6224 echo "$osc_rpc_stats check passed!"
6229 run_test 101c "check stripe_size aligned read-ahead ================="
6232 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6233 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6238 local file=$DIR/$tfile
6239 local sz_MB=${FILESIZE_101d:-500}
6240 local ra_MB=${READAHEAD_MB:-40}
6242 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6243 [ $free_MB -lt $sz_MB ] &&
6244 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6246 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6247 $SETSTRIPE -c -1 $file || error "setstripe failed"
6249 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6250 echo Cancel LRU locks on lustre client to flush the client cache
6251 cancel_lru_locks osc
6253 echo Disable read-ahead
6254 local old_READAHEAD=$(set_read_ahead 0)
6256 echo Reading the test file $file with read-ahead disabled
6257 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6259 echo Cancel LRU locks on lustre client to flush the client cache
6260 cancel_lru_locks osc
6261 echo Enable read-ahead with ${ra_MB}MB
6262 set_read_ahead $ra_MB
6264 echo Reading the test file $file with read-ahead enabled
6265 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6267 echo "read-ahead disabled time read $raOFF"
6268 echo "read-ahead enabled time read $raON"
6270 set_read_ahead $old_READAHEAD
6272 wait_delete_completed
6274 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6275 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6277 run_test 101d "file read with and without read-ahead enabled"
6280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6281 local file=$DIR/$tfile
6282 local size_KB=500 #KB
6286 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6287 local need_KB=$((count * size_KB))
6288 [[ $free_KB -le $need_KB ]] &&
6289 skip_env "Need free space $need_KB, have $free_KB" && return
6291 echo "Creating $count ${size_KB}K test files"
6292 for ((i = 0; i < $count; i++)); do
6293 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6296 echo "Cancel LRU locks on lustre client to flush the client cache"
6297 cancel_lru_locks osc
6299 echo "Reset readahead stats"
6300 $LCTL set_param -n llite.*.read_ahead_stats 0
6302 for ((i = 0; i < $count; i++)); do
6303 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6306 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6307 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6309 for ((i = 0; i < $count; i++)); do
6310 rm -rf $file.$i 2>/dev/null
6313 #10000 means 20% reads are missing in readahead
6314 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6316 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6318 cleanup_test101f() {
6320 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6321 rm -rf $DIR/$tfile 2>/dev/null
6325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6326 local file=$DIR/$tfile
6329 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6330 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6331 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6332 trap cleanup_test101f EXIT
6334 echo Cancel LRU locks on lustre client to flush the client cache
6335 cancel_lru_locks osc
6337 echo Reset readahead stats
6338 $LCTL set_param -n llite.*.read_ahead_stats 0
6339 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6340 # readahead should read in 2M file on second read, so only miss
6342 echo Random 4K reads on 2M file for 1000 times
6343 $READS -f $file -s 2097152 -b 4096 -n $nreads
6345 echo checking missing pages
6346 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6347 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6349 [ $miss -lt 3 ] || error "misses too much pages!"
6352 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6355 test_mkdir -p $DIR/$tdir
6356 chown $RUNAS_ID $DIR/$tdir
6359 STRIPE_COUNT=$OSTCOUNT
6360 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6362 trap cleanup_test102 EXIT
6364 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6366 for num in 1 2 3 4; do
6367 for count in $(seq 1 $STRIPE_COUNT); do
6368 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6369 local size=`expr $STRIPE_SIZE \* $num`
6370 local file=file"$num-$idx-$count"
6371 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6377 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6383 rm -rf $DIR/d0.sanity/d102
6387 local testfile=$DIR/$tfile
6391 [ "$UID" != 0 ] && skip_env "must run as root" && return
6392 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6393 skip_env "must have user_xattr" && return
6395 [ -z "$(which setfattr 2>/dev/null)" ] &&
6396 skip_env "could not find setfattr" && return
6398 echo "set/get xattr..."
6399 setfattr -n trusted.name1 -v value1 $testfile ||
6400 error "setfattr -n trusted.name1=value1 $testfile failed"
6401 getfattr -n trusted.name1 $testfile 2> /dev/null |
6402 grep "trusted.name1=.value1" ||
6403 error "$testfile missing trusted.name1=value1"
6405 setfattr -n user.author1 -v author1 $testfile ||
6406 error "setfattr -n user.author1=author1 $testfile failed"
6407 getfattr -n user.author1 $testfile 2> /dev/null |
6408 grep "user.author1=.author1" ||
6409 error "$testfile missing trusted.author1=author1"
6412 setfattr -n trusted.name2 -v value2 $testfile ||
6413 error "$testfile unable to set trusted.name2"
6414 setfattr -n trusted.name3 -v value3 $testfile ||
6415 error "$testfile unable to set trusted.name3"
6416 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6417 grep "trusted.name" | wc -l) -eq 3 ] ||
6418 error "$testfile missing 3 trusted.name xattrs"
6420 setfattr -n user.author2 -v author2 $testfile ||
6421 error "$testfile unable to set user.author2"
6422 setfattr -n user.author3 -v author3 $testfile ||
6423 error "$testfile unable to set user.author3"
6424 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6425 grep "user.author" | wc -l) -eq 3 ] ||
6426 error "$testfile missing 3 user.author xattrs"
6428 echo "remove xattr..."
6429 setfattr -x trusted.name1 $testfile ||
6430 error "$testfile error deleting trusted.name1"
6431 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6432 error "$testfile did not delete trusted.name1 xattr"
6434 setfattr -x user.author1 $testfile ||
6435 error "$testfile error deleting user.author1"
6436 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6437 error "$testfile did not delete trusted.name1 xattr"
6439 # b10667: setting lustre special xattr be silently discarded
6440 echo "set lustre special xattr ..."
6441 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6442 error "$testfile allowed setting trusted.lov"
6444 run_test 102a "user xattr test =================================="
6447 [ -z "$(which setfattr 2>/dev/null)" ] &&
6448 skip_env "could not find setfattr" && return
6450 # b10930: get/set/list trusted.lov xattr
6451 echo "get/set/list trusted.lov xattr ..."
6452 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6453 local testfile=$DIR/$tfile
6454 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6455 error "setstripe failed"
6456 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6457 error "getstripe failed"
6458 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6459 error "can't get trusted.lov from $testfile"
6461 local testfile2=${testfile}2
6462 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6463 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6466 setfattr -n trusted.lov -v $value $testfile2
6467 local stripe_size=$($GETSTRIPE -S $testfile2)
6468 local stripe_count=$($GETSTRIPE -c $testfile2)
6469 [[ $stripe_size -eq 65536 ]] ||
6470 error "stripe size $stripe_size != 65536"
6471 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6472 error "stripe count $stripe_count != $STRIPECOUNT"
6475 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6478 [ -z "$(which setfattr 2>/dev/null)" ] &&
6479 skip_env "could not find setfattr" && return
6481 # b10930: get/set/list lustre.lov xattr
6482 echo "get/set/list lustre.lov xattr ..."
6483 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6484 test_mkdir -p $DIR/$tdir
6485 chown $RUNAS_ID $DIR/$tdir
6486 local testfile=$DIR/$tdir/$tfile
6487 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6488 error "setstripe failed"
6489 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6490 error "getstripe failed"
6491 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6492 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6494 local testfile2=${testfile}2
6495 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6496 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6498 $RUNAS $MCREATE $testfile2
6499 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6500 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6501 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6502 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6503 [ $stripe_count -eq $STRIPECOUNT ] ||
6504 error "stripe count $stripe_count != $STRIPECOUNT"
6506 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6508 compare_stripe_info1() {
6509 local stripe_index_all_zero=true
6511 for num in 1 2 3 4; do
6512 for count in $(seq 1 $STRIPE_COUNT); do
6513 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6514 local size=$((STRIPE_SIZE * num))
6515 local file=file"$num-$offset-$count"
6516 stripe_size=$(lfs getstripe -S $PWD/$file)
6517 [[ $stripe_size -ne $size ]] &&
6518 error "$file: size $stripe_size != $size"
6519 stripe_count=$(lfs getstripe -c $PWD/$file)
6520 # allow fewer stripes to be created, ORI-601
6521 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6522 error "$file: count $stripe_count != $count"
6523 stripe_index=$(lfs getstripe -i $PWD/$file)
6524 [[ $stripe_index -ne 0 ]] &&
6525 stripe_index_all_zero=false
6529 $stripe_index_all_zero &&
6530 error "all files are being extracted starting from OST index 0"
6535 [ -n "$(which tar 2>/dev/null)" ] &&
6536 strings $(which tar) | grep -q "lustre" && echo tar
6540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6541 # b10930: tar test for trusted.lov xattr
6542 TAR=$(find_lustre_tar)
6543 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6544 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6546 test_mkdir -p $DIR/d102d
6547 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6549 compare_stripe_info1
6551 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6555 # b10930: tar test for trusted.lov xattr
6556 TAR=$(find_lustre_tar)
6557 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6558 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6560 test_mkdir -p $DIR/d102f
6562 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6564 compare_stripe_info1
6566 run_test 102f "tar copy files, not keep osts ==========="
6569 local xsize=${1:-1024} # in bytes
6570 local file=$DIR/$tfile
6572 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6573 skip "must have user_xattr" && return 0
6574 [ -z "$(which setfattr 2>/dev/null)" ] &&
6575 skip_env "could not find setfattr" && return 0
6576 [ -z "$(which getfattr 2>/dev/null)" ] &&
6577 skip_env "could not find getfattr" && return 0
6581 local value="$(generate_string $xsize)"
6583 local xbig=trusted.big
6584 log "save $xbig on $file"
6585 setfattr -n $xbig -v $value $file ||
6586 error "saving $xbig on $file failed"
6588 local orig=$(get_xattr_value $xbig $file)
6589 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6591 local xsml=trusted.sml
6592 log "save $xsml on $file"
6593 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6595 local new=$(get_xattr_value $xbig $file)
6596 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6598 log "grow $xsml on $file"
6599 setfattr -n $xsml -v "$value" $file ||
6600 error "growing $xsml on $file failed"
6602 new=$(get_xattr_value $xbig $file)
6603 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6604 log "$xbig still valid after growing $xsml"
6609 test_102h() { # bug 15777
6612 run_test 102h "grow xattr from inside inode to external block"
6615 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6616 grow_xattr $(max_xattr_size)
6618 run_test 102ha "grow xattr from inside inode to external inode"
6620 test_102i() { # bug 17038
6621 [ -z "$(which getfattr 2>/dev/null)" ] &&
6622 skip "could not find getfattr" && return
6624 ln -s $DIR/$tfile $DIR/${tfile}link
6625 getfattr -n trusted.lov $DIR/$tfile ||
6626 error "lgetxattr on $DIR/$tfile failed"
6627 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6628 grep -i "no such attr" ||
6629 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6630 rm -f $DIR/$tfile $DIR/${tfile}link
6632 run_test 102i "lgetxattr test on symbolic link ============"
6635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6636 TAR=$(find_lustre_tar)
6637 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6638 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6639 setup_test102 "$RUNAS"
6640 test_mkdir -p $DIR/d102j
6641 chown $RUNAS_ID $DIR/d102j
6642 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6644 compare_stripe_info1 "$RUNAS"
6646 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6649 [ -z "$(which setfattr 2>/dev/null)" ] &&
6650 skip "could not find setfattr" && return
6652 # b22187 just check that does not crash for regular file.
6653 setfattr -n trusted.lov $DIR/$tfile
6654 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6655 local test_kdir=$DIR/d102k
6656 test_mkdir $test_kdir
6657 local default_size=`$GETSTRIPE -S $test_kdir`
6658 local default_count=`$GETSTRIPE -c $test_kdir`
6659 local default_offset=`$GETSTRIPE -i $test_kdir`
6660 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6661 error 'dir setstripe failed'
6662 setfattr -n trusted.lov $test_kdir
6663 local stripe_size=`$GETSTRIPE -S $test_kdir`
6664 local stripe_count=`$GETSTRIPE -c $test_kdir`
6665 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6666 [ $stripe_size -eq $default_size ] ||
6667 error "stripe size $stripe_size != $default_size"
6668 [ $stripe_count -eq $default_count ] ||
6669 error "stripe count $stripe_count != $default_count"
6670 [ $stripe_offset -eq $default_offset ] ||
6671 error "stripe offset $stripe_offset != $default_offset"
6672 rm -rf $DIR/$tfile $test_kdir
6674 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6677 [ -z "$(which getfattr 2>/dev/null)" ] &&
6678 skip "could not find getfattr" && return
6680 # LU-532 trusted. xattr is invisible to non-root
6681 local testfile=$DIR/$tfile
6685 echo "listxattr as user..."
6686 chown $RUNAS_ID $testfile
6687 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6688 grep -q "trusted" &&
6689 error "$testfile trusted xattrs are user visible"
6693 run_test 102l "listxattr size test =================================="
6695 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6696 local path=$DIR/$tfile
6699 listxattr_size_check $path || error "listattr_size_check $path failed"
6701 run_test 102m "Ensure listxattr fails on small bufffer ========"
6705 getxattr() { # getxattr path name
6706 # Return the base64 encoding of the value of xattr name on path.
6710 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6712 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6714 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6716 getfattr --absolute-names --encoding=base64 --name=$name $path |
6717 awk -F= -v name=$name '$1 == name {
6718 print substr($0, index($0, "=") + 1);
6722 test_102n() { # LU-4101 mdt: protect internal xattrs
6723 local file0=$DIR/$tfile.0
6724 local file1=$DIR/$tfile.1
6725 local xattr0=$TMP/$tfile.0
6726 local xattr1=$TMP/$tfile.1
6730 [ -z "$(which setfattr 2>/dev/null)" ] &&
6731 skip "could not find setfattr" && return
6733 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6735 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6739 rm -rf $file0 $file1 $xattr0 $xattr1
6742 # Get 'before' xattrs of $file1.
6743 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6745 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6746 # Try to copy xattr from $file0 to $file1.
6747 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6749 setfattr --name=trusted.$name --value="$value" $file1 ||
6750 error "setxattr 'trusted.$name' failed"
6752 # Try to set a garbage xattr.
6753 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6755 setfattr --name=trusted.$name --value="$value" $file1 ||
6756 error "setxattr 'trusted.$name' failed"
6758 # Try to remove the xattr from $file1. We don't care if this
6759 # appears to succeed or fail, we just don't want there to be
6760 # any changes or crashes.
6761 setfattr --remove=$trusted.$name $file1 2> /dev/null
6764 # Get 'after' xattrs of file1.
6765 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6767 if ! diff $xattr0 $xattr1; then
6768 error "before and after xattrs of '$file1' differ"
6771 rm -rf $file0 $file1 $xattr0 $xattr1
6775 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6777 test_102p() { # LU-4703 setxattr did not check ownership
6778 local testfile=$DIR/$tfile
6780 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6781 skip "MDS needs to be at least 2.5.56" && return
6785 echo "setfacl as user..."
6786 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6787 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6789 echo "setfattr as user..."
6790 setfacl -m "u:$RUNAS_ID:---" $testfile
6791 $RUNAS setfattr -x system.posix_acl_access $testfile
6792 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6794 run_test 102p "check setxattr(2) correctly fails without permission"
6798 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6803 [ "$UID" != 0 ] && skip_env "must run as root" && return
6804 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6805 skip "must have acl enabled" && return
6806 [ -z "$(which setfacl 2>/dev/null)" ] &&
6807 skip_env "could not find setfacl" && return
6808 $GSS && skip "could not run under gss" && return
6810 declare -a identity_old
6812 for num in $(seq $MDSCOUNT); do
6813 switch_identity $num true || identity_old[$num]=$?
6820 echo "performing cp ..."
6821 run_acl_subtest cp || error "run_acl_subtest cp failed"
6822 echo "performing getfacl-noacl..."
6823 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6824 echo "performing misc..."
6825 run_acl_subtest misc || error "misc test failed"
6826 echo "performing permissions..."
6827 run_acl_subtest permissions || error "permissions failed"
6828 echo "performing setfacl..."
6829 run_acl_subtest setfacl || error "setfacl test failed"
6831 # inheritance test got from HP
6832 echo "performing inheritance..."
6833 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6834 chmod +x make-tree || error "chmod +x failed"
6835 run_acl_subtest inheritance || error "inheritance test failed"
6838 echo "LU-974 ignore umask when acl is enabled..."
6839 run_acl_subtest 974 || error "LU-974 umask test failed"
6840 if [ $MDSCOUNT -ge 2 ]; then
6841 run_acl_subtest 974_remote ||
6842 error "LU-974 umask test failed under remote dir"
6845 echo "LU-2561 newly created file is same size as directory..."
6846 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6847 run_acl_subtest 2561 || error "LU-2561 test failed"
6849 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6852 run_acl_subtest 4924 || error "LU-4924 test failed"
6857 for num in $(seq $MDSCOUNT); do
6858 if [ "${identity_old[$num]}" = 1 ]; then
6859 switch_identity $num false || identity_old[$num]=$?
6863 run_test 103 "acl test ========================================="
6866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6868 lfs df || error "lfs df failed"
6869 lfs df -ih || error "lfs df -ih failed"
6870 lfs df -h $DIR || error "lfs df -h $DIR failed"
6871 lfs df -i $DIR || error "lfs df -i $DIR failed"
6872 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6873 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6875 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6876 lctl --device %$OSC deactivate
6877 lfs df || error "lfs df with deactivated OSC failed"
6878 lctl --device %$OSC activate
6879 # wait the osc back to normal
6880 wait_osc_import_state client ost FULL
6882 lfs df || error "lfs df with reactivated OSC failed"
6885 run_test 104a "lfs df [-ih] [path] test ========================="
6888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6889 [ $RUNAS_ID -eq $UID ] &&
6890 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6892 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6893 grep "Permission denied" | wc -l)))
6894 if [ $denied_cnt -ne 0 ]; then
6895 error "lfs check servers test failed"
6898 run_test 104b "$RUNAS lfs check servers test ===================="
6901 # doesn't work on 2.4 kernels
6903 if $(flock_is_enabled); then
6904 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6906 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6910 run_test 105a "flock when mounted without -o flock test ========"
6914 if $(flock_is_enabled); then
6915 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6917 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6921 run_test 105b "fcntl when mounted without -o flock test ========"
6925 if $(flock_is_enabled); then
6926 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6928 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6932 run_test 105c "lockf when mounted without -o flock test ========"
6934 test_105d() { # bug 15924
6935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6936 test_mkdir -p $DIR/$tdir
6937 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6938 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6939 $LCTL set_param fail_loc=0x80000315
6940 flocks_test 2 $DIR/$tdir
6942 run_test 105d "flock race (should not freeze) ========"
6944 test_105e() { # bug 22660 && 22040
6945 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6947 flocks_test 3 $DIR/$tfile
6949 run_test 105e "Two conflicting flocks from same process ======="
6951 test_106() { #bug 10921
6952 test_mkdir -p $DIR/$tdir
6953 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6954 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6956 run_test 106 "attempt exec of dir followed by chown of that dir"
6959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6966 local save_pattern=$(sysctl -n kernel.core_pattern)
6967 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6968 sysctl -w kernel.core_pattern=$file
6969 sysctl -w kernel.core_uses_pid=0
6977 kill -s 11 $SLEEPPID
6979 if [ -e $file ]; then
6980 size=`stat -c%s $file`
6981 [ $size -eq 0 ] && error "Fail to create core file $file"
6983 error "Fail to create core file $file"
6986 sysctl -w kernel.core_pattern=$save_pattern
6987 sysctl -w kernel.core_uses_pid=$save_uses_pid
6990 run_test 107 "Coredump on SIG"
6993 test_mkdir -p $DIR/$tdir
6994 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6995 error "mkdir with 255 char failed"
6996 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6997 error "mkdir with 256 char should fail, but did not"
6998 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6999 error "create with 255 char failed"
7000 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7001 error "create with 256 char should fail, but did not"
7006 run_test 110 "filename length checking"
7009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7010 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7011 tail -1 | cut -c11-20)
7012 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7013 echo "Starting with $OSTIO_pre threads"
7016 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7017 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7018 echo "$NUMTEST creates/unlinks"
7019 test_mkdir -p $DIR/$tdir
7020 createmany -o $DIR/$tdir/$tfile $NUMTEST
7021 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7023 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7024 tail -1 | cut -c11-20)
7026 # don't return an error
7027 [ $OSTIO_post == $OSTIO_pre ] && echo \
7028 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7029 echo "This may be fine, depending on what ran before this test" &&
7030 echo "and how fast this system is." && return
7032 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7034 run_test 115 "verify dynamic thread creation===================="
7037 wait_delete_completed
7038 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7039 echo OST kbytes available: ${AVAIL[@]}
7040 MAXI=0; MAXV=${AVAIL[0]}
7041 MINI=0; MINV=${AVAIL[0]}
7042 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7043 #echo OST $i: ${AVAIL[i]}kb
7044 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7045 MAXV=${AVAIL[i]}; MAXI=$i
7047 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7048 MINV=${AVAIL[i]}; MINI=$i
7051 echo Min free space: OST $MINI: $MINV
7052 echo Max free space: OST $MAXI: $MAXV
7055 test_116a() { # was previously test_116()
7056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7057 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7059 echo -n "Free space priority "
7060 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7065 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7066 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7068 trap simple_cleanup_common EXIT
7071 # Check if we need to generate uneven OSTs
7072 test_mkdir -p $DIR/$tdir/OST${MINI}
7073 local FILL=$(($MINV / 4))
7074 local DIFF=$(($MAXV - $MINV))
7075 local DIFF2=$(($DIFF * 100 / $MINV))
7077 local threshold=$(do_facet $SINGLEMDS \
7078 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7079 threshold=${threshold%%%}
7080 echo -n "Check for uneven OSTs: "
7081 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7083 if [[ $DIFF2 -gt $threshold ]]; then
7085 echo "Don't need to fill OST$MINI"
7087 # generate uneven OSTs. Write 2% over the QOS threshold value
7089 DIFF=$(($threshold - $DIFF2 + 2))
7090 DIFF2=$(( ($MINV * $DIFF)/100 ))
7091 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7092 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7093 error "setstripe failed"
7094 DIFF=$(($DIFF2 / 2048))
7096 while [ $i -lt $DIFF ]; do
7098 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7099 bs=2M count=1 2>/dev/null
7108 DIFF=$(($MAXV - $MINV))
7109 DIFF2=$(($DIFF * 100 / $MINV))
7110 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7111 if [[ $DIFF2 -gt $threshold ]]; then
7114 echo "failed - QOS mode won't be used"
7115 skip "QOS imbalance criteria not met"
7116 simple_cleanup_common
7120 MINI1=$MINI; MINV1=$MINV
7121 MAXI1=$MAXI; MAXV1=$MAXV
7123 # now fill using QOS
7124 $SETSTRIPE -c 1 $DIR/$tdir
7125 FILL=$(($FILL / 200))
7126 if [ $FILL -gt 600 ]; then
7129 echo "writing $FILL files to QOS-assigned OSTs"
7131 while [ $i -lt $FILL ]; do
7133 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7137 echo "wrote $i 200k files"
7141 echo "Note: free space may not be updated, so measurements might be off"
7143 DIFF2=$(($MAXV - $MINV))
7144 echo "free space delta: orig $DIFF final $DIFF2"
7145 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7146 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7147 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7148 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7149 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7150 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7152 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7154 # Figure out which files were written where
7155 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7156 awk '/'$MINI1': / {print $2; exit}')
7158 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7159 echo "$MINC files created on smaller OST $MINI1"
7160 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7161 awk '/'$MAXI1': / {print $2; exit}')
7163 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7164 echo "$MAXC files created on larger OST $MAXI1"
7165 FILL=$(($MAXC * 100 / $MINC - 100))
7166 [[ $MINC -gt 0 ]] &&
7167 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7168 [[ $MAXC -gt $MINC ]] ||
7169 error_ignore LU-9 "stripe QOS didn't balance free space"
7170 simple_cleanup_common
7172 run_test 116a "stripe QOS: free space balance ==================="
7174 test_116b() { # LU-2093
7175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7176 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7177 head -1 2>/dev/null)" ] && skip "no QOS" && return
7178 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7180 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7181 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7182 do_facet $SINGLEMDS lctl set_param \
7183 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7185 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7186 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7187 do_facet $SINGLEMDS lctl set_param fail_loc=0
7189 do_facet $SINGLEMDS lctl set_param \
7190 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7192 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7194 test_117() # bug 10891
7196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7197 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7198 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7199 lctl set_param fail_loc=0x21e
7200 > $DIR/$tfile || error "truncate failed"
7201 lctl set_param fail_loc=0
7202 echo "Truncate succeeded."
7205 run_test 117 "verify osd extend =========="
7207 NO_SLOW_RESENDCOUNT=4
7208 export OLD_RESENDCOUNT=""
7209 set_resend_count () {
7210 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7211 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7212 lctl set_param -n $PROC_RESENDCOUNT $1
7213 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7216 # for reduce test_118* time (b=14842)
7217 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7219 # Reset async IO behavior after error case
7221 FILE=$DIR/reset_async
7223 # Ensure all OSCs are cleared
7224 $SETSTRIPE -c -1 $FILE
7225 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7230 test_118a() #bug 11710
7232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7235 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7236 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7237 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7239 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7240 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7245 run_test 118a "verify O_SYNC works =========="
7249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7250 remote_ost_nodsh && skip "remote OST with nodsh" && return
7254 #define OBD_FAIL_OST_ENOENT 0x217
7255 set_nodes_failloc "$(osts_nodes)" 0x217
7256 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7258 set_nodes_failloc "$(osts_nodes)" 0
7259 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7260 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7263 if [[ $RC -eq 0 ]]; then
7264 error "Must return error due to dropped pages, rc=$RC"
7268 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7269 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7273 echo "Dirty pages not leaked on ENOENT"
7275 # Due to the above error the OSC will issue all RPCs syncronously
7276 # until a subsequent RPC completes successfully without error.
7277 $MULTIOP $DIR/$tfile Ow4096yc
7282 run_test 118b "Reclaim dirty pages on fatal error =========="
7286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7288 # for 118c, restore the original resend count, LU-1940
7289 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7290 set_resend_count $OLD_RESENDCOUNT
7291 remote_ost_nodsh && skip "remote OST with nodsh" && return
7295 #define OBD_FAIL_OST_EROFS 0x216
7296 set_nodes_failloc "$(osts_nodes)" 0x216
7298 # multiop should block due to fsync until pages are written
7299 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7303 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7304 error "Multiop failed to block on fsync, pid=$MULTIPID"
7307 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7309 if [[ $WRITEBACK -eq 0 ]]; then
7310 error "No page in writeback, writeback=$WRITEBACK"
7313 set_nodes_failloc "$(osts_nodes)" 0
7316 if [[ $RC -ne 0 ]]; then
7317 error "Multiop fsync failed, rc=$RC"
7320 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7321 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7323 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7324 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7328 echo "Dirty pages flushed via fsync on EROFS"
7331 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7333 # continue to use small resend count to reduce test_118* time (b=14842)
7334 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7339 remote_ost_nodsh && skip "remote OST with nodsh" && return
7343 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7344 set_nodes_failloc "$(osts_nodes)" 0x214
7345 # multiop should block due to fsync until pages are written
7346 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7350 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7351 error "Multiop failed to block on fsync, pid=$MULTIPID"
7354 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7356 if [[ $WRITEBACK -eq 0 ]]; then
7357 error "No page in writeback, writeback=$WRITEBACK"
7360 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7361 set_nodes_failloc "$(osts_nodes)" 0
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 gaurenteed flushed via fsync"
7374 run_test 118d "Fsync validation inject a delay of the bulk =========="
7377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7380 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7381 lctl set_param fail_loc=0x8000040a
7383 # Should simulate EINVAL error which is fatal
7384 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7386 if [[ $RC -eq 0 ]]; then
7387 error "Must return error due to dropped pages, rc=$RC"
7390 lctl set_param fail_loc=0x0
7392 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7393 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7394 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7396 if [[ $LOCKED -ne 0 ]]; then
7397 error "Locked pages remain in cache, locked=$LOCKED"
7400 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7401 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7405 echo "No pages locked after fsync"
7410 run_test 118f "Simulate unrecoverable OSC side error =========="
7413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7416 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7417 lctl set_param fail_loc=0x406
7419 # simulate local -ENOMEM
7420 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7423 lctl set_param fail_loc=0
7424 if [[ $RC -eq 0 ]]; then
7425 error "Must return error due to dropped pages, rc=$RC"
7428 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7429 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7430 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7432 if [[ $LOCKED -ne 0 ]]; then
7433 error "Locked pages remain in cache, locked=$LOCKED"
7436 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7437 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7441 echo "No pages locked after fsync"
7446 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7450 remote_ost_nodsh && skip "remote OST with nodsh" && return
7454 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7455 set_nodes_failloc "$(osts_nodes)" 0x20e
7456 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7457 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7460 set_nodes_failloc "$(osts_nodes)" 0
7461 if [[ $RC -eq 0 ]]; then
7462 error "Must return error due to dropped pages, rc=$RC"
7465 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7466 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7467 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7469 if [[ $LOCKED -ne 0 ]]; then
7470 error "Locked pages remain in cache, locked=$LOCKED"
7473 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7474 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7478 echo "No pages locked after fsync"
7482 run_test 118h "Verify timeout in handling recoverables errors =========="
7484 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7488 remote_ost_nodsh && skip "remote OST with nodsh" && return
7492 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7493 set_nodes_failloc "$(osts_nodes)" 0x20e
7495 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7496 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7499 set_nodes_failloc "$(osts_nodes)" 0
7503 if [[ $RC -ne 0 ]]; then
7504 error "got error, but should be not, rc=$RC"
7507 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7508 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7509 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7510 if [[ $LOCKED -ne 0 ]]; then
7511 error "Locked pages remain in cache, locked=$LOCKED"
7514 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7515 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7519 echo "No pages locked after fsync"
7523 run_test 118i "Fix error before timeout in recoverable error =========="
7525 [ "$SLOW" = "no" ] && set_resend_count 4
7528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7529 remote_ost_nodsh && skip "remote OST with nodsh" && return
7533 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7534 set_nodes_failloc "$(osts_nodes)" 0x220
7536 # return -EIO from OST
7537 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7539 set_nodes_failloc "$(osts_nodes)" 0x0
7540 if [[ $RC -eq 0 ]]; then
7541 error "Must return error due to dropped pages, rc=$RC"
7544 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7545 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7546 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7547 if [[ $LOCKED -ne 0 ]]; then
7548 error "Locked pages remain in cache, locked=$LOCKED"
7551 # in recoverable error on OST we want resend and stay until it finished
7552 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7553 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7557 echo "No pages locked after fsync"
7561 run_test 118j "Simulate unrecoverable OST side error =========="
7565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7566 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7568 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7569 set_nodes_failloc "$(osts_nodes)" 0x20e
7570 test_mkdir -p $DIR/$tdir
7572 for ((i=0;i<10;i++)); do
7573 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7574 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7581 set_nodes_failloc "$(osts_nodes)" 0
7584 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7590 test_mkdir -p $DIR/$tdir
7591 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7594 run_test 118l "fsync dir ========="
7596 test_118m() # LU-3066
7598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7599 test_mkdir -p $DIR/$tdir
7600 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7603 run_test 118m "fdatasync dir ========="
7605 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7607 test_119a() # bug 11737
7609 BSIZE=$((512 * 1024))
7610 directio write $DIR/$tfile 0 1 $BSIZE
7611 # We ask to read two blocks, which is more than a file size.
7612 # directio will indicate an error when requested and actual
7613 # sizes aren't equeal (a normal situation in this case) and
7614 # print actual read amount.
7615 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7616 if [ "$NOB" != "$BSIZE" ]; then
7617 error "read $NOB bytes instead of $BSIZE"
7621 run_test 119a "Short directIO read must return actual read amount"
7623 test_119b() # bug 11737
7625 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7627 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7628 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7630 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7631 error "direct read failed"
7634 run_test 119b "Sparse directIO read must return actual read amount"
7636 test_119c() # bug 13099
7639 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7640 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7643 run_test 119c "Testing for direct read hitting hole"
7645 test_119d() # bug 15950
7647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7648 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7649 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7651 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7652 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7653 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7654 lctl set_param fail_loc=0x40d
7655 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7658 cat $DIR/$tfile > /dev/null &
7659 lctl set_param fail_loc=0
7662 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7664 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7665 error "the read rpcs have not completed in 2s"
7667 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7669 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7673 test_mkdir -p $DIR/$tdir
7674 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7675 skip "no early lock cancel on server" && return 0
7677 lru_resize_disable mdc
7678 lru_resize_disable osc
7679 cancel_lru_locks mdc
7680 # asynchronous object destroy at MDT could cause bl ast to client
7681 cancel_lru_locks osc
7683 stat $DIR/$tdir > /dev/null
7684 can1=$(do_facet $SINGLEMDS \
7685 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7686 awk '/ldlm_cancel/ {print $2}')
7687 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7688 awk '/ldlm_bl_callback/ {print $2}')
7689 test_mkdir -c1 $DIR/$tdir/d1
7690 can2=$(do_facet $SINGLEMDS \
7691 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7692 awk '/ldlm_cancel/ {print $2}')
7693 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7694 awk '/ldlm_bl_callback/ {print $2}')
7695 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7696 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7697 lru_resize_enable mdc
7698 lru_resize_enable osc
7700 run_test 120a "Early Lock Cancel: mkdir test"
7703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7704 test_mkdir $DIR/$tdir
7705 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7706 skip "no early lock cancel on server" && return 0
7707 lru_resize_disable mdc
7708 lru_resize_disable osc
7709 cancel_lru_locks mdc
7710 stat $DIR/$tdir > /dev/null
7711 can1=$(do_facet $SINGLEMDS \
7712 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7713 awk '/ldlm_cancel/ {print $2}')
7714 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7715 awk '/ldlm_bl_callback/ {print $2}')
7717 can2=$(do_facet $SINGLEMDS \
7718 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7719 awk '/ldlm_cancel/ {print $2}')
7720 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7721 awk '/ldlm_bl_callback/ {print $2}')
7722 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7723 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7724 lru_resize_enable mdc
7725 lru_resize_enable osc
7727 run_test 120b "Early Lock Cancel: create test"
7730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7731 test_mkdir -c1 $DIR/$tdir
7732 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7733 skip "no early lock cancel on server" && return 0
7734 lru_resize_disable mdc
7735 lru_resize_disable osc
7736 test_mkdir -p -c1 $DIR/$tdir/d1
7737 test_mkdir -p -c1 $DIR/$tdir/d2
7738 touch $DIR/$tdir/d1/f1
7739 cancel_lru_locks mdc
7740 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7741 can1=$(do_facet $SINGLEMDS \
7742 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7743 awk '/ldlm_cancel/ {print $2}')
7744 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7745 awk '/ldlm_bl_callback/ {print $2}')
7746 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7747 can2=$(do_facet $SINGLEMDS \
7748 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7749 awk '/ldlm_cancel/ {print $2}')
7750 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7751 awk '/ldlm_bl_callback/ {print $2}')
7752 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7753 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7754 lru_resize_enable mdc
7755 lru_resize_enable osc
7757 run_test 120c "Early Lock Cancel: link test"
7760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7761 test_mkdir -p -c1 $DIR/$tdir
7762 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7763 skip "no early lock cancel on server" && return 0
7764 lru_resize_disable mdc
7765 lru_resize_disable osc
7767 cancel_lru_locks mdc
7768 stat $DIR/$tdir > /dev/null
7769 can1=$(do_facet $SINGLEMDS \
7770 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7771 awk '/ldlm_cancel/ {print $2}')
7772 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7773 awk '/ldlm_bl_callback/ {print $2}')
7774 chmod a+x $DIR/$tdir
7775 can2=$(do_facet $SINGLEMDS \
7776 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7777 awk '/ldlm_cancel/ {print $2}')
7778 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7779 awk '/ldlm_bl_callback/ {print $2}')
7780 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7781 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7782 lru_resize_enable mdc
7783 lru_resize_enable osc
7785 run_test 120d "Early Lock Cancel: setattr test"
7788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7789 test_mkdir -p -c1 $DIR/$tdir
7790 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7791 skip "no early lock cancel on server" && return 0
7792 lru_resize_disable mdc
7793 lru_resize_disable osc
7794 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7795 cancel_lru_locks mdc
7796 cancel_lru_locks osc
7797 dd if=$DIR/$tdir/f1 of=/dev/null
7798 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7799 # XXX client can not do early lock cancel of OST lock
7800 # during unlink (LU-4206), so cancel osc lock now.
7801 cancel_lru_locks osc
7802 can1=$(do_facet $SINGLEMDS \
7803 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7804 awk '/ldlm_cancel/ {print $2}')
7805 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7806 awk '/ldlm_bl_callback/ {print $2}')
7807 unlink $DIR/$tdir/f1
7809 can2=$(do_facet $SINGLEMDS \
7810 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7811 awk '/ldlm_cancel/ {print $2}')
7812 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7813 awk '/ldlm_bl_callback/ {print $2}')
7814 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7815 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7816 lru_resize_enable mdc
7817 lru_resize_enable osc
7819 run_test 120e "Early Lock Cancel: unlink test"
7822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7823 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7824 skip "no early lock cancel on server" && return 0
7825 test_mkdir -p -c1 $DIR/$tdir
7826 lru_resize_disable mdc
7827 lru_resize_disable osc
7828 test_mkdir -p -c1 $DIR/$tdir/d1
7829 test_mkdir -p -c1 $DIR/$tdir/d2
7830 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7831 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7832 cancel_lru_locks mdc
7833 cancel_lru_locks osc
7834 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7835 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7836 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7837 # XXX client can not do early lock cancel of OST lock
7838 # during rename (LU-4206), so cancel osc lock now.
7839 cancel_lru_locks osc
7840 can1=$(do_facet $SINGLEMDS \
7841 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7842 awk '/ldlm_cancel/ {print $2}')
7843 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7844 awk '/ldlm_bl_callback/ {print $2}')
7845 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7847 can2=$(do_facet $SINGLEMDS \
7848 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7849 awk '/ldlm_cancel/ {print $2}')
7850 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7851 awk '/ldlm_bl_callback/ {print $2}')
7852 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7853 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7854 lru_resize_enable mdc
7855 lru_resize_enable osc
7857 run_test 120f "Early Lock Cancel: rename test"
7860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7861 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7862 skip "no early lock cancel on server" && return 0
7863 lru_resize_disable mdc
7864 lru_resize_disable osc
7866 echo create $count files
7867 test_mkdir -p $DIR/$tdir
7868 cancel_lru_locks mdc
7869 cancel_lru_locks osc
7872 can0=$(do_facet $SINGLEMDS \
7873 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7874 awk '/ldlm_cancel/ {print $2}')
7875 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7876 awk '/ldlm_bl_callback/ {print $2}')
7877 createmany -o $DIR/$tdir/f $count
7879 can1=$(do_facet $SINGLEMDS \
7880 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7881 awk '/ldlm_cancel/ {print $2}')
7882 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7883 awk '/ldlm_bl_callback/ {print $2}')
7885 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7886 echo rm $count files
7889 can2=$(do_facet $SINGLEMDS \
7890 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7891 awk '/ldlm_cancel/ {print $2}')
7892 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7893 awk '/ldlm_bl_callback/ {print $2}')
7895 echo total: $count removes in $((t2-t1))
7896 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7898 # wait for commitment of removal
7899 lru_resize_enable mdc
7900 lru_resize_enable osc
7902 run_test 120g "Early Lock Cancel: performance test"
7904 test_121() { #bug #10589
7905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7907 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7908 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7909 lctl set_param fail_loc=0x310
7910 cancel_lru_locks osc > /dev/null
7911 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7912 lctl set_param fail_loc=0
7913 [[ $reads -eq $writes ]] ||
7914 error "read $reads blocks, must be $writes blocks"
7916 run_test 121 "read cancel race ========="
7918 test_123a() { # was test 123, statahead(bug 11401)
7919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7921 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7922 log "testing on UP system. Performance may be not as good as expected."
7927 test_mkdir -p $DIR/$tdir
7928 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7929 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7931 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7932 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7934 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7935 lctl set_param -n llite.*.statahead_max 0
7936 lctl get_param llite.*.statahead_max
7937 cancel_lru_locks mdc
7938 cancel_lru_locks osc
7940 time ls -l $DIR/$tdir | wc -l
7942 delta=$((etime - stime))
7943 log "ls $i files without statahead: $delta sec"
7944 lctl set_param llite.*.statahead_max=$max
7946 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7947 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7948 cancel_lru_locks mdc
7949 cancel_lru_locks osc
7951 time ls -l $DIR/$tdir | wc -l
7953 delta_sa=$((etime - stime))
7954 log "ls $i files with statahead: $delta_sa sec"
7955 lctl get_param -n llite.*.statahead_stats
7956 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7958 [[ $swrong -lt $ewrong ]] &&
7959 log "statahead was stopped, maybe too many locks held!"
7960 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7962 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7963 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7964 lctl set_param -n llite.*.statahead_max 0
7965 lctl get_param llite.*.statahead_max
7966 cancel_lru_locks mdc
7967 cancel_lru_locks osc
7969 time ls -l $DIR/$tdir | wc -l
7971 delta=$((etime - stime))
7972 log "ls $i files again without statahead: $delta sec"
7973 lctl set_param llite.*.statahead_max=$max
7974 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7975 if [ $SLOWOK -eq 0 ]; then
7976 error "ls $i files is slower with statahead!"
7978 log "ls $i files is slower with statahead!"
7984 [ $delta -gt 20 ] && break
7985 [ $delta -gt 8 ] && MULT=$((50 / delta))
7986 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7994 delta=$((etime - stime))
7995 log "rm -r $DIR/$tdir/: $delta seconds"
7997 lctl get_param -n llite.*.statahead_stats
7999 run_test 123a "verify statahead work"
8001 test_123b () { # statahead(bug 15027)
8002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8003 test_mkdir -p $DIR/$tdir
8004 createmany -o $DIR/$tdir/$tfile-%d 1000
8006 cancel_lru_locks mdc
8007 cancel_lru_locks osc
8009 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8010 lctl set_param fail_loc=0x80000803
8011 ls -lR $DIR/$tdir > /dev/null
8013 lctl set_param fail_loc=0x0
8014 lctl get_param -n llite.*.statahead_stats
8019 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8023 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8024 skip "no lru resize on server" && return 0
8026 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8028 log "create $NR files at $DIR/$tdir"
8029 createmany -o $DIR/$tdir/f $NR ||
8030 error "failed to create $NR files in $DIR/$tdir"
8032 cancel_lru_locks mdc
8033 ls -l $DIR/$tdir > /dev/null
8037 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8038 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8039 LRU_SIZE=$($LCTL get_param -n $PARAM)
8040 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8041 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8043 log "NS=$(basename $NSDIR)"
8048 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8049 skip "Not enough cached locks created!"
8056 # We know that lru resize allows one client to hold $LIMIT locks
8057 # for 10h. After that locks begin to be killed by client.
8059 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8062 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8063 # killing locks. Some time was spent for creating locks. This means
8064 # that up to the moment of sleep finish we must have killed some of
8065 # them (10-100 locks). This depends on how fast ther were created.
8066 # Many of them were touched in almost the same moment and thus will
8067 # be killed in groups.
8068 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8070 # Use $LRU_SIZE_B here to take into account real number of locks
8071 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8072 local LRU_SIZE_B=$LRU_SIZE
8074 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8075 log "OLD_LVF=$OLD_LVF"
8076 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8078 # Let's make sure that we really have some margin. Client checks
8079 # cached locks every 10 sec.
8081 log "Sleep ${SLEEP} sec"
8083 while ((SEC<$SLEEP)); do
8087 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8091 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8092 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8094 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8095 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8096 unlinkmany $DIR/$tdir/f $NR
8100 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8101 log "unlink $NR files at $DIR/$tdir"
8102 unlinkmany $DIR/$tdir/f $NR
8104 run_test 124a "lru resize ======================================="
8106 get_max_pool_limit()
8108 local limit=$($LCTL get_param \
8109 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8112 if [[ $l -gt $max ]]; then
8120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8121 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8122 skip "no lru resize on server" && return 0
8124 LIMIT=$(get_max_pool_limit)
8126 NR=$(($(default_lru_size)*20))
8127 if [[ $NR -gt $LIMIT ]]; then
8128 log "Limit lock number by $LIMIT locks"
8131 lru_resize_disable mdc
8132 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8133 error "failed to create $DIR/$tdir/disable_lru_resize"
8135 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8136 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8137 cancel_lru_locks mdc
8140 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8143 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8146 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8150 nolruresize_delta=$((etime-stime))
8151 log "ls -la time: $nolruresize_delta seconds"
8152 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8153 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8155 lru_resize_enable mdc
8156 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8157 error "failed to create $DIR/$tdir/enable_lru_resize"
8159 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8160 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8161 cancel_lru_locks mdc
8164 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8167 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8170 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8174 lruresize_delta=$((etime-stime))
8175 log "ls -la time: $lruresize_delta seconds"
8176 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8178 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8179 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8180 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8181 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8183 log "lru resize performs the same with no lru resize"
8185 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8187 run_test 124b "lru resize (performance test) ======================="
8189 test_125() { # 13358
8190 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8191 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8192 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8193 test_mkdir -p $DIR/d125 || error "mkdir failed"
8194 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8195 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8196 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8198 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8200 test_126() { # bug 12829/13455
8201 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8202 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8203 $GSS && skip "must run as gss disabled" && return
8205 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8206 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8208 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8210 run_test 126 "check that the fsgid provided by the client is taken into account"
8212 test_127a() { # bug 15521
8213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8214 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8215 $LCTL set_param osc.*.stats=0
8216 FSIZE=$((2048 * 1024))
8217 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8218 cancel_lru_locks osc
8219 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8221 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8222 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8223 echo "got $COUNT $NAME"
8224 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8225 eval $NAME=$COUNT || error "Wrong proc format"
8228 read_bytes|write_bytes)
8229 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8230 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8231 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8232 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8233 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8234 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8235 error "sumsquare is too small: $SUMSQ"
8236 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8237 error "sumsquare is too big: $SUMSQ"
8241 done < $DIR/${tfile}.tmp
8243 #check that we actually got some stats
8244 [ "$read_bytes" ] || error "Missing read_bytes stats"
8245 [ "$write_bytes" ] || error "Missing write_bytes stats"
8246 [ "$read_bytes" != 0 ] || error "no read done"
8247 [ "$write_bytes" != 0 ] || error "no write done"
8249 run_test 127a "verify the client stats are sane"
8251 test_127b() { # bug LU-333
8252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8253 $LCTL set_param llite.*.stats=0
8254 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8255 # perform 2 reads and writes so MAX is different from SUM.
8256 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8257 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8258 cancel_lru_locks osc
8259 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8260 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8262 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8263 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8264 echo "got $COUNT $NAME"
8265 eval $NAME=$COUNT || error "Wrong proc format"
8269 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8270 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8271 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8272 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8275 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8276 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8277 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8278 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8282 done < $TMP/${tfile}.tmp
8284 #check that we actually got some stats
8285 [ "$read_bytes" ] || error "Missing read_bytes stats"
8286 [ "$write_bytes" ] || error "Missing write_bytes stats"
8287 [ "$read_bytes" != 0 ] || error "no read done"
8288 [ "$write_bytes" != 0 ] || error "no write done"
8290 run_test 127b "verify the llite client stats are sane"
8292 test_128() { # bug 15212
8294 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8299 result=$(grep error $TMP/$tfile.log)
8301 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8303 run_test 128 "interactive lfs for 2 consecutive find's"
8310 local LDPROC=/proc/fs/ldiskfs
8311 local facets=$(get_facets MDS)
8313 for facet in ${facets//,/ }; do
8314 canondev=$(ldiskfs_canon \
8315 *.$(convert_facet2label $facet).mntdev $facet)
8316 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8317 LDPROC=/sys/fs/ldiskfs
8318 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8324 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8325 skip "Only applicable to ldiskfs-based MDTs"
8328 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8333 test_mkdir -p $DIR/$tdir
8335 # block size of mds1
8336 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8337 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8338 local MAX=$((MDSBLOCKSIZE * 3))
8340 local I=$(stat -c%s "$DIR/$tdir")
8342 local STRIPE_COUNT=1
8343 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8344 MAX=$((MAX*STRIPE_COUNT))
8345 while [[ $I -le $MAX ]]; do
8346 $MULTIOP $DIR/$tdir/$J Oc
8348 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8349 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8350 #and EFBIG for previous versions
8351 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8353 echo "return code $rc received as expected"
8354 multiop $DIR/$tdir/$J Oc ||
8355 error_exit "multiop failed w/o dir size limit"
8357 I=$(stat -c%s "$DIR/$tdir")
8359 if [ $(lustre_version_code $SINGLEMDS) -lt \
8360 $(version_code 2.4.51) ]
8362 [[ $I -eq $MAX ]] && return 0
8364 [[ $I -gt $MAX ]] && return 0
8366 error_exit "current dir size $I, previous limit $MAX"
8367 elif [ $rc -ne 0 ]; then
8369 error_exit "return code $rc received instead of expected " \
8370 "$EFBIG or $ENOSPC, files in dir $I"
8373 I=$(stat -c%s "$DIR/$tdir")
8377 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8379 run_test 129 "test directory size limit ========================"
8388 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8389 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8392 trap cleanup_130 EXIT RETURN
8394 local fm_file=$DIR/$tfile
8395 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8396 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8397 error "dd failed for $fm_file"
8399 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8400 filefrag -ves $fm_file
8402 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8403 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8404 [ $RC != 0 ] && error "filefrag $fm_file failed"
8406 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8407 grep -v "ext:" | grep -v "found")
8408 lun=$($GETSTRIPE -i $fm_file)
8410 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8413 for line in $filefrag_op
8415 frag_lun=`echo $line | cut -d: -f5`
8416 ext_len=`echo $line | cut -d: -f4`
8417 if (( $frag_lun != $lun )); then
8419 error "FIEMAP on 1-stripe file($fm_file) failed"
8422 (( tot_len += ext_len ))
8425 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8427 error "FIEMAP on 1-stripe file($fm_file) failed;"
8433 echo "FIEMAP on single striped file succeeded"
8435 run_test 130a "FIEMAP (1-stripe file)"
8438 [ "$OSTCOUNT" -lt "2" ] &&
8439 skip_env "skipping FIEMAP on 2-stripe file test" && return
8441 [ "$OSTCOUNT" -ge "10" ] &&
8442 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8444 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8445 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8448 trap cleanup_130 EXIT RETURN
8450 local fm_file=$DIR/$tfile
8451 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8452 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8453 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8455 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8456 error "dd failed on $fm_file"
8458 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8459 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8460 grep -v "ext:" | grep -v "found")
8462 last_lun=$(echo $filefrag_op | cut -d: -f5)
8467 for line in $filefrag_op
8469 frag_lun=`echo $line | cut -d: -f5`
8470 ext_len=`echo $line | cut -d: -f4`
8471 if (( $frag_lun != $last_lun )); then
8472 if (( tot_len != 1024 )); then
8474 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8481 (( tot_len += ext_len ))
8484 if (( num_luns != 2 || tot_len != 1024 )); then
8486 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8492 echo "FIEMAP on 2-stripe file succeeded"
8494 run_test 130b "FIEMAP (2-stripe file)"
8497 [ "$OSTCOUNT" -lt "2" ] &&
8498 skip_env "skipping FIEMAP on 2-stripe file" && return
8500 [ "$OSTCOUNT" -ge "10" ] &&
8501 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8503 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8504 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8507 trap cleanup_130 EXIT RETURN
8509 local fm_file=$DIR/$tfile
8510 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8511 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8512 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8514 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8516 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8517 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8519 last_lun=`echo $filefrag_op | cut -d: -f5`
8524 for line in $filefrag_op
8526 frag_lun=`echo $line | cut -d: -f5`
8527 ext_len=`echo $line | cut -d: -f4`
8528 if (( $frag_lun != $last_lun )); then
8529 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8530 if (( logical != 512 )); then
8532 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8535 if (( tot_len != 512 )); then
8537 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8544 (( tot_len += ext_len ))
8547 if (( num_luns != 2 || tot_len != 512 )); then
8549 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8555 echo "FIEMAP on 2-stripe file with hole succeeded"
8557 run_test 130c "FIEMAP (2-stripe file with hole)"
8560 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8562 [ "$OSTCOUNT" -ge "10" ] &&
8563 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8565 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8566 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8568 trap cleanup_130 EXIT RETURN
8570 local fm_file=$DIR/$tfile
8571 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8572 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8573 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8575 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8576 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8577 error "dd failed on $fm_file"
8579 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8580 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8581 grep -v "ext:" | grep -v "found"`
8583 last_lun=`echo $filefrag_op | cut -d: -f5`
8588 for line in $filefrag_op
8590 frag_lun=`echo $line | cut -d: -f5`
8591 ext_len=`echo $line | cut -d: -f4`
8592 if (( $frag_lun != $last_lun )); then
8593 if (( tot_len != 1024 )); then
8595 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8602 (( tot_len += ext_len ))
8605 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8607 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8613 echo "FIEMAP on N-stripe file succeeded"
8615 run_test 130d "FIEMAP (N-stripe file)"
8618 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8620 [ "$OSTCOUNT" -ge "10" ] &&
8621 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8623 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8624 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8626 trap cleanup_130 EXIT RETURN
8628 local fm_file=$DIR/$tfile
8629 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8630 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8631 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8634 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8635 for ((i = 0; i < $NUM_BLKS; i++))
8637 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8640 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8641 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8643 last_lun=`echo $filefrag_op | cut -d: -f5`
8648 for line in $filefrag_op
8650 frag_lun=`echo $line | cut -d: -f5`
8651 ext_len=`echo $line | cut -d: -f4`
8652 if (( $frag_lun != $last_lun )); then
8653 if (( tot_len != $EXPECTED_LEN )); then
8655 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8662 (( tot_len += ext_len ))
8665 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8667 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8673 echo "FIEMAP with continuation calls succeeded"
8675 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8677 # Test for writev/readv
8679 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8680 error "writev test failed"
8681 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8682 error "readv failed"
8685 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8688 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8689 error "append writev test failed"
8690 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8691 error "append writev test failed"
8694 run_test 131b "test append writev"
8697 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8700 run_test 131c "test read/write on file w/o objects"
8703 rwv -f $DIR/$tfile -w -n 1 1572864
8704 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8705 if [ "$NOB" != 1572864 ]; then
8706 error "Short read filed: read $NOB bytes instead of 1572864"
8710 run_test 131d "test short read"
8713 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8714 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8715 error "read hitting hole failed"
8718 run_test 131e "test read hitting hole"
8723 for node in $(osts_nodes); do
8724 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8725 [ x$gl = x"" ] && gl=0
8726 gl_sum=$((gl_sum + gl))
8736 if [ x$som = x"enabled" ]; then
8737 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8738 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8739 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8741 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8742 MOUNTOPT="$MOUNTOPT,som_preview"
8743 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8746 # do remount to make new mount-conf parameters actual
8753 test_132() { #1028, SOM
8754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8755 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8756 local num=$(get_mds_dir $DIR)
8757 local mymds=mds${num}
8758 local MOUNTOPT_SAVE=$MOUNTOPT
8760 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8761 cancel_lru_locks osc
8763 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8765 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8766 stat $DIR/$tfile >/dev/null
8767 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8768 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8770 som_mode_switch $som1 $gl1 $gl2
8772 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8773 cancel_lru_locks osc
8775 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8776 if [ $som1 == $som2 ]; then
8777 error "som is still "$som2
8778 if [ x$som2 = x"enabled" ]; then
8785 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8786 stat $DIR/$tfile >/dev/null
8787 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8788 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8789 som_mode_switch $som2 $gl1 $gl2
8790 MOUNTOPT=$MOUNTOPT_SAVE
8792 run_test 132 "som avoids glimpse rpc"
8798 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8800 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8802 *) error "Wrong argument $1" ;;
8805 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8806 # if the argument $3 is zero, it means any stat increment is ok.
8807 if [[ $3 -gt 0 ]]; then
8808 count=$(echo $res | awk '{ print $2 }')
8809 [[ $count -ne $3 ]] &&
8810 error "The $2 counter on $1 is wrong - expected $3"
8815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8816 remote_ost_nodsh && skip "remote OST with nodsh" && return
8817 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8819 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8820 { skip "MDS doesn't support rename stats"; return; }
8821 local testdir=$DIR/${tdir}/stats_testdir
8822 mkdir -p $DIR/${tdir}
8825 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8826 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8828 # verify mdt stats first.
8829 mkdir ${testdir} || error "mkdir failed"
8830 check_stats $SINGLEMDS "mkdir" 1
8831 touch ${testdir}/${tfile} || "touch failed"
8832 check_stats $SINGLEMDS "open" 1
8833 check_stats $SINGLEMDS "close" 1
8834 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8835 check_stats $SINGLEMDS "mknod" 1
8836 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8837 check_stats $SINGLEMDS "unlink" 1
8838 rm -f ${testdir}/${tfile} || error "file remove failed"
8839 check_stats $SINGLEMDS "unlink" 2
8841 # remove working dir and check mdt stats again.
8842 rmdir ${testdir} || error "rmdir failed"
8843 check_stats $SINGLEMDS "rmdir" 1
8845 local testdir1=$DIR/${tdir}/stats_testdir1
8847 mkdir -p ${testdir1}
8848 touch ${testdir1}/test1
8849 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8850 check_stats $SINGLEMDS "crossdir_rename" 1
8852 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8853 check_stats $SINGLEMDS "samedir_rename" 1
8857 run_test 133a "Verifying MDT stats ========================================"
8860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8861 remote_ost_nodsh && skip "remote OST with nodsh" && return
8862 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8863 local testdir=$DIR/${tdir}/stats_testdir
8864 mkdir -p ${testdir} || error "mkdir failed"
8865 touch ${testdir}/${tfile} || "touch failed"
8866 cancel_lru_locks mdc
8869 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8870 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8872 # extra mdt stats verification.
8873 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8874 check_stats $SINGLEMDS "setattr" 1
8875 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8876 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8878 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8879 check_stats $SINGLEMDS "getattr" 1
8881 $LFS df || error "lfs failed"
8882 check_stats $SINGLEMDS "statfs" 1
8886 run_test 133b "Verifying extra MDT stats =================================="
8889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8890 remote_ost_nodsh && skip "remote OST with nodsh" && return
8891 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8892 local testdir=$DIR/${tdir}/stats_testdir
8893 test_mkdir -p ${testdir} || error "mkdir failed"
8895 # verify obdfilter stats.
8896 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8898 cancel_lru_locks osc
8899 wait_delete_completed
8902 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8903 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8905 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8907 cancel_lru_locks osc
8908 check_stats ost "write" 1
8910 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8911 check_stats ost "read" 1
8913 > ${testdir}/${tfile} || error "truncate failed"
8914 check_stats ost "punch" 1
8916 rm -f ${testdir}/${tfile} || error "file remove failed"
8917 wait_delete_completed
8918 check_stats ost "destroy" 1
8922 run_test 133c "Verifying OST stats ========================================"
8929 while [ $value -ge 2 ]; do
8934 if [ $orig -gt $order ]; then
8942 local size=('K' 'M' 'G' 'T');
8944 local size_string=$value
8946 while [ $value -ge 1024 ]; do
8947 if [ $i -gt 3 ]; then
8948 #T is the biggest unit we get here, if that is bigger,
8950 size_string=${value}T
8953 value=$((value >> 10))
8954 if [ $value -lt 1024 ]; then
8955 size_string=${value}${size[$i]}
8966 local context=${2:-.}
8967 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8969 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8975 remote_ost_nodsh && skip "remote OST with nodsh" && return
8976 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8977 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8978 { skip "MDS doesn't support rename stats"; return; }
8980 local testdir1=$DIR/${tdir}/stats_testdir1
8981 local testdir2=$DIR/${tdir}/stats_testdir2
8983 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8985 mkdir -p ${testdir1} || error "mkdir failed"
8986 mkdir -p ${testdir2} || error "mkdir failed"
8988 createmany -o $testdir1/test 512 || error "createmany failed"
8990 # check samedir rename size
8991 mv ${testdir1}/test0 ${testdir1}/test_0
8993 local testdir1_size=$(ls -l $DIR/${tdir} |
8994 awk '/stats_testdir1/ {print $5}')
8995 local testdir2_size=$(ls -l $DIR/${tdir} |
8996 awk '/stats_testdir2/ {print $5}')
8998 testdir1_size=$(order_2 $testdir1_size)
8999 testdir2_size=$(order_2 $testdir2_size)
9001 testdir1_size=$(size_in_KMGT $testdir1_size)
9002 testdir2_size=$(size_in_KMGT $testdir2_size)
9004 echo "source rename dir size: ${testdir1_size}"
9005 echo "target rename dir size: ${testdir2_size}"
9007 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9008 eval $cmd || error "$cmd failed"
9009 local samedir=$($cmd | grep 'same_dir')
9010 local same_sample=$(get_rename_size $testdir1_size)
9011 [ -z "$samedir" ] && error "samedir_rename_size count error"
9012 [[ $same_sample -eq 1 ]] ||
9013 error "samedir_rename_size error $same_sample"
9014 echo "Check same dir rename stats success"
9016 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9018 # check crossdir rename size
9019 mv ${testdir1}/test_0 ${testdir2}/test_0
9021 testdir1_size=$(ls -l $DIR/${tdir} |
9022 awk '/stats_testdir1/ {print $5}')
9023 testdir2_size=$(ls -l $DIR/${tdir} |
9024 awk '/stats_testdir2/ {print $5}')
9026 testdir1_size=$(order_2 $testdir1_size)
9027 testdir2_size=$(order_2 $testdir2_size)
9029 testdir1_size=$(size_in_KMGT $testdir1_size)
9030 testdir2_size=$(size_in_KMGT $testdir2_size)
9032 echo "source rename dir size: ${testdir1_size}"
9033 echo "target rename dir size: ${testdir2_size}"
9035 eval $cmd || error "$cmd failed"
9036 local crossdir=$($cmd | grep 'crossdir')
9037 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9038 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9039 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9040 [[ $src_sample -eq 1 ]] ||
9041 error "crossdir_rename_size error $src_sample"
9042 [[ $tgt_sample -eq 1 ]] ||
9043 error "crossdir_rename_size error $tgt_sample"
9044 echo "Check cross dir rename stats success"
9047 run_test 133d "Verifying rename_stats ========================================"
9050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9051 local testdir=$DIR/${tdir}/stats_testdir
9052 local ctr f0 f1 bs=32768 count=42 sum
9054 remote_ost_nodsh && skip "remote OST with nodsh" && return
9055 mkdir -p ${testdir} || error "mkdir failed"
9057 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9059 for ctr in {write,read}_bytes; do
9061 cancel_lru_locks osc
9063 do_facet ost1 $LCTL set_param -n \
9064 "obdfilter.*.exports.clear=clear"
9066 if [ $ctr = write_bytes ]; then
9068 f1=${testdir}/${tfile}
9070 f0=${testdir}/${tfile}
9074 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9077 cancel_lru_locks osc
9079 sum=$(do_facet ost1 $LCTL get_param \
9080 "obdfilter.*.exports.*.stats" |
9081 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9082 $1 == ctr { sum += $7 }
9083 END { printf("%0.0f", sum) }')
9085 if ((sum != bs * count)); then
9086 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9092 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9095 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9098 # First without trusting modes.
9099 find $proc_dirs -exec cat '{}' \; &> /dev/null
9101 # Second verifying readability.
9104 -exec cat '{}' \; &> /dev/null ||
9105 error "proc file read failed"
9107 for facet in $SINGLEMDS ost1; do
9108 do_facet $facet find $proc_dirs \
9109 ! -name req_history \
9110 -exec cat '{}' \\\; &> /dev/null
9112 do_facet $facet find $proc_dirs \
9113 ! -name req_history \
9115 -exec cat '{}' \\\; &> /dev/null ||
9116 error "proc file read failed"
9119 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9122 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9125 # Second verifying readability.
9128 -not -name force_lbug \
9129 -not -name changelog_mask \
9130 -exec badarea_io '{}' \; &> /dev/null ||
9131 error "find $proc_dirs failed"
9133 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9134 skip "Too old lustre on MDS"
9136 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9137 skip "Too old lustre on ost1"
9139 for facet in $SINGLEMDS ost1; do
9140 do_facet $facet find $proc_dirs \
9142 -not -name force_lbug \
9143 -not -name changelog_mask \
9144 -exec badarea_io '{}' \\\; &> /dev/null ||
9145 error "$facet find $proc_dirs failed"
9149 # remount the FS in case writes/reads /proc break the FS
9150 cleanup || error "failed to unmount"
9151 setup || error "failed to setup"
9154 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9156 test_140() { #bug-17379
9157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9158 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9159 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9160 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9162 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9163 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9165 while i=`expr $i + 1`; do
9166 test_mkdir -p $i || error "Creating dir $i"
9167 cd $i || error "Changing to $i"
9168 ln -s ../stat stat || error "Creating stat symlink"
9169 # Read the symlink until ELOOP present,
9170 # not LBUGing the system is considered success,
9171 # we didn't overrun the stack.
9172 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9174 if [ $ret -eq 40 ]; then
9177 error "Open stat symlink"
9183 echo "The symlink depth = $i"
9184 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9185 error "Invalid symlink depth"
9187 # Test recursive symlink
9188 ln -s symlink_self symlink_self
9189 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9190 echo "open symlink_self returns $ret"
9191 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9193 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9197 local TF="$TMP/$tfile"
9199 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9201 cancel_lru_locks osc
9202 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9203 remount_client $MOUNT
9205 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9208 $TRUNCATE $DIR/$tfile 6000
9209 cancel_lru_locks osc
9210 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9213 echo "12345" >>$DIR/$tfile
9214 cancel_lru_locks osc
9215 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9218 echo "12345" >>$DIR/$tfile
9219 cancel_lru_locks osc
9220 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9225 run_test 150 "truncate/append tests"
9227 #LU-2902 roc_hit was not able to read all values from lproc
9228 function roc_hit_init() {
9229 local list=$(comma_list $(osts_nodes))
9230 local dir=$DIR/$tdir-check
9231 local file=$dir/file
9237 #use setstripe to do a write to every ost
9238 for i in $(seq 0 $((OSTCOUNT-1))); do
9239 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9240 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9241 idx=$(printf %04x $i)
9242 BEFORE=$(get_osd_param $list *OST*$idx stats |
9243 awk '$1 == "cache_access" {sum += $2}
9244 END { printf("%0.0f", sum) }')
9246 cancel_lru_locks osc
9247 cat $file >/dev/null
9249 AFTER=$(get_osd_param $list *OST*$idx stats |
9250 awk '$1 == "cache_access" {sum += $2}
9251 END { printf("%0.0f", sum) }')
9253 echo BEFORE:$BEFORE AFTER:$AFTER
9254 if ! let "AFTER - BEFORE == 4"; then
9256 error "roc_hit is not safe to use"
9264 function roc_hit() {
9265 local list=$(comma_list $(osts_nodes))
9266 echo $(get_osd_param $list '' stats |
9267 awk '$1 == "cache_hit" {sum += $2}
9268 END { printf("%0.0f", sum) }')
9271 function set_cache() {
9274 if [ "$2" == "off" ]; then
9277 local list=$(comma_list $(osts_nodes))
9278 set_osd_param $list '' $1_cache_enable $on
9280 cancel_lru_locks osc
9284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9285 remote_ost_nodsh && skip "remote OST with nodsh" && return
9288 local list=$(comma_list $(osts_nodes))
9290 # check whether obdfilter is cache capable at all
9291 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9292 echo "not cache-capable obdfilter"
9296 # check cache is enabled on all obdfilters
9297 if get_osd_param $list '' read_cache_enable | grep 0; then
9298 echo "oss cache is disabled"
9302 set_osd_param $list '' writethrough_cache_enable 1
9304 # check write cache is enabled on all obdfilters
9305 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9306 echo "oss write cache is NOT enabled"
9312 #define OBD_FAIL_OBD_NO_LRU 0x609
9313 do_nodes $list $LCTL set_param fail_loc=0x609
9315 # pages should be in the case right after write
9316 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9319 local BEFORE=$(roc_hit)
9320 cancel_lru_locks osc
9321 cat $DIR/$tfile >/dev/null
9322 local AFTER=$(roc_hit)
9324 do_nodes $list $LCTL set_param fail_loc=0
9326 if ! let "AFTER - BEFORE == CPAGES"; then
9327 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9330 # the following read invalidates the cache
9331 cancel_lru_locks osc
9332 set_osd_param $list '' read_cache_enable 0
9333 cat $DIR/$tfile >/dev/null
9335 # now data shouldn't be found in the cache
9337 cancel_lru_locks osc
9338 cat $DIR/$tfile >/dev/null
9340 if let "AFTER - BEFORE != 0"; then
9341 error "IN CACHE: before: $BEFORE, after: $AFTER"
9344 set_osd_param $list '' read_cache_enable 1
9347 run_test 151 "test cache on oss and controls ==============================="
9350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9351 local TF="$TMP/$tfile"
9353 # simulate ENOMEM during write
9354 #define OBD_FAIL_OST_NOMEM 0x226
9355 lctl set_param fail_loc=0x80000226
9356 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9358 sync || error "sync failed"
9359 lctl set_param fail_loc=0
9361 # discard client's cache
9362 cancel_lru_locks osc
9364 # simulate ENOMEM during read
9365 lctl set_param fail_loc=0x80000226
9366 cmp $TF $DIR/$tfile || error "cmp failed"
9367 lctl set_param fail_loc=0
9371 run_test 152 "test read/write with enomem ============================"
9374 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9376 run_test 153 "test if fdatasync does not crash ======================="
9378 dot_lustre_fid_permission_check() {
9380 local ffid=$MOUNT/.lustre/fid/$fid
9383 echo "stat fid $fid"
9384 stat $ffid > /dev/null || error "stat $ffid failed."
9385 echo "touch fid $fid"
9386 touch $ffid || error "touch $ffid failed."
9387 echo "write to fid $fid"
9388 cat /etc/hosts > $ffid || error "write $ffid failed."
9389 echo "read fid $fid"
9390 diff /etc/hosts $ffid || error "read $ffid failed."
9391 echo "append write to fid $fid"
9392 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9393 echo "rename fid $fid"
9394 mv $ffid $test_dir/$tfile.1 &&
9395 error "rename $ffid to $tfile.1 should fail."
9396 touch $test_dir/$tfile.1
9397 mv $test_dir/$tfile.1 $ffid &&
9398 error "rename $tfile.1 to $ffid should fail."
9399 rm -f $test_dir/$tfile.1
9400 echo "truncate fid $fid"
9401 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9402 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9403 echo "link fid $fid"
9404 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9406 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9407 echo "setfacl fid $fid"
9408 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9409 echo "getfacl fid $fid"
9410 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9412 echo "unlink fid $fid"
9413 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9414 echo "mknod fid $fid"
9415 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9417 fid=[0xf00000400:0x1:0x0]
9418 ffid=$MOUNT/.lustre/fid/$fid
9420 echo "stat non-exist fid $fid"
9421 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9422 echo "write to non-exist fid $fid"
9423 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9424 echo "link new fid $fid"
9425 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9427 mkdir -p $test_dir/$tdir
9428 touch $test_dir/$tdir/$tfile
9429 fid=$($LFS path2fid $test_dir/$tdir)
9432 error "error: could not get fid for $test_dir/$dir/$tfile."
9434 ffid=$MOUNT/.lustre/fid/$fid
9437 ls $ffid > /dev/null || error "ls $ffid failed."
9438 echo "touch $fid/$tfile.1"
9439 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9441 echo "touch $MOUNT/.lustre/fid/$tfile"
9442 touch $MOUNT/.lustre/fid/$tfile && \
9443 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9445 echo "setxattr to $MOUNT/.lustre/fid"
9446 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9448 echo "listxattr for $MOUNT/.lustre/fid"
9449 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9451 echo "delxattr from $MOUNT/.lustre/fid"
9452 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9454 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9455 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9456 error "touch invalid fid should fail."
9458 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9459 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9460 error "touch non-normal fid should fail."
9462 echo "rename $tdir to $MOUNT/.lustre/fid"
9463 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9464 error "rename to $MOUNT/.lustre/fid should fail."
9466 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9468 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9469 local new_obf_mode=777
9471 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9472 chmod $new_obf_mode $DIR/.lustre/fid ||
9473 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9475 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9476 [ $obf_mode -eq $new_obf_mode ] ||
9477 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9479 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9480 chmod $old_obf_mode $DIR/.lustre/fid ||
9481 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9484 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9485 fid=$($LFS path2fid $test_dir/$tfile-2)
9486 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9487 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9488 error "create lov data thru .lustre should fail."
9489 echo "cp /etc/passwd $test_dir/$tfile-2"
9490 cp /etc/passwd $test_dir/$tfile-2 ||
9491 error "copy to $test_dir/$tfile-2 failed."
9492 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9493 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9494 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9496 rm -rf $test_dir/tfile.lnk
9497 rm -rf $test_dir/$tfile-2
9501 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9502 skip "Need MDS version at least 2.4.1" && return
9505 local FID=$($LFS path2fid $DIR/$tfile)
9506 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9508 # check that we get the same pathname back
9509 local FOUND=$($LFS fid2path $MOUNT $FID)
9510 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9511 [ "$FOUND" != "$DIR/$tfile" ] &&
9512 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9516 run_test 154A "lfs path2fid and fid2path basic checks"
9519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9520 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9521 { skip "Need MDS version at least 2.2.51"; return 0; }
9522 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9524 cp /etc/hosts $DIR/$tfile
9526 fid=$($LFS path2fid $DIR/$tfile)
9528 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9530 dot_lustre_fid_permission_check "$fid" $DIR ||
9531 error "dot lustre permission check $fid failed"
9533 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9535 touch $MOUNT/.lustre/file &&
9536 error "creation is not allowed under .lustre"
9538 mkdir $MOUNT/.lustre/dir &&
9539 error "mkdir is not allowed under .lustre"
9543 run_test 154a "Open-by-FID"
9546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9547 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9548 { skip "Need MDS version at least 2.2.51"; return 0; }
9550 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9552 local remote_dir=$DIR/$tdir/remote_dir
9557 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9558 error "create remote directory failed"
9560 cp /etc/hosts $remote_dir/$tfile
9562 fid=$($LFS path2fid $remote_dir/$tfile)
9564 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9566 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9567 error "dot lustre permission check $fid failed"
9570 run_test 154b "Open-by-FID for remote directory"
9573 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9574 skip "Need MDS version at least 2.4.1" && return
9576 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9577 local FID1=$($LFS path2fid $DIR/$tfile.1)
9578 local FID2=$($LFS path2fid $DIR/$tfile.2)
9579 local FID3=$($LFS path2fid $DIR/$tfile.3)
9582 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9583 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9584 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9586 [ "$FID" = "${!want}" ] ||
9587 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9591 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9592 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9593 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9597 run_test 154c "lfs path2fid and fid2path multiple arguments"
9600 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9601 skip "Need MDS version at least 2.5.53" && return
9604 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9608 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9615 fid=$($LFS path2fid $DIR/$tfile)
9618 cmd="exec $fd<$DIR/$tfile"
9620 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9621 echo $fid_list | grep $fid
9624 cmd="exec $fd>/dev/null"
9626 if [ $rc -ne 0 ]; then
9627 error "FID $fid not found in open files list $fid_list"
9630 run_test 154d "Verify open file fid"
9632 test_155_small_load() {
9633 local temp=$TMP/$tfile
9634 local file=$DIR/$tfile
9636 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9637 error "dd of=$temp bs=6096 count=1 failed"
9639 cancel_lru_locks osc
9640 cmp $temp $file || error "$temp $file differ"
9642 $TRUNCATE $temp 6000
9643 $TRUNCATE $file 6000
9644 cmp $temp $file || error "$temp $file differ (truncate1)"
9646 echo "12345" >>$temp
9647 echo "12345" >>$file
9648 cmp $temp $file || error "$temp $file differ (append1)"
9650 echo "12345" >>$temp
9651 echo "12345" >>$file
9652 cmp $temp $file || error "$temp $file differ (append2)"
9658 test_155_big_load() {
9659 remote_ost_nodsh && skip "remote OST with nodsh" && return
9660 local temp=$TMP/$tfile
9661 local file=$DIR/$tfile
9664 local cache_size=$(do_facet ost$((MAXI+1)) \
9665 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9666 local large_file_size=$((cache_size * 2))
9668 echo "OSS cache size: $cache_size KB"
9669 echo "Large file size: $large_file_size KB"
9671 [ $MAXV -le $large_file_size ] && \
9672 skip_env "max available OST size needs > $large_file_size KB" && \
9675 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9677 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9678 error "dd of=$temp bs=$large_file_size count=1k failed"
9681 cancel_lru_locks osc
9682 cmp $temp $file || error "$temp $file differ"
9689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9691 set_cache writethrough on
9694 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9699 set_cache writethrough off
9702 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9707 set_cache writethrough on
9710 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9715 set_cache writethrough off
9718 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9723 set_cache writethrough on
9726 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9731 set_cache writethrough off
9734 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9739 set_cache writethrough on
9742 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9747 set_cache writethrough off
9750 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9757 local file="$DIR/$tfile"
9759 [ "$(facet_fstype ost1)" = "zfs" ] &&
9760 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9765 log "Turn on read and write cache"
9767 set_cache writethrough on
9769 log "Write data and read it back."
9770 log "Read should be satisfied from the cache."
9771 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9773 cancel_lru_locks osc
9774 cat $file >/dev/null
9776 if ! let "AFTER - BEFORE == CPAGES"; then
9777 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9779 log "cache hits:: before: $BEFORE, after: $AFTER"
9782 log "Read again; it should be satisfied from the cache."
9784 cancel_lru_locks osc
9785 cat $file >/dev/null
9787 if ! let "AFTER - BEFORE == CPAGES"; then
9788 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9790 log "cache hits:: before: $BEFORE, after: $AFTER"
9794 log "Turn off the read cache and turn on the write cache"
9796 set_cache writethrough on
9798 log "Read again; it should be satisfied from the cache."
9800 cancel_lru_locks osc
9801 cat $file >/dev/null
9803 if ! let "AFTER - BEFORE == CPAGES"; then
9804 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9806 log "cache hits:: before: $BEFORE, after: $AFTER"
9809 log "Read again; it should not be satisfied from the cache."
9811 cancel_lru_locks osc
9812 cat $file >/dev/null
9814 if ! let "AFTER - BEFORE == 0"; then
9815 error "IN CACHE: before: $BEFORE, after: $AFTER"
9817 log "cache hits:: before: $BEFORE, after: $AFTER"
9820 log "Write data and read it back."
9821 log "Read should be satisfied from the cache."
9822 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9824 cancel_lru_locks osc
9825 cat $file >/dev/null
9827 if ! let "AFTER - BEFORE == CPAGES"; then
9828 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9830 log "cache hits:: before: $BEFORE, after: $AFTER"
9833 log "Read again; it should not be satisfied from the cache."
9835 cancel_lru_locks osc
9836 cat $file >/dev/null
9838 if ! let "AFTER - BEFORE == 0"; then
9839 error "IN CACHE: before: $BEFORE, after: $AFTER"
9841 log "cache hits:: before: $BEFORE, after: $AFTER"
9845 log "Turn off read and write cache"
9847 set_cache writethrough off
9849 log "Write data and read it back"
9850 log "It should not be satisfied from the cache."
9852 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9853 cancel_lru_locks osc
9855 cat $file >/dev/null
9857 if ! let "AFTER - BEFORE == 0"; then
9858 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9860 log "cache hits:: before: $BEFORE, after: $AFTER"
9863 log "Turn on the read cache and turn off the write cache"
9865 set_cache writethrough off
9867 log "Write data and read it back"
9868 log "It should not be satisfied from the cache."
9870 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9872 cancel_lru_locks osc
9873 cat $file >/dev/null
9875 if ! let "AFTER - BEFORE == 0"; then
9876 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9878 log "cache hits:: before: $BEFORE, after: $AFTER"
9881 log "Read again; it should be satisfied from the cache."
9883 cancel_lru_locks osc
9884 cat $file >/dev/null
9886 if ! let "AFTER - BEFORE == CPAGES"; then
9887 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9889 log "cache hits:: before: $BEFORE, after: $AFTER"
9894 run_test 156 "Verification of tunables ============================"
9898 if [[ $MDSCOUNT -gt 1 ]]; then
9899 error_ignore bz17935 $*
9907 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9909 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9911 if [ $MASK -eq 1 ]; then
9912 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9914 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9918 changelog_extract_field() {
9924 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9925 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9931 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9932 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9933 { skip "Need MDS version at least 2.2.0"; return; }
9935 local CL_USERS="mdd.$MDT0.changelog_users"
9936 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9937 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9938 echo "Registered as changelog user $USER"
9939 $GET_CL_USERS | grep -q $USER ||
9940 error "User $USER not found in changelog_users"
9943 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9944 touch $DIR/$tdir/pics/2008/zachy/timestamp
9945 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9946 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9947 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9948 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9949 rm $DIR/$tdir/pics/desktop.jpg
9951 $LFS changelog $MDT0 | tail -5
9953 echo "verifying changelog mask"
9954 changelog_chmask "MKDIR"
9955 changelog_chmask "CLOSE"
9957 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9958 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9960 changelog_chmask "MKDIR"
9961 changelog_chmask "CLOSE"
9963 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9964 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9966 $LFS changelog $MDT0
9967 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9968 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9969 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9970 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9973 echo "verifying target fid"
9974 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9975 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9976 [ "$fidc" == "$fidf" ] ||
9977 err17935 "fid in changelog $fidc != file fid $fidf"
9978 echo "verifying parent fid"
9979 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9980 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9981 [ "$fidc" == "$fidf" ] ||
9982 err17935 "pfid in changelog $fidc != dir fid $fidf"
9984 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9985 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9986 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9987 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9988 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9989 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9991 MIN_REC=$($GET_CL_USERS |
9992 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9993 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9994 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9995 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9996 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9998 # LU-3446 changelog index reset on MDT restart
9999 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10000 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10001 $LFS changelog_clear $MDT0 $USER 0
10002 stop $SINGLEMDS || error "Fail to stop MDT."
10003 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10004 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10005 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10006 [ $CUR_REC1 == $CUR_REC2 ] ||
10007 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10009 echo "verifying user deregister"
10010 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10011 $GET_CL_USERS | grep -q $USER &&
10012 error "User $USER still in changelog_users"
10014 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10015 if [ $USERS -eq 0 ]; then
10016 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10017 touch $DIR/$tdir/chloe
10018 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10019 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10020 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10022 echo "$USERS other changelog users; can't verify off"
10025 run_test 160a "changelog sanity"
10027 test_160b() { # LU-3587
10028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10029 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10030 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10031 { skip "Need MDS version at least 2.2.0"; return; }
10033 local CL_USERS="mdd.$MDT0.changelog_users"
10034 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10035 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10036 echo "Registered as changelog user $USER"
10037 $GET_CL_USERS | grep -q $USER ||
10038 error "User $USER not found in changelog_users"
10040 local LONGNAME1=$(str_repeat a 255)
10041 local LONGNAME2=$(str_repeat b 255)
10044 echo "creating very long named file"
10045 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10046 echo "moving very long named file"
10047 mv $LONGNAME1 $LONGNAME2
10049 $LFS changelog $MDT0 | grep RENME
10051 echo "deregistering $USER"
10052 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10056 run_test 160b "Verify that very long rename doesn't crash in changelog"
10060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10062 # Registration step
10063 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10064 changelog_register -n)
10067 mkdir -p $DIR/$tdir
10068 $MCREATE $DIR/$tdir/foo_160c
10069 changelog_chmask "TRUNC"
10070 $TRUNCATE $DIR/$tdir/foo_160c 200
10071 changelog_chmask "TRUNC"
10072 $TRUNCATE $DIR/$tdir/foo_160c 199
10073 $LFS changelog $MDT0
10074 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10075 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10076 $LFS changelog_clear $MDT0 $USER 0
10078 # Deregistration step
10079 echo "deregistering $USER"
10080 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10082 run_test 160c "verify that changelog log catch the truncate event"
10085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10086 test_mkdir -p -c1 $DIR/$tdir
10087 cp /etc/hosts $DIR/$tdir/$tfile
10088 test_mkdir -c1 $DIR/$tdir/foo1
10089 test_mkdir -c1 $DIR/$tdir/foo2
10090 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10091 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10092 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10093 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10094 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10095 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10096 $LFS fid2path $DIR $FID
10097 err17935 "bad link ea"
10100 rm $DIR/$tdir/foo2/zachary
10102 rm $DIR/$tdir/foo2/thor
10104 rm $DIR/$tdir/$tfile
10106 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10107 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10109 $LFS fid2path $DIR $FID
10110 err17935 "bad link rename"
10112 rm $DIR/$tdir/foo2/maggie
10115 local longname=filename_avg_len_is_thirty_two_
10116 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10117 error "failed to hardlink many files"
10118 links=$($LFS fid2path $DIR $FID | wc -l)
10119 echo -n "${links}/1000 links in link EA"
10120 [[ $links -gt 60 ]] ||
10121 err17935 "expected at least 60 links in link EA"
10122 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10123 error "failed to unlink many hardlinks"
10125 run_test 161a "link ea sanity"
10128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10129 [ $MDSCOUNT -lt 2 ] &&
10130 skip "skipping remote directory test" && return
10132 local remote_dir=$DIR/$tdir/remote_dir
10134 mkdir -p $DIR/$tdir
10135 $LFS mkdir -i $MDTIDX $remote_dir ||
10136 error "create remote directory failed"
10138 cp /etc/hosts $remote_dir/$tfile
10139 mkdir -p $remote_dir/foo1
10140 mkdir -p $remote_dir/foo2
10141 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10142 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10143 ln $remote_dir/$tfile $remote_dir/foo1/luna
10144 ln $remote_dir/$tfile $remote_dir/foo2/thor
10146 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10148 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10149 $LFS fid2path $DIR $FID
10150 err17935 "bad link ea"
10153 rm $remote_dir/foo2/zachary
10155 rm $remote_dir/foo2/thor
10157 rm $remote_dir/$tfile
10159 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10160 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10161 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10162 $LFS fid2path $DIR $FID
10163 err17935 "bad link rename"
10165 rm $remote_dir/foo2/maggie
10168 local longname=filename_avg_len_is_thirty_two_
10169 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10170 error "failed to hardlink many files"
10171 links=$($LFS fid2path $DIR $FID | wc -l)
10172 echo -n "${links}/1000 links in link EA"
10173 [[ ${links} -gt 60 ]] ||
10174 err17935 "expected at least 60 links in link EA"
10175 unlinkmany $remote_dir/foo2/$longname 1000 ||
10176 error "failed to unlink many hardlinks"
10178 run_test 161b "link ea sanity under remote directory"
10181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10182 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10183 skip "Need MDS version at least 2.1.5" && return
10185 # define CLF_RENAME_LAST 0x0001
10186 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10187 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10188 changelog_register -n)
10190 mkdir -p $DIR/$tdir
10191 touch $DIR/$tdir/foo_161c
10192 touch $DIR/$tdir/bar_161c
10193 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10194 $LFS changelog $MDT0 | grep RENME
10195 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10197 $LFS changelog_clear $MDT0 $USER 0
10198 if [ x$flags != "x0x1" ]; then
10199 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10201 error "flag $flags is not 0x1"
10203 echo "rename overwrite a target having nlink = 1," \
10204 "changelog record has flags of $flags"
10206 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10207 touch $DIR/$tdir/foo_161c
10208 touch $DIR/$tdir/bar_161c
10209 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10210 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10211 $LFS changelog $MDT0 | grep RENME
10212 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10213 $LFS changelog_clear $MDT0 $USER 0
10214 if [ x$flags != "x0x0" ]; then
10215 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10217 error "flag $flags is not 0x0"
10219 echo "rename overwrite a target having nlink > 1," \
10220 "changelog record has flags of $flags"
10222 # rename doesn't overwrite a target (changelog flag 0x0)
10223 touch $DIR/$tdir/foo_161c
10224 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10225 $LFS changelog $MDT0 | grep RENME
10226 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10227 $LFS changelog_clear $MDT0 $USER 0
10228 if [ x$flags != "x0x0" ]; then
10229 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10231 error "flag $flags is not 0x0"
10233 echo "rename doesn't overwrite a target," \
10234 "changelog record has flags of $flags"
10236 # define CLF_UNLINK_LAST 0x0001
10237 # unlink a file having nlink = 1 (changelog flag 0x1)
10238 rm -f $DIR/$tdir/foo2_161c
10239 $LFS changelog $MDT0 | grep UNLNK
10240 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10241 $LFS changelog_clear $MDT0 $USER 0
10242 if [ x$flags != "x0x1" ]; then
10243 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10245 error "flag $flags is not 0x1"
10247 echo "unlink a file having nlink = 1," \
10248 "changelog record has flags of $flags"
10250 # unlink a file having nlink > 1 (changelog flag 0x0)
10251 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10252 rm -f $DIR/$tdir/foobar_161c
10253 $LFS changelog $MDT0 | grep UNLNK
10254 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10255 $LFS changelog_clear $MDT0 $USER 0
10256 if [ x$flags != "x0x0" ]; then
10257 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10259 error "flag $flags is not 0x0"
10261 echo "unlink a file having nlink > 1," \
10262 "changelog record has flags of $flags"
10263 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10265 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10272 local path=$(${LFS} fid2path $*)
10275 if [ $RC -ne 0 ]; then
10276 err17935 "path looked up of $expected failed. Error $RC"
10278 elif [ "${path}" != "${expected}" ]; then
10279 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10282 echo "fid $fid resolves to path $path (expected $expected)"
10286 # Make changes to filesystem
10287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10288 test_mkdir -p -c1 $DIR/$tdir/d2
10289 touch $DIR/$tdir/d2/$tfile
10290 touch $DIR/$tdir/d2/x1
10291 touch $DIR/$tdir/d2/x2
10292 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10293 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10295 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10296 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10299 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10300 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10301 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10303 # softlink to wrong file
10304 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10305 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10306 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10309 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10310 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10311 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10312 # fid2path dir/fsname should both work
10313 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10314 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10316 # hardlink count: check that there are 2 links
10317 # Doesnt work with CMD yet: 17935
10318 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10319 err17935 "expected 2 links"
10321 # hardlink indexing: remove the first link
10322 rm $DIR/$tdir/d2/p/q/r/hlink
10323 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10327 run_test 162 "path lookup sanity"
10330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10331 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10334 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10335 error "create striped dir failed"
10337 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10338 tail -n 1 | awk '{print $2}')
10339 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10341 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10342 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10345 for ((i=0;i<5;i++)); do
10346 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10347 error "get fid for f$i failed"
10348 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
10350 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10351 error "get fid for d$i failed"
10352 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
10357 run_test 162b "striped directory path lookup sanity"
10360 # do directio so as not to populate the page cache
10361 log "creating a 10 Mb file"
10362 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10363 log "starting reads"
10364 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10365 log "truncating the file"
10366 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10368 kill %+ || true # reads might have finished
10369 echo "wait until dd is finished"
10371 log "removing the temporary file"
10372 rm -rf $DIR/$tfile || error "tmp file removal failed"
10374 run_test 169 "parallel read and truncate should not deadlock"
10377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10378 $LCTL clear # bug 18514
10379 $LCTL debug_daemon start $TMP/${tfile}_log_good
10381 $LCTL debug_daemon stop
10382 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10383 error "sed failed to read log_good"
10385 $LCTL debug_daemon start $TMP/${tfile}_log_good
10387 $LCTL debug_daemon stop
10389 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10390 error "lctl df log_bad failed"
10392 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10393 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10395 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10396 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10398 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10399 error "bad_line good_line1 good_line2 are empty"
10401 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10402 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10403 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10405 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10406 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10407 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10409 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10410 error "bad_line_new good_line_new are empty"
10412 local expected_good=$((good_line1 + good_line2*2))
10414 rm -f $TMP/${tfile}*
10415 # LU-231, short malformed line may not be counted into bad lines
10416 if [ $bad_line -ne $bad_line_new ] &&
10417 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10418 error "expected $bad_line bad lines, but got $bad_line_new"
10422 if [ $expected_good -ne $good_line_new ]; then
10423 error "expected $expected_good good lines, but got $good_line_new"
10428 run_test 170 "test lctl df to handle corrupted log ====================="
10430 test_171() { # bug20592
10431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10432 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10433 $LCTL set_param fail_loc=0x50e
10434 $LCTL set_param fail_val=3000
10435 multiop_bg_pause $DIR/$tfile O_s || true
10437 kill -USR1 $MULTIPID
10441 if dmesg | grep "recursive fault"; then
10442 error "caught a recursive fault"
10444 $LCTL set_param fail_loc=0
10447 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10449 # it would be good to share it with obdfilter-survey/libecho code
10450 setup_obdecho_osc () {
10453 local obdfilter_name=$2
10454 echo "Creating new osc for $obdfilter_name on $ost_nid"
10455 # make sure we can find loopback nid
10456 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10458 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10459 ${obdfilter_name}_osc_UUID || rc=2; }
10460 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10461 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10465 cleanup_obdecho_osc () {
10466 local obdfilter_name=$1
10467 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10468 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10475 local pages=${3:-64}
10480 local obd_size=$(get_obd_size $node $OBD)
10481 local page_size=$(get_page_size $node)
10482 if [[ -n "$obd_size" ]]; then
10483 local new_count=$((obd_size / (pages * page_size / 1024)))
10484 [[ $new_count -ge $count ]] || count=$new_count
10487 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10488 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10490 if [ $rc -eq 0 ]; then
10491 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10492 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10494 echo "New object id is $id"
10495 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10497 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10498 "test_brw $count w v $pages $id" || rc=4; }
10499 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10501 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10502 "cleanup" || rc=5; }
10503 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10504 "detach" || rc=6; }
10505 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10511 remote_ost_nodsh && skip "remote OST with nodsh" && return
10513 local rmmod_local=0
10515 if ! module_loaded obdecho; then
10516 load_module obdecho/obdecho
10520 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10521 local host=$(lctl get_param -n osc.$osc.import |
10522 awk '/current_connection:/ {print $2}' )
10523 local target=$(lctl get_param -n osc.$osc.import |
10524 awk '/target:/ {print $2}' )
10525 target=${target%_UUID}
10527 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10528 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10529 [[ -n $target ]] && cleanup_obdecho_osc $target
10530 [ $rmmod_local -eq 1 ] && rmmod obdecho
10533 run_test 180a "test obdecho on osc"
10536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10537 remote_ost_nodsh && skip "remote OST with nodsh" && return
10539 local rmmod_remote=0
10541 do_facet ost1 "lsmod | grep -q obdecho || " \
10542 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10543 "modprobe obdecho; }" && rmmod_remote=1
10544 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10545 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10546 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10549 run_test 180b "test obdecho directly on obdfilter"
10551 test_180c() { # LU-2598
10552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10553 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10554 skip "Need MDS version at least 2.4.0" && return
10557 local rmmod_remote=false
10558 local pages=16384 # 64MB bulk I/O RPC size
10561 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10562 rmmod_remote=true || error "failed to load module obdecho"
10564 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10566 if [ -n "$target" ]; then
10567 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10569 echo "there is no obdfilter target on ost1"
10572 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10575 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10577 test_181() { # bug 22177
10578 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10579 # create enough files to index the directory
10580 createmany -o $DIR/$tdir/foobar 4000
10581 # print attributes for debug purpose
10584 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10586 # remove the files & current working dir
10587 unlinkmany $DIR/$tdir/foobar 4000
10589 kill -USR1 $MULTIPID
10591 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10594 run_test 181 "Test open-unlinked dir ========================"
10597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10598 # disable MDC RPC lock wouldn't crash client
10602 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10603 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10604 $LCTL set_param fail_loc=0x804
10606 for (( i=0; i < $tcount; i++ )) ; do
10607 mkdir $DIR/$tdir/$i
10608 createmany -o $DIR/$tdir/$i/f- $fcount &
10612 for (( i=0; i < $tcount; i++ )) ; do
10613 unlinkmany $DIR/$tdir/$i/f- $fcount &
10619 $LCTL set_param fail_loc=0
10621 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10623 test_183() { # LU-2275
10624 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10625 skip "Need MDS version at least 2.3.56" && return
10627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10628 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10629 echo aaa > $DIR/$tdir/$tfile
10631 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10632 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10634 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10635 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10637 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10639 # Flush negative dentry cache
10640 touch $DIR/$tdir/$tfile
10642 # We are not checking for any leaked references here, they'll
10643 # become evident next time we do cleanup with module unload.
10646 run_test 183 "No crash or request leak in case of strange dispositions ========"
10648 # test suite 184 is for LU-2016, LU-2017
10650 check_swap_layouts_support && return 0
10652 dir0=$DIR/$tdir/$testnum
10653 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10658 $SETSTRIPE -c1 $file1
10660 $SETSTRIPE -c2 $file2
10662 gen1=$($GETSTRIPE -g $file1)
10663 gen2=$($GETSTRIPE -g $file2)
10665 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10666 gen=$($GETSTRIPE -g $file1)
10667 [[ $gen1 != $gen ]] ||
10668 "Layout generation on $file1 does not change"
10669 gen=$($GETSTRIPE -g $file2)
10670 [[ $gen2 != $gen ]] ||
10671 "Layout generation on $file2 does not change"
10673 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10674 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10676 run_test 184a "Basic layout swap"
10679 check_swap_layouts_support && return 0
10681 dir0=$DIR/$tdir/$testnum
10682 mkdir -p $dir0 || error "creating dir $dir0"
10689 $SETSTRIPE -c1 $file1
10690 $SETSTRIPE -c2 $file2
10691 $SETSTRIPE -c1 $file3
10692 chown $RUNAS_ID $file3
10693 gen1=$($GETSTRIPE -g $file1)
10694 gen2=$($GETSTRIPE -g $file2)
10696 $LFS swap_layouts $dir1 $dir2 &&
10697 error "swap of directories layouts should fail"
10698 $LFS swap_layouts $dir1 $file1 &&
10699 error "swap of directory and file layouts should fail"
10700 $RUNAS $LFS swap_layouts $file1 $file2 &&
10701 error "swap of file we cannot write should fail"
10702 $LFS swap_layouts $file1 $file3 &&
10703 error "swap of file with different owner should fail"
10704 /bin/true # to clear error code
10706 run_test 184b "Forbidden layout swap (will generate errors)"
10709 check_swap_layouts_support && return 0
10711 local dir0=$DIR/$tdir/$testnum
10712 mkdir -p $dir0 || error "creating dir $dir0"
10714 local ref1=$dir0/ref1
10715 local ref2=$dir0/ref2
10716 local file1=$dir0/file1
10717 local file2=$dir0/file2
10718 # create a file large enough for the concurent test
10719 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10720 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10721 echo "ref file size: ref1($(stat -c %s $ref1))," \
10722 "ref2($(stat -c %s $ref2))"
10725 dd if=$ref1 of=$file1 bs=16k &
10728 # Make sure dd starts to copy file
10729 while [ ! -f $file1 ]; do sleep 0.1; done
10731 $LFS swap_layouts $file1 $file2
10734 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10735 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10737 # how many bytes copied before swapping layout
10738 local copied=$(stat -c %s $file2)
10739 local remaining=$(stat -c %s $ref1)
10740 remaining=$((remaining - copied))
10741 echo "Copied $copied bytes before swapping layout..."
10743 cmp -n $copied $file1 $ref2 | grep differ &&
10744 error "Content mismatch [0, $copied) of ref2 and file1"
10745 cmp -n $copied $file2 $ref1 ||
10746 error "Content mismatch [0, $copied) of ref1 and file2"
10747 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10748 error "Content mismatch [$copied, EOF) of ref1 and file1"
10751 rm -f $ref1 $ref2 $file1 $file2
10753 run_test 184c "Concurrent write and layout swap"
10756 check_swap_layouts_support && return 0
10757 [ -z "$(which getfattr 2>/dev/null)" ] &&
10758 skip "no getfattr command" && return 0
10760 local file1=$DIR/$tdir/$tfile-1
10761 local file2=$DIR/$tdir/$tfile-2
10762 local file3=$DIR/$tdir/$tfile-3
10766 mkdir -p $DIR/$tdir
10767 touch $file1 || error "create $file1 failed"
10768 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10769 error "create $file2 failed"
10770 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10771 error "create $file3 failed"
10772 lovea1=$($LFS getstripe $file1 | sed 1d)
10774 $LFS swap_layouts $file2 $file3 ||
10775 error "swap $file2 $file3 layouts failed"
10776 $LFS swap_layouts $file1 $file2 ||
10777 error "swap $file1 $file2 layouts failed"
10779 lovea2=$($LFS getstripe $file2 | sed 1d)
10780 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10782 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10783 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10785 run_test 184d "allow stripeless layouts swap"
10788 test_185() { # LU-2441
10789 # LU-3553 - no volatile file support in old servers
10790 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10791 { skip "Need MDS version at least 2.3.60"; return 0; }
10793 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10794 touch $DIR/$tdir/spoo
10795 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10796 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10797 error "cannot create/write a volatile file"
10798 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10799 error "FID is still valid after close"
10801 multiop_bg_pause $DIR/$tdir vVw4096_c
10808 # assume that the next FID for this client is sequential, since stdout
10809 # is unfortunately eaten by multiop_bg_pause
10810 local n=$((${fidv[1]} + 1))
10811 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10812 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10813 error "FID is missing before close"
10814 kill -USR1 $multi_pid
10815 # 1 second delay, so if mtime change we will see it
10817 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10818 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10820 run_test 185 "Volatile file support"
10823 local dir0=$DIR/$tdir/$testnum
10824 mkdir -p $dir0 || error "creating dir $dir0"
10826 local file=$dir0/file1
10827 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10828 local dv1=$($LFS data_version $file)
10829 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10830 local dv2=$($LFS data_version $file)
10831 [[ $dv1 != $dv2 ]] ||
10832 error "data version did not change on write $dv1 == $dv2"
10837 run_test 187a "Test data version change"
10840 local dir0=$DIR/$tdir/$testnum
10841 mkdir -p $dir0 || error "creating dir $dir0"
10843 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10844 [[ ${DV[0]} != ${DV[1]} ]] ||
10845 error "data version did not change on write"\
10846 " ${DV[0]} == ${DV[1]}"
10851 run_test 187b "Test data version change on volatile file"
10854 check_file_in_pool()
10859 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10862 for t in $tlist ; do
10863 [ "$i" -eq "$t" ] && continue 2
10866 echo "pool list: $tlist"
10867 echo "striping: $res"
10868 error_noexit "$file not allocated in $pool"
10875 echo "Creating new pool"
10878 create_pool $FSNAME.$pool ||
10879 { error_noexit "No pool created, result code $?"; return 1; }
10880 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10881 { error_noexit "$pool not in lfs pool_list"; return 2; }
10884 pool_add_targets() {
10885 echo "Adding targets to pool"
10891 local list=$(seq $first $step $last)
10893 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10894 do_facet mgs $LCTL pool_add \
10895 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10896 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10897 | sort -u | tr '\n' ' ' " "$t" || {
10898 error_noexit "Add to pool failed"
10901 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10902 local addcount=$(((last - first) / step + 1))
10903 [ $lfscount -eq $addcount ] || {
10904 error_noexit "lfs pool_list bad ost count" \
10905 "$lfscount != $addcount"
10913 echo "Setting pool on directory $tdir"
10915 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10917 error_noexit "Cannot set pool $pool to $tdir"
10924 echo "Checking pool on directory $tdir"
10926 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10927 [ "$res" = "$pool" ] && return 0
10929 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10933 pool_dir_rel_path() {
10934 echo "Testing relative path works well"
10939 mkdir -p $root/$tdir/$tdir
10941 pool_set_dir $pool $tdir || return 1
10942 pool_set_dir $pool ./$tdir || return 2
10943 pool_set_dir $pool ../$tdir || return 3
10944 pool_set_dir $pool ../$tdir/$tdir || return 4
10945 rm -rf $tdir; cd - > /dev/null
10948 pool_alloc_files() {
10949 echo "Checking files allocation from directory pool"
10956 for i in $(seq -w 1 $count)
10958 local file=$tdir/file-$i
10960 check_file_in_pool $file $pool "$tlist" || \
10961 failed=$((failed + 1))
10963 [ "$failed" = 0 ] && return 0
10965 error_noexit "$failed files not allocated in $pool"
10969 pool_create_files() {
10970 echo "Creating files in pool"
10978 for i in $(seq -w 1 $count)
10980 local file=$tdir/spoo-$i
10981 $SETSTRIPE -p $pool $file
10982 check_file_in_pool $file $pool "$tlist" || \
10983 failed=$((failed + 1))
10985 [ "$failed" = 0 ] && return 0
10987 error_noexit "$failed files not allocated in $pool"
10992 echo "Checking 'lfs df' output"
10995 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10997 local res=$($LFS df --pool $FSNAME.$pool |
10999 grep "$FSNAME-OST" |
11001 [ "$res" = "$t" ] && return 0
11003 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
11007 pool_file_rel_path() {
11008 echo "Creating files in a pool with relative pathname"
11013 { error_noexit "unable to create $tdir"; return 1 ; }
11014 local file="/..$tdir/$tfile-1"
11015 $SETSTRIPE -p $pool $file ||
11016 { error_noexit "unable to create $file" ; return 2 ; }
11019 $SETSTRIPE -p $pool $tfile-2 || {
11020 error_noexit "unable to create $tfile-2 in $tdir"
11025 pool_remove_first_target() {
11026 echo "Removing first target from a pool"
11029 local pname="lov.$FSNAME-*.pools.$pool"
11030 local t=$($LCTL get_param -n $pname | head -n1)
11031 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11032 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
11033 error_noexit "$t not removed from $FSNAME.$pool"
11038 pool_remove_all_targets() {
11039 echo "Removing all targets from pool"
11042 local pname="lov.$FSNAME-*.pools.$pool"
11043 for t in $($LCTL get_param -n $pname | sort -u)
11045 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11047 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
11048 error_noexit "Pool $FSNAME.$pool cannot be drained"
11051 # striping on an empty/nonexistant pool should fall back
11052 # to "pool of everything"
11054 error_noexit "failed to use fallback striping for empty pool"
11057 # setstripe on an empty pool should fail
11058 $SETSTRIPE -p $pool $file 2>/dev/null && {
11059 error_noexit "expected failure when creating file" \
11067 echo "Destroying pool"
11071 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
11074 # striping on an empty/nonexistant pool should fall back
11075 # to "pool of everything"
11077 error_noexit "failed to use fallback striping for missing pool"
11080 # setstripe on an empty pool should fail
11081 $SETSTRIPE -p $pool $file 2>/dev/null && {
11082 error_noexit "expected failure when creating file" \
11083 "with missing pool"
11087 # get param should return err once pool is gone
11088 if wait_update $HOSTNAME "lctl get_param -n \
11089 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
11091 remove_pool_from_list $FSNAME.$pool
11094 error_noexit "Pool $FSNAME.$pool is not destroyed"
11099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11100 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11102 local POOL=${POOL:-cea1}
11103 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11104 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11107 local last_ost=$(($OSTCOUNT - 1))
11109 local ost_list=$(seq $first_ost $ost_step $last_ost)
11110 local ost_range="$first_ost $last_ost $ost_step"
11111 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11112 local file_dir=$POOL_ROOT/file_tst
11116 # former test_200a test_200b
11117 pool_add $POOL || { rc=$? ; break; }
11118 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11119 # former test_200c test_200d
11120 mkdir -p $test_path
11121 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11122 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11123 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11124 || { rc=$? ; break; }
11125 # former test_200e test_200f
11126 local files=$((OSTCOUNT*3))
11127 pool_alloc_files $POOL $test_path $files "$ost_list" \
11128 || { rc=$? ; break; }
11129 pool_create_files $POOL $file_dir $files "$ost_list" \
11130 || { rc=$? ; break; }
11131 # former test_200g test_200h
11132 pool_lfs_df $POOL || { rc=$? ; break; }
11133 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11135 # former test_201a test_201b test_201c
11136 pool_remove_first_target $POOL || { rc=$? ; break; }
11138 local f=$test_path/$tfile
11139 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11140 pool_remove $POOL $f || { rc=$? ; break; }
11147 run_test 200 "OST pools"
11149 # usage: default_attr <count | size | offset>
11151 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11154 # usage: check_default_stripe_attr
11155 check_default_stripe_attr() {
11156 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11158 --stripe-count|--count)
11159 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11160 --stripe-size|--size)
11161 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11162 --stripe-index|--index)
11165 error "unknown getstripe attr '$1'"
11168 [ $ACTUAL != $EXPECTED ] &&
11169 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11173 test_mkdir -p $DIR/$tdir
11174 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11176 check_default_stripe_attr --stripe-count
11177 check_default_stripe_attr --stripe-size
11178 check_default_stripe_attr --stripe-index
11182 run_test 204a "Print default stripe attributes ================="
11185 test_mkdir -p $DIR/$tdir
11186 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11188 check_default_stripe_attr --stripe-size
11189 check_default_stripe_attr --stripe-index
11193 run_test 204b "Print default stripe size and offset ==========="
11196 test_mkdir -p $DIR/$tdir
11197 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11199 check_default_stripe_attr --stripe-count
11200 check_default_stripe_attr --stripe-index
11204 run_test 204c "Print default stripe count and offset ==========="
11207 test_mkdir -p $DIR/$tdir
11208 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11210 check_default_stripe_attr --stripe-count
11211 check_default_stripe_attr --stripe-size
11215 run_test 204d "Print default stripe count and size ============="
11218 test_mkdir -p $DIR/$tdir
11219 $SETSTRIPE -d $DIR/$tdir
11221 check_default_stripe_attr --stripe-count --raw
11222 check_default_stripe_attr --stripe-size --raw
11223 check_default_stripe_attr --stripe-index --raw
11227 run_test 204e "Print raw stripe attributes ================="
11230 test_mkdir -p $DIR/$tdir
11231 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11233 check_default_stripe_attr --stripe-size --raw
11234 check_default_stripe_attr --stripe-index --raw
11238 run_test 204f "Print raw stripe size and offset ==========="
11241 test_mkdir -p $DIR/$tdir
11242 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11244 check_default_stripe_attr --stripe-count --raw
11245 check_default_stripe_attr --stripe-index --raw
11249 run_test 204g "Print raw stripe count and offset ==========="
11252 test_mkdir -p $DIR/$tdir
11253 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11255 check_default_stripe_attr --stripe-count --raw
11256 check_default_stripe_attr --stripe-size --raw
11260 run_test 204h "Print raw stripe count and size ============="
11262 # Figure out which job scheduler is being used, if any,
11263 # or use a fake one
11264 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11265 JOBENV=SLURM_JOB_ID
11266 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11268 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11270 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11271 JOBENV=LOADL_STEP_ID
11272 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11278 verify_jobstats() {
11282 # clear old jobstats
11283 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11284 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11286 # use a new JobID for this test, or we might see an old one
11287 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11291 log "Using JobID environment variable $JOBENV=$JOBVAL"
11293 if [ $JOBENV = "FAKE_JOBID" ]; then
11294 FAKE_JOBID=$JOBVAL $cmd
11299 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11300 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11301 do_facet $FACET lctl get_param mdt.*.job_stats |
11302 grep $JOBVAL || error "No job stats found on MDT $FACET"
11304 if [ "$target" = "ost" -o "$target" = "both" ]; then
11306 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11307 grep $JOBVAL || error "No job stats found on OST $FACET"
11313 NEW_JOBENV=${1:-$OLD_JOBENV}
11314 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11315 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11318 test_205() { # Job stats
11319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11320 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11321 skip "Server doesn't support jobstats" && return 0
11322 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11325 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11326 if [ $OLD_JOBENV != $JOBENV ]; then
11327 jobstats_set $JOBENV
11328 trap jobstats_set EXIT
11332 cmd="mkdir $DIR/$tfile"
11333 verify_jobstats "$cmd" "mdt"
11335 cmd="rm -fr $DIR/$tfile"
11336 verify_jobstats "$cmd" "mdt"
11338 cmd="mknod $DIR/$tfile c 1 3"
11339 verify_jobstats "$cmd" "mdt"
11341 cmd="rm -f $DIR/$tfile"
11342 verify_jobstats "$cmd" "mdt"
11344 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11345 verify_jobstats "$cmd" "mdt"
11347 cmd="touch $DIR/$tfile"
11348 verify_jobstats "$cmd" "both"
11350 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11351 verify_jobstats "$cmd" "ost"
11353 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11354 verify_jobstats "$cmd" "ost"
11356 cmd="$TRUNCATE $DIR/$tfile 0"
11357 verify_jobstats "$cmd" "both"
11359 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11360 verify_jobstats "$cmd" "mdt"
11363 rm -f $DIR/jobstats_test_rename
11365 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11367 run_test 205 "Verify job stats"
11369 # LU-1480, LU-1773 and LU-1657
11371 mkdir -p $DIR/$tdir
11372 $SETSTRIPE -c -1 $DIR/$tdir
11373 #define OBD_FAIL_LOV_INIT 0x1403
11374 $LCTL set_param fail_loc=0xa0001403
11375 $LCTL set_param fail_val=1
11376 touch $DIR/$tdir/$tfile || true
11378 run_test 206 "fail lov_init_raid0() doesn't lbug"
11381 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11382 local fsz=`stat -c %s $DIR/$tfile`
11383 cancel_lru_locks mdc
11385 # do not return layout in getattr intent
11386 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11387 $LCTL set_param fail_loc=0x170
11388 local sz=`stat -c %s $DIR/$tfile`
11390 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11394 run_test 207a "can refresh layout at glimpse"
11397 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11398 local cksum=`md5sum $DIR/$tfile`
11399 local fsz=`stat -c %s $DIR/$tfile`
11400 cancel_lru_locks mdc
11401 cancel_lru_locks osc
11403 # do not return layout in getattr intent
11404 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11405 $LCTL set_param fail_loc=0x171
11407 # it will refresh layout after the file is opened but before read issues
11408 echo checksum is "$cksum"
11409 echo "$cksum" |md5sum -c --quiet || error "file differs"
11413 run_test 207b "can refresh layout at open"
11416 # FIXME: in this test suite, only RD lease is used. This is okay
11417 # for now as only exclusive open is supported. After generic lease
11418 # is done, this test suite should be revised. - Jinshan
11420 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11421 { skip "Need MDS version at least 2.4.52"; return 0; }
11423 echo "==== test 1: verify get lease work"
11424 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11426 echo "==== test 2: verify lease can be broken by upcoming open"
11427 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11431 $MULTIOP $DIR/$tfile oO_RDONLY:c
11432 kill -USR1 $PID && wait $PID || error "break lease error"
11434 echo "==== test 3: verify lease can't be granted if an open already exists"
11435 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11439 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11440 kill -USR1 $PID && wait $PID || error "open file error"
11442 echo "==== test 4: lease can sustain over recovery"
11443 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11449 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11451 echo "==== test 5: lease broken can't be regained by replay"
11452 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11456 # open file to break lease and then recovery
11457 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11460 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11464 run_test 208 "Exclusive open"
11467 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11468 skip_env "must have disp_stripe" && return
11471 sync; sleep 5; sync;
11473 echo 3 > /proc/sys/vm/drop_caches
11474 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11476 # open/close 500 times
11477 for i in $(seq 500); do
11481 echo 3 > /proc/sys/vm/drop_caches
11482 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11484 echo "before: $req_before, after: $req_after"
11485 [ $((req_after - req_before)) -ge 300 ] &&
11486 error "open/close requests are not freed"
11489 run_test 209 "read-only open/close requests should be freed promptly"
11493 size=$((size % 8192 + 1))
11494 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11495 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11496 rm -f $DIR/f212 $DIR/f212.xyz
11498 run_test 212 "Sendfile test ============================================"
11501 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11502 cancel_lru_locks osc
11503 lctl set_param fail_loc=0x8000040f
11504 # generate a read lock
11505 cat $DIR/$tfile > /dev/null
11506 # write to the file, it will try to cancel the above read lock.
11507 cat /etc/hosts >> $DIR/$tfile
11509 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11511 test_214() { # for bug 20133
11512 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11513 for (( i=0; i < 340; i++ )) ; do
11514 touch $DIR/$tdir/d214c/a$i
11517 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11518 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11519 ls $DIR/d214c || error "ls $DIR/d214c failed"
11520 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11521 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11523 run_test 214 "hash-indexed directory test - bug 20133"
11525 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11526 create_lnet_proc_files() {
11527 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11528 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11530 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11531 rm -f "$TMP/lnet_$1.sys_tmp"
11534 # counterpart of create_lnet_proc_files
11535 remove_lnet_proc_files() {
11536 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11539 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11540 # 3rd arg as regexp for body
11541 check_lnet_proc_stats() {
11542 local l=$(cat "$TMP/lnet_$1" |wc -l)
11543 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11545 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11548 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11549 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11550 # optional and can be regexp for 2nd line (lnet.routes case)
11551 check_lnet_proc_entry() {
11552 local blp=2 # blp stands for 'position of 1st line of body'
11553 [ -z "$5" ] || blp=3 # lnet.routes case
11555 local l=$(cat "$TMP/lnet_$1" |wc -l)
11556 # subtracting one from $blp because the body can be empty
11557 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11559 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11560 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11562 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11563 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11565 # bail out if any unexpected line happened
11566 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11567 [ "$?" != 0 ] || error "$2 misformatted"
11570 test_215() { # for bugs 18102, 21079, 21517
11571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11572 local N='(0|[1-9][0-9]*)' # non-negative numeric
11573 local P='[1-9][0-9]*' # positive numeric
11574 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11575 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11576 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11577 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11579 local L1 # regexp for 1st line
11580 local L2 # regexp for 2nd line (optional)
11581 local BR # regexp for the rest (body)
11583 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11584 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11585 create_lnet_proc_files "stats"
11586 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11587 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11588 remove_lnet_proc_files "stats"
11590 # /proc/sys/lnet/routes should look like this:
11591 # Routing disabled/enabled
11592 # net hops priority state router
11593 # where net is a string like tcp0, hops > 0, priority >= 0,
11594 # state is up/down,
11595 # router is a string like 192.168.1.1@tcp2
11596 L1="^Routing (disabled|enabled)$"
11597 L2="^net +hops +priority +state +router$"
11598 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11599 create_lnet_proc_files "routes"
11600 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11601 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11602 remove_lnet_proc_files "routes"
11604 # /proc/sys/lnet/routers should look like this:
11605 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11606 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11607 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11608 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11609 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11610 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11611 create_lnet_proc_files "routers"
11612 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11613 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11614 remove_lnet_proc_files "routers"
11616 # /proc/sys/lnet/peers should look like this:
11617 # nid refs state last max rtr min tx min queue
11618 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11619 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11620 # numeric (0 or >0 or <0), queue >= 0.
11621 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11622 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11623 create_lnet_proc_files "peers"
11624 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11625 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11626 remove_lnet_proc_files "peers"
11628 # /proc/sys/lnet/buffers should look like this:
11629 # pages count credits min
11630 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11631 L1="^pages +count +credits +min$"
11632 BR="^ +$N +$N +$I +$I$"
11633 create_lnet_proc_files "buffers"
11634 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11635 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11636 remove_lnet_proc_files "buffers"
11638 # /proc/sys/lnet/nis should look like this:
11639 # nid status alive refs peer rtr max tx min
11640 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11641 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11642 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11643 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11644 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11645 create_lnet_proc_files "nis"
11646 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11647 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11648 remove_lnet_proc_files "nis"
11650 # can we successfully write to /proc/sys/lnet/stats?
11651 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11652 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11654 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11656 test_216() { # bug 20317
11657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11658 remote_ost_nodsh && skip "remote OST with nodsh" && return
11661 local facets=$(get_facets OST)
11662 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11664 save_lustre_params client "osc.*.contention_seconds" > $p
11665 save_lustre_params $facets \
11666 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11667 save_lustre_params $facets \
11668 "ldlm.namespaces.filter-*.contended_locks" >> $p
11669 save_lustre_params $facets \
11670 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11673 # agressive lockless i/o settings
11674 for node in $(osts_nodes); do
11675 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'
11677 lctl set_param -n osc.*.contention_seconds 60
11679 $DIRECTIO write $DIR/$tfile 0 10 4096
11680 $CHECKSTAT -s 40960 $DIR/$tfile
11682 # disable lockless i/o
11683 for node in $(osts_nodes); do
11684 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'
11686 lctl set_param -n osc.*.contention_seconds 0
11689 dd if=/dev/zero of=$DIR/$tfile count=0
11690 $CHECKSTAT -s 0 $DIR/$tfile
11692 restore_lustre_params <$p
11696 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11698 test_217() { # bug 22430
11699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11703 for node in $(nodes_list); do
11704 nid=$(host_nids_address $node $NETTYPE)
11705 if [[ $nid = *-* ]] ; then
11706 echo "lctl ping $nid@$NETTYPE"
11707 lctl ping $nid@$NETTYPE
11709 echo "skipping $node (no hyphen detected)"
11713 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11716 # do directio so as not to populate the page cache
11717 log "creating a 10 Mb file"
11718 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11719 log "starting reads"
11720 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11721 log "truncating the file"
11722 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11724 kill %+ || true # reads might have finished
11725 echo "wait until dd is finished"
11727 log "removing the temporary file"
11728 rm -rf $DIR/$tfile || error "tmp file removal failed"
11730 run_test 218 "parallel read and truncate should not deadlock ======================="
11733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11734 # write one partial page
11735 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11736 # set no grant so vvp_io_commit_write will do sync write
11737 $LCTL set_param fail_loc=0x411
11738 # write a full page at the end of file
11739 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11741 $LCTL set_param fail_loc=0
11742 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11743 $LCTL set_param fail_loc=0x411
11744 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11747 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11748 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11750 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11752 test_220() { #LU-325
11753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11754 remote_ost_nodsh && skip "remote OST with nodsh" && return
11757 test_mkdir -p $DIR/$tdir
11758 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11759 awk '{print $2}' | sed -e 's/_UUID$//')
11762 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11763 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11764 osc.$mdtosc_proc1.prealloc_last_id)
11765 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11766 osc.$mdtosc_proc1.prealloc_next_id)
11770 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11771 #define OBD_FAIL_OST_ENOINO 0x229
11772 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11773 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11774 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11776 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11778 MDSOBJS=$((last_id - next_id))
11779 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11781 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11782 echo "OST still has $count kbytes free"
11784 echo "create $MDSOBJS files @next_id..."
11785 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11787 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11788 osc.$mdtosc_proc1.prealloc_last_id)
11789 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11790 osc.$mdtosc_proc1.prealloc_next_id)
11792 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11797 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11798 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11800 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11801 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11802 echo "unlink $MDSOBJS files @$next_id..."
11803 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11805 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11809 dd if=`which date` of=$MOUNT/date oflag=sync
11810 chmod +x $MOUNT/date
11812 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11813 $LCTL set_param fail_loc=0x80001401
11815 $MOUNT/date > /dev/null
11818 run_test 221 "make sure fault and truncate race to not cause OOM"
11821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11823 test_mkdir -p $DIR/$tdir
11824 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11825 createmany -o $DIR/$tdir/$tfile 10
11826 cancel_lru_locks mdc
11827 cancel_lru_locks osc
11828 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11829 $LCTL set_param fail_loc=0x31a
11830 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11831 $LCTL set_param fail_loc=0
11834 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11839 test_mkdir -p $DIR/$tdir
11840 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11841 createmany -o $DIR/$tdir/$tfile 10
11842 cancel_lru_locks mdc
11843 cancel_lru_locks osc
11844 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11845 $LCTL set_param fail_loc=0x31a
11846 rm -r $DIR/$tdir || "AGL for rmdir failed"
11847 $LCTL set_param fail_loc=0
11849 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11854 test_mkdir -p $DIR/$tdir
11855 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11856 createmany -o $DIR/$tdir/$tfile 10
11857 cancel_lru_locks mdc
11858 cancel_lru_locks osc
11859 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11860 $LCTL set_param fail_loc=0x31b
11861 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11862 $LCTL set_param fail_loc=0
11865 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11867 test_224a() { # LU-1039, MRP-303
11868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11869 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11870 $LCTL set_param fail_loc=0x508
11871 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11872 $LCTL set_param fail_loc=0
11875 run_test 224a "Don't panic on bulk IO failure"
11877 test_224b() { # LU-1039, MRP-303
11878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11879 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11880 cancel_lru_locks osc
11881 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11882 $LCTL set_param fail_loc=0x515
11883 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11884 $LCTL set_param fail_loc=0
11887 run_test 224b "Don't panic on bulk IO failure"
11889 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11892 if [ -z ${MDSSURVEY} ]; then
11893 skip_env "mds-survey not found" && return
11896 [ $MDSCOUNT -ge 2 ] &&
11897 skip "skipping now for more than one MDT" && return
11899 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11900 { skip "Need MDS version at least 2.2.51"; return; }
11902 local mds=$(facet_host $SINGLEMDS)
11903 local target=$(do_nodes $mds 'lctl dl' | \
11904 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11906 local cmd1="file_count=1000 thrhi=4"
11907 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11908 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11909 local cmd="$cmd1 $cmd2 $cmd3"
11911 rm -f ${TMP}/mds_survey*
11913 eval $cmd || error "mds-survey with zero-stripe failed"
11914 cat ${TMP}/mds_survey*
11915 rm -f ${TMP}/mds_survey*
11917 run_test 225a "Metadata survey sanity with zero-stripe"
11920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11922 if [ -z ${MDSSURVEY} ]; then
11923 skip_env "mds-survey not found" && return
11925 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11926 { skip "Need MDS version at least 2.2.51"; return; }
11928 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11929 skip_env "Need to mount OST to test" && return
11932 [ $MDSCOUNT -ge 2 ] &&
11933 skip "skipping now for more than one MDT" && return
11934 local mds=$(facet_host $SINGLEMDS)
11935 local target=$(do_nodes $mds 'lctl dl' | \
11936 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11938 local cmd1="file_count=1000 thrhi=4"
11939 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11940 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11941 local cmd="$cmd1 $cmd2 $cmd3"
11943 rm -f ${TMP}/mds_survey*
11945 eval $cmd || error "mds-survey with stripe_count failed"
11946 cat ${TMP}/mds_survey*
11947 rm -f ${TMP}/mds_survey*
11949 run_test 225b "Metadata survey sanity with stripe_count = 1"
11951 mcreate_path2fid () {
11957 local path=$DIR/$tdir/$name
11962 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11963 error "cannot create $desc"
11965 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11967 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11969 fid_path=$($LFS fid2path $MOUNT $fid)
11971 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11973 [ "$path" == "$fid_path" ] ||
11974 error "fid2path returned $fid_path, expected $path"
11976 echo "pass with $path and $fid"
11981 mkdir -p $DIR/$tdir
11983 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11984 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11985 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11986 mcreate_path2fid 0040666 0 0 dir "directory"
11987 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11988 mcreate_path2fid 0100666 0 0 file "regular file"
11989 mcreate_path2fid 0120666 0 0 link "symbolic link"
11990 mcreate_path2fid 0140666 0 0 sock "socket"
11992 run_test 226a "call path2fid and fid2path on files of all type"
11995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11999 mkdir -p $DIR/$tdir
12000 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12001 error "create remote directory failed"
12002 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12003 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12004 "character special file (null)"
12005 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12006 "character special file (no device)"
12007 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12008 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12009 "block special file (loop)"
12010 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12011 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12012 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12014 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12016 # LU-1299 Executing or running ldd on a truncated executable does not
12017 # cause an out-of-memory condition.
12019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12020 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12021 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12022 chmod +x $MOUNT/date
12024 $MOUNT/date > /dev/null
12025 ldd $MOUNT/date > /dev/null
12028 run_test 227 "running truncated executable does not cause OOM"
12030 # LU-1512 try to reuse idle OI blocks
12032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12033 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12034 skip "non-ldiskfs backend" && return
12036 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12037 local myDIR=$DIR/$tdir
12040 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12041 $LCTL set_param fail_loc=0x80001002
12042 createmany -o $myDIR/t- 10000
12043 $LCTL set_param fail_loc=0
12044 # The guard is current the largest FID holder
12046 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12048 local IDX=$(($SEQ % 64))
12050 do_facet $SINGLEMDS sync
12051 # Make sure journal flushed.
12053 local blk1=$(do_facet $SINGLEMDS \
12054 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12055 grep Blockcount | awk '{print $4}')
12057 # Remove old files, some OI blocks will become idle.
12058 unlinkmany $myDIR/t- 10000
12059 # Create new files, idle OI blocks should be reused.
12060 createmany -o $myDIR/t- 2000
12061 do_facet $SINGLEMDS sync
12062 # Make sure journal flushed.
12064 local blk2=$(do_facet $SINGLEMDS \
12065 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12066 grep Blockcount | awk '{print $4}')
12068 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12070 run_test 228a "try to reuse idle OI blocks"
12073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12074 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12075 skip "non-ldiskfs backend" && return
12077 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12078 local myDIR=$DIR/$tdir
12081 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12082 $LCTL set_param fail_loc=0x80001002
12083 createmany -o $myDIR/t- 10000
12084 $LCTL set_param fail_loc=0
12085 # The guard is current the largest FID holder
12087 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12089 local IDX=$(($SEQ % 64))
12091 do_facet $SINGLEMDS sync
12092 # Make sure journal flushed.
12094 local blk1=$(do_facet $SINGLEMDS \
12095 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12096 grep Blockcount | awk '{print $4}')
12098 # Remove old files, some OI blocks will become idle.
12099 unlinkmany $myDIR/t- 10000
12102 stop $SINGLEMDS || error "Fail to stop MDT."
12104 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12106 df $MOUNT || error "Fail to df."
12107 # Create new files, idle OI blocks should be reused.
12108 createmany -o $myDIR/t- 2000
12109 do_facet $SINGLEMDS sync
12110 # Make sure journal flushed.
12112 local blk2=$(do_facet $SINGLEMDS \
12113 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12114 grep Blockcount | awk '{print $4}')
12116 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12118 run_test 228b "idle OI blocks can be reused after MDT restart"
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 # 20000 files can guarantee there are index nodes in the OI file
12133 createmany -o $myDIR/t- 20000
12134 $LCTL set_param fail_loc=0
12135 # The guard is current the largest FID holder
12137 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12139 local IDX=$(($SEQ % 64))
12141 do_facet $SINGLEMDS sync
12142 # Make sure journal flushed.
12144 local blk1=$(do_facet $SINGLEMDS \
12145 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12146 grep Blockcount | awk '{print $4}')
12148 # Remove old files, some OI blocks will become idle.
12149 unlinkmany $myDIR/t- 20000
12151 # The OI file should become empty now
12153 # Create new files, idle OI blocks should be reused.
12154 createmany -o $myDIR/t- 2000
12155 do_facet $SINGLEMDS sync
12156 # Make sure journal flushed.
12158 local blk2=$(do_facet $SINGLEMDS \
12159 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12160 grep Blockcount | awk '{print $4}')
12162 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12164 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12166 test_229() { # LU-2482, LU-3448
12167 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12168 skip "No HSM support on MDS of $(get_lustre_version)," \
12169 "need 2.4.53 at least" && return
12170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12171 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12175 # Create a file with a released layout and stripe count 2.
12176 $MULTIOP $DIR/$tfile H2c ||
12177 error "failed to create file with released layout"
12179 $GETSTRIPE -v $DIR/$tfile
12181 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12182 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12184 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12185 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12186 stat $DIR/$tfile || error "failed to stat released file"
12188 chown $RUNAS_ID $DIR/$tfile ||
12189 error "chown $RUNAS_ID $DIR/$tfile failed"
12191 chgrp $RUNAS_ID $DIR/$tfile ||
12192 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12194 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12195 rm $DIR/$tfile || error "failed to remove released file"
12197 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12204 mkdir -p $DIR/$tdir/test_230_local
12205 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12206 [ $mdt_idx -ne 0 ] &&
12207 error "create local directory on wrong MDT $mdt_idx"
12209 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12210 error "create remote directory failed"
12211 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12212 [ $mdt_idx -ne $MDTIDX ] &&
12213 error "create remote directory on wrong MDT $mdt_idx"
12215 createmany -o $DIR/$tdir/test_230/t- 10 ||
12216 error "create files on remote directory failed"
12217 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12218 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12219 rm -r $DIR/$tdir || error "unlink remote directory failed"
12221 run_test 230a "Create remote directory and files under the remote directory"
12224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12232 local migrate_dir=$DIR/$tdir/migrate_dir
12233 local other_dir=$DIR/$tdir/other_dir
12235 mkdir -p $migrate_dir
12236 mkdir -p $other_dir
12237 for ((i=0; i<10; i++)); do
12238 mkdir -p $migrate_dir/dir_${i}
12239 createmany -o $migrate_dir/dir_${i}/f 10 ||
12240 error "create files under remote dir failed $i"
12243 cp /etc/passwd $migrate_dir/$tfile
12244 cp /etc/passwd $other_dir/$tfile
12245 chattr +SAD $migrate_dir
12246 chattr +SAD $migrate_dir/$tfile
12248 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12249 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12250 local old_dir_mode=$(stat -c%f $migrate_dir)
12251 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12253 mkdir -p $migrate_dir/dir_default_stripe2
12254 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12255 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12257 mkdir -p $other_dir
12258 ln $migrate_dir/$tfile $other_dir/luna
12259 ln $migrate_dir/$tfile $migrate_dir/sofia
12260 ln $other_dir/$tfile $migrate_dir/david
12261 ln -s $migrate_dir/$tfile $other_dir/zachary
12262 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12263 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12265 $LFS mv -v -M $MDTIDX $migrate_dir ||
12266 error "migrate remote dir error"
12268 echo "migratate to MDT1, then checking.."
12269 for ((i=0; i<10; i++)); do
12270 for file in $(find $migrate_dir/dir_${i}); do
12271 mdt_index=$($LFS getstripe -M $file)
12272 [ $mdt_index == $MDTIDX ] ||
12273 error "$file is not on MDT${MDTIDX}"
12277 # the multiple link file should still in MDT0
12278 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12279 [ $mdt_index == 0 ] ||
12280 error "$file is not on MDT${MDTIDX}"
12282 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12283 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12284 error " expect $old_dir_flag get $new_dir_flag"
12286 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12287 [ "$old_file_flag" = "$new_file_flag" ] ||
12288 error " expect $old_file_flag get $new_file_flag"
12290 local new_dir_mode=$(stat -c%f $migrate_dir)
12291 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12292 error "expect mode $old_dir_mode get $new_dir_mode"
12294 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12295 [ "$old_file_mode" = "$new_file_mode" ] ||
12296 error "expect mode $old_file_mode get $new_file_mode"
12298 diff /etc/passwd $migrate_dir/$tfile ||
12299 error "$tfile different after migration"
12301 diff /etc/passwd $other_dir/luna ||
12302 error "luna different after migration"
12304 diff /etc/passwd $migrate_dir/sofia ||
12305 error "sofia different after migration"
12307 diff /etc/passwd $migrate_dir/david ||
12308 error "david different after migration"
12310 diff /etc/passwd $other_dir/zachary ||
12311 error "zachary different after migration"
12313 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12314 error "${tfile}_ln different after migration"
12316 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12317 error "${tfile}_ln_other different after migration"
12319 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12320 [ $stripe_count = 2 ] ||
12321 error "dir strpe_count $d != 2 after migration."
12323 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12324 [ $stripe_count = 2 ] ||
12325 error "file strpe_count $d != 2 after migration."
12327 #migrate back to MDT0
12329 $LFS mv -v -M $MDTIDX $migrate_dir ||
12330 error "migrate remote dir error"
12332 echo "migrate back to MDT0, checking.."
12333 for file in $(find $migrate_dir); do
12334 mdt_index=$($LFS getstripe -M $file)
12335 [ $mdt_index == $MDTIDX ] ||
12336 error "$file is not on MDT${MDTIDX}"
12339 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12340 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12341 error " expect $old_dir_flag get $new_dir_flag"
12343 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12344 [ "$old_file_flag" = "$new_file_flag" ] ||
12345 error " expect $old_file_flag get $new_file_flag"
12347 local new_dir_mode=$(stat -c%f $migrate_dir)
12348 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12349 error "expect mode $old_dir_mode get $new_dir_mode"
12351 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12352 [ "$old_file_mode" = "$new_file_mode" ] ||
12353 error "expect mode $old_file_mode get $new_file_mode"
12355 diff /etc/passwd ${migrate_dir}/$tfile ||
12356 error "$tfile different after migration"
12358 diff /etc/passwd ${other_dir}/luna ||
12359 error "luna different after migration"
12361 diff /etc/passwd ${migrate_dir}/sofia ||
12362 error "sofia different after migration"
12364 diff /etc/passwd ${other_dir}/zachary ||
12365 error "zachary different after migration"
12367 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12368 error "${tfile}_ln different after migration"
12370 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12371 error "${tfile}_ln_other different after migration"
12373 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12374 [ $stripe_count = 2 ] ||
12375 error "dir strpe_count $d != 2 after migration."
12377 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12378 [ $stripe_count = 2 ] ||
12379 error "file strpe_count $d != 2 after migration."
12381 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12383 run_test 230b "migrate directory"
12386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12387 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12392 #If migrating directory fails in the middle, all entries of
12393 #the directory is still accessiable.
12394 mkdir -p $DIR/$tdir
12396 createmany -o $DIR/$tdir/f 10 ||
12397 error "create files under ${tdir} failed"
12399 #failed after migrating 5 entries
12400 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12401 do_facet mds1 lctl set_param fail_loc=0x20001801
12402 do_facet mds1 lctl set_param fail_val=5
12403 local t=`ls $DIR/$tdir | wc -l`
12404 $LFS mv -M $MDTIDX $DIR/$tdir &&
12405 error "migrate should failed after 5 entries"
12406 local u=`ls $DIR/$tdir | wc -l`
12407 [ "$u" == "$t" ] || error "$u != $t during migration"
12409 for file in $(find $DIR/$tdir); do
12410 stat $file || error "stat $file failed"
12413 do_facet mds1 lctl set_param fail_loc=0
12414 do_facet mds1 lctl set_param fail_val=0
12416 $LFS mv -M $MDTIDX $DIR/$tdir ||
12417 error "migrate open files should failed with open files"
12419 echo "Finish migration, then checking.."
12420 for file in $(find $DIR/$tdir); do
12421 mdt_index=$($LFS getstripe -M $file)
12422 [ $mdt_index == $MDTIDX ] ||
12423 error "$file is not on MDT${MDTIDX}"
12426 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12428 run_test 230c "check directory accessiblity if migration is failed"
12431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12438 mkdir -p $DIR/$tdir
12440 for ((i=0; i<100; i++)); do
12441 mkdir -p $DIR/$tdir/dir_${i}
12442 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12443 error "create files under remote dir failed $i"
12446 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12448 echo "Finish migration, then checking.."
12449 for file in $(find $DIR/$tdir); do
12450 mdt_index=$($LFS getstripe -M $file)
12451 [ $mdt_index == $MDTIDX ] ||
12452 error "$file is not on MDT${MDTIDX}"
12455 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12457 run_test 230d "check migrate big directory"
12461 # For simplicity this test assumes that max_pages_per_rpc
12462 # is the same across all OSCs
12463 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12464 local bulk_size=$((max_pages * 4096))
12466 mkdir -p $DIR/$tdir
12468 # clear the OSC stats
12469 $LCTL set_param osc.*.stats=0 &>/dev/null
12471 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12472 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12473 oflag=direct &>/dev/null || error "dd failed"
12475 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12476 if [ x$nrpcs != "x1" ]; then
12477 error "found $nrpc ost_write RPCs, not 1 as expected"
12480 # Drop the OSC cache, otherwise we will read from it
12481 cancel_lru_locks osc
12483 # clear the OSC stats
12484 $LCTL set_param osc.*.stats=0 &>/dev/null
12486 # Client reads $bulk_size.
12487 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12488 iflag=direct &>/dev/null || error "dd failed"
12490 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12491 if [ x$nrpcs != "x1" ]; then
12492 error "found $nrpc ost_read RPCs, not 1 as expected"
12495 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12498 mkdir -p $DIR/$tdir
12500 for i in {0..1023}; do
12501 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12502 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12503 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12507 run_test 231b "must not assert on fully utilized OST request buffer"
12510 mkdir -p $DIR/$tdir
12511 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12512 $LCTL set_param fail_loc=0x31c
12514 # ignore dd failure
12515 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12517 $LCTL set_param fail_loc=0
12518 umount_client $MOUNT || error "umount failed"
12519 mount_client $MOUNT || error "mount failed"
12521 run_test 232 "failed lock should not block umount"
12524 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12525 { skip "Need MDS version at least 2.3.64"; return; }
12527 local fid=$($LFS path2fid $MOUNT)
12528 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12529 error "cannot access $MOUNT using its FID '$fid'"
12531 run_test 233a "checking that OBF of the FS root succeeds"
12534 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12535 { skip "Need MDS version at least 2.5.90"; return; }
12537 local fid=$($LFS path2fid $MOUNT/.lustre)
12538 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12539 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12541 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12542 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12543 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12545 run_test 233b "checking that OBF of the FS .lustre succeeds"
12548 local p="$TMP/sanityN-$TESTNAME.parameters"
12549 save_lustre_params client "llite.*.xattr_cache" > $p
12550 lctl set_param llite.*.xattr_cache 1 ||
12551 { skip "xattr cache is not supported"; return 0; }
12553 mkdir -p $DIR/$tdir || error "mkdir failed"
12554 touch $DIR/$tdir/$tfile || error "touch failed"
12555 # OBD_FAIL_LLITE_XATTR_ENOMEM
12556 $LCTL set_param fail_loc=0x1405
12557 if [ ! -f /etc/SuSE-release ]; then
12558 # attr pre-2.4.44-7 had a bug with rc
12559 # LU-3703 - SLES clients have older attr
12560 getfattr -n user.attr $DIR/$tdir/$tfile &&
12561 error "getfattr should have failed with ENOMEM"
12563 $LCTL set_param fail_loc=0x0
12566 restore_lustre_params < $p
12569 run_test 234 "xattr cache should not crash on ENOMEM"
12572 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12573 skip "Need MDS version at least 2.4.52" && return
12574 flock_deadlock $DIR/$tfile
12579 124) error "process hangs on a deadlock"
12581 *) error "error executing flock_deadlock $DIR/$tfile"
12585 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12589 check_swap_layouts_support && return 0
12590 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12592 local ref1=/etc/passwd
12593 local ref2=/etc/group
12594 local file1=$DIR/$tdir/f1
12595 local file2=$DIR/$tdir/f2
12597 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12598 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12599 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12600 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12601 local fd=$(free_fd)
12602 local cmd="exec $fd<>$file2"
12605 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12606 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12609 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12614 run_test 236 "Layout swap on open unlinked file"
12616 # test to verify file handle related system calls
12617 # (name_to_handle_at/open_by_handle_at)
12618 # The new system calls are supported in glibc >= 2.14.
12621 echo "Test file_handle syscalls" > $DIR/$tfile
12622 check_fhandle_syscalls $DIR/$tfile ||
12623 error "check_fhandle_syscalls failed"
12625 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12627 # LU-4659 linkea consistency
12630 ln $DIR/$tfile $DIR/$tfile.lnk
12631 touch $DIR/$tfile.new
12632 mv $DIR/$tfile.new $DIR/$tfile
12633 local fid1=$(lfs path2fid $DIR/$tfile)
12634 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12635 local path1=$(lfs fid2path $FSNAME $fid1)
12636 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12637 local path2=$(lfs fid2path $FSNAME $fid2)
12638 [ $tfile.lnk == $path2 ] ||
12639 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12642 run_test 238 "Verify linkea consistency"
12644 cleanup_test_300() {
12648 test_striped_dir() {
12653 mkdir -p $DIR/$tdir
12655 SAVE_UMASK=$(umask)
12656 trap cleanup_test_300 RETURN EXIT
12658 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12659 $DIR/$tdir/striped_dir ||
12660 error "set striped dir error"
12662 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12663 [ "$mode" = "755" ] || error "expect 755 got $mode"
12665 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12666 if [ "$stripe_count" != "2" ]; then
12667 error "stripe_count is $stripe_count, expect 2"
12670 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12671 if [ "$stripe_index" != "$mdt_index" ]; then
12672 error "stripe_index is $stripe_index, expect $mdt_index"
12675 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12676 error "nlink error after create striped dir"
12678 mkdir $DIR/$tdir/striped_dir/a
12679 mkdir $DIR/$tdir/striped_dir/b
12681 stat $DIR/$tdir/striped_dir/a ||
12682 error "create dir under striped dir failed"
12683 stat $DIR/$tdir/striped_dir/b ||
12684 error "create dir under striped dir failed"
12686 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12687 error "nlink error after mkdir"
12689 rmdir $DIR/$tdir/striped_dir/a
12690 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12691 error "nlink error after rmdir"
12693 rmdir $DIR/$tdir/striped_dir/b
12694 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12695 error "nlink error after rmdir"
12697 rmdir $DIR/$tdir/striped_dir ||
12698 error "rmdir striped dir error"
12706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12709 test_striped_dir 0 || error "failed on striped dir on MDT0"
12710 test_striped_dir 1 || error "failed on striped dir on MDT0"
12712 run_test 300a "basic striped dir sanity test"
12715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12716 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12722 test_mkdir $DIR/$tdir || error "mkdir fail"
12723 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12724 error "set striped dir error"
12725 for ((i=0; i<10; i++)); do
12726 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12728 touch $DIR/$tdir/striped_dir/file_$i ||
12729 error "touch error $i"
12730 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12731 [ $mtime1 -eq $mtime2 ] &&
12732 error "mtime not change after create"
12734 rm -f $DIR/$tdir/striped_dir/file_$i ||
12735 error "unlink error $i"
12736 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12737 [ $mtime2 -eq $mtime3 ] &&
12738 error "mtime did not change after unlink"
12742 run_test 300b "check ctime/mtime for striped dir"
12745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12746 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12749 mkdir -p $DIR/$tdir
12750 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12751 error "set striped dir error"
12753 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12754 error "chown striped dir failed"
12756 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12757 error "create 5k files failed"
12759 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12761 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12765 run_test 300c "chown && check ls under striped directory"
12768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12769 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12773 mkdir -p $DIR/$tdir
12774 $SETSTRIPE -c 2 $DIR/$tdir
12776 #local striped directory
12777 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12778 error "set striped dir error"
12779 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12780 error "create 10 files failed"
12782 #remote striped directory
12783 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12784 error "set striped dir error"
12785 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12786 error "create 10 files failed"
12788 for file in $(find $DIR/$tdir); do
12789 stripe_count=$($GETSTRIPE -c $file)
12790 [ $stripe_count -eq 2 ] ||
12791 error "wrong stripe $stripe_count for $file"
12796 run_test 300d "check default stripe under striped directory"
12799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12800 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12804 mkdir -p $DIR/$tdir
12806 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12807 error "set striped dir error"
12809 touch $DIR/$tdir/striped_dir/a
12810 touch $DIR/$tdir/striped_dir/b
12811 touch $DIR/$tdir/striped_dir/c
12813 mkdir $DIR/$tdir/striped_dir/dir_a
12814 mkdir $DIR/$tdir/striped_dir/dir_b
12815 mkdir $DIR/$tdir/striped_dir/dir_c
12817 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12818 error "set striped dir under striped dir error"
12820 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12821 error "set striped dir under striped dir error"
12823 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12824 error "set striped dir under striped dir error"
12826 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12827 error "rename file under striped dir should fail"
12829 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12830 error "rename dir under striped dir should fail"
12832 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12833 error "rename dir under different stripes should fail"
12835 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12836 error "rename file under striped dir should succeed"
12838 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12839 error "rename dir under striped dir should succeed"
12843 run_test 300e "check rename under striped directory"
12846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12847 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12852 mkdir -p $DIR/$tdir
12854 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12855 error "set striped dir error"
12857 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12858 error "set striped dir error"
12860 touch $DIR/$tdir/striped_dir/a
12861 mkdir $DIR/$tdir/striped_dir/dir_a
12862 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12863 error "create striped dir under striped dir fails"
12865 touch $DIR/$tdir/striped_dir1/b
12866 mkdir $DIR/$tdir/striped_dir1/dir_b
12867 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12868 error "create striped dir under striped dir fails"
12870 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12871 error "rename file under different striped dir should fail"
12873 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12874 error "rename dir under different striped dir should fail"
12876 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12877 error "rename striped dir under diff striped dir should fail"
12879 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12880 error "rename file under diff striped dirs fails"
12882 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12883 error "rename dir under diff striped dirs fails"
12887 run_test 300f "check rename cross striped directory"
12890 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12895 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12896 $DIR/$tdir/striped_dir ||
12897 error "set striped dir error"
12899 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12900 error "set default stripe on striped dir error"
12902 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
12903 [ $stripe_count -eq $MDSCOUNT ] ||
12904 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
12906 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12908 for dir in $(find $DIR/$tdir/striped_dir/*); do
12909 stripe_count=$($LFS getdirstripe -c $dir)
12910 [ $stripe_count -eq $MDSCOUNT ] ||
12911 error "expect $MDSCOUNT get $stripe_count for $dir"
12914 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12915 #change default stripe count to 2
12916 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12917 error "set default stripe on striped dir error"
12919 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12921 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12923 #change default stripe count to 1
12924 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12925 error "set default stripe on striped dir error"
12927 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12928 for dir in $(find $DIR/$tdir/striped_dir/*); do
12929 stripe_count=$($LFS getdirstripe -c $dir)
12930 [ $stripe_count -eq 1 ] ||
12931 error "expect 1 get $stripe_count for $dir"
12933 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12935 run_test 300g "check default striped directory for striped directory"
12937 test_400a() { # LU-1606, was conf-sanity test_74
12938 local extra_flags=''
12939 local out=$TMP/$tfile
12940 local prefix=/usr/include/lustre
12943 if ! which $CC > /dev/null 2>&1; then
12944 skip_env "$CC is not installed"
12948 if ! [[ -d $prefix ]]; then
12949 # Assume we're running in tree and fixup the include path.
12950 extra_flags+=" -I$LUSTRE/../libcfs/include"
12951 extra_flags+=" -I$LUSTRE/include"
12952 extra_flags+=" -L$LUSTRE/utils"
12955 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
12956 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
12957 error "client api broken"
12960 run_test 400a "Lustre client api program can compile and link"
12962 test_400b() { # LU-1606, LU-5011
12964 local out=$TMP/$tfile
12965 local prefix=/usr/include/lustre
12967 # We use a hard coded prefix so that this test will not fail
12968 # when run in tree. There are headers in lustre/include/lustre/
12969 # that are not packaged (like lustre_idl.h) and have more
12970 # complicated include dependencies (like config.h and lnet/types.h).
12971 # Since this test about correct packaging we just skip them when
12972 # they don't exist (see below) rather than try to fixup cppflags.
12974 if ! which $CC > /dev/null 2>&1; then
12975 skip_env "$CC is not installed"
12979 for header in $prefix/*.h; do
12980 if ! [[ -f "$header" ]]; then
12984 if [[ "$(basename $header)" == liblustreapi.h ]]; then
12985 continue # liblustreapi.h is deprecated.
12988 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
12989 error "cannot compile '$header'"
12992 run_test 400b "packaged headers can be compiled"
12995 # tests that do cleanup/setup should be run at the end
12999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13001 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13002 $LCTL set_param fail_loc=0x903
13003 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
13004 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
13007 FAIL_ON_ERROR=true cleanup
13008 FAIL_ON_ERROR=true setup
13010 run_test 900 "umount should not race with any mgc requeue thread"
13013 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13014 check_and_cleanup_lustre
13015 if [ "$I_MOUNTED" != "yes" ]; then
13016 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true