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: LU-9693 LU-6493 LU-9693 3561 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 45 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 LU-10199
16 ALWAYS_EXCEPT=" 407 253 312 56xb $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
23 if [ -r /etc/SuSE-release ]
25 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
26 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
28 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
35 if is_sles11; then # LU-4341
36 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
39 SRCDIR=$(cd $(dirname $0); echo $PWD)
40 export PATH=$PATH:/sbin
46 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
47 CREATETEST=${CREATETEST:-createtest}
49 LFIND=${LFIND:-"$LFS find"}
50 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
52 OPENFILE=${OPENFILE:-openfile}
53 OPENUNLINK=${OPENUNLINK:-openunlink}
54 export MULTIOP=${MULTIOP:-multiop}
55 READS=${READS:-"reads"}
56 MUNLINK=${MUNLINK:-munlink}
57 SOCKETSERVER=${SOCKETSERVER:-socketserver}
58 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
59 MEMHOG=${MEMHOG:-memhog}
60 DIRECTIO=${DIRECTIO:-directio}
61 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
63 CHECK_GRANT=${CHECK_GRANT:-"yes"}
64 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
65 export PARALLEL=${PARALLEL:-"no"}
67 export NAME=${NAME:-local}
74 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
75 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
76 . $LUSTRE/tests/test-framework.sh
78 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
82 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
84 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
85 # bug number for skipped test: LU-1957
86 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
88 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
95 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
96 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
105 check_swap_layouts_support()
107 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
108 { skip "Does not support layout lock."; return 0; }
112 check_and_setup_lustre
116 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
117 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
118 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
120 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
121 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
122 rm -rf $DIR/[Rdfs][0-9]*
124 # $RUNAS_ID may get set incorrectly somewhere else
125 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
127 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
131 if [ "${ONLY}" = "MOUNT" ] ; then
132 echo "Lustre is up, please go on"
136 echo "preparing for tests involving mounts"
137 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
139 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
140 echo # add a newline after mke2fs.
144 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
145 lctl set_param debug=-1 2> /dev/null || true
148 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
150 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
152 run_test 0a "touch; rm ====================="
155 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
156 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
158 run_test 0b "chmod 0755 $DIR ============================="
161 $LCTL get_param mdc.*.import | grep "state: FULL" ||
162 error "import not FULL"
163 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
166 run_test 0c "check import proc"
169 test_mkdir $DIR/$tdir
170 test_mkdir $DIR/$tdir/d2
171 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
172 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
175 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
177 run_test 1 "mkdir; remkdir; rmdir"
180 test_mkdir $DIR/$tdir
181 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
182 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
184 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
186 run_test 2 "mkdir; touch; rmdir; check file"
189 test_mkdir $DIR/$tdir
190 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
191 touch $DIR/$tdir/$tfile
192 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
194 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
196 run_test 3 "mkdir; touch; rmdir; check dir"
198 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
200 test_mkdir -i 1 $DIR/$tdir
202 touch $DIR/$tdir/$tfile ||
203 error "Create file under remote directory failed"
206 error "Expect error removing in-use dir $DIR/$tdir"
208 test -d $DIR/$tdir || error "Remote directory disappeared"
210 rm -rf $DIR/$tdir || error "remove remote dir error"
212 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
215 test_mkdir $DIR/$tdir
216 test_mkdir $DIR/$tdir/d2
217 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
218 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
224 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
225 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
227 error "$tfile does not have perm 0666 or UID $UID"
228 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile should be 0666 and owned by UID $UID"
232 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
237 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
238 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
239 error "$tfile should be owned by UID $RUNAS_ID"
240 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
244 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
249 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
250 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
251 error "$tfile should be owned by GID $UID"
252 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
256 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
260 test_mkdir $DIR/$tdir
261 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
262 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
263 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
264 test_mkdir $DIR/$tdir/d/subdir
265 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
266 error "$tdir/d/subdir should be GID $RUNAS_GID"
267 if [[ $MDSCOUNT -gt 1 ]]; then
268 # check remote dir sgid inherite
269 $LFS mkdir -i 0 $DIR/$tdir.local ||
270 error "mkdir $tdir.local failed"
271 chmod g+s $DIR/$tdir.local ||
272 error "chmod $tdir.local failed"
273 chgrp $RUNAS_GID $DIR/$tdir.local ||
274 error "chgrp $tdir.local failed"
275 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
276 error "mkdir $tdir.remote failed"
277 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
278 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
279 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
280 error "$tdir.remote should be mode 02755"
283 run_test 6g "verify new dir in sgid dir inherits group"
285 test_6h() { # bug 7331
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
287 touch $DIR/$tfile || error "touch failed"
288 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
289 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
290 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
291 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
292 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
294 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
297 test_mkdir $DIR/$tdir
298 $MCREATE $DIR/$tdir/$tfile
299 chmod 0666 $DIR/$tdir/$tfile
300 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
301 error "$tdir/$tfile should be mode 0666"
303 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
306 if [ ! -d $DIR/$tdir ]; then
307 test_mkdir $DIR/$tdir
309 $MCREATE $DIR/$tdir/$tfile
310 echo -n foo > $DIR/$tdir/$tfile
311 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
312 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
314 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
317 test_mkdir $DIR/$tdir
318 touch $DIR/$tdir/$tfile
319 chmod 0666 $DIR/$tdir/$tfile
320 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
321 error "$tfile mode not 0666"
323 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
326 test_mkdir $DIR/$tdir
327 test_mkdir $DIR/$tdir/d2
328 test_mkdir $DIR/$tdir/d2/d3
329 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
331 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
334 test_mkdir $DIR/$tdir
335 test_mkdir $DIR/$tdir/d2
336 touch $DIR/$tdir/d2/$tfile
337 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
338 error "$tdir/d2/$tfile not a file"
340 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
343 test_mkdir $DIR/$tdir
344 test_mkdir $DIR/$tdir/d2
345 chmod 0666 $DIR/$tdir/d2
346 chmod 0705 $DIR/$tdir/d2
347 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
348 error "$tdir/d2 mode not 0705"
350 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
353 test_mkdir $DIR/$tdir
354 touch $DIR/$tdir/$tfile
355 chmod 0666 $DIR/$tdir/$tfile
356 chmod 0654 $DIR/$tdir/$tfile
357 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
358 error "$tdir/d2 mode not 0654"
360 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
363 test_mkdir $DIR/$tdir
364 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
366 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
367 error "$tdir/$tfile size not 0 after truncate"
369 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
372 test_mkdir $DIR/$tdir
373 touch $DIR/$tdir/$tfile
375 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
377 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
380 test_mkdir $DIR/$tdir
381 touch $DIR/$tdir/$tfile
382 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
383 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
384 error "$tdir/${tfile_2} not a file after rename"
385 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
387 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
390 test_mkdir $DIR/$tdir
391 touch $DIR/$tdir/$tfile
392 rm -rf $DIR/$tdir/$tfile
393 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
395 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
398 test_mkdir $DIR/$tdir
399 touch $DIR/$tdir/$tfile
400 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
402 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
403 error "$tdir/l-exist not a symlink"
404 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not referencing a file"
406 rm -f $DIR/$tdir/l-exist
407 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
409 run_test 17a "symlinks: create, remove (real)"
412 test_mkdir $DIR/$tdir
413 ln -s no-such-file $DIR/$tdir/l-dangle
415 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
416 error "$tdir/l-dangle not referencing no-such-file"
417 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing non-existent file"
419 rm -f $DIR/$tdir/l-dangle
420 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
422 run_test 17b "symlinks: create, remove (dangling)"
424 test_17c() { # bug 3440 - don't save failed open RPC for replay
425 test_mkdir $DIR/$tdir
426 ln -s foo $DIR/$tdir/$tfile
427 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
429 run_test 17c "symlinks: open dangling (should return error)"
432 test_mkdir $DIR/$tdir
433 ln -s foo $DIR/$tdir/$tfile
434 touch $DIR/$tdir/$tfile || error "creating to new symlink"
436 run_test 17d "symlinks: create dangling"
439 test_mkdir $DIR/$tdir
440 local foo=$DIR/$tdir/$tfile
441 ln -s $foo $foo || error "create symlink failed"
442 ls -l $foo || error "ls -l failed"
443 ls $foo && error "ls not failed" || true
445 run_test 17e "symlinks: create recursive symlink (should return error)"
448 test_mkdir $DIR/$tdir
449 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
454 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
457 run_test 17f "symlinks: long and very long symlink name"
459 # str_repeat(S, N) generate a string that is string S repeated N times
464 while [ $((n -= 1)) -ge 0 ]; do
470 # Long symlinks and LU-2241
472 test_mkdir $DIR/$tdir
473 local TESTS="59 60 61 4094 4095"
475 # Fix for inode size boundary in 2.1.4
476 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
479 # Patch not applied to 2.2 or 2.3 branches
480 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
481 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
484 # skip long symlink name for rhel6.5.
485 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
486 grep -q '6.5' /etc/redhat-release &>/dev/null &&
487 TESTS="59 60 61 4062 4063"
490 local SYMNAME=$(str_repeat 'x' $i)
491 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
492 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
495 run_test 17g "symlinks: really long symlink name and inode boundaries"
497 test_17h() { #bug 17378
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir $DIR/$tdir
502 if [[ $MDSCOUNT -gt 1 ]]; then
503 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
507 $LFS setstripe -c -1 $DIR/$tdir
508 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
509 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
510 touch $DIR/$tdir/$tfile || true
512 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
514 test_17i() { #bug 20018
515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
517 test_mkdir -c1 $DIR/$tdir
518 local foo=$DIR/$tdir/$tfile
520 if [[ $MDSCOUNT -gt 1 ]]; then
521 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
525 ln -s $foo $foo || error "create symlink failed"
526 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
527 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
528 ls -l $foo && error "error not detected"
531 run_test 17i "don't panic on short symlink"
533 test_17k() { #bug 22301
534 [[ -z "$(which rsync 2>/dev/null)" ]] &&
535 skip "no rsync command" && return 0
536 rsync --help | grep -q xattr ||
537 skip_env "$(rsync --version | head -n1) does not support xattrs"
538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
539 test_mkdir $DIR/$tdir
540 test_mkdir $DIR/$tdir.new
541 touch $DIR/$tdir/$tfile
542 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
543 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
544 error "rsync failed with xattrs enabled"
546 run_test 17k "symlinks: rsync with xattrs enabled"
548 test_17l() { # LU-279
549 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
550 skip "no getfattr command" && return 0
551 test_mkdir $DIR/$tdir
552 touch $DIR/$tdir/$tfile
553 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
554 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
555 # -h to not follow symlinks. -m '' to list all the xattrs.
556 # grep to remove first line: '# file: $path'.
557 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
559 lgetxattr_size_check $path $xattr ||
560 error "lgetxattr_size_check $path $xattr failed"
564 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
568 local short_sym="0123456789"
569 local wdir=$DIR/$tdir
572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
573 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
574 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
575 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
577 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
578 skip "ldiskfs only test" && return 0
580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
584 # create a long symlink file
585 for ((i = 0; i < 4; ++i)); do
586 long_sym=${long_sym}${long_sym}
589 echo "create 512 short and long symlink files under $wdir"
590 for ((i = 0; i < 256; ++i)); do
591 ln -sf ${long_sym}"a5a5" $wdir/long-$i
592 ln -sf ${short_sym}"a5a5" $wdir/short-$i
598 wait_delete_completed
600 echo "recreate the 512 symlink files with a shorter string"
601 for ((i = 0; i < 512; ++i)); do
602 # rewrite the symlink file with a shorter string
603 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
604 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
607 local mds_index=$(($($LFS getstripe -M $wdir) + 1))
608 local devname=$(mdsdevname $mds_index)
610 echo "stop and checking mds${mds_index}:"
611 # e2fsck should not return error
613 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
616 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
617 error "start mds${mds_index} failed"
618 df $MOUNT > /dev/null 2>&1
620 error "e2fsck detected error for short/long symlink: rc=$rc"
622 run_test 17m "run e2fsck against MDT which contains short/long symlink"
624 check_fs_consistency_17n() {
628 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
629 # so it only check MDT1/MDT2 instead of all of MDTs.
630 for mdt_index in 1 2; do
631 local devname=$(mdsdevname $mdt_index)
632 # e2fsck should not return error
634 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
637 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
638 error "mount mds$mdt_index failed"
639 df $MOUNT > /dev/null 2>&1
647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
648 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
649 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
650 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
652 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
653 skip "ldiskfs only test" && return 0
655 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
659 test_mkdir $DIR/$tdir
660 for ((i=0; i<10; i++)); do
661 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
662 error "create remote dir error $i"
663 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
664 error "create files under remote dir failed $i"
667 check_fs_consistency_17n ||
668 error "e2fsck report error after create files under remote dir"
670 for ((i = 0; i < 10; i++)); do
671 rm -rf $DIR/$tdir/remote_dir_${i} ||
672 error "destroy remote dir error $i"
675 check_fs_consistency_17n ||
676 error "e2fsck report error after unlink files under remote dir"
678 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
679 skip "lustre < 2.4.50 does not support migrate mv " && return
681 for ((i = 0; i < 10; i++)); do
682 mkdir -p $DIR/$tdir/remote_dir_${i}
683 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
684 error "create files under remote dir failed $i"
685 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
686 error "migrate remote dir error $i"
688 check_fs_consistency_17n || error "e2fsck report error after migration"
690 for ((i = 0; i < 10; i++)); do
691 rm -rf $DIR/$tdir/remote_dir_${i} ||
692 error "destroy remote dir error $i"
695 check_fs_consistency_17n || error "e2fsck report error after unlink"
697 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
700 remote_mds_nodsh && skip "remote MDS with nodsh" && return
701 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
702 skip "Need MDS version at least 2.3.64" && return
704 local wdir=$DIR/${tdir}o
710 mdt_index=$($LFS getstripe -M $wdir/$tfile)
711 mdt_index=$((mdt_index + 1))
714 #fail mds will wait the failover finish then set
715 #following fail_loc to avoid interfer the recovery process.
718 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
719 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
720 ls -l $wdir/$tfile && rc=1
721 do_facet mds${mdt_index} lctl set_param fail_loc=0
722 [[ $rc -eq 0 ]] || error "stat file should fail"
724 run_test 17o "stat file with incompat LMA feature"
727 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
728 ls $DIR || error "Failed to ls $DIR: $?"
730 run_test 18 "touch .../f ; ls ... =============================="
736 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
738 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
741 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
743 run_test 19b "ls -l .../f19 (should return error) =============="
746 [ $RUNAS_ID -eq $UID ] &&
747 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
748 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
750 run_test 19c "$RUNAS touch .../f19 (should return error) =="
753 cat $DIR/f19 && error || true
755 run_test 19d "cat .../f19 (should return error) =============="
764 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
766 run_test 20 "touch .../f ; ls -l ..."
769 test_mkdir $DIR/$tdir
770 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
771 ln -s dangle $DIR/$tdir/link
772 echo foo >> $DIR/$tdir/link
773 cat $DIR/$tdir/dangle
774 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
775 $CHECKSTAT -f -t file $DIR/$tdir/link ||
776 error "$tdir/link not linked to a file"
778 run_test 21 "write to dangling link"
781 local wdir=$DIR/$tdir
783 chown $RUNAS_ID:$RUNAS_GID $wdir
784 (cd $wdir || error "cd $wdir failed";
785 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
787 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
788 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
789 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
790 error "checkstat -u failed"
792 run_test 22 "unpack tar archive as non-root user"
796 test_mkdir $DIR/$tdir
797 local file=$DIR/$tdir/$tfile
799 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
800 openfile -f O_CREAT:O_EXCL $file &&
801 error "$file recreate succeeded" || true
803 run_test 23a "O_CREAT|O_EXCL in subdir"
805 test_23b() { # bug 18988
806 test_mkdir $DIR/$tdir
807 local file=$DIR/$tdir/$tfile
810 echo foo > $file || error "write filed"
811 echo bar >> $file || error "append filed"
812 $CHECKSTAT -s 8 $file || error "wrong size"
815 run_test 23b "O_APPEND check"
819 echo '-- same directory rename'
820 test_mkdir $DIR/$tdir
821 touch $DIR/$tdir/$tfile.1
822 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
823 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
825 run_test 24a "rename file to non-existent target"
828 test_mkdir $DIR/$tdir
829 touch $DIR/$tdir/$tfile.{1,2}
830 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
831 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
832 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
834 run_test 24b "rename file to existing target"
837 test_mkdir $DIR/$tdir
838 test_mkdir $DIR/$tdir/d$testnum.1
839 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
840 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
841 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
843 run_test 24c "rename directory to non-existent target"
846 test_mkdir -c1 $DIR/$tdir
847 test_mkdir -c1 $DIR/$tdir/d$testnum.1
848 test_mkdir -c1 $DIR/$tdir/d$testnum.2
849 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
850 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
851 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
853 run_test 24d "rename directory to existing target"
856 echo '-- cross directory renames --'
860 mv $DIR/R5a/f $DIR/R5b/g
861 $CHECKSTAT -a $DIR/R5a/f || error
862 $CHECKSTAT -t file $DIR/R5b/g || error
864 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
869 touch $DIR/R6a/f $DIR/R6b/g
870 mv $DIR/R6a/f $DIR/R6b/g
871 $CHECKSTAT -a $DIR/R6a/f || error
872 $CHECKSTAT -t file $DIR/R6b/g || error
874 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
879 test_mkdir $DIR/R7a/d
880 mv $DIR/R7a/d $DIR/R7b/e
881 $CHECKSTAT -a $DIR/R7a/d || error
882 $CHECKSTAT -t dir $DIR/R7b/e || error
884 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
887 test_mkdir -c1 $DIR/R8a
888 test_mkdir -c1 $DIR/R8b
889 test_mkdir -c1 $DIR/R8a/d
890 test_mkdir -c1 $DIR/R8b/e
891 mrename $DIR/R8a/d $DIR/R8b/e
892 $CHECKSTAT -a $DIR/R8a/d || error
893 $CHECKSTAT -t dir $DIR/R8b/e || error
895 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
898 echo "-- rename error cases"
902 mrename $DIR/R9/f $DIR/R9/a
903 $CHECKSTAT -t file $DIR/R9/f || error
904 $CHECKSTAT -t dir $DIR/R9/a || error
905 $CHECKSTAT -a $DIR/R9/a/f || error
907 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
911 mrename $DIR/R10/f $DIR/R10/g
912 $CHECKSTAT -t dir $DIR/R10 || error
913 $CHECKSTAT -a $DIR/R10/f || error
914 $CHECKSTAT -a $DIR/R10/g || error
916 run_test 24j "source does not exist ============================"
920 test_mkdir $DIR/R11a/d
922 mv $DIR/R11a/f $DIR/R11a/d
923 $CHECKSTAT -a $DIR/R11a/f || error
924 $CHECKSTAT -t file $DIR/R11a/d/f || error
926 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
928 # bug 2429 - rename foo foo foo creates invalid file
931 $MULTIOP $f OcNs || error
933 run_test 24l "Renaming a file to itself ========================"
937 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
938 # on ext3 this does not remove either the source or target files
939 # though the "expected" operation would be to remove the source
940 $CHECKSTAT -t file ${f} || error "${f} missing"
941 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
943 run_test 24m "Renaming a file to a hard link to itself ========="
947 # this stats the old file after it was renamed, so it should fail
951 $CHECKSTAT ${f}.rename
954 run_test 24n "Statting the old file after renaming (Posix rename 2)"
957 test_mkdir $DIR/$tdir
958 rename_many -s random -v -n 10 $DIR/$tdir
960 run_test 24o "rename of files during htree split"
965 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
966 mrename $DIR/R12a $DIR/R12b
967 $CHECKSTAT -a $DIR/R12a || error
968 $CHECKSTAT -t dir $DIR/R12b || error
969 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
970 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
972 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
974 cleanup_multiop_pause() {
980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
983 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
984 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
987 trap cleanup_multiop_pause EXIT
988 mrename $DIR/R13a $DIR/R13b
989 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
990 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
991 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
992 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
993 cleanup_multiop_pause
994 wait $MULTIPID || error "multiop close failed"
996 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
998 test_24r() { #bug 3789
1000 test_mkdir $DIR/R14a/b
1001 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1002 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1003 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1005 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1008 test_mkdir $DIR/R15a
1009 test_mkdir $DIR/R15a/b
1010 test_mkdir $DIR/R15a/b/c
1011 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1012 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1013 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1015 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1017 test_mkdir $DIR/R16a
1018 test_mkdir $DIR/R16a/b
1019 test_mkdir $DIR/R16a/b/c
1020 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1021 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1022 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1024 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1026 test_24u() { # bug12192
1027 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1028 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1030 run_test 24u "create stripe file"
1034 size=$(getconf PAGE_SIZE 2>/dev/null)
1035 echo -n ${size:-4096}
1038 simple_cleanup_common() {
1041 [ -z "$DIR" -o -z "$tdir" ] && return 0
1043 local start=$SECONDS
1046 wait_delete_completed
1047 echo "cleanup time $((SECONDS - start))"
1051 max_pages_per_rpc() {
1052 local mdtname="$(printf "MDT%04x" ${1:-0})"
1053 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1058 local nrfiles=${COUNT:-100000}
1059 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1060 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1062 local fname="$DIR/$tdir/$tfile"
1063 test_mkdir "$(dirname $fname)"
1064 # assume MDT0000 has the fewest inodes
1065 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1066 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1067 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1069 trap simple_cleanup_common EXIT
1071 createmany -m "$fname" $nrfiles
1073 cancel_lru_locks mdc
1074 lctl set_param mdc.*.stats clear
1076 # was previously test_24D: LU-6101
1077 # readdir() returns correct number of entries after cursor reload
1078 local num_ls=$(ls $DIR/$tdir | wc -l)
1079 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1080 local num_all=$(ls -a $DIR/$tdir | wc -l)
1081 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1082 $num_all -ne $((nrfiles + 2)) ]; then
1083 error "Expected $nrfiles files, got $num_ls " \
1084 "($num_uniq unique $num_all .&..)"
1086 # LU-5 large readdir
1087 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1088 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1089 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1090 # take into account of overhead in lu_dirpage header and end mark in
1091 # each page, plus one in rpc_num calculation.
1092 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1093 local page_entries=$((($(page_size) - 24) / dirent_size))
1094 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1095 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1096 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1097 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1098 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1099 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1100 error "large readdir doesn't take effect: " \
1101 "$mds_readpage should be about $rpc_max"
1103 simple_cleanup_common
1105 run_test 24v "list large directory (test hash collision, b=17560)"
1107 test_24w() { # bug21506
1109 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1110 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1111 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1112 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1113 [[ "$SZ1" -eq "$SZ2" ]] ||
1114 error "Error reading at the end of the file $tfile"
1116 run_test 24w "Reading a file larger than 4Gb"
1119 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1121 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1122 skip "Need MDS version at least 2.7.56" && return
1124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1126 local remote_dir=$DIR/$tdir/remote_dir
1128 test_mkdir $DIR/$tdir
1129 $LFS mkdir -i $MDTIDX $remote_dir ||
1130 error "create remote directory failed"
1132 test_mkdir $DIR/$tdir/src_dir
1133 touch $DIR/$tdir/src_file
1134 test_mkdir $remote_dir/tgt_dir
1135 touch $remote_dir/tgt_file
1137 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1138 error "rename dir cross MDT failed!"
1140 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1141 error "rename file cross MDT failed!"
1143 touch $DIR/$tdir/ln_file
1144 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1145 error "ln file cross MDT failed"
1147 rm -rf $DIR/$tdir || error "Can not delete directories"
1149 run_test 24x "cross MDT rename/link"
1152 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1154 local remote_dir=$DIR/$tdir/remote_dir
1157 test_mkdir $DIR/$tdir
1158 $LFS mkdir -i $mdtidx $remote_dir ||
1159 error "create remote directory failed"
1161 test_mkdir $remote_dir/src_dir
1162 touch $remote_dir/src_file
1163 test_mkdir $remote_dir/tgt_dir
1164 touch $remote_dir/tgt_file
1166 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1167 error "rename subdir in the same remote dir failed!"
1169 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1170 error "rename files in the same remote dir failed!"
1172 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1173 error "link files in the same remote dir failed!"
1175 rm -rf $DIR/$tdir || error "Can not delete directories"
1177 run_test 24y "rename/link on the same dir should succeed"
1179 test_24A() { # LU-3182
1183 test_mkdir $DIR/$tdir
1184 trap simple_cleanup_common EXIT
1185 createmany -m $DIR/$tdir/$tfile $NFILES
1186 local t=$(ls $DIR/$tdir | wc -l)
1187 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1188 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1189 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1190 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1193 simple_cleanup_common || error "Can not delete directories"
1195 run_test 24A "readdir() returns correct number of entries."
1197 test_24B() { # LU-4805
1198 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1201 test_mkdir $DIR/$tdir
1202 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1203 error "create striped dir failed"
1205 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1206 [ $count -eq 2 ] || error "Expected 2, got $count"
1208 touch $DIR/$tdir/striped_dir/a
1210 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1211 [ $count -eq 3 ] || error "Expected 3, got $count"
1213 touch $DIR/$tdir/striped_dir/.f
1215 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1216 [ $count -eq 4 ] || error "Expected 4, got $count"
1218 rm -rf $DIR/$tdir || error "Can not delete directories"
1220 run_test 24B "readdir for striped dir return correct number of entries"
1223 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1229 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1230 error "create striped dir failed"
1232 cd $DIR/$tdir/d0/striped_dir
1234 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1235 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1236 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1238 [ "$d0_ino" = "$parent_ino" ] ||
1239 error ".. wrong, expect $d0_ino, get $parent_ino"
1241 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1242 error "mv striped dir failed"
1244 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1246 [ "$d1_ino" = "$parent_ino" ] ||
1247 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1249 run_test 24C "check .. in striped dir"
1252 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1256 mkdir $DIR/$tdir/src_dir
1257 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1258 error "create remote source failed"
1260 touch $DIR/$tdir/src_dir/src_child/a
1262 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1263 error "create remote target dir failed"
1265 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1266 error "create remote target child failed"
1268 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1269 error "rename dir cross MDT failed!"
1273 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1274 error "src_child still exists after rename"
1276 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1277 error "missing file(a) after rename"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24E "cross MDT rename/link"
1284 echo '== symlink sanity ============================================='
1288 touch $DIR/s25/foo || error
1290 run_test 25a "create file in symlinked directory ==============="
1293 [ ! -d $DIR/d25 ] && test_25a
1294 $CHECKSTAT -t file $DIR/s25/foo || error
1296 run_test 25b "lookup file in symlinked directory ==============="
1300 test_mkdir $DIR/d26/d26-2
1301 ln -s d26/d26-2 $DIR/s26
1302 touch $DIR/s26/foo || error
1304 run_test 26a "multiple component symlink ======================="
1307 test_mkdir -p $DIR/$tdir/d26-2
1308 ln -s $tdir/d26-2/foo $DIR/s26-2
1309 touch $DIR/s26-2 || error
1311 run_test 26b "multiple component symlink at end of lookup ======"
1314 test_mkdir $DIR/d26.2
1315 touch $DIR/d26.2/foo
1316 ln -s d26.2 $DIR/s26.2-1
1317 ln -s s26.2-1 $DIR/s26.2-2
1318 ln -s s26.2-2 $DIR/s26.2-3
1319 chmod 0666 $DIR/s26.2-3/foo
1321 run_test 26c "chain of symlinks"
1323 # recursive symlinks (bug 439)
1325 ln -s d26-3/foo $DIR/d26-3
1327 run_test 26d "create multiple component recursive symlink"
1330 [ ! -h $DIR/d26-3 ] && test_26d
1333 run_test 26e "unlink multiple component recursive symlink"
1335 # recursive symlinks (bug 7022)
1337 test_mkdir $DIR/$tdir
1338 test_mkdir $DIR/$tdir/$tfile
1339 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1340 test_mkdir -p lndir/bar1
1341 test_mkdir $DIR/$tdir/$tfile/$tfile
1342 cd $tfile || error "cd $tfile failed"
1343 ln -s .. dotdot || error "ln dotdot failed"
1344 ln -s dotdot/lndir lndir || error "ln lndir failed"
1345 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1346 output=`ls $tfile/$tfile/lndir/bar1`
1347 [ "$output" = bar1 ] && error "unexpected output"
1348 rm -r $tfile || error "rm $tfile failed"
1349 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1351 run_test 26f "rm -r of a directory which has recursive symlink"
1354 test_mkdir $DIR/$tdir
1355 $LFS getstripe $DIR/$tdir
1356 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1357 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1358 cp /etc/hosts $DIR/$tdir/$tfile || error
1360 run_test 27a "one stripe file"
1363 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1364 test_mkdir $DIR/$tdir
1365 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1366 $LFS getstripe -c $DIR/$tdir/$tfile
1367 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1368 error "two-stripe file doesn't have two stripes"
1370 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1372 run_test 27b "create and write to two stripe file"
1375 test_mkdir $DIR/$tdir
1376 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1377 error "setstripe failed"
1378 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1379 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1381 run_test 27d "create file with default settings"
1384 # LU-5839 adds check for existed layout before setting it
1385 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1386 skip "Need MDS version at least 2.7.56" && return
1387 test_mkdir $DIR/$tdir
1388 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1389 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1390 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1392 run_test 27e "setstripe existing file (should return error)"
1395 test_mkdir $DIR/$tdir
1396 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1397 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1398 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1399 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1400 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1401 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1403 run_test 27f "setstripe with bad stripe size (should return error)"
1406 test_mkdir $DIR/$tdir
1407 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1408 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1409 error "$DIR/$tdir/$tfile has object"
1411 run_test 27g "$LFS getstripe with no objects"
1414 test_mkdir $DIR/$tdir
1415 touch $DIR/$tdir/$tfile || error "touch failed"
1416 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1417 error "missing objects"
1419 run_test 27i "$LFS getstripe with some objects"
1422 test_mkdir $DIR/$tdir
1423 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1424 error "setstripe failed" || true
1426 run_test 27j "setstripe with bad stripe offset (should return error)"
1428 test_27k() { # bug 2844
1429 test_mkdir $DIR/$tdir
1430 local file=$DIR/$tdir/$tfile
1431 local ll_max_blksize=$((4 * 1024 * 1024))
1432 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1433 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1434 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1435 dd if=/dev/zero of=$file bs=4k count=1
1436 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1437 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1439 run_test 27k "limit i_blksize for broken user apps"
1442 mcreate $DIR/$tfile || error "creating file"
1443 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1444 error "setstripe should have failed" || true
1446 run_test 27l "check setstripe permissions (should return error)"
1449 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1451 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1453 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1454 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1457 trap simple_cleanup_common EXIT
1458 test_mkdir $DIR/$tdir
1459 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1460 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1461 error "dd should fill OST0"
1463 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1465 [ $i -gt 256 ] && break
1468 touch $DIR/$tdir/$tfile.$i
1469 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1470 awk '{print $1}'| grep -w "0") ] &&
1471 error "OST0 was full but new created file still use it"
1473 touch $DIR/$tdir/$tfile.$i
1474 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1475 awk '{print $1}'| grep -w "0") ] &&
1476 error "OST0 was full but new created file still use it"
1477 simple_cleanup_common
1479 run_test 27m "create file while OST0 was full"
1482 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1483 head -n 1 | awk '{ print $1 * 2 }')
1487 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1488 # if the OST isn't full anymore.
1490 local OSTIDX=${1:-""}
1492 local list=$(comma_list $(osts_nodes))
1493 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1495 do_nodes $list lctl set_param fail_loc=0
1496 sync # initiate all OST_DESTROYs from MDS to OST
1500 exhaust_precreations() {
1503 local FAILIDX=${3:-$OSTIDX}
1504 local ofacet=ost$((OSTIDX + 1))
1506 test_mkdir -p -c1 $DIR/$tdir
1507 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1508 local mfacet=mds$((mdtidx + 1))
1509 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1511 local OST=$(ostname_from_index $OSTIDX)
1514 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1515 local last_id=$(do_facet $mfacet lctl get_param -n \
1516 osc.$mdtosc_proc1.prealloc_last_id)
1517 local next_id=$(do_facet $mfacet lctl get_param -n \
1518 osc.$mdtosc_proc1.prealloc_next_id)
1520 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1521 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1523 test_mkdir -p $DIR/$tdir/${OST}
1524 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1525 #define OBD_FAIL_OST_ENOSPC 0x215
1526 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1527 echo "Creating to objid $last_id on ost $OST..."
1528 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1529 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1530 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1534 exhaust_all_precreations() {
1536 for (( i=0; i < OSTCOUNT; i++ )) ; do
1537 exhaust_precreations $i $1 -1
1542 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1544 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1545 remote_ost_nodsh && skip "remote OST with nodsh" && return
1548 rm -f $DIR/$tdir/$tfile
1549 exhaust_precreations 0 0x80000215
1550 $LFS setstripe -c -1 $DIR/$tdir
1551 touch $DIR/$tdir/$tfile || error
1552 $LFS getstripe $DIR/$tdir/$tfile
1555 run_test 27n "create file with some full OSTs"
1558 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1560 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1561 remote_ost_nodsh && skip "remote OST with nodsh" && return
1564 rm -f $DIR/$tdir/$tfile
1565 exhaust_all_precreations 0x215
1567 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1572 run_test 27o "create file with all full OSTs (should error)"
1575 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 remote_ost_nodsh && skip "remote OST with nodsh" && return
1581 rm -f $DIR/$tdir/$tfile
1582 test_mkdir $DIR/$tdir
1584 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1585 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1586 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1588 exhaust_precreations 0 0x80000215
1589 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1590 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1591 $LFS getstripe $DIR/$tdir/$tfile
1595 run_test 27p "append to a truncated file with some full OSTs"
1598 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1600 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1601 remote_ost_nodsh && skip "remote OST with nodsh" && return
1604 rm -f $DIR/$tdir/$tfile
1606 test_mkdir $DIR/$tdir
1607 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1608 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1609 error "truncate $DIR/$tdir/$tfile failed"
1610 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1612 exhaust_all_precreations 0x215
1614 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1615 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1619 run_test 27q "append to truncated file with all OSTs full (should error)"
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 remote_ost_nodsh && skip "remote OST with nodsh" && return
1628 rm -f $DIR/$tdir/$tfile
1629 exhaust_precreations 0 0x80000215
1631 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1635 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1637 test_27s() { # bug 10725
1638 test_mkdir $DIR/$tdir
1639 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1640 local stripe_count=0
1641 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1642 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1643 error "stripe width >= 2^32 succeeded" || true
1646 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1648 test_27t() { # bug 10864
1653 $WLFS getstripe $tfile
1656 run_test 27t "check that utils parse path correctly"
1658 test_27u() { # bug 4900
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 local list=$(comma_list $(mdts_nodes))
1664 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1665 do_nodes $list $LCTL set_param fail_loc=0x139
1666 test_mkdir -p $DIR/$tdir
1667 trap simple_cleanup_common EXIT
1668 createmany -o $DIR/$tdir/t- 1000
1669 do_nodes $list $LCTL set_param fail_loc=0
1671 TLOG=$TMP/$tfile.getstripe
1672 $LFS getstripe $DIR/$tdir > $TLOG
1673 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1674 unlinkmany $DIR/$tdir/t- 1000
1676 [[ $OBJS -gt 0 ]] &&
1677 error "$OBJS objects created on OST-0. See $TLOG" || pass
1679 run_test 27u "skip object creation on OSC w/o objects"
1681 test_27v() { # bug 4900
1682 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1684 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1685 remote_ost_nodsh && skip "remote OST with nodsh" && return
1687 exhaust_all_precreations 0x215
1690 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1692 touch $DIR/$tdir/$tfile
1693 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1695 for (( i=1; i < OSTCOUNT; i++ )); do
1696 do_facet ost$i lctl set_param fail_loc=0x705
1698 local START=`date +%s`
1699 createmany -o $DIR/$tdir/$tfile 32
1701 local FINISH=`date +%s`
1702 local TIMEOUT=`lctl get_param -n timeout`
1703 local PROCESS=$((FINISH - START))
1704 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1705 error "$FINISH - $START >= $TIMEOUT / 2"
1706 sleep $((TIMEOUT / 2 - PROCESS))
1709 run_test 27v "skip object creation on slow OST"
1711 test_27w() { # bug 10997
1712 test_mkdir $DIR/$tdir
1713 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1714 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1715 error "stripe size $size != 65536" || true
1716 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1717 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1719 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1722 [[ $OSTCOUNT -lt 2 ]] &&
1723 skip_env "skipping multiple stripe count/offset test" && return
1725 test_mkdir $DIR/$tdir
1726 for i in $(seq 1 $OSTCOUNT); do
1728 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1729 error "setstripe -c $i -i $offset failed"
1730 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1731 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1732 [ $count -ne $i ] && error "stripe count $count != $i" || true
1733 [ $index -ne $offset ] &&
1734 error "stripe offset $index != $offset" || true
1737 run_test 27wa "check $LFS setstripe -c -i options"
1740 remote_ost_nodsh && skip "remote OST with nodsh" && return
1741 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1743 OFFSET=$(($OSTCOUNT - 1))
1745 local OST=$(ostname_from_index $OSTIDX)
1747 test_mkdir $DIR/$tdir
1748 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1749 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1751 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1752 for i in $(seq 0 $OFFSET); do
1753 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1754 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1755 error "OST0 was degraded but new created file still use it"
1757 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1759 run_test 27x "create files while OST0 is degraded"
1762 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1763 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1764 remote_ost_nodsh && skip "remote OST with nodsh" && return
1765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1767 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1768 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1769 osc.$mdtosc.prealloc_last_id)
1770 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1771 osc.$mdtosc.prealloc_next_id)
1772 local fcount=$((last_id - next_id))
1773 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1774 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1776 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1777 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1778 local OST_DEACTIVE_IDX=-1
1783 for OSC in $MDS_OSCS; do
1784 OST=$(osc_to_ost $OSC)
1785 OSTIDX=$(index_from_ostuuid $OST)
1786 if [ $OST_DEACTIVE_IDX == -1 ]; then
1787 OST_DEACTIVE_IDX=$OSTIDX
1789 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1790 echo $OSC "is Deactivated:"
1791 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1795 OSTIDX=$(index_from_ostuuid $OST)
1796 test_mkdir $DIR/$tdir
1797 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1799 for OSC in $MDS_OSCS; do
1800 OST=$(osc_to_ost $OSC)
1801 OSTIDX=$(index_from_ostuuid $OST)
1802 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1803 echo $OST "is degraded:"
1804 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1805 obdfilter.$OST.degraded=1
1810 createmany -o $DIR/$tdir/$tfile $fcount
1812 for OSC in $MDS_OSCS; do
1813 OST=$(osc_to_ost $OSC)
1814 OSTIDX=$(index_from_ostuuid $OST)
1815 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1816 echo $OST "is recovered from degraded:"
1817 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1818 obdfilter.$OST.degraded=0
1820 do_facet $SINGLEMDS lctl --device %$OSC activate
1824 # all osp devices get activated, hence -1 stripe count restored
1825 local stripe_count=0
1827 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1828 # devices get activated.
1830 $LFS setstripe -c -1 $DIR/$tfile
1831 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1833 [ $stripe_count -ne $OSTCOUNT ] &&
1834 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1837 run_test 27y "create files while OST0 is degraded and the rest inactive"
1843 lmm_count=$($GETSTRIPE -c $1)
1844 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1845 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1847 local old_ifs="$IFS"
1849 fid=($($LFS path2fid $1))
1852 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1853 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1855 # compare lmm_seq and lu_fid->f_seq
1856 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1857 # compare lmm_object_id and lu_fid->oid
1858 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1860 # check the trusted.fid attribute of the OST objects of the file
1861 local have_obdidx=false
1863 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1864 # skip lines up to and including "obdidx"
1865 [ -z "$obdidx" ] && break
1866 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1867 $have_obdidx || continue
1869 local ost=$((obdidx + 1))
1870 local dev=$(ostdevname $ost)
1873 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1875 seq=$(echo $seq | sed -e "s/^0x//g")
1876 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1877 oid_hex=$(echo $oid)
1879 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1881 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1885 # Don't unmount/remount the OSTs if we don't need to do that.
1886 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1887 # update too, until that use mount/ll_decode_filter_fid/mount.
1888 # Re-enable when debugfs will understand new filter_fid.
1890 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1891 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1892 $dev 2>/dev/null" | grep "parent=")
1894 if [ -z "$ff" ]; then
1896 mount_fstype ost$ost
1897 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1898 $(facet_mntpt ost$ost)/$obj_file)
1899 unmount_fstype ost$ost
1900 start ost$ost $dev $OST_MOUNT_OPTS
1904 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1906 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1908 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1909 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1911 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1912 # stripe_size=1048576 component_id=1 component_start=0 \
1913 # component_end=33554432
1914 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1915 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1916 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1918 if grep -q 'stripe=' <<<$ff; then
1919 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1921 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1922 # into f_ver in this case. See comment on ff_parent.
1923 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1926 # compare lmm_seq and filter_fid->ff_parent.f_seq
1927 [ $ff_pseq = $lmm_seq ] ||
1928 error "FF parent SEQ $ff_pseq != $lmm_seq"
1929 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1930 [ $ff_poid = $lmm_oid ] ||
1931 error "FF parent OID $ff_poid != $lmm_oid"
1932 (($ff_pstripe == $stripe_nr)) ||
1933 error "FF stripe $ff_pstripe != $stripe_nr"
1935 stripe_nr=$((stripe_nr + 1))
1936 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1938 if grep -q 'stripe_count=' <<<$ff; then
1939 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1940 -e 's/ .*//' <<<$ff)
1941 [ $lmm_count = $ff_scnt ] ||
1942 error "FF stripe count $lmm_count != $ff_scnt"
1948 remote_ost_nodsh && skip "remote OST with nodsh" && return
1949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1950 test_mkdir $DIR/$tdir
1952 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1953 { error "setstripe -c -1 failed"; return 1; }
1954 # We need to send a write to every object to get parent FID info set.
1955 # This _should_ also work for setattr, but does not currently.
1956 # touch $DIR/$tdir/$tfile-1 ||
1957 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1958 { error "dd $tfile-1 failed"; return 2; }
1959 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1960 { error "setstripe -c -1 failed"; return 3; }
1961 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1962 { error "dd $tfile-2 failed"; return 4; }
1964 # make sure write RPCs have been sent to OSTs
1967 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1968 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1970 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1972 test_27A() { # b=19102
1973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1974 local restore_size=$($GETSTRIPE -S $MOUNT)
1975 local restore_count=$($GETSTRIPE -c $MOUNT)
1976 local restore_offset=$($GETSTRIPE -i $MOUNT)
1977 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1978 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1979 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1980 local default_size=$($GETSTRIPE -S $MOUNT)
1981 local default_offset=$($GETSTRIPE -i $MOUNT)
1982 local dsize=$((1024 * 1024))
1983 [ $default_size -eq $dsize ] ||
1984 error "stripe size $default_size != $dsize"
1985 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1986 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1988 run_test 27A "check filesystem-wide default LOV EA values"
1990 test_27B() { # LU-2523
1991 test_mkdir $DIR/$tdir
1992 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1994 # open f1 with O_LOV_DELAY_CREATE
1996 # call setstripe ioctl on open file descriptor for f1
1998 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2002 # open f1 with O_LOV_DELAY_CREATE
2004 # call setstripe ioctl on open file descriptor for f1
2006 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2008 # Allow multiop to fail in imitation of NFS's busted semantics.
2011 run_test 27B "call setstripe on open unlinked file/rename victim"
2013 test_27C() { #LU-2871
2014 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2022 test_mkdir $DIR/$tdir
2024 for i in $(seq 0 $((OSTCOUNT - 1))); do
2025 # set stripe across all OSTs starting from OST$i
2026 $SETSTRIPE -i $i -c -1 $tfile$i
2027 # get striping information
2028 ost_idx=($($GETSTRIPE $tfile$i |
2029 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2033 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2034 error "${#ost_idx[@]} != $OSTCOUNT"
2036 for index in $(seq 0 $((OSTCOUNT - 1))); do
2038 for j in $(echo ${ost_idx[@]}); do
2039 if [ $index -eq $j ]; then
2045 error "Can not find $index in ${ost_idx[@]}"
2049 run_test 27C "check full striping across all OSTs"
2052 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2053 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2055 local POOL=${POOL:-testpool}
2057 local last_ost=$(($OSTCOUNT - 1))
2059 local ost_list=$(seq $first_ost $ost_step $last_ost)
2060 local ost_range="$first_ost $last_ost $ost_step"
2062 test_mkdir $DIR/$tdir
2063 pool_add $POOL || error "pool_add failed"
2064 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2067 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2069 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2070 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2071 skip27D += "-s 30,31"
2072 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2073 error "llapi_layout_test failed"
2075 destroy_test_pools || error "destroy test pools failed"
2077 run_test 27D "validate llapi_layout API"
2079 # Verify that default_easize is increased from its initial value after
2080 # accessing a widely striped file.
2082 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2083 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2084 skip "client does not have LU-3338 fix" && return
2086 # 72 bytes is the minimum space required to store striping
2087 # information for a file striped across one OST:
2088 # (sizeof(struct lov_user_md_v3) +
2089 # sizeof(struct lov_user_ost_data_v1))
2091 $LCTL set_param -n llite.*.default_easize $min_easize ||
2092 error "lctl set_param failed"
2093 local easize=$($LCTL get_param -n llite.*.default_easize)
2095 [ $easize -eq $min_easize ] ||
2096 error "failed to set default_easize"
2098 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2099 error "setstripe failed"
2103 easize=$($LCTL get_param -n llite.*.default_easize)
2105 [ $easize -gt $min_easize ] ||
2106 error "default_easize not updated"
2108 run_test 27E "check that default extended attribute size properly increases"
2110 test_27F() { # LU-5346/LU-7975
2111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2112 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2113 skip "Need MDS version at least 2.8.51" && return
2114 remote_ost_nodsh && skip "remote OST with nodsh" && return
2116 test_mkdir $DIR/$tdir
2118 $SETSTRIPE -c 2 $DIR/$tdir
2120 # stop all OSTs to reproduce situation for LU-7975 ticket
2121 for num in $(seq $OSTCOUNT); do
2125 # open/create f0 with O_LOV_DELAY_CREATE
2126 # truncate f0 to a non-0 size
2128 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2130 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2131 # open/write it again to force delayed layout creation
2132 cat /etc/hosts > $DIR/$tdir/f0 &
2136 for num in $(seq $OSTCOUNT); do
2137 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2138 error "ost$num failed to start"
2141 wait $catpid || error "cat failed"
2143 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2144 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2147 run_test 27F "Client resend delayed layout creation with non-zero size"
2149 # createtest also checks that device nodes are created and
2150 # then visible correctly (#2091)
2151 test_28() { # bug 2091
2153 $CREATETEST $DIR/d28/ct || error
2155 run_test 28 "create/mknod/mkdir with bad file types ============"
2158 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2159 sync; sleep 1; sync # flush out any dirty pages from previous tests
2166 declare -i LOCKCOUNTORIG=0
2167 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2168 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2170 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2172 declare -i LOCKUNUSEDCOUNTORIG=0
2173 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2174 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2181 declare -i LOCKCOUNTCURRENT=0
2182 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2183 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2186 declare -i LOCKUNUSEDCOUNTCURRENT=0
2187 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2188 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2191 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2192 $LCTL set_param -n ldlm.dump_namespaces ""
2193 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2194 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2195 log "dumped log to $TMP/test_29.dk (bug 5793)"
2198 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2199 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2200 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2201 log "dumped log to $TMP/test_29.dk (bug 5793)"
2205 run_test 29 "IT_GETATTR regression ============================"
2207 test_30a() { # was test_30
2208 cp $(which ls) $DIR || cp /bin/ls $DIR
2212 run_test 30a "execute binary from Lustre (execve) =============="
2215 cp `which ls` $DIR || cp /bin/ls $DIR
2217 $RUNAS $DIR/ls / || error
2220 run_test 30b "execute binary from Lustre as non-root ==========="
2222 test_30c() { # b=22376
2223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2224 cp `which ls` $DIR || cp /bin/ls $DIR
2226 cancel_lru_locks mdc
2227 cancel_lru_locks osc
2228 $RUNAS $DIR/ls / || error
2231 run_test 30c "execute binary from Lustre without read perms ===="
2234 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2235 $CHECKSTAT -a $DIR/f31 || error
2237 run_test 31a "open-unlink file =================================="
2240 touch $DIR/f31 || error
2241 ln $DIR/f31 $DIR/f31b || error
2242 $MULTIOP $DIR/f31b Ouc || error
2243 $CHECKSTAT -t file $DIR/f31 || error
2245 run_test 31b "unlink file with multiple links while open ======="
2248 touch $DIR/f31 || error
2249 ln $DIR/f31 $DIR/f31c || error
2250 multiop_bg_pause $DIR/f31 O_uc || return 1
2252 $MULTIOP $DIR/f31c Ouc
2253 kill -USR1 $MULTIPID
2256 run_test 31c "open-unlink file with multiple links ============="
2259 opendirunlink $DIR/d31d $DIR/d31d || error
2260 $CHECKSTAT -a $DIR/d31d || error
2262 run_test 31d "remove of open directory ========================="
2264 test_31e() { # bug 2904
2265 openfilleddirunlink $DIR/d31e || error
2267 run_test 31e "remove of open non-empty directory ==============="
2269 test_31f() { # bug 4554
2270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2272 test_mkdir $DIR/d31f
2273 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2274 cp /etc/hosts $DIR/d31f
2276 $GETSTRIPE $DIR/d31f/hosts
2277 multiop_bg_pause $DIR/d31f D_c || return 1
2280 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2281 test_mkdir $DIR/d31f
2282 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2283 cp /etc/hosts $DIR/d31f
2285 $GETSTRIPE $DIR/d31f/hosts
2286 multiop_bg_pause $DIR/d31f D_c || return 1
2289 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2290 wait $MULTIPID || error "first opendir $MULTIPID failed"
2294 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2295 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2298 run_test 31f "remove of open directory with open-unlink file ==="
2301 echo "-- cross directory link --"
2302 test_mkdir -c1 $DIR/${tdir}ga
2303 test_mkdir -c1 $DIR/${tdir}gb
2304 touch $DIR/${tdir}ga/f
2305 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2306 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2307 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2308 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2309 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2311 run_test 31g "cross directory link==============="
2314 echo "-- cross directory link --"
2315 test_mkdir -c1 $DIR/${tdir}
2316 test_mkdir -c1 $DIR/${tdir}/dir
2317 touch $DIR/${tdir}/f
2318 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2319 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2320 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2321 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2322 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2324 run_test 31h "cross directory link under child==============="
2327 echo "-- cross directory link --"
2328 test_mkdir -c1 $DIR/$tdir
2329 test_mkdir -c1 $DIR/$tdir/dir
2330 touch $DIR/$tdir/dir/f
2331 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2332 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2333 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2334 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2335 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2337 run_test 31i "cross directory link under parent==============="
2340 test_mkdir -c1 -p $DIR/$tdir
2341 test_mkdir -c1 -p $DIR/$tdir/dir1
2342 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2343 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2344 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2345 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2348 run_test 31j "link for directory==============="
2351 test_mkdir -c1 -p $DIR/$tdir
2353 touch $DIR/$tdir/exist
2354 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2355 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2356 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2357 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2358 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2359 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2360 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2363 run_test 31k "link to file: the same, non-existing, dir==============="
2369 touch $DIR/d31m2/exist
2370 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2371 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2372 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2373 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2374 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2375 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2378 run_test 31m "link to file: the same, non-existing, dir==============="
2381 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2382 nlink=$(stat --format=%h $DIR/$tfile)
2383 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2385 local cmd="exec $fd<$DIR/$tfile"
2388 trap "eval $cmd" EXIT
2389 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2390 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2391 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2392 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2393 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2396 run_test 31n "check link count of unlinked file"
2399 local TEMPNAME=$(mktemp $1_XXXXXX)
2400 mlink $TEMPNAME $1 2> /dev/null &&
2401 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2405 test_31o() { # LU-2901
2406 test_mkdir $DIR/$tdir
2407 for LOOP in $(seq 100); do
2408 rm -f $DIR/$tdir/$tfile*
2409 for THREAD in $(seq 8); do
2410 link_one $DIR/$tdir/$tfile.$LOOP &
2413 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2414 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2415 error "$LINKS duplicate links to $tfile.$LOOP" &&
2419 run_test 31o "duplicate hard links with same filename"
2422 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2424 test_mkdir $DIR/$tdir
2425 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2426 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2428 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2429 error "open unlink test1 failed"
2430 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2431 error "open unlink test2 failed"
2433 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2434 error "test1 still exists"
2435 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2436 error "test2 still exists"
2438 run_test 31p "remove of open striped directory"
2440 cleanup_test32_mount() {
2443 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2444 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2445 losetup -d $loopdev || true
2451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2452 echo "== more mountpoints and symlinks ================="
2453 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2454 trap cleanup_test32_mount EXIT
2455 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2456 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2457 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2458 cleanup_test32_mount
2460 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2464 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2465 trap cleanup_test32_mount EXIT
2466 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2467 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2468 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2469 cleanup_test32_mount
2471 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2476 trap cleanup_test32_mount EXIT
2477 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2478 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2479 test_mkdir -p $DIR/$tdir/d2/test_dir
2480 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2481 cleanup_test32_mount
2483 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2487 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2488 trap cleanup_test32_mount EXIT
2489 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2490 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2491 test_mkdir -p $DIR/$tdir/d2/test_dir
2492 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2493 cleanup_test32_mount
2495 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2499 test_mkdir -p $DIR/$tdir/tmp
2500 local tmp_dir=$DIR/$tdir/tmp
2501 ln -s $DIR/$tdir $tmp_dir/symlink11
2502 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2503 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2504 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2506 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2510 test_mkdir -p $DIR/$tdir/tmp
2511 local tmp_dir=$DIR/$tdir/tmp
2512 ln -s $DIR/$tdir $tmp_dir/symlink11
2513 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2514 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2515 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2517 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2520 local tmp_dir=$DIR/$tdir/tmp
2521 test_mkdir -p $tmp_dir
2522 test_mkdir $DIR/${tdir}2
2523 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2524 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2525 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2526 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2527 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2528 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2530 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2533 rm -fr $DIR/$tdir $DIR/${tdir}2
2534 tmp_dir=$DIR/$tdir/tmp
2535 test_mkdir -p $tmp_dir
2536 test_mkdir $DIR/${tdir}2
2537 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2538 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2539 ls $tmp_dir/symlink12 || error "listing symlink12"
2540 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2542 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2546 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2547 trap cleanup_test32_mount EXIT
2548 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2549 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2550 touch $DIR/$tdir/test_file
2551 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2552 cleanup_test32_mount
2554 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2558 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2559 trap cleanup_test32_mount EXIT
2560 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2561 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2562 touch $DIR/$tdir/test_file
2563 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2564 cleanup_test32_mount
2566 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2571 trap cleanup_test32_mount EXIT
2572 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2573 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2574 test_mkdir -p $DIR/$tdir/d2
2575 touch $DIR/$tdir/d2/test_file || error
2576 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2577 cleanup_test32_mount
2579 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 trap cleanup_test32_mount EXIT
2585 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2586 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2587 test_mkdir -p $DIR/$tdir/d2
2588 touch $DIR/$tdir/d2/test_file
2589 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2590 cleanup_test32_mount
2592 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2596 test_mkdir -p $DIR/d32m/tmp
2597 TMP_DIR=$DIR/d32m/tmp
2598 ln -s $DIR $TMP_DIR/symlink11
2599 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2600 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2601 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2603 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2607 test_mkdir -p $DIR/d32n/tmp
2608 TMP_DIR=$DIR/d32n/tmp
2609 ln -s $DIR $TMP_DIR/symlink11
2610 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2611 ls -l $DIR/d32n/tmp/symlink11 || error
2612 ls -l $DIR/d32n/symlink01 || error
2614 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2618 test_mkdir -p $DIR/d32o/tmp
2619 TMP_DIR=$DIR/d32o/tmp
2620 ln -s $DIR/$tfile $TMP_DIR/symlink12
2621 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2622 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2623 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2624 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2625 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2627 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2637 test_mkdir -p $DIR/d32p/tmp
2639 TMP_DIR=$DIR/d32p/tmp
2641 ln -s $DIR/$tfile $TMP_DIR/symlink12
2643 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2645 cat $DIR/d32p/tmp/symlink12 || error
2647 cat $DIR/d32p/symlink02 || error
2650 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2654 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2655 trap cleanup_test32_mount EXIT
2656 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2657 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2658 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2659 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2660 cleanup_test32_mount
2662 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2666 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2667 trap cleanup_test32_mount EXIT
2668 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2669 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2670 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2671 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2672 cleanup_test32_mount
2674 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2679 chmod 444 $DIR/$tfile
2680 chown $RUNAS_ID $DIR/$tfile
2682 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2685 run_test 33aa "write file with mode 444 (should return error)"
2689 test_mkdir $DIR/$tdir
2690 chown $RUNAS_ID $DIR/$tdir
2691 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2692 error "$RUNAS create $tdir/$tfile failed"
2693 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2694 error "open RDWR" || true
2696 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2700 test_mkdir $DIR/$tdir
2701 chown $RUNAS_ID $DIR/$tdir
2702 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2704 run_test 33b "test open file with malformed flags (No panic)"
2707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2713 remote_ost_nodsh && skip "remote OST with nodsh" && return
2716 test_mkdir $DIR/$tdir
2717 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2720 for ostnum in $(seq $OSTCOUNT); do
2721 # test-framework's OST numbering is one-based, while Lustre's
2723 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2724 # Parsing llobdstat's output sucks; we could grep the /proc
2725 # path, but that's likely to not be as portable as using the
2726 # llobdstat utility. So we parse lctl output instead.
2727 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2728 obdfilter/$ostname/stats |
2729 awk '/^write_bytes/ {print $7}' )
2730 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2731 if (( ${write_bytes:-0} > 0 ))
2738 $all_zeros || return 0
2741 echo foo > $DIR/$tdir/bar
2745 # Total up write_bytes after writing. We'd better find non-zeros.
2746 for ostnum in $(seq $OSTCOUNT); do
2747 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2748 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2749 obdfilter/$ostname/stats |
2750 awk '/^write_bytes/ {print $7}' )
2751 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2752 if (( ${write_bytes:-0} > 0 ))
2761 for ostnum in $(seq $OSTCOUNT); do
2762 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2763 echo "Check that write_bytes is present in obdfilter/*/stats:"
2764 do_facet ost$ostnum lctl get_param -n \
2765 obdfilter/$ostname/stats
2767 error "OST not keeping write_bytes stats (b22312)"
2770 run_test 33c "test llobdstat and write_bytes"
2773 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2776 local remote_dir=$DIR/$tdir/remote_dir
2778 test_mkdir $DIR/$tdir
2779 $LFS mkdir -i $MDTIDX $remote_dir ||
2780 error "create remote directory failed"
2782 touch $remote_dir/$tfile
2783 chmod 444 $remote_dir/$tfile
2784 chown $RUNAS_ID $remote_dir/$tfile
2786 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2788 chown $RUNAS_ID $remote_dir
2789 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2790 error "create" || true
2791 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2792 error "open RDWR" || true
2793 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2795 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2798 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2802 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2803 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2804 mkdir $DIR/$tdir/local_dir
2806 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2807 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2808 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2810 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2811 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2813 rmdir $DIR/$tdir/* || error "rmdir failed"
2816 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2817 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2818 mkdir $DIR/$tdir/local_dir
2820 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2821 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2822 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2824 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2825 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2827 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2830 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2831 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2832 mkdir $DIR/$tdir/local_dir
2834 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2835 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2836 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2838 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2839 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2841 run_test 33e "mkdir and striped directory should have same mode"
2845 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2849 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2850 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2853 chmod go+rwx $DIR/$tdir
2854 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2855 trap cleanup_33f EXIT
2857 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2858 error "cannot create striped directory"
2860 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2861 error "cannot create files in striped directory"
2863 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2864 error "cannot remove files in striped directory"
2866 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2867 error "cannot remove striped directory"
2871 run_test 33f "nonroot user can create, access, and remove a striped directory"
2874 mkdir -p $DIR/$tdir/dir2
2876 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2878 [[ $err =~ "exists" ]] || error "Not exists error"
2880 run_test 33g "nonroot user create already existing root created file"
2882 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2885 $MCREATE $DIR/f34 || error
2886 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2887 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2888 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2889 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2891 run_test 34a "truncate file that has not been opened ==========="
2894 [ ! -f $DIR/f34 ] && test_34a
2895 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2896 $OPENFILE -f O_RDONLY $DIR/f34
2897 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2898 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2900 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2903 [ ! -f $DIR/f34 ] && test_34a
2904 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2905 $OPENFILE -f O_RDWR $DIR/f34
2906 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2907 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2909 run_test 34c "O_RDWR opening file-with-size works =============="
2912 [ ! -f $DIR/f34 ] && test_34a
2913 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2914 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2917 run_test 34d "write to sparse file ============================="
2921 $MCREATE $DIR/f34e || error
2922 $TRUNCATE $DIR/f34e 1000 || error
2923 $CHECKSTAT -s 1000 $DIR/f34e || error
2924 $OPENFILE -f O_RDWR $DIR/f34e
2925 $CHECKSTAT -s 1000 $DIR/f34e || error
2927 run_test 34e "create objects, some with size and some without =="
2929 test_34f() { # bug 6242, 6243
2930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2933 $MCREATE $DIR/f34f || error
2934 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2935 dd if=$DIR/f34f of=$TMP/f34f
2936 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2937 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2938 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2939 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2940 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2942 run_test 34f "read from a file with no objects until EOF ======="
2945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2946 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2947 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2948 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2949 cancel_lru_locks osc
2950 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2951 error "wrong size after lock cancel"
2953 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2954 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2955 error "expanding truncate failed"
2956 cancel_lru_locks osc
2957 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2958 error "wrong expanded size after lock cancel"
2960 run_test 34g "truncate long file ==============================="
2963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2967 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2968 sync # Flush the cache so that multiop below does not block on cache
2969 # flush when getting the group lock
2970 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2973 # Since just timed wait is not good enough, let's do a sync write
2974 # that way we are sure enough time for a roundtrip + processing
2975 # passed + 2 seconds of extra margin.
2976 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2980 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2981 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2985 local nsz=`stat -c %s $DIR/$tfile`
2986 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2988 run_test 34h "ftruncate file under grouplock should not block"
2991 cp /bin/sh $DIR/f35a
2993 chown $RUNAS_ID $DIR/f35a
2994 $RUNAS $DIR/f35a && error || true
2997 run_test 35a "exec file with mode 444 (should return and not leak)"
3001 utime $DIR/f36 || error
3003 run_test 36a "MDS utime check (mknod, utime)"
3007 utime $DIR/f36 || error
3009 run_test 36b "OST utime check (open, utime)"
3014 chown $RUNAS_ID $DIR/d36
3015 $RUNAS utime $DIR/d36/f36 || error
3017 run_test 36c "non-root MDS utime check (mknod, utime)"
3020 [ ! -d $DIR/d36 ] && test_36c
3021 echo "" > $DIR/d36/f36
3022 $RUNAS utime $DIR/d36/f36 || error
3024 run_test 36d "non-root OST utime check (open, utime)"
3027 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3028 test_mkdir $DIR/$tdir
3029 touch $DIR/$tdir/$tfile
3030 $RUNAS utime $DIR/$tdir/$tfile &&
3031 error "utime worked, expected failure" || true
3033 run_test 36e "utime on non-owned file (should return error)"
3037 local LANG_SAVE=$LANG
3038 local LC_LANG_SAVE=$LC_LANG
3039 export LANG=C LC_LANG=C # for date language
3041 DATESTR="Dec 20 2000"
3042 test_mkdir $DIR/$tdir
3043 lctl set_param fail_loc=$fl
3045 cp /etc/hosts $DIR/$tdir/$tfile
3046 sync & # write RPC generated with "current" inode timestamp, but delayed
3048 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3049 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3050 cancel_lru_locks osc
3051 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3053 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3054 echo "BEFORE: $LS_BEFORE" && \
3055 echo "AFTER : $LS_AFTER" && \
3056 echo "WANT : $DATESTR" && \
3057 error "$DIR/$tdir/$tfile timestamps changed" || true
3059 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3064 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3065 subr_36fh "0x80000214"
3067 run_test 36f "utime on file racing with OST BRW write =========="
3070 remote_ost_nodsh && skip "remote OST with nodsh" && return
3071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3076 test_mkdir $DIR/$tdir
3077 fmd_max_age=$(do_facet ost1 \
3078 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3081 fmd_before=$(do_facet ost1 \
3082 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3083 touch $DIR/$tdir/$tfile
3084 sleep $((fmd_max_age + 12))
3085 fmd_after=$(do_facet ost1 \
3086 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3088 echo "fmd_before: $fmd_before"
3089 echo "fmd_after: $fmd_after"
3090 [[ $fmd_after -gt $fmd_before ]] &&
3091 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3092 error "fmd didn't expire after ping" || true
3094 run_test 36g "filter mod data cache expiry ====================="
3097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3098 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3099 subr_36fh "0x80000227"
3101 run_test 36h "utime on file racing with OST BRW write =========="
3104 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3106 test_mkdir $DIR/$tdir
3107 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3109 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3110 local new_mtime=$((mtime + 200))
3112 #change Modify time of striped dir
3113 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3114 error "change mtime failed"
3116 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3118 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3120 run_test 36i "change mtime on striped directory"
3122 # test_37 - duplicate with tests 32q 32r
3125 local file=$DIR/$tfile
3127 openfile -f O_DIRECTORY $file
3130 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3131 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3133 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3135 test_39a() { # was test_39
3137 touch $DIR/${tfile}2
3138 # ls -l $DIR/$tfile $DIR/${tfile}2
3139 # ls -lu $DIR/$tfile $DIR/${tfile}2
3140 # ls -lc $DIR/$tfile $DIR/${tfile}2
3142 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3143 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3145 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3147 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3149 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3150 error "O_TRUNC didn't change timestamps"
3153 run_test 39a "mtime changed on create"
3156 test_mkdir -c1 $DIR/$tdir
3157 cp -p /etc/passwd $DIR/$tdir/fopen
3158 cp -p /etc/passwd $DIR/$tdir/flink
3159 cp -p /etc/passwd $DIR/$tdir/funlink
3160 cp -p /etc/passwd $DIR/$tdir/frename
3161 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3164 echo "aaaaaa" >> $DIR/$tdir/fopen
3165 echo "aaaaaa" >> $DIR/$tdir/flink
3166 echo "aaaaaa" >> $DIR/$tdir/funlink
3167 echo "aaaaaa" >> $DIR/$tdir/frename
3169 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3170 local link_new=`stat -c %Y $DIR/$tdir/flink`
3171 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3172 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3174 cat $DIR/$tdir/fopen > /dev/null
3175 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3176 rm -f $DIR/$tdir/funlink2
3177 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3179 for (( i=0; i < 2; i++ )) ; do
3180 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3181 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3182 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3183 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3185 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3186 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3187 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3188 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3190 cancel_lru_locks osc
3191 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3194 run_test 39b "mtime change on open, link, unlink, rename ======"
3196 # this should be set to past
3197 TEST_39_MTIME=`date -d "1 year ago" +%s`
3203 local mtime0=`stat -c %Y $DIR1/$tfile`
3205 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3206 local mtime1=`stat -c %Y $DIR1/$tfile`
3207 [ "$mtime1" = $TEST_39_MTIME ] || \
3208 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3211 echo hello >> $DIR1/$tfile
3213 local mtime2=`stat -c %Y $DIR1/$tfile`
3214 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3215 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3217 mv $DIR1/$tfile $DIR1/$tfile-1
3219 for (( i=0; i < 2; i++ )) ; do
3220 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3221 [ "$mtime2" = "$mtime3" ] || \
3222 error "mtime ($mtime2) changed (to $mtime3) on rename"
3224 cancel_lru_locks osc
3225 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3228 run_test 39c "mtime change on rename ==========================="
3232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3235 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3237 for (( i=0; i < 2; i++ )) ; do
3238 local mtime=`stat -c %Y $DIR1/$tfile`
3239 [ $mtime = $TEST_39_MTIME ] || \
3240 error "mtime($mtime) is not set to $TEST_39_MTIME"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3246 run_test 39d "create, utime, stat =============================="
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3252 local mtime1=`stat -c %Y $DIR1/$tfile`
3254 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3256 for (( i=0; i < 2; i++ )) ; do
3257 local mtime2=`stat -c %Y $DIR1/$tfile`
3258 [ $mtime2 = $TEST_39_MTIME ] || \
3259 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3261 cancel_lru_locks osc
3262 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3265 run_test 39e "create, stat, utime, stat ========================"
3269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3271 mtime1=`stat -c %Y $DIR1/$tfile`
3274 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3276 for (( i=0; i < 2; i++ )) ; do
3277 local mtime2=`stat -c %Y $DIR1/$tfile`
3278 [ $mtime2 = $TEST_39_MTIME ] || \
3279 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3281 cancel_lru_locks osc
3282 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3285 run_test 39f "create, stat, sleep, utime, stat ================="
3289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3290 echo hello >> $DIR1/$tfile
3291 local mtime1=`stat -c %Y $DIR1/$tfile`
3294 chmod o+r $DIR1/$tfile
3296 for (( i=0; i < 2; i++ )) ; do
3297 local mtime2=`stat -c %Y $DIR1/$tfile`
3298 [ "$mtime1" = "$mtime2" ] || \
3299 error "lost mtime: $mtime2, should be $mtime1"
3301 cancel_lru_locks osc
3302 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3305 run_test 39g "write, chmod, stat ==============================="
3309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3314 echo hello >> $DIR1/$tfile
3315 local mtime1=`stat -c %Y $DIR1/$tfile`
3317 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3319 if [ "$d1" != "$d2" ]; then
3320 echo "write and touch not within one second"
3322 for (( i=0; i < 2; i++ )) ; do
3323 local mtime2=`stat -c %Y $DIR1/$tfile`
3324 [ "$mtime2" = $TEST_39_MTIME ] || \
3325 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3327 cancel_lru_locks osc
3328 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3332 run_test 39h "write, utime within one second, stat ============="
3335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3339 echo hello >> $DIR1/$tfile
3340 local mtime1=`stat -c %Y $DIR1/$tfile`
3342 mv $DIR1/$tfile $DIR1/$tfile-1
3344 for (( i=0; i < 2; i++ )) ; do
3345 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3347 [ "$mtime1" = "$mtime2" ] || \
3348 error "lost mtime: $mtime2, should be $mtime1"
3350 cancel_lru_locks osc
3351 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3354 run_test 39i "write, rename, stat =============================="
3357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3358 start_full_debug_logging
3362 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3363 lctl set_param fail_loc=0x80000412
3364 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3365 error "multiop failed"
3367 local mtime1=`stat -c %Y $DIR1/$tfile`
3369 mv $DIR1/$tfile $DIR1/$tfile-1
3371 kill -USR1 $multipid
3372 wait $multipid || error "multiop close failed"
3374 for (( i=0; i < 2; i++ )) ; do
3375 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3376 [ "$mtime1" = "$mtime2" ] ||
3377 error "mtime is lost on close: $mtime2, " \
3380 cancel_lru_locks osc
3381 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3383 lctl set_param fail_loc=0
3384 stop_full_debug_logging
3386 run_test 39j "write, rename, close, stat ======================="
3389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3393 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3395 local mtime1=`stat -c %Y $DIR1/$tfile`
3397 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3399 kill -USR1 $multipid
3400 wait $multipid || error "multiop close failed"
3402 for (( i=0; i < 2; i++ )) ; do
3403 local mtime2=`stat -c %Y $DIR1/$tfile`
3405 [ "$mtime2" = $TEST_39_MTIME ] || \
3406 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3408 cancel_lru_locks osc
3409 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3412 run_test 39k "write, utime, close, stat ========================"
3414 # this should be set to future
3415 TEST_39_ATIME=`date -d "1 year" +%s`
3418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3419 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3420 local atime_diff=$(do_facet $SINGLEMDS \
3421 lctl get_param -n mdd.*MDT0000*.atime_diff)
3425 # test setting directory atime to future
3426 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3427 local atime=$(stat -c %X $DIR/$tdir)
3428 [ "$atime" = $TEST_39_ATIME ] ||
3429 error "atime is not set to future: $atime, $TEST_39_ATIME"
3431 # test setting directory atime from future to now
3432 local now=$(date +%s)
3433 touch -a -d @$now $DIR/$tdir
3435 atime=$(stat -c %X $DIR/$tdir)
3436 [ "$atime" -eq "$now" ] ||
3437 error "atime is not updated from future: $atime, $now"
3439 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3442 # test setting directory atime when now > dir atime + atime_diff
3443 local d1=$(date +%s)
3445 local d2=$(date +%s)
3446 cancel_lru_locks mdc
3447 atime=$(stat -c %X $DIR/$tdir)
3448 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3449 error "atime is not updated : $atime, should be $d2"
3451 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3454 # test not setting directory atime when now < dir atime + atime_diff
3456 cancel_lru_locks mdc
3457 atime=$(stat -c %X $DIR/$tdir)
3458 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3459 error "atime is updated to $atime, should remain $d1<atime<$d2"
3461 do_facet $SINGLEMDS \
3462 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3464 run_test 39l "directory atime update ==========================="
3467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3470 local far_past_mtime=$(date -d "May 29 1953" +%s)
3471 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3473 touch -m -d @$far_past_mtime $DIR1/$tfile
3474 touch -a -d @$far_past_atime $DIR1/$tfile
3476 for (( i=0; i < 2; i++ )) ; do
3477 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3478 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3479 error "atime or mtime set incorrectly"
3481 cancel_lru_locks osc
3482 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3485 run_test 39m "test atime and mtime before 1970"
3487 test_39n() { # LU-3832
3488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3489 local atime_diff=$(do_facet $SINGLEMDS \
3490 lctl get_param -n mdd.*MDT0000*.atime_diff)
3495 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3498 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3499 atime0=$(stat -c %X $DIR/$tfile)
3502 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3503 atime1=$(stat -c %X $DIR/$tfile)
3506 cancel_lru_locks mdc
3507 cancel_lru_locks osc
3508 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3509 atime2=$(stat -c %X $DIR/$tfile)
3511 do_facet $SINGLEMDS \
3512 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3514 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3515 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3517 run_test 39n "check that O_NOATIME is honored"
3520 TESTDIR=$DIR/$tdir/$tfile
3521 [ -e $TESTDIR ] && rm -rf $TESTDIR
3528 links2=$(stat -c %h .)
3529 [ $(($links1 + 2)) != $links2 ] &&
3530 error "wrong links count $(($links1 + 2)) != $links2"
3532 links3=$(stat -c %h .)
3533 [ $(($links1 + 1)) != $links3 ] &&
3534 error "wrong links count $links1 != $links3"
3537 run_test 39o "directory cached attributes updated after create"
3540 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3542 TESTDIR=$DIR/$tdir/$tdir
3543 [ -e $TESTDIR ] && rm -rf $TESTDIR
3544 test_mkdir -p $TESTDIR
3548 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3549 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3551 links2=$(stat -c %h .)
3552 [ $(($links1 + 2)) != $links2 ] &&
3553 error "wrong links count $(($links1 + 2)) != $links2"
3555 links3=$(stat -c %h .)
3556 [ $(($links1 + 1)) != $links3 ] &&
3557 error "wrong links count $links1 != $links3"
3560 run_test 39p "remote directory cached attributes updated after create ========"
3563 test_39q() { # LU-8041
3564 local testdir=$DIR/$tdir
3566 multiop_bg_pause $testdir D_c || error "multiop failed"
3568 cancel_lru_locks mdc
3569 kill -USR1 $multipid
3570 local atime=$(stat -c %X $testdir)
3571 [ "$atime" -ne 0 ] || error "atime is zero"
3573 run_test 39q "close won't zero out atime"
3576 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3577 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3578 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3579 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3580 error "$tfile is not 4096 bytes in size"
3582 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3586 small_write $DIR/f41 18
3588 run_test 41 "test small file write + fstat ====================="
3590 count_ost_writes() {
3591 lctl get_param -n ${OSC}.*.stats |
3592 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3593 END { printf("%0.0f", writes) }'
3600 BG_DIRTY_RATIO_SAVE=10
3601 MAX_BG_DIRTY_RATIO=25
3605 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3606 # dirty_ratio, dirty_background_ratio
3607 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3608 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3609 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3610 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3612 # if file not here, we are a 2.4 kernel
3613 kill -CONT `pidof kupdated`
3618 # setup the trap first, so someone cannot exit the test at the
3619 # exact wrong time and mess up a machine
3620 trap start_writeback EXIT
3621 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3622 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3623 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3624 sysctl -w vm.dirty_writeback_centisecs=0
3625 sysctl -w vm.dirty_writeback_centisecs=0
3626 # save and increase /proc/sys/vm/dirty_ratio
3627 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3628 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3629 # save and increase /proc/sys/vm/dirty_background_ratio
3630 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3631 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3633 # if file not here, we are a 2.4 kernel
3634 kill -STOP `pidof kupdated`
3638 # ensure that all stripes have some grant before we test client-side cache
3640 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3641 dd if=/dev/zero of=$i bs=4k count=1
3646 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3647 # file truncation, and file removal.
3649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3651 cancel_lru_locks $OSC
3653 sync; sleep 1; sync # just to be safe
3654 BEFOREWRITES=`count_ost_writes`
3655 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3656 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3657 AFTERWRITES=`count_ost_writes`
3658 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3659 error "$BEFOREWRITES < $AFTERWRITES"
3662 run_test 42a "ensure that we don't flush on close"
3665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3667 cancel_lru_locks $OSC
3670 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3671 BEFOREWRITES=$(count_ost_writes)
3672 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3673 AFTERWRITES=$(count_ost_writes)
3674 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3675 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3677 BEFOREWRITES=$(count_ost_writes)
3678 sync || error "sync: $?"
3679 AFTERWRITES=$(count_ost_writes)
3680 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3681 error "$BEFOREWRITES < $AFTERWRITES on sync"
3683 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3687 run_test 42b "test destroy of file with cached dirty data ======"
3689 # if these tests just want to test the effect of truncation,
3690 # they have to be very careful. consider:
3691 # - the first open gets a {0,EOF}PR lock
3692 # - the first write conflicts and gets a {0, count-1}PW
3693 # - the rest of the writes are under {count,EOF}PW
3694 # - the open for truncate tries to match a {0,EOF}PR
3695 # for the filesize and cancels the PWs.
3696 # any number of fixes (don't get {0,EOF} on open, match
3697 # composite locks, do smarter file size management) fix
3698 # this, but for now we want these tests to verify that
3699 # the cancellation with truncate intent works, so we
3700 # start the file with a full-file pw lock to match against
3701 # until the truncate.
3706 cancel_lru_locks $OSC
3708 # prime the file with 0,EOF PW to match
3712 # now the real test..
3713 dd if=/dev/zero of=$file bs=1024 count=100
3714 BEFOREWRITES=`count_ost_writes`
3715 $TRUNCATE $file $offset
3716 cancel_lru_locks $OSC
3717 AFTERWRITES=`count_ost_writes`
3722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3724 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3725 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3728 run_test 42c "test partial truncate of file with cached dirty data"
3731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3733 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3734 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3737 run_test 42d "test complete truncate of file with cached dirty data"
3739 test_42e() { # bug22074
3740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3741 local TDIR=$DIR/${tdir}e
3742 local pagesz=$(page_size)
3743 local pages=16 # hardcoded 16 pages, don't change it.
3744 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3745 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3749 test_mkdir $DIR/${tdir}e
3750 $SETSTRIPE -c 1 $TDIR
3751 createmany -o $TDIR/f $files
3753 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3755 # we assume that with $OSTCOUNT files, at least one of them will
3756 # be allocated on OST0.
3757 warmup_files=$((OSTCOUNT * max_dirty_mb))
3758 createmany -o $TDIR/w $warmup_files
3760 # write a large amount of data into one file and sync, to get good
3761 # avail_grant number from OST.
3762 for ((i=0; i<$warmup_files; i++)); do
3763 idx=$($GETSTRIPE -i $TDIR/w$i)
3764 [ $idx -ne 0 ] && continue
3765 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3768 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3770 $LCTL get_param $proc_osc0/cur_dirty_bytes
3771 $LCTL get_param $proc_osc0/cur_grant_bytes
3773 # create as much dirty pages as we can while not to trigger the actual
3774 # RPCs directly. but depends on the env, VFS may trigger flush during this
3775 # period, hopefully we are good.
3776 for ((i=0; i<$warmup_files; i++)); do
3777 idx=$($GETSTRIPE -i $TDIR/w$i)
3778 [ $idx -ne 0 ] && continue
3779 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3781 $LCTL get_param $proc_osc0/cur_dirty_bytes
3782 $LCTL get_param $proc_osc0/cur_grant_bytes
3784 # perform the real test
3785 $LCTL set_param $proc_osc0/rpc_stats 0
3786 for ((;i<$files; i++)); do
3787 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3788 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3791 $LCTL get_param $proc_osc0/rpc_stats
3794 local have_ppr=false
3795 $LCTL get_param $proc_osc0/rpc_stats |
3796 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3797 # skip lines until we are at the RPC histogram data
3798 [ "$PPR" == "pages" ] && have_ppr=true && continue
3799 $have_ppr || continue
3801 # we only want the percent stat for < 16 pages
3802 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3804 percent=$((percent + WPCT))
3805 if [[ $percent -gt 15 ]]; then
3806 error "less than 16-pages write RPCs" \
3813 run_test 42e "verify sub-RPC writes are not done synchronously"
3815 test_43A() { # was test_43
3816 test_mkdir $DIR/$tdir
3817 cp -p /bin/ls $DIR/$tdir/$tfile
3818 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3820 # give multiop a chance to open
3823 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3826 run_test 43A "execution of file opened for write should return -ETXTBSY"
3829 test_mkdir $DIR/$tdir
3830 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3831 cp -p multiop $DIR/$tdir/multiop
3832 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3833 error "multiop open $TMP/$tfile.junk failed"
3835 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3836 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3837 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3839 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3843 test_mkdir $DIR/$tdir
3844 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3845 cp -p multiop $DIR/$tdir/multiop
3846 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3847 error "multiop open $TMP/$tfile.junk failed"
3849 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3850 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3851 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3853 run_test 43b "truncate of file being executed should return -ETXTBSY"
3856 local testdir="$DIR/$tdir"
3859 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3860 ( cd $testdir && md5sum -c )
3862 run_test 43c "md5sum of copy into lustre"
3864 test_44A() { # was test_44
3865 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3866 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3867 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3869 run_test 44A "zero length read from a sparse stripe"
3872 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3874 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3875 [[ $nstripe -gt $OSTCOUNT ]] &&
3876 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3878 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3880 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3881 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3885 OFFSETS="0 $((stride/2)) $((stride-1))"
3886 for offset in $OFFSETS; do
3887 for i in $(seq 0 $((nstripe-1))); do
3888 local GLOBALOFFSETS=""
3890 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3891 local myfn=$DIR/d44a-$size
3892 echo "--------writing $myfn at $size"
3893 ll_sparseness_write $myfn $size ||
3894 error "ll_sparseness_write"
3895 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3896 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3897 error "ll_sparseness_verify $GLOBALOFFSETS"
3899 for j in $(seq 0 $((nstripe-1))); do
3901 size=$((((j + $nstripe )*$stride + $offset)))
3902 ll_sparseness_write $myfn $size ||
3903 error "ll_sparseness_write"
3904 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3906 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3907 error "ll_sparseness_verify $GLOBALOFFSETS"
3912 run_test 44a "test sparse pwrite ==============================="
3916 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
3922 before=`dirty_osc_total`
3923 echo executing "\"$*\""
3925 after=`dirty_osc_total`
3926 echo before $before, after $after
3929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3931 # Obtain grants from OST if it supports it
3932 echo blah > ${f}_grant
3935 do_dirty_record "echo blah > $f"
3936 [[ $before -eq $after ]] && error "write wasn't cached"
3937 do_dirty_record "> $f"
3938 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3939 do_dirty_record "echo blah > $f"
3940 [[ $before -eq $after ]] && error "write wasn't cached"
3941 do_dirty_record "sync"
3942 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3943 do_dirty_record "echo blah > $f"
3944 [[ $before -eq $after ]] && error "write wasn't cached"
3945 do_dirty_record "cancel_lru_locks osc"
3946 [[ $before -gt $after ]] ||
3947 error "lock cancellation didn't lower dirty count"
3950 run_test 45 "osc io page accounting ============================"
3952 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3953 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3954 # objects offset and an assert hit when an rpc was built with 1023's mapped
3955 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3961 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3963 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3964 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3968 run_test 46 "dirtying a previously written page ================"
3970 # test_47 is removed "Device nodes check" is moved to test_28
3972 test_48a() { # bug 2399
3973 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3974 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3975 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3977 test_mkdir $DIR/$tdir
3979 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3980 test_mkdir $DIR/$tdir
3981 touch foo || error "'touch foo' failed after recreating cwd"
3983 touch .foo || error "'touch .foo' failed after recreating cwd"
3985 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3986 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3987 cd . || error "'cd .' failed after recreating cwd"
3988 mkdir . && error "'mkdir .' worked after recreating cwd"
3989 rmdir . && error "'rmdir .' worked after recreating cwd"
3990 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3991 cd .. || error "'cd ..' failed after recreating cwd"
3993 run_test 48a "Access renamed working dir (should return errors)="
3995 test_48b() { # bug 2399
3997 test_mkdir $DIR/$tdir
3999 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4000 touch foo && error "'touch foo' worked after removing cwd"
4001 mkdir foo && error "'mkdir foo' worked after removing cwd"
4002 touch .foo && error "'touch .foo' worked after removing cwd"
4003 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4004 ls . > /dev/null && error "'ls .' worked after removing cwd"
4005 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4006 mkdir . && error "'mkdir .' worked after removing cwd"
4007 rmdir . && error "'rmdir .' worked after removing cwd"
4008 ln -s . foo && error "'ln -s .' worked after removing cwd"
4009 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4011 run_test 48b "Access removed working dir (should return errors)="
4013 test_48c() { # bug 2350
4014 #lctl set_param debug=-1
4017 test_mkdir -p $DIR/$tdir/dir
4019 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4020 $TRACE touch foo && error "touch foo worked after removing cwd"
4021 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4022 touch .foo && error "touch .foo worked after removing cwd"
4023 mkdir .foo && error "mkdir .foo worked after removing cwd"
4024 $TRACE ls . && error "'ls .' worked after removing cwd"
4025 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4026 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4027 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4028 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4029 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4031 run_test 48c "Access removed working subdir (should return errors)"
4033 test_48d() { # bug 2350
4034 #lctl set_param debug=-1
4037 test_mkdir -p $DIR/$tdir/dir
4039 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4040 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4041 $TRACE touch foo && error "'touch foo' worked after removing parent"
4042 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4043 touch .foo && error "'touch .foo' worked after removing parent"
4044 mkdir .foo && error "mkdir .foo worked after removing parent"
4045 $TRACE ls . && error "'ls .' worked after removing parent"
4046 $TRACE ls .. && error "'ls ..' worked after removing parent"
4047 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4048 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4049 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4052 run_test 48d "Access removed parent subdir (should return errors)"
4054 test_48e() { # bug 4134
4055 #lctl set_param debug=-1
4058 test_mkdir -p $DIR/$tdir/dir
4060 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4061 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4062 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4063 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4064 # On a buggy kernel addition of "touch foo" after cd .. will
4065 # produce kernel oops in lookup_hash_it
4066 touch ../foo && error "'cd ..' worked after recreate parent"
4068 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4070 run_test 48e "Access to recreated parent subdir (should return errors)"
4072 test_49() { # LU-1030
4073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4074 remote_ost_nodsh && skip "remote OST with nodsh" && return
4075 # get ost1 size - lustre-OST0000
4076 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4078 # write 800M at maximum
4079 [[ $ost1_size -lt 2 ]] && ost1_size=2
4080 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4082 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4083 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4086 # change max_pages_per_rpc while writing the file
4087 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4088 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4089 # loop until dd process exits
4090 while ps ax -opid | grep -wq $dd_pid; do
4091 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4092 sleep $((RANDOM % 5 + 1))
4094 # restore original max_pages_per_rpc
4095 $LCTL set_param $osc1_mppc=$orig_mppc
4096 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4098 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4102 test_mkdir $DIR/$tdir
4104 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4106 run_test 50 "special situations: /proc symlinks ==============="
4108 test_51a() { # was test_51
4109 # bug 1516 - create an empty entry right after ".." then split dir
4110 test_mkdir -c1 $DIR/$tdir
4111 touch $DIR/$tdir/foo
4112 $MCREATE $DIR/$tdir/bar
4114 createmany -m $DIR/$tdir/longfile 201
4116 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4117 $MCREATE $DIR/$tdir/longfile$FNUM
4122 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4124 run_test 51a "special situations: split htree with empty entry =="
4126 cleanup_print_lfs_df () {
4133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4134 local dir=$DIR/$tdir
4136 local nrdirs=$((65536 + 100))
4138 # cleanup the directory
4145 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4146 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4147 [[ $numfree -lt $nrdirs ]] &&
4148 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4151 # need to check free space for the directories as well
4152 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4153 numfree=$(( blkfree / $(fs_inode_ksize) ))
4154 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4157 trap cleanup_print_lfs_df EXIT
4160 createmany -d $dir/d $nrdirs || {
4161 unlinkmany $dir/d $nrdirs
4162 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4166 nrdirs=$(ls -U $dir | wc -l)
4168 # unlink all but 100 subdirectories, then check it still works
4170 local delete=$((nrdirs - left))
4175 # for ldiskfs the nlink count should be 1, but this is OSD specific
4176 # and so this is listed for informational purposes only
4177 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4178 unlinkmany -d $dir/d $delete ||
4179 error "unlink of first $delete subdirs failed"
4181 echo "nlink between: $(stat -c %h $dir)"
4182 local found=$(ls -U $dir | wc -l)
4183 [ $found -ne $left ] &&
4184 error "can't find subdirs: found only $found, expected $left"
4186 unlinkmany -d $dir/d $delete $left ||
4187 error "unlink of second $left subdirs failed"
4188 # regardless of whether the backing filesystem tracks nlink accurately
4189 # or not, the nlink count shouldn't be more than "." and ".." here
4190 local after=$(stat -c %h $dir)
4191 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4192 echo "nlink after: $after"
4194 cleanup_print_lfs_df
4196 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4200 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4201 test_mkdir $DIR/$tdir
4202 createmany -o $DIR/$tdir/t- 1000
4203 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4204 for N in $(seq 0 $((OSTCOUNT - 1))); do
4205 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4206 END { printf("%0.0f", objs) }' $TMP/$tfile)
4207 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4208 '($1 == '$N') { objs += 1 } \
4209 END { printf("%0.0f", objs) }')
4210 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4212 unlinkmany $DIR/$tdir/t- 1000
4215 for N in $(seq 1 $((OSTCOUNT - 1))); do
4216 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4217 error "OST $N has less objects vs OST $NLAST" \
4218 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4219 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4220 error "OST $N has less objects vs OST $NLAST" \
4221 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4223 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4224 error "OST $N has less #0 objects vs OST $NLAST" \
4225 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4226 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4227 error "OST $N has less #0 objects vs OST $NLAST" \
4228 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4233 run_test 51d "check object distribution"
4236 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4237 skip "ldiskfs only test"
4241 test_mkdir -c1 $DIR/$tdir
4242 test_mkdir -c1 $DIR/$tdir/d0
4244 touch $DIR/$tdir/d0/foo
4245 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4246 error "file exceed 65000 nlink limit!"
4247 unlinkmany $DIR/$tdir/d0/f- 65001
4250 run_test 51e "check file nlink limit"
4253 test_mkdir $DIR/$tdir
4256 local ulimit_old=$(ulimit -n)
4257 local spare=20 # number of spare fd's for scripts/libraries, etc.
4258 local mdt=$(lfs getstripe -M $DIR/$tdir)
4259 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4261 echo "MDT$mdt numfree=$numfree, max=$max"
4262 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4263 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4264 while ! ulimit -n $((numfree + spare)); do
4265 numfree=$((numfree * 3 / 4))
4267 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4269 echo "left ulimit at $ulimit_old"
4272 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4273 unlinkmany $DIR/$tdir/f $numfree
4274 error "create+open $numfree files in $DIR/$tdir failed"
4276 ulimit -n $ulimit_old
4278 # if createmany exits at 120s there will be fewer than $numfree files
4279 unlinkmany $DIR/$tdir/f $numfree || true
4281 run_test 51f "check many open files limit"
4284 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4285 test_mkdir $DIR/$tdir
4286 touch $DIR/$tdir/foo
4287 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4288 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4289 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4290 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4291 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4293 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4294 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4295 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4297 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4298 cp -r $DIR/$tdir $TMP/
4299 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4301 run_test 52a "append-only flag test (should return errors)"
4304 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4305 test_mkdir $DIR/$tdir
4306 touch $DIR/$tdir/foo
4307 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4308 cat test > $DIR/$tdir/foo && error "cat test worked"
4309 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4310 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4311 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4313 echo foo >> $DIR/$tdir/foo && error "echo worked"
4314 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4315 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4316 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4317 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4319 chattr -i $DIR/$tdir/foo || error "chattr failed"
4321 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4323 run_test 52b "immutable flag test (should return errors) ======="
4326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4327 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4328 remote_ost_nodsh && skip "remote OST with nodsh" && return
4341 local support_last_seq=true
4343 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4344 support_last_seq=false
4347 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4349 for value in $(do_facet $SINGLEMDS \
4350 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4351 param=$(echo ${value[0]} | cut -d "=" -f1)
4352 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4354 if $support_last_seq; then
4355 param_seq=$(echo $param |
4356 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4357 mds_last_seq=$(do_facet $SINGLEMDS \
4358 $LCTL get_param -n $param_seq)
4360 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4362 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4363 node=$(facet_active_host ost$((ostnum+1)))
4364 param="obdfilter.$ostname.last_id"
4365 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4366 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4367 ost_last_id=$ost_last
4369 if $support_last_seq; then
4370 ost_last_id=$(echo $ost_last |
4371 awk -F':' '{print $2}' |
4373 ost_last_seq=$(echo $ost_last |
4374 awk -F':' '{print $1}')
4375 [[ $ost_last_seq = $mds_last_seq ]] || continue
4378 if [[ $ost_last_id != $mds_last ]]; then
4379 error "$ost_last_id != $mds_last"
4386 $found || error "can not match last_seq/last_id for $mdtosc"
4389 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4392 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4394 $SOCKETSERVER $DIR/socket ||
4395 error "$SOCKETSERVER $DIR/socket failed: $?"
4396 $SOCKETCLIENT $DIR/socket ||
4397 error "$SOCKETCLIENT $DIR/socket failed: $?"
4398 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4400 run_test 54a "unix domain socket test =========================="
4406 dd if=/dev/zero of=$f bs=$(page_size) count=1
4408 run_test 54b "char device works in lustre ======================"
4411 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4412 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4413 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4415 for i in $(seq 3 7); do
4416 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4425 loopdev="$DIR/loop54c"
4428 $UMOUNT $DIR/$tdir || rc=$?
4429 losetup -d $loopdev || true
4430 losetup -d $LOOPDEV || true
4431 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4437 loopdev="$DIR/loop54c"
4440 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4441 trap cleanup_54c EXIT
4442 mknod $loopdev b 7 $LOOPNUM
4443 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4444 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4445 losetup $loopdev $DIR/$tfile ||
4446 error "can't set up $loopdev for $DIR/$tfile"
4447 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4448 test_mkdir $DIR/$tdir
4449 mount -t ext2 $loopdev $DIR/$tdir ||
4450 error "error mounting $loopdev on $DIR/$tdir"
4451 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4454 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4458 run_test 54c "block device works in lustre ====================="
4464 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4466 run_test 54d "fifo device works in lustre ======================"
4471 cp -aL /dev/console $f
4472 echo $string > $f || error "echo $string to $f failed"
4474 run_test 54e "console/tty device works in lustre ======================"
4476 #The test_55 used to be iopen test and it was removed by bz#24037.
4477 #run_test 55 "check iopen_connect_dentry() ======================"
4479 test_56a() { # was test_56
4482 test_mkdir -p $DIR/$tdir/dir
4484 NUMFILESx2=$(($NUMFILES * 2))
4485 for i in $(seq 1 $NUMFILES); do
4486 touch $DIR/$tdir/file$i
4487 touch $DIR/$tdir/dir/file$i
4490 # test lfs getstripe with --recursive
4491 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4492 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4493 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4494 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4495 [[ $FILENUM -eq $NUMFILES ]] ||
4496 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4497 echo "$GETSTRIPE --recursive passed."
4499 # test lfs getstripe with file instead of dir
4500 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4501 [[ $FILENUM -eq 1 ]] ||
4502 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4503 echo "$GETSTRIPE file1 passed."
4505 #test lfs getstripe with --verbose
4506 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4507 grep -c lmm_magic) -eq $NUMFILES ]] ||
4508 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4509 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4510 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4512 #test lfs getstripe with -v prints lmm_fid
4513 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4514 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4515 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4516 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4517 echo "$GETSTRIPE --verbose passed."
4519 #check for FID information
4520 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4521 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4522 awk '/lmm_fid: / { print $2 }')
4523 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4524 [ "$fid1" != "$fid2" ] &&
4525 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4526 [ "$fid1" != "$fid3" ] &&
4527 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4528 echo "$GETSTRIPE --fid passed."
4530 #test lfs getstripe with --obd
4531 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4532 grep -q "unknown obduuid" ||
4533 error "$GETSTRIPE --obd wrong_uuid should return error message"
4535 [[ $OSTCOUNT -lt 2 ]] &&
4536 skip_env "skipping other $GETSTRIPE --obd test" && return
4539 OBDUUID=$(ostuuid_from_index $OSTIDX)
4540 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4541 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4542 [[ $FOUND -eq $FILENUM ]] ||
4543 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4544 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4545 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4546 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4547 error "$GETSTRIPE --obd: should not show file on other obd"
4548 echo "$GETSTRIPE --obd passed"
4550 run_test 56a "check $GETSTRIPE"
4553 test_mkdir $DIR/$tdir
4555 for i in $(seq 1 $NUMDIRS); do
4556 test_mkdir $DIR/$tdir/dir$i
4559 # test lfs getdirstripe default mode is non-recursion, which is
4560 # different from lfs getstripe
4561 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4562 [[ $dircnt -eq 1 ]] ||
4563 error "$LFS getdirstripe: found $dircnt, not 1"
4564 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4565 grep -c lmv_stripe_count)
4566 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4567 error "$LFS getdirstripe --recursive: found $dircnt, \
4568 not $((NUMDIRS + 1))"
4570 run_test 56b "check $LFS getdirstripe"
4574 local ost_name=$(ostname_from_index $ost_idx)
4576 local old_status=$(ost_dev_status $ost_idx)
4577 [[ -z "$old_status" ]] ||
4578 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4580 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4583 local new_status=$(ost_dev_status $ost_idx)
4584 [[ "$new_status" = "D" ]] ||
4585 error "OST $ost_name is in status of '$new_status', not 'D'"
4587 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4590 new_status=$(ost_dev_status $ost_idx)
4591 [[ -z "$new_status" ]] ||
4592 error "OST $ost_name is in status of '$new_status', not ''"
4594 run_test 56c "check 'lfs df' showing device status"
4599 local LOCAL_NUMFILES="$1"
4600 local LOCAL_NUMDIRS="$2"
4601 local MKDIR_PARAMS="$3"
4602 local DIR_STRIPE_PARAMS="$4"
4604 if [ ! -d "$TDIR" ] ; then
4605 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4606 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4607 for i in `seq 1 $LOCAL_NUMFILES` ; do
4610 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4611 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4612 for j in `seq 1 $LOCAL_NUMFILES` ; do
4613 touch $TDIR/dir$i/file$j
4619 setup_56_special() {
4623 if [ ! -e "$TDIR/loop1b" ] ; then
4624 for i in `seq 1 $LOCAL_NUMFILES` ; do
4625 mknod $TDIR/loop${i}b b 7 $i
4626 mknod $TDIR/null${i}c c 1 3
4627 ln -s $TDIR/file1 $TDIR/link${i}l
4629 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4630 mknod $TDIR/dir$i/loop${i}b b 7 $i
4631 mknod $TDIR/dir$i/null${i}c c 1 3
4632 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4641 setup_56 $NUMFILES $NUMDIRS
4643 EXPECTED=$(($NUMDIRS + 2))
4644 # test lfs find with -name
4645 for i in $(seq 1 $NUMFILES) ; do
4646 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4647 [ $NUMS -eq $EXPECTED ] ||
4648 error "lfs find -name \"*$i\" $TDIR wrong: "\
4649 "found $NUMS, expected $EXPECTED"
4652 run_test 56g "check lfs find -name ============================="
4658 setup_56 $NUMFILES $NUMDIRS
4660 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4661 # test lfs find with ! -name
4662 for i in $(seq 1 $NUMFILES) ; do
4663 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4664 [ $NUMS -eq $EXPECTED ] ||
4665 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4666 "found $NUMS, expected $EXPECTED"
4669 run_test 56h "check lfs find ! -name"
4673 test_mkdir $DIR/$tdir
4674 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4675 CMD="$LFIND -ost $UUID $DIR/$tdir"
4677 [ -z "$OUT" ] || error "'$CMD' returned directory '$OUT'"
4679 run_test 56i "check 'lfs find -ost UUID' skips directories"
4683 setup_56_special $NUMFILES $NUMDIRS
4685 EXPECTED=$((NUMDIRS + 1))
4686 CMD="$LFIND -type d $TDIR"
4687 NUMS=$($CMD | wc -l)
4688 [ $NUMS -eq $EXPECTED ] ||
4689 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4691 run_test 56j "check lfs find -type d ============================="
4695 setup_56_special $NUMFILES $NUMDIRS
4697 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4698 CMD="$LFIND -type f $TDIR"
4699 NUMS=$($CMD | wc -l)
4700 [ $NUMS -eq $EXPECTED ] ||
4701 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4703 run_test 56k "check lfs find -type f ============================="
4707 setup_56_special $NUMFILES $NUMDIRS
4709 EXPECTED=$((NUMDIRS + NUMFILES))
4710 CMD="$LFIND -type b $TDIR"
4711 NUMS=$($CMD | wc -l)
4712 [ $NUMS -eq $EXPECTED ] ||
4713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4715 run_test 56l "check lfs find -type b ============================="
4719 setup_56_special $NUMFILES $NUMDIRS
4721 EXPECTED=$((NUMDIRS + NUMFILES))
4722 CMD="$LFIND -type c $TDIR"
4723 NUMS=$($CMD | wc -l)
4724 [ $NUMS -eq $EXPECTED ] ||
4725 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4727 run_test 56m "check lfs find -type c ============================="
4731 setup_56_special $NUMFILES $NUMDIRS
4733 EXPECTED=$((NUMDIRS + NUMFILES))
4734 CMD="$LFIND -type l $TDIR"
4735 NUMS=$($CMD | wc -l)
4736 [ $NUMS -eq $EXPECTED ] ||
4737 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4739 run_test 56n "check lfs find -type l ============================="
4743 setup_56 $NUMFILES $NUMDIRS
4744 utime $TDIR/file1 > /dev/null || error "utime (1)"
4745 utime $TDIR/file2 > /dev/null || error "utime (2)"
4746 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4747 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4748 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4749 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4752 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4753 [ $NUMS -eq $EXPECTED ] || \
4754 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4757 CMD="$LFIND -mtime 0 $TDIR"
4758 NUMS=$($CMD | wc -l)
4759 [ $NUMS -eq $EXPECTED ] ||
4760 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4762 run_test 56o "check lfs find -mtime for old files =========================="
4765 [ $RUNAS_ID -eq $UID ] &&
4766 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4769 setup_56 $NUMFILES $NUMDIRS
4771 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4773 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4774 NUMS=$($CMD | wc -l)
4775 [ $NUMS -eq $EXPECTED ] || \
4776 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4778 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4779 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4780 NUMS=$($CMD | wc -l)
4781 [ $NUMS -eq $EXPECTED ] || \
4782 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4784 run_test 56p "check lfs find -uid and ! -uid ==============================="
4787 [ $RUNAS_ID -eq $UID ] &&
4788 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4791 setup_56 $NUMFILES $NUMDIRS
4793 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4796 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4797 NUMS=$($CMD | wc -l)
4798 [ $NUMS -eq $EXPECTED ] ||
4799 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4801 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4802 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4803 NUMS=$($CMD | wc -l)
4804 [ $NUMS -eq $EXPECTED ] ||
4805 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4807 run_test 56q "check lfs find -gid and ! -gid ==============================="
4811 setup_56 $NUMFILES $NUMDIRS
4814 CMD="$LFIND -size 0 -type f $TDIR"
4815 NUMS=$($CMD | wc -l)
4816 [ $NUMS -eq $EXPECTED ] ||
4817 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4819 CMD="$LFIND ! -size 0 -type f $TDIR"
4820 NUMS=$($CMD | wc -l)
4821 [ $NUMS -eq $EXPECTED ] ||
4822 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4823 echo "test" > $TDIR/$tfile
4824 echo "test2" > $TDIR/$tfile.2 && sync
4826 CMD="$LFIND -size 5 -type f $TDIR"
4827 NUMS=$($CMD | wc -l)
4828 [ $NUMS -eq $EXPECTED ] ||
4829 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4831 CMD="$LFIND -size +5 -type f $TDIR"
4832 NUMS=$($CMD | wc -l)
4833 [ $NUMS -eq $EXPECTED ] ||
4834 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4836 CMD="$LFIND -size +0 -type f $TDIR"
4837 NUMS=$($CMD | wc -l)
4838 [ $NUMS -eq $EXPECTED ] ||
4839 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4841 CMD="$LFIND ! -size -5 -type f $TDIR"
4842 NUMS=$($CMD | wc -l)
4843 [ $NUMS -eq $EXPECTED ] ||
4844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4846 CMD="$LFIND -size -5 -type f $TDIR"
4847 NUMS=$($CMD | wc -l)
4848 [ $NUMS -eq $EXPECTED ] ||
4849 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4851 run_test 56r "check lfs find -size works =========================="
4853 test_56s() { # LU-611
4858 for i in $(seq 1 $NUMDIRS); do
4859 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4862 CMD="$LFIND -c $OSTCOUNT $TDIR"
4863 NUMS=$($CMD | wc -l)
4864 [ $NUMS -eq $EXPECTED ] || {
4866 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4870 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4871 if [[ $OSTCOUNT -gt 1 ]]; then
4872 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4876 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4880 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4881 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4882 NUMS=$($CMD | wc -l)
4883 [ $NUMS -eq $EXPECTED ] || {
4885 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4888 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4889 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4890 NUMS=$($CMD | wc -l)
4891 [ $NUMS -eq $EXPECTED ] || {
4893 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4897 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4898 NUMS=$($CMD | wc -l)
4899 [ $NUMS -eq $EXPECTED ] || {
4901 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4904 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4905 NUMS=$($CMD | wc -l)
4906 [ $NUMS -eq $EXPECTED ] || {
4908 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4912 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4913 NUMS=$($CMD | wc -l)
4914 [ $NUMS -eq $EXPECTED ] || {
4916 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4919 run_test 56s "check lfs find -stripe-count works"
4921 test_56t() { # LU-611
4926 for i in $(seq 1 $NUMDIRS); do
4927 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4930 CMD="$LFIND -S 4M $TDIR"
4931 NUMS=$($CMD | wc -l)
4932 [ $NUMS -eq $EXPECTED ] || {
4934 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4938 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
4940 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4942 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4943 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4944 NUMS=$($CMD | wc -l)
4945 [ $NUMS -eq $EXPECTED ] ||
4946 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4948 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4949 NUMS=$($CMD | wc -l)
4950 [ $NUMS -eq $EXPECTED ] ||
4951 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4953 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4954 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4955 NUMS=$($CMD | wc -l)
4956 [ $NUMS -eq $EXPECTED ] ||
4957 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4959 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4960 NUMS=$($CMD | wc -l)
4961 [ $NUMS -eq $EXPECTED ] ||
4962 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4965 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4966 NUMS=$($CMD | wc -l)
4967 [ $NUMS -eq $EXPECTED ] ||
4968 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4970 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4971 NUMS=$($CMD | wc -l)
4972 [ $NUMS -eq $EXPECTED ] ||
4973 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4976 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4977 NUMS=$($CMD | wc -l)
4978 [ $NUMS -eq $EXPECTED ] ||
4979 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4981 run_test 56t "check lfs find -stripe-size works"
4983 test_56u() { # LU-611
4985 setup_56 $NUMFILES $NUMDIRS "-i 0"
4987 if [[ $OSTCOUNT -gt 1 ]]; then
4988 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4994 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4995 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4996 NUMS=$($CMD | wc -l)
4997 [ $NUMS -eq $EXPECTED ] ||
4998 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5001 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5002 NUMS=$($CMD | wc -l)
5003 [ $NUMS -eq $EXPECTED ] ||
5004 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5006 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5007 NUMS=$($CMD | wc -l)
5008 [ $NUMS -eq $EXPECTED ] ||
5009 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5012 # This should produce an error and not return any files
5013 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5014 NUMS=$($CMD 2>/dev/null | wc -l)
5015 [ $NUMS -eq $EXPECTED ] ||
5016 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5018 if [[ $OSTCOUNT -gt 1 ]]; then
5019 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5020 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5021 NUMS=$($CMD | wc -l)
5022 [ $NUMS -eq $EXPECTED ] ||
5023 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5026 run_test 56u "check lfs find -stripe-index works"
5033 setup_56 $NUMFILES $NUMDIRS
5035 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5036 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5038 for file in $($LFIND -mdt $UUID $TDIR); do
5039 file_mdt_idx=$($GETSTRIPE -M $file)
5040 [ $file_mdt_idx -eq $MDT_IDX ] ||
5041 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5044 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5047 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 rm -rf $TDIR || error "remove $TDIR failed"
5052 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5055 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5056 error "$GETSTRIPE -S -d $TDIR failed"
5057 stripe_size=${stripe_size%% *}
5059 local file_size=$((stripe_size * OSTCOUNT))
5060 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5061 local required_space=$((file_num * file_size))
5063 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5065 [[ $free_space -le $((required_space / 1024)) ]] &&
5066 skip_env "need $required_space bytes, have $free_space KB" &&
5070 local dd_count=$((file_size / dd_bs))
5072 # write data into the files
5076 for i in $(seq 1 $NUMFILES); do
5078 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5079 error "write data into $file failed"
5081 for i in $(seq 1 $NUMDIRS); do
5082 for j in $(seq 1 $NUMFILES); do
5083 file=$TDIR/dir$i/file$j
5084 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5085 error "write data into $file failed"
5089 # $LFS_MIGRATE will fail if hard link migration is unsupported
5090 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5091 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5092 error "creating links to $TDIR/dir1/file1 failed"
5096 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5099 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5101 eval $cmd || error "$cmd failed"
5103 check_stripe_count $TDIR/file1 $expected
5105 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5107 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5108 # OST 1 if it is on OST 0. This file is small enough to
5109 # be on only one stripe.
5110 file=$TDIR/migr_1_ost
5111 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5112 error "write data into $file failed"
5113 local obdidx=$($LFS getstripe -i $file)
5114 local oldmd5=$(md5sum $file)
5116 [[ $obdidx -eq 0 ]] && newobdidx=1
5117 cmd="$LFS migrate -i $newobdidx $file"
5119 eval $cmd || error "$cmd failed"
5120 local realobdix=$($LFS getstripe -i $file)
5121 local newmd5=$(md5sum $file)
5122 [[ $newobdidx -ne $realobdix ]] &&
5123 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5124 [[ "$oldmd5" != "$newmd5" ]] &&
5125 error "md5sum differ: $oldmd5, $newmd5"
5129 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5131 eval $cmd || error "$cmd failed"
5133 for j in $(seq 1 $NUMFILES); do
5134 check_stripe_count $TDIR/dir1/file$j $expected
5137 # lfs_migrate works with lfs find
5138 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5139 $LFS_MIGRATE -y -c $expected"
5141 eval $cmd || error "$cmd failed"
5143 for i in $(seq 2 $NUMFILES); do
5144 check_stripe_count $TDIR/file$i $expected
5146 for i in $(seq 2 $NUMDIRS); do
5147 for j in $(seq 1 $NUMFILES); do
5148 check_stripe_count $TDIR/dir$i/file$j $expected
5152 run_test 56w "check lfs_migrate -c stripe_count works"
5155 check_swap_layouts_support && return 0
5156 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5158 local dir0=$DIR/$tdir
5159 local ref1=/etc/passwd
5160 local file1=$dir0/file1
5162 test_mkdir $dir0 || error "creating dir $dir0"
5163 $LFS setstripe -c 2 $file1
5165 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5166 stripe=$($LFS getstripe -c $file1)
5167 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5168 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5173 run_test 56x "lfs migration support"
5176 check_swap_layouts_support && return 0
5177 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5179 local dir0=$DIR/$tdir/$testnum
5182 local ref1=/etc/passwd
5183 local file1=$dir0/file1
5185 $LFS setstripe -c 2 $file1
5187 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5188 local stripe=$($LFS getstripe -c $file1)
5189 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5190 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5195 run_test 56xa "lfs migration --block support"
5197 check_migrate_links() {
5199 local file1="$dir/file1"
5202 local total_count=$(($begin + $count - 1))
5203 local symlink_count=10
5206 if [ ! -f "$file1" ]; then
5207 echo -n "creating initial file..."
5208 $LFS setstripe -c 1 -S "512k" "$file1" ||
5209 error "cannot setstripe initial file"
5212 echo -n "creating symlinks..."
5213 for s in $(seq 1 $symlink_count); do
5214 ln -s "$file1" "$dir/slink$s" ||
5215 error "cannot create symlinks"
5219 echo -n "creating nonlinked files..."
5220 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5221 error "cannot create nonlinked files"
5226 if [ ! -f "$dir/file$total_count" ]; then
5227 echo -n "creating hard links $begin:$total_count..."
5228 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5229 /dev/null || error "cannot create hard links"
5233 echo -n "checking number of hard links listed in xattrs..."
5234 local fid=$($LFS getstripe -F "$file1")
5235 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5238 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5239 echo "hard link list has unexpected size, skipping test"
5242 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5243 error "link names should exceed xattrs size"
5246 echo -n "migrating files..."
5247 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5249 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5252 # make sure all links have been properly migrated
5253 echo -n "verifying files..."
5254 fid=$($LFS getstripe -F "$file1") ||
5255 error "cannot get fid for file $file1"
5256 for i in $(seq 2 $total_count); do
5257 local fid2=$($LFS getstripe -F $dir/file$i)
5258 [ "$fid2" == "$fid" ] ||
5259 error "migrated hard link has mismatched FID"
5262 # make sure hard links were properly detected, and migration was
5263 # performed only once for the entire link set; nonlinked files should
5265 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5266 local expected=$(($uniq_count + 1))
5267 [ "$actual" -eq "$expected" ] ||
5268 error "hard links individually migrated ($actual != $expected)"
5270 # make sure the correct number of hard links are present
5271 local hardlinks=$(stat -c '%h' "$file1")
5272 [ $hardlinks -eq $total_count ] ||
5273 error "num hard links $hardlinks != $total_count"
5280 local dir0="$DIR/$tdir"
5282 test_mkdir "$dir0" || error "cannot create dir $dir0"
5284 echo "testing lfs migrate mode when all links fit within xattrs"
5285 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
5287 echo "testing rsync mode when all links fit within xattrs"
5288 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
5290 echo "testing lfs migrate mode when all links do not fit within xattrs"
5291 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
5293 echo "testing rsync mode when all links do not fit within xattrs"
5294 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
5299 run_test 56xb "lfs migration hard link support"
5302 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5303 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5307 local dir0=$DIR/$tdir/$testnum
5309 local f1=$dir0/file1
5310 local f2=$dir0/file2
5312 touch $f1 || error "creating std file $f1"
5313 $MULTIOP $f2 H2c || error "creating released file $f2"
5315 # a directory can be raid0, so ask only for files
5316 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5317 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5319 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5320 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5322 # only files can be released, so no need to force file search
5323 res=$($LFIND $dir0 -L released)
5324 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5326 res=$($LFIND $dir0 \! -L released)
5327 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5330 run_test 56y "lfs find -L raid0|released"
5332 test_56z() { # LU-4824
5333 # This checks to make sure 'lfs find' continues after errors
5334 # There are two classes of errors that should be caught:
5335 # - If multiple paths are provided, all should be searched even if one
5337 # - If errors are encountered during the search, it should not terminate
5340 test_mkdir $DIR/$tdir
5341 for i in d{0..9}; do
5342 test_mkdir $DIR/$tdir/$i
5344 touch $DIR/$tdir/d{0..9}/$tfile
5345 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5346 error "$LFS find did not return an error"
5347 # Make a directory unsearchable. This should NOT be the last entry in
5348 # directory order. Arbitrarily pick the 6th entry
5349 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5350 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5351 # The user should be able to see 10 directories and 9 files
5352 [ $count == 19 ] || error "$LFS find did not continue after error"
5354 run_test 56z "lfs find should continue after an error"
5356 test_56aa() { # LU-5937
5357 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5360 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5362 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5363 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5365 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5367 run_test 56aa "lfs find --size under striped dir"
5370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5371 # note test will not do anything if MDS is not local
5372 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5373 skip "ldiskfs only test"
5377 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5378 local MNTDEV="osd*.*MDT*.mntdev"
5379 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5380 [ -z "$DEV" ] && error "can't access $MNTDEV"
5381 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5382 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5383 error "can't access $DEV"
5384 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5385 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5389 run_test 57a "verify MDS filesystem created with large inodes =="
5392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5393 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5394 skip "ldiskfs only test"
5398 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5399 local dir=$DIR/$tdir
5403 local FILEN=$dir/f$FILECOUNT
5405 rm -rf $dir || error "removing $dir"
5407 local mdtidx=$($LFS getstripe -M $dir)
5408 local mdtname=MDT$(printf %04x $mdtidx)
5409 local facet=mds$((mdtidx + 1))
5411 echo "mcreating $FILECOUNT files"
5412 createmany -m $dir/f 1 $FILECOUNT || \
5413 error "creating files in $dir"
5415 # verify that files do not have EAs yet
5416 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5417 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5421 df $dir #make sure we get new statfs data
5422 local MDSFREE=$(do_facet $facet \
5423 lctl get_param -n osd*.*$mdtname.kbytesfree)
5424 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5425 echo "opening files to create objects/EAs"
5427 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5428 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5431 # verify that files have EAs now
5432 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5433 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5435 sleep 1 #make sure we get new statfs data
5437 local MDSFREE2=$(do_facet $facet \
5438 lctl get_param -n osd*.*$mdtname.kbytesfree)
5439 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5440 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5441 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5442 error "MDC before $MDCFREE != after $MDCFREE2"
5444 echo "MDC before $MDCFREE != after $MDCFREE2"
5445 echo "unable to confirm if MDS has large inodes"
5450 run_test 57b "default LOV EAs are stored inside large inodes ==="
5453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5454 [ -z "$(which wiretest 2>/dev/null)" ] &&
5455 skip_env "could not find wiretest" && return
5458 run_test 58 "verify cross-platform wire constants =============="
5461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5462 echo "touch 130 files"
5463 createmany -o $DIR/f59- 130
5465 unlinkmany $DIR/f59- 130
5467 # wait for commitment of removal
5468 wait_delete_completed
5470 run_test 59 "verify cancellation of llog records async ========="
5472 TEST60_HEAD="test_60 run $RANDOM"
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5475 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5476 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5477 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5478 skip_env "missing subtest run-llog.sh" && return
5480 log "$TEST60_HEAD - from kernel mode"
5481 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5482 do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
5483 do_facet mgs $LCTL dk > $TMP/$tfile
5485 # LU-6388: test llog_reader
5486 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5487 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5488 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5489 skip_env "missing llog_reader" && return
5490 local fstype=$(facet_fstype mgs)
5491 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5492 skip_env "Only for ldiskfs or zfs type mgs" && return
5494 local mntpt=$(facet_mntpt mgs)
5495 local mgsdev=$(mgsdevname 1)
5507 #get fid and record list
5508 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5510 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5512 #remount mgs as ldiskfs or zfs type
5513 stop mgs || error "stop mgs failed"
5514 mount_fstype mgs || error "remount mgs failed"
5515 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5518 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5519 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5524 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5526 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5528 echo "obj_file is $obj_file"
5529 do_facet mgs $llog_reader $obj_file
5531 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5532 awk '{ print $3 }' | sed -e "s/^type=//g")
5533 if [ $rec_type != $rec ]; then
5534 echo "FAILED test_60a wrong record type $rec_type," \
5540 #check obj path if record type is LLOG_LOGID_MAGIC
5541 if [ "$rec" == "1064553b" ]; then
5542 path=$(do_facet mgs $llog_reader $obj_file |
5543 grep "path=" | awk '{ print $NF }' |
5544 sed -e "s/^path=//g")
5545 if [ $obj_file != $mntpt/$path ]; then
5546 echo "FAILED test_60a wrong obj path" \
5547 "$montpt/$path, should be $obj_file"
5554 #restart mgs before "error", otherwise it will block the next test
5555 stop mgs || error "stop mgs failed"
5556 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5557 $pass || error "test failed, see FAILED test_60a messages for specifics"
5559 run_test 60a "llog_test run from kernel module and test llog_reader"
5562 # test old logid format
5563 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5564 do_facet mgs $LCTL dl | grep MGS
5565 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5566 error "old llog_print failed"
5569 # test new logid format
5570 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5571 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5572 error "new llog_print failed"
5575 run_test 60aa "llog_print works with FIDs and simple names"
5577 test_60b() { # bug 6411
5578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5580 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5592 [[ $LLOG_COUNT -gt 100 ]] &&
5593 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5595 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5599 echo "create 5000 files"
5600 createmany -o $DIR/f60c- 5000
5601 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5602 lctl set_param fail_loc=0x80000137
5603 unlinkmany $DIR/f60c- 5000
5604 lctl set_param fail_loc=0
5606 run_test 60c "unlink file when mds full"
5609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5610 SAVEPRINTK=$(lctl get_param -n printk)
5612 # verify "lctl mark" is even working"
5613 MESSAGE="test message ID $RANDOM $$"
5614 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5615 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5617 lctl set_param printk=0 || error "set lnet.printk failed"
5618 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5619 MESSAGE="new test message ID $RANDOM $$"
5620 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5621 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5622 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5624 lctl set_param -n printk="$SAVEPRINTK"
5626 run_test 60d "test printk console message masking"
5629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5630 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5632 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5633 do_facet mds1 lctl set_param fail_loc=0x15b
5636 run_test 60e "no space while new llog is being created"
5639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5641 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5642 cancel_lru_locks osc
5643 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5646 run_test 61 "mmap() writes don't make sync hang ================"
5648 # bug 2330 - insufficient obd_match error checking causes LBUG
5650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5653 cancel_lru_locks osc
5654 lctl set_param fail_loc=0x405
5655 cat $f && error "cat succeeded, expect -EIO"
5656 lctl set_param fail_loc=0
5658 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5659 # match every page all of the time.
5660 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5662 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5663 # Though this test is irrelevant anymore, it helped to reveal some
5664 # other grant bugs (LU-4482), let's keep it.
5665 test_63a() { # was test_63
5666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5667 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5668 for i in `seq 10` ; do
5669 dd if=/dev/zero of=$DIR/f63 bs=8k &
5675 rm -f $DIR/f63 || true
5677 run_test 63a "Verify oig_wait interruption does not crash ======="
5679 # bug 2248 - async write errors didn't return to application on sync
5680 # bug 3677 - async write errors left page locked
5682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5684 lctl set_param debug=-1
5686 # ensure we have a grant to do async writes
5687 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5690 sync # sync lest earlier test intercept the fail_loc
5692 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5693 lctl set_param fail_loc=0x80000406
5694 $MULTIOP $DIR/$tfile Owy && \
5695 error "sync didn't return ENOMEM"
5696 sync; sleep 2; sync # do a real sync this time to flush page
5697 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5698 error "locked page left in cache after async error" || true
5701 run_test 63b "async write errors should be returned to fsync ==="
5704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5706 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5708 run_test 64a "verify filter grant calculations (in kernel) ====="
5711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5712 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5714 run_test 64b "check out-of-space detection on client"
5717 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5719 run_test 64c "verify grant shrink"
5721 # bug 1414 - set/get directories' stripe info
5723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5724 test_mkdir $DIR/$tdir
5726 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5728 run_test 65a "directory with no stripe info"
5731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5732 test_mkdir $DIR/$tdir
5733 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5735 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5738 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5740 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5744 [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
5745 test_mkdir $DIR/$tdir
5746 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
5748 $LFS setstripe -S $((stripesize * 4)) -i 1 \
5749 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5751 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5753 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5757 test_mkdir $DIR/$tdir
5758 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5759 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5761 if [[ $STRIPECOUNT -le 0 ]]; then
5763 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5764 #LOV_MAX_STRIPE_COUNT is 2000
5765 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5767 sc=$(($STRIPECOUNT - 1))
5769 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5770 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5771 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5772 error "lverify failed"
5774 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5778 test_mkdir $DIR/$tdir
5780 $SETSTRIPE $DIR/$tdir || error "setstripe"
5781 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5782 error "no stripe info failed"
5784 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5786 run_test 65e "directory setstripe defaults"
5789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5790 test_mkdir $DIR/${tdir}f
5791 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5793 run_test 65f "dir setstripe permission (should return error) ==="
5796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5797 test_mkdir $DIR/$tdir
5798 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5800 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5801 error "setstripe -S failed"
5802 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
5803 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
5804 error "delete default stripe failed"
5806 run_test 65g "directory setstripe -d"
5809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5810 test_mkdir $DIR/$tdir
5811 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5813 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5814 error "setstripe -S failed"
5815 test_mkdir $DIR/$tdir/dd1
5816 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5817 error "stripe info inherit failed"
5819 run_test 65h "directory stripe info inherit ===================="
5821 test_65i() { # bug6367
5822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5823 $SETSTRIPE -S 65536 -c -1 $MOUNT
5825 run_test 65i "set non-default striping on root directory (bug 6367)="
5827 test_65ia() { # bug12836
5828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5829 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5831 run_test 65ia "getstripe on -1 default directory striping"
5833 test_65ib() { # bug12836
5834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5835 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5837 run_test 65ib "getstripe -v on -1 default directory striping"
5839 test_65ic() { # bug12836
5840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5841 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5843 run_test 65ic "new find on -1 default directory striping"
5845 test_65j() { # bug6367
5846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5848 # if we aren't already remounting for each test, do so for this test
5849 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5850 cleanup || error "failed to unmount"
5853 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5855 run_test 65j "set default striping on root directory (bug 6367)="
5857 test_65k() { # bug11679
5858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5859 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5860 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5862 local disable_precreate=true
5863 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5864 disable_precreate=false
5866 echo "Check OST status: "
5867 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5868 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5870 for OSC in $MDS_OSCS; do
5871 echo $OSC "is active"
5872 do_facet $SINGLEMDS lctl --device %$OSC activate
5875 for INACTIVE_OSC in $MDS_OSCS; do
5876 local ost=$(osc_to_ost $INACTIVE_OSC)
5877 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5878 lov.*md*.target_obd |
5879 awk -F: /$ost/'{ print $1 }' | head -n 1)
5882 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5883 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5885 echo "Deactivate: " $INACTIVE_OSC
5886 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5888 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5889 osp.$ost*MDT0000.create_count")
5890 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5891 osp.$ost*MDT0000.max_create_count")
5892 $disable_precreate &&
5893 do_facet $SINGLEMDS "lctl set_param -n \
5894 osp.$ost*MDT0000.max_create_count=0"
5896 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5897 [ -f $DIR/$tdir/$idx ] && continue
5898 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5899 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5900 error "setstripe $idx should succeed"
5901 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5903 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5906 do_facet $SINGLEMDS "lctl set_param -n \
5907 osp.$ost*MDT0000.max_create_count=$max_count"
5908 do_facet $SINGLEMDS "lctl set_param -n \
5909 osp.$ost*MDT0000.create_count=$count"
5910 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5911 echo $INACTIVE_OSC "is Activate"
5913 wait_osc_import_state mds ost$ostnum FULL
5916 run_test 65k "validate manual striping works properly with deactivated OSCs"
5918 test_65l() { # bug 12836
5919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5920 test_mkdir -p $DIR/$tdir/test_dir
5921 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5922 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5924 run_test 65l "lfs find on -1 stripe dir ========================"
5927 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
5930 run_test 65m "normal user can't set filesystem default stripe"
5932 # bug 2543 - update blocks count on client
5934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5936 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5937 sync; sync_all_data; sync; sync_all_data
5938 cancel_lru_locks osc
5939 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5940 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5942 run_test 66 "update inode blocks count on client ==============="
5945 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5949 swapon -s | awk '($1 == "'$1'") { print $4 }'
5952 # bug5265, obdfilter oa2dentry return -ENOENT
5953 # #define OBD_FAIL_SRV_ENOENT 0x217
5955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5956 remote_ost_nodsh && skip "remote OST with nodsh" && return
5959 $SETSTRIPE -c 1 -i 0 $f
5961 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5963 do_facet ost1 lctl set_param fail_loc=0x217
5964 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5965 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5967 do_facet ost1 lctl set_param fail_loc=0
5968 $DIRECTIO write $f 0 2 || error "write error"
5970 cancel_lru_locks osc
5971 $DIRECTIO read $f 0 1 || error "read error"
5973 do_facet ost1 lctl set_param fail_loc=0x217
5974 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5976 do_facet ost1 lctl set_param fail_loc=0
5979 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5982 test_mkdir $DIR/$tdir
5983 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5984 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5986 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5988 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5990 [ "$RUNAS_ID" = "$UID" ] &&
5991 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5993 # Check that testing environment is properly set up. Skip if not
5994 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5995 skip_env "User $RUNAS_ID does not exist - skipping"
5999 chmod 777 $DIR/$tfile
6000 chmod ug+s $DIR/$tfile
6001 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6002 error "$RUNAS dd $DIR/$tfile failed"
6003 # See if we are still setuid/sgid
6004 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6005 error "S/gid is not dropped on write"
6006 # Now test that MDS is updated too
6007 cancel_lru_locks mdc
6008 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6009 error "S/gid is not dropped on MDS"
6012 run_test 72a "Test that remove suid works properly (bug5695) ===="
6014 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6017 [ "$RUNAS_ID" = "$UID" ] && \
6018 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6019 [ "$RUNAS_ID" -eq 0 ] && \
6020 skip_env "RUNAS_ID = 0 -- skipping" && return
6022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6023 # Check that testing environment is properly set up. Skip if not
6024 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6025 skip_env "User $RUNAS_ID does not exist - skipping"
6028 touch $DIR/${tfile}-f{g,u}
6029 test_mkdir $DIR/${tfile}-dg
6030 test_mkdir $DIR/${tfile}-du
6031 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6032 chmod g+s $DIR/${tfile}-{f,d}g
6033 chmod u+s $DIR/${tfile}-{f,d}u
6034 for perm in 777 2777 4777; do
6035 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6036 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6037 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6038 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6042 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6044 # bug 3462 - multiple simultaneous MDC requests
6046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6047 test_mkdir $DIR/d73-1
6048 test_mkdir $DIR/d73-2
6049 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6052 lctl set_param fail_loc=0x80000129
6053 $MULTIOP $DIR/d73-1/f73-2 Oc &
6055 lctl set_param fail_loc=0
6057 $MULTIOP $DIR/d73-2/f73-3 Oc &
6061 wait $pid1 || return 1
6065 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6066 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6067 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6071 run_test 73 "multiple MDC requests (should not deadlock)"
6073 test_74a() { # bug 6149, 6184
6074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6075 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6077 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6078 # will spin in a tight reconnection loop
6080 $LCTL set_param fail_loc=0x8000030e
6081 # get any lock that won't be difficult - lookup works.
6083 $LCTL set_param fail_loc=0
6087 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6089 test_74b() { # bug 13310
6090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6091 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6093 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6094 # will spin in a tight reconnection loop
6095 $LCTL set_param fail_loc=0x8000030e
6096 # get a "difficult" lock
6098 $LCTL set_param fail_loc=0
6102 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6106 #define OBD_FAIL_LDLM_NEW_LOCK
6107 $LCTL set_param fail_loc=0x319
6108 touch $DIR/$tfile && error "touch successful"
6109 $LCTL set_param fail_loc=0
6112 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6115 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6118 test_76() { # Now for bug 20433, added originally in bug 1443
6119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6120 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6121 cancel_lru_locks osc
6122 BEFORE_INODES=$(num_inodes)
6123 echo "before inodes: $BEFORE_INODES"
6125 [ "$SLOW" = "no" ] && COUNT=100
6126 for i in $(seq $COUNT); do
6130 cancel_lru_locks osc
6131 AFTER_INODES=$(num_inodes)
6132 echo "after inodes: $AFTER_INODES"
6134 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6136 AFTER_INODES=$(num_inodes)
6138 echo "wait $wait seconds inodes: $AFTER_INODES"
6139 if [ $wait -gt 30 ]; then
6140 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6144 run_test 76 "confirm clients recycle inodes properly ===="
6150 # Note: in sptlrpc modes which enable its own bulk checksum, the
6151 # original crc32_le bulk checksum will be automatically disabled,
6152 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6153 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6154 # In this case set_checksums() will not be no-op, because sptlrpc
6155 # bulk checksum will be enabled all through the test.
6157 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6158 lctl set_param -n osc.*.checksums $1
6162 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6163 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6164 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6165 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6168 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6169 log "set checksum type to $1"
6172 F77_TMP=$TMP/f77-temp
6175 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6176 error "error writing to $F77_TMP"
6179 test_77a() { # bug 10889
6180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6181 $GSS && skip "could not run with gss" && return
6182 [ ! -f $F77_TMP ] && setup_f77
6184 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6188 run_test 77a "normal checksum read/write operation"
6190 test_77b() { # bug 10889
6191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6192 $GSS && skip "could not run with gss" && return
6193 [ ! -f $F77_TMP ] && setup_f77
6194 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6195 $LCTL set_param fail_loc=0x80000409
6198 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6199 error "dd error: $?"
6200 $LCTL set_param fail_loc=0
6202 for algo in $CKSUM_TYPES; do
6203 cancel_lru_locks osc
6204 set_checksum_type $algo
6205 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6206 $LCTL set_param fail_loc=0x80000408
6207 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6208 $LCTL set_param fail_loc=0
6211 set_checksum_type $ORIG_CSUM_TYPE
6214 run_test 77b "checksum error on client write, read"
6219 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6221 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6222 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6223 $check_ost && [ -n $ost_file_prefix ] &&
6224 do_facet ost1 rm -f ${ost_file_prefix}\*
6228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6229 $GSS && skip "could not run with gss" && return
6232 local osc_file_prefix
6234 local check_ost=false
6235 local ost_file_prefix
6241 # ensure corruption will occur on first OSS/OST
6242 $LFS setstripe -i 0 $DIR/$tfile
6244 [ ! -f $F77_TMP ] && setup_f77
6245 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6246 error "dd write error: $?"
6247 fid=$($LFS path2fid $DIR/$tfile)
6249 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6252 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6253 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6255 echo "OSS do not support bulk pages dump upon error"
6258 osc_file_prefix=$($LCTL get_param -n debug_path)
6259 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6261 trap cleanup_77c EXIT
6264 # enable bulk pages dump upon error on Client
6265 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6266 # enable bulk pages dump upon error on OSS
6268 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6270 # flush Client cache to allow next read to reach OSS
6271 cancel_lru_locks osc
6273 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6274 $LCTL set_param fail_loc=0x80000408
6275 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6276 $LCTL set_param fail_loc=0
6280 # check cksum dump on Client
6281 osc_file=$(ls ${osc_file_prefix}*)
6282 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6283 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6284 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6285 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6286 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6288 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6289 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6290 error "dump content does not match on Client"
6292 $check_ost || skip "No need to check cksum dump on OSS"
6294 # check cksum dump on OSS
6295 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6296 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6297 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6298 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6299 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6300 error "dump content does not match on OSS"
6304 run_test 77c "checksum error on client read with debug"
6306 test_77d() { # bug 10889
6307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6308 $GSS && skip "could not run with gss" && return
6309 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6310 $LCTL set_param fail_loc=0x80000409
6312 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6313 error "direct write: rc=$?"
6314 $LCTL set_param fail_loc=0
6317 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6318 $LCTL set_param fail_loc=0x80000408
6320 cancel_lru_locks osc
6321 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6322 error "direct read: rc=$?"
6323 $LCTL set_param fail_loc=0
6326 run_test 77d "checksum error on OST direct write, read"
6328 test_77f() { # bug 10889
6329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6330 $GSS && skip "could not run with gss" && return
6332 for algo in $CKSUM_TYPES; do
6333 cancel_lru_locks osc
6334 set_checksum_type $algo
6335 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6336 $LCTL set_param fail_loc=0x409
6337 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6338 error "direct write succeeded"
6339 $LCTL set_param fail_loc=0
6341 set_checksum_type $ORIG_CSUM_TYPE
6344 run_test 77f "repeat checksum error on write (expect error)"
6346 test_77g() { # bug 10889
6347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6348 $GSS && skip "could not run with gss" && return
6349 remote_ost_nodsh && skip "remote OST with nodsh" && return
6351 [ ! -f $F77_TMP ] && setup_f77
6353 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6354 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6355 do_facet ost1 lctl set_param fail_loc=0x8000021a
6357 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6358 error "write error: rc=$?"
6359 do_facet ost1 lctl set_param fail_loc=0
6362 cancel_lru_locks osc
6363 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6364 do_facet ost1 lctl set_param fail_loc=0x8000021b
6366 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6367 do_facet ost1 lctl set_param fail_loc=0
6370 run_test 77g "checksum error on OST write, read"
6372 test_77j() { # bug 13805
6373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6374 $GSS && skip "could not run with gss" && return
6375 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6376 lctl set_param fail_loc=0x40c
6377 remount_client $MOUNT
6378 lctl set_param fail_loc=0
6379 # wait async osc connect to finish and reflect updated state value
6381 for (( i=0; i < OSTCOUNT; i++ )) ; do
6382 wait_osc_import_state client ost$((i+1)) FULL
6385 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6386 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6387 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6388 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6390 remount_client $MOUNT
6392 run_test 77j "client only supporting ADLER32"
6394 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6403 test_78() { # bug 10901
6404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6405 remote_ost || { skip_env "local OST" && return; }
6408 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6409 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6410 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6411 echo "MemTotal: $MEMTOTAL"
6413 # reserve 256MB of memory for the kernel and other running processes,
6414 # and then take 1/2 of the remaining memory for the read/write buffers.
6415 if [ $MEMTOTAL -gt 512 ] ;then
6416 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6418 # for those poor memory-starved high-end clusters...
6419 MEMTOTAL=$((MEMTOTAL / 2))
6421 echo "Mem to use for directio: $MEMTOTAL"
6423 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6424 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6425 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6426 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6428 echo "Smallest OST: $SMALLESTOST"
6429 [[ $SMALLESTOST -lt 10240 ]] &&
6430 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6432 trap cleanup_test_78 EXIT
6434 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6435 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6437 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6438 echo "File size: $F78SIZE"
6439 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6440 for i in $(seq 1 $NSEQ); do
6441 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6442 echo directIO rdwr round $i of $NSEQ
6443 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6448 run_test 78 "handle large O_DIRECT writes correctly ============"
6450 test_79() { # bug 12743
6451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6452 wait_delete_completed
6454 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6455 BKFREE=$(calc_osc_kbytes kbytesfree)
6456 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6458 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6459 DFTOTAL=`echo $STRING | cut -d, -f1`
6460 DFUSED=`echo $STRING | cut -d, -f2`
6461 DFAVAIL=`echo $STRING | cut -d, -f3`
6462 DFFREE=$(($DFTOTAL - $DFUSED))
6464 ALLOWANCE=$((64 * $OSTCOUNT))
6466 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6467 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6468 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6470 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6471 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6472 error "df free($DFFREE) mismatch OST free($BKFREE)"
6474 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6475 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6476 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6479 run_test 79 "df report consistency check ======================="
6481 test_80() { # bug 10718
6482 remote_ost_nodsh && skip "remote OST with nodsh" && return
6483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6484 # relax strong synchronous semantics for slow backends like ZFS
6485 local soc="obdfilter.*.sync_on_lock_cancel"
6486 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6488 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6489 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6490 facet_active_host $host; done | sort -u)
6491 do_nodes $hosts lctl set_param $soc=never
6494 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6496 local BEFORE=`date +%s`
6497 cancel_lru_locks osc
6498 local AFTER=`date +%s`
6499 local DIFF=$((AFTER-BEFORE))
6500 if [ $DIFF -gt 1 ] ; then
6501 error "elapsed for 1M@1T = $DIFF"
6504 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6508 run_test 80 "Page eviction is equally fast at high offsets too ===="
6510 test_81a() { # LU-456
6511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6512 remote_ost_nodsh && skip "remote OST with nodsh" && return
6513 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6514 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6515 do_facet ost1 lctl set_param fail_loc=0x80000228
6517 # write should trigger a retry and success
6518 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6519 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6521 if [ $RC -ne 0 ] ; then
6522 error "write should success, but failed for $RC"
6525 run_test 81a "OST should retry write when get -ENOSPC ==============="
6527 test_81b() { # LU-456
6528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6529 remote_ost_nodsh && skip "remote OST with nodsh" && return
6530 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6531 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6532 do_facet ost1 lctl set_param fail_loc=0x228
6534 # write should retry several times and return -ENOSPC finally
6535 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6536 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6539 if [ $RC -ne $ENOSPC ] ; then
6540 error "dd should fail for -ENOSPC, but succeed."
6543 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6545 test_82() { # LU-1031
6546 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6550 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6552 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6554 kill -USR1 $MULTIPID2
6556 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6557 error "First grouplock does not block second one"
6559 echo "Second grouplock blocks first one"
6561 kill -USR1 $MULTIPID1
6565 run_test 82 "Basic grouplock test"
6568 local sfile="/boot/System.map-$(uname -r)"
6569 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6570 $LCTL set_param fail_loc=0x140d
6571 cp $sfile $DIR/$tfile || error "write failed"
6572 diff -c $sfile $DIR/$tfile || error "files are different"
6573 $LCTL set_param fail_loc=0
6576 run_test 83 "Short write in ptask ==============================="
6579 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6581 test_mkdir $DIR/$tdir.cvsroot
6582 chown $RUNAS_ID $DIR/$tdir.cvsroot
6585 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
6588 # some versions of cvs import exit(1) when asked to import links or
6589 # files they can't read. ignore those files.
6590 local toignore=$(find . -type l -printf '-I %f\n' -o \
6591 ! -perm /4 -printf '-I %f\n')
6592 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
6593 $tdir.reposname vtag rtag
6596 test_mkdir $DIR/$tdir.reposname
6597 chown $RUNAS_ID $DIR/$tdir.reposname
6598 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
6600 cd $DIR/$tdir.reposname
6602 $RUNAS cvs add -m 'addmsg' foo99
6604 $RUNAS cvs commit -m 'nomsg' foo99
6605 rm -fr $DIR/$tdir.cvsroot
6607 run_test 99 "cvs strange file/directory operations"
6610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6611 [[ "$NETTYPE" =~ tcp ]] ||
6612 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6615 remote_ost_nodsh && skip "remote OST with nodsh" && return
6616 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6618 { skip "useless for local single node setup" && return; }
6620 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6621 [ "$PROT" != "tcp" ] && continue
6622 RPORT=$(echo $REMOTE | cut -d: -f2)
6623 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6626 LPORT=`echo $LOCAL | cut -d: -f2`
6627 if [ $LPORT -ge 1024 ]; then
6628 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6630 error_exit "local: $LPORT > 1024, remote: $RPORT"
6633 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6635 run_test 100 "check local port using privileged port ==========="
6637 function get_named_value()
6646 echo $line | sed "s/^$tag[ ]*//"
6653 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6654 awk '/^max_cached_mb/ { print $2 }')
6657 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6663 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6667 local cache_limit=32
6669 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6670 trap cleanup_101a EXIT
6671 $LCTL set_param -n llite.*.read_ahead_stats 0
6672 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6675 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6677 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6678 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6681 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6682 get_named_value 'read but discarded' | cut -d" " -f1); do
6683 discard=$(($discard + $s))
6687 if [[ $(($discard * 10)) -gt $nreads ]]; then
6688 $LCTL get_param osc.*-osc*.rpc_stats
6689 $LCTL get_param llite.*.read_ahead_stats
6690 error "too many ($discard) discarded pages"
6692 rm -f $DIR/$tfile || true
6694 run_test 101a "check read-ahead for random reads"
6697 test_mkdir $DIR/$tdir
6698 local STRIPE_SIZE=$1
6699 local FILE_LENGTH=$2
6702 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6704 local list=$(comma_list $(osts_nodes))
6705 set_osd_param $list '' read_cache_enable 0
6706 set_osd_param $list '' writethrough_cache_enable 0
6708 trap cleanup_test101bc EXIT
6709 # prepare the read-ahead file
6710 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6712 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6713 count=$FILE_SIZE_MB 2> /dev/null
6717 cleanup_test101bc() {
6722 local list=$(comma_list $(osts_nodes))
6723 set_osd_param $list '' read_cache_enable 1
6724 set_osd_param $list '' writethrough_cache_enable 1
6728 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6733 local STRIPE_SIZE=$2
6734 local FILE_LENGTH=$3
6735 local RA_INC=1048576
6736 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6737 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6738 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6739 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6740 get_named_value 'read but discarded' |
6741 cut -d" " -f1 | calc_total)
6742 if [[ $DISCARD -gt $discard_limit ]]; then
6743 $LCTL get_param llite.*.read_ahead_stats
6744 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6746 echo "Read-ahead success for size ${READ_SIZE}"
6751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6752 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6753 local STRIPE_SIZE=1048576
6754 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6755 if [ $SLOW == "yes" ]; then
6756 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6758 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6761 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6763 # prepare the read-ahead file
6764 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6765 cancel_lru_locks osc
6766 for BIDX in 2 4 8 16 32 64 128 256
6768 local BSIZE=$((BIDX*4096))
6769 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6770 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6771 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6772 $LCTL set_param -n llite.*.read_ahead_stats 0
6773 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6774 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6775 cancel_lru_locks osc
6776 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6781 run_test 101b "check stride-io mode read-ahead ================="
6784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6785 local STRIPE_SIZE=1048576
6786 local FILE_LENGTH=$((STRIPE_SIZE*100))
6790 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6792 cancel_lru_locks osc
6793 $LCTL set_param osc.*.rpc_stats 0
6794 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6795 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6796 local stats=$($LCTL get_param -n $osc_rpc_stats)
6797 local lines=$(echo "$stats" | awk 'END {print NR;}')
6800 if [ $lines -le 20 ]; then
6803 for size in 1 2 4 8; do
6804 local rpc=$(echo "$stats" |
6805 awk '($1 == "'$size':") {print $2; exit; }')
6807 error "Small $((size*4))k read IO $rpc !"
6809 echo "$osc_rpc_stats check passed!"
6814 run_test 101c "check stripe_size aligned read-ahead ================="
6817 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6818 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6823 local file=$DIR/$tfile
6824 local sz_MB=${FILESIZE_101d:-500}
6825 local ra_MB=${READAHEAD_MB:-40}
6827 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6828 [ $free_MB -lt $sz_MB ] &&
6829 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6831 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6832 $SETSTRIPE -c -1 $file || error "setstripe failed"
6834 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6835 echo Cancel LRU locks on lustre client to flush the client cache
6836 cancel_lru_locks osc
6838 echo Disable read-ahead
6839 local old_READAHEAD=$(set_read_ahead 0)
6841 echo Reading the test file $file with read-ahead disabled
6842 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6844 echo Cancel LRU locks on lustre client to flush the client cache
6845 cancel_lru_locks osc
6846 echo Enable read-ahead with ${ra_MB}MB
6847 set_read_ahead $ra_MB
6849 echo Reading the test file $file with read-ahead enabled
6850 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6852 echo "read-ahead disabled time read $raOFF"
6853 echo "read-ahead enabled time read $raON"
6855 set_read_ahead $old_READAHEAD
6857 wait_delete_completed
6859 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6860 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6862 run_test 101d "file read with and without read-ahead enabled"
6865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6866 local file=$DIR/$tfile
6867 local size_KB=500 #KB
6871 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6872 local need_KB=$((count * size_KB))
6873 [[ $free_KB -le $need_KB ]] &&
6874 skip_env "Need free space $need_KB, have $free_KB" && return
6876 echo "Creating $count ${size_KB}K test files"
6877 for ((i = 0; i < $count; i++)); do
6878 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6881 echo "Cancel LRU locks on lustre client to flush the client cache"
6882 cancel_lru_locks $OSC
6884 echo "Reset readahead stats"
6885 $LCTL set_param -n llite.*.read_ahead_stats 0
6887 for ((i = 0; i < $count; i++)); do
6888 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6891 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6892 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6894 for ((i = 0; i < $count; i++)); do
6895 rm -rf $file.$i 2>/dev/null
6898 #10000 means 20% reads are missing in readahead
6899 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6901 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6904 which iozone || { skip "no iozone installed" && return; }
6906 local old_debug=$($LCTL get_param debug)
6907 old_debug=${old_debug#*=}
6908 $LCTL set_param debug="reada mmap"
6910 # create a test file
6911 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6913 echo Cancel LRU locks on lustre client to flush the client cache
6914 cancel_lru_locks osc
6916 echo Reset readahead stats
6917 $LCTL set_param -n llite.*.read_ahead_stats 0
6919 echo mmap read the file with small block size
6920 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
6923 echo checking missing pages
6924 $LCTL get_param llite.*.read_ahead_stats
6925 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6926 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6928 $LCTL set_param debug="$old_debug"
6929 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
6932 run_test 101f "check mmap read performance"
6934 test_101g_brw_size_test() {
6936 local pages=$((mb * 1048576 / $(page_size)))
6938 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
6939 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
6940 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
6941 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
6945 $LCTL set_param -n osc.*.rpc_stats=0
6947 # 10 RPCs should be enough for the test
6949 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
6950 { error "dd write ${mb} MB blocks failed"; return 3; }
6951 cancel_lru_locks osc
6952 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
6953 { error "dd write ${mb} MB blocks failed"; return 4; }
6955 # calculate number of full-sized read and write RPCs
6956 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
6957 sed -n '/pages per rpc/,/^$/p' |
6958 awk '/'$pages':/ { reads += $2; writes += $6 }; \
6959 END { print reads,writes }'))
6960 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
6962 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
6970 local osts=$(get_facets OST)
6971 local list=$(comma_list $(osts_nodes))
6972 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6973 local brw_size="obdfilter.*.brw_size"
6975 $LFS setstripe -i 0 -c 1 $DIR/$tfile
6977 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
6978 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) -a \
6979 $(lustre_version_code client) -ge $(version_code 2.8.52) ]; then
6980 [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] &&
6982 if [[ $orig_mb -lt 16 ]]; then
6983 save_lustre_params $osts "$brw_size" > $p
6984 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
6985 error "set 16MB RPC size failed"
6987 echo "remount client to enable new RPC size"
6988 remount_client $MOUNT || error "remount_client failed"
6991 test_101g_brw_size_test 16 || error "16MB RPC test failed"
6992 # should be able to set brw_size=12, but no rpc_stats for that
6993 test_101g_brw_size_test 8 || error "8MB RPC test failed"
6996 test_101g_brw_size_test 4 || error "4MB RPC test failed"
6998 if [[ $orig_mb -lt 16 ]]; then
6999 restore_lustre_params < $p
7000 remount_client $MOUNT || error "remount_client restore failed"
7003 rm -f $p $DIR/$tfile
7005 run_test 101g "Big bulk(4/16 MiB) readahead"
7008 test_mkdir $DIR/$tdir
7009 chown $RUNAS_ID $DIR/$tdir
7012 STRIPE_COUNT=$OSTCOUNT
7013 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7015 trap cleanup_test102 EXIT
7017 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7019 for num in 1 2 3 4; do
7020 for count in $(seq 1 $STRIPE_COUNT); do
7021 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7022 local size=`expr $STRIPE_SIZE \* $num`
7023 local file=file"$num-$idx-$count"
7024 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7030 $1 tar cf $TMP/f102.tar $tdir --xattrs
7036 rm -rf $DIR/d0.sanity/d102
7040 local testfile=$DIR/$tfile
7044 [ "$UID" != 0 ] && skip_env "must run as root" && return
7045 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7046 skip_env "must have user_xattr" && return
7048 [ -z "$(which setfattr 2>/dev/null)" ] &&
7049 skip_env "could not find setfattr" && return
7051 echo "set/get xattr..."
7052 setfattr -n trusted.name1 -v value1 $testfile ||
7053 error "setfattr -n trusted.name1=value1 $testfile failed"
7054 getfattr -n trusted.name1 $testfile 2> /dev/null |
7055 grep "trusted.name1=.value1" ||
7056 error "$testfile missing trusted.name1=value1"
7058 setfattr -n user.author1 -v author1 $testfile ||
7059 error "setfattr -n user.author1=author1 $testfile failed"
7060 getfattr -n user.author1 $testfile 2> /dev/null |
7061 grep "user.author1=.author1" ||
7062 error "$testfile missing trusted.author1=author1"
7065 setfattr -n trusted.name2 -v value2 $testfile ||
7066 error "$testfile unable to set trusted.name2"
7067 setfattr -n trusted.name3 -v value3 $testfile ||
7068 error "$testfile unable to set trusted.name3"
7069 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7070 grep "trusted.name" | wc -l) -eq 3 ] ||
7071 error "$testfile missing 3 trusted.name xattrs"
7073 setfattr -n user.author2 -v author2 $testfile ||
7074 error "$testfile unable to set user.author2"
7075 setfattr -n user.author3 -v author3 $testfile ||
7076 error "$testfile unable to set user.author3"
7077 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7078 grep "user.author" | wc -l) -eq 3 ] ||
7079 error "$testfile missing 3 user.author xattrs"
7081 echo "remove xattr..."
7082 setfattr -x trusted.name1 $testfile ||
7083 error "$testfile error deleting trusted.name1"
7084 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7085 error "$testfile did not delete trusted.name1 xattr"
7087 setfattr -x user.author1 $testfile ||
7088 error "$testfile error deleting user.author1"
7089 echo "set lustre special xattr ..."
7090 $LFS setstripe -c1 $testfile
7091 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7092 awk -F "=" '/trusted.lov/ { print $2 }' )
7093 setfattr -n "trusted.lov" -v $lovea $testfile ||
7094 error "$testfile doesn't ignore setting trusted.lov again"
7095 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7096 error "$testfile allow setting invalid trusted.lov"
7099 run_test 102a "user xattr test =================================="
7102 [ -z "$(which setfattr 2>/dev/null)" ] &&
7103 skip_env "could not find setfattr" && return
7105 # b10930: get/set/list trusted.lov xattr
7106 echo "get/set/list trusted.lov xattr ..."
7107 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7108 local testfile=$DIR/$tfile
7109 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7110 error "setstripe failed"
7111 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7112 error "getstripe failed"
7113 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7114 error "can't get trusted.lov from $testfile"
7116 local testfile2=${testfile}2
7117 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7118 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7121 setfattr -n trusted.lov -v $value $testfile2
7122 local stripe_size=$($GETSTRIPE -S $testfile2)
7123 local stripe_count=$($GETSTRIPE -c $testfile2)
7124 [[ $stripe_size -eq 65536 ]] ||
7125 error "stripe size $stripe_size != 65536"
7126 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7127 error "stripe count $stripe_count != $STRIPECOUNT"
7130 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7133 [ -z "$(which setfattr 2>/dev/null)" ] &&
7134 skip_env "could not find setfattr" && return
7136 # b10930: get/set/list lustre.lov xattr
7137 echo "get/set/list lustre.lov xattr ..."
7138 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7139 test_mkdir $DIR/$tdir
7140 chown $RUNAS_ID $DIR/$tdir
7141 local testfile=$DIR/$tdir/$tfile
7142 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7143 error "setstripe failed"
7144 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7145 error "getstripe failed"
7146 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7147 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7149 local testfile2=${testfile}2
7150 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7151 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7153 $RUNAS $MCREATE $testfile2
7154 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7155 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7156 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7157 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7158 [ $stripe_count -eq $STRIPECOUNT ] ||
7159 error "stripe count $stripe_count != $STRIPECOUNT"
7161 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7163 compare_stripe_info1() {
7164 local stripe_index_all_zero=true
7166 for num in 1 2 3 4; do
7167 for count in $(seq 1 $STRIPE_COUNT); do
7168 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7169 local size=$((STRIPE_SIZE * num))
7170 local file=file"$num-$offset-$count"
7171 stripe_size=$($LFS getstripe -S $PWD/$file)
7172 [[ $stripe_size -ne $size ]] &&
7173 error "$file: size $stripe_size != $size"
7174 stripe_count=$($LFS getstripe -c $PWD/$file)
7175 # allow fewer stripes to be created, ORI-601
7176 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7177 error "$file: count $stripe_count != $count"
7178 stripe_index=$($LFS getstripe -i $PWD/$file)
7179 [[ $stripe_index -ne 0 ]] &&
7180 stripe_index_all_zero=false
7184 $stripe_index_all_zero &&
7185 error "all files are being extracted starting from OST index 0"
7189 have_xattrs_include() {
7190 tar --help | grep -q xattrs-include &&
7191 echo --xattrs-include="lustre.*"
7195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7196 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7197 XINC=$(have_xattrs_include)
7199 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7201 compare_stripe_info1
7203 run_test 102d "tar restore stripe info from tarfile,not keep osts"
7206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7207 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7208 XINC=$(have_xattrs_include)
7210 test_mkdir $DIR/$tdir.restore
7212 tar cf - --xattrs $tdir | tar xf - \
7213 -C $DIR/$tdir.restore --xattrs $XINC
7214 cd $DIR/$tdir.restore/$tdir
7215 compare_stripe_info1
7217 run_test 102f "tar copy files, not keep osts"
7220 local xsize=${1:-1024} # in bytes
7221 local file=$DIR/$tfile
7223 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7224 skip "must have user_xattr" && return 0
7225 [ -z "$(which setfattr 2>/dev/null)" ] &&
7226 skip_env "could not find setfattr" && return 0
7227 [ -z "$(which getfattr 2>/dev/null)" ] &&
7228 skip_env "could not find getfattr" && return 0
7232 local value="$(generate_string $xsize)"
7234 local xbig=trusted.big
7235 log "save $xbig on $file"
7236 setfattr -n $xbig -v $value $file ||
7237 error "saving $xbig on $file failed"
7239 local orig=$(get_xattr_value $xbig $file)
7240 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7242 local xsml=trusted.sml
7243 log "save $xsml on $file"
7244 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7246 local new=$(get_xattr_value $xbig $file)
7247 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7249 log "grow $xsml on $file"
7250 setfattr -n $xsml -v "$value" $file ||
7251 error "growing $xsml on $file failed"
7253 new=$(get_xattr_value $xbig $file)
7254 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7255 log "$xbig still valid after growing $xsml"
7260 test_102h() { # bug 15777
7263 run_test 102h "grow xattr from inside inode to external block"
7266 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7267 grow_xattr $(max_xattr_size)
7269 run_test 102ha "grow xattr from inside inode to external inode"
7271 test_102i() { # bug 17038
7272 [ -z "$(which getfattr 2>/dev/null)" ] &&
7273 skip "could not find getfattr" && return
7275 ln -s $DIR/$tfile $DIR/${tfile}link
7276 getfattr -n trusted.lov $DIR/$tfile ||
7277 error "lgetxattr on $DIR/$tfile failed"
7278 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7279 grep -i "no such attr" ||
7280 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7281 rm -f $DIR/$tfile $DIR/${tfile}link
7283 run_test 102i "lgetxattr test on symbolic link ============"
7286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7287 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7288 XINC=$(have_xattrs_include)
7289 setup_test102 "$RUNAS"
7290 chown $RUNAS_ID $DIR/$tdir
7291 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7293 compare_stripe_info1 "$RUNAS"
7295 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7298 [ -z "$(which setfattr 2>/dev/null)" ] &&
7299 skip "could not find setfattr" && return
7301 # b22187 just check that does not crash for regular file.
7302 setfattr -n trusted.lov $DIR/$tfile
7303 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
7304 local test_kdir=$DIR/$tdir
7305 test_mkdir $test_kdir
7306 local default_size=$($LFS getstripe -S $test_kdir)
7307 local default_count=$($LFS getstripe -c $test_kdir)
7308 local default_offset=$($LFS getstripe -i $test_kdir)
7309 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7310 error 'dir setstripe failed'
7311 setfattr -n trusted.lov $test_kdir
7312 local stripe_size=$($LFS getstripe -S $test_kdir)
7313 local stripe_count=$($LFS getstripe -c $test_kdir)
7314 local stripe_offset=$($LFS getstripe -i $test_kdir)
7315 [ $stripe_size -eq $default_size ] ||
7316 error "stripe size $stripe_size != $default_size"
7317 [ $stripe_count -eq $default_count ] ||
7318 error "stripe count $stripe_count != $default_count"
7319 [ $stripe_offset -eq $default_offset ] ||
7320 error "stripe offset $stripe_offset != $default_offset"
7321 rm -rf $DIR/$tfile $test_kdir
7323 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7326 [ -z "$(which getfattr 2>/dev/null)" ] &&
7327 skip "could not find getfattr" && return
7329 # LU-532 trusted. xattr is invisible to non-root
7330 local testfile=$DIR/$tfile
7334 echo "listxattr as user..."
7335 chown $RUNAS_ID $testfile
7336 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7337 grep -q "trusted" &&
7338 error "$testfile trusted xattrs are user visible"
7342 run_test 102l "listxattr size test =================================="
7344 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7345 local path=$DIR/$tfile
7348 listxattr_size_check $path || error "listattr_size_check $path failed"
7350 run_test 102m "Ensure listxattr fails on small bufffer ========"
7354 getxattr() { # getxattr path name
7355 # Return the base64 encoding of the value of xattr name on path.
7359 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7361 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7363 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7365 getfattr --absolute-names --encoding=base64 --name=$name $path |
7366 awk -F= -v name=$name '$1 == name {
7367 print substr($0, index($0, "=") + 1);
7371 test_102n() { # LU-4101 mdt: protect internal xattrs
7372 [ -z "$(which setfattr 2>/dev/null)" ] &&
7373 skip "could not find setfattr" && return
7374 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7376 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7380 local file0=$DIR/$tfile.0
7381 local file1=$DIR/$tfile.1
7382 local xattr0=$TMP/$tfile.0
7383 local xattr1=$TMP/$tfile.1
7384 local namelist="lov lma lmv link fid version som hsm"
7388 rm -rf $file0 $file1 $xattr0 $xattr1
7391 # Get 'before' xattrs of $file1.
7392 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7394 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7395 namelist+=" lfsck_namespace"
7396 for name in $namelist; do
7397 # Try to copy xattr from $file0 to $file1.
7398 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7400 setfattr --name=trusted.$name --value="$value" $file1 ||
7401 error "setxattr 'trusted.$name' failed"
7403 # Try to set a garbage xattr.
7404 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7406 if [[ x$name == "xlov" ]]; then
7407 setfattr --name=trusted.lov --value="$value" $file1 &&
7408 error "setxattr invalid 'trusted.lov' success"
7410 setfattr --name=trusted.$name --value="$value" $file1 ||
7411 error "setxattr invalid 'trusted.$name' failed"
7414 # Try to remove the xattr from $file1. We don't care if this
7415 # appears to succeed or fail, we just don't want there to be
7416 # any changes or crashes.
7417 setfattr --remove=$trusted.$name $file1 2> /dev/null
7420 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7423 # Try to copy xattr from $file0 to $file1.
7424 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7426 setfattr --name=trusted.$name --value="$value" $file1 ||
7427 error "setxattr 'trusted.$name' failed"
7429 # Try to set a garbage xattr.
7430 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7432 setfattr --name=trusted.$name --value="$value" $file1 ||
7433 error "setxattr 'trusted.$name' failed"
7435 # Try to remove the xattr from $file1. We don't care if this
7436 # appears to succeed or fail, we just don't want there to be
7437 # any changes or crashes.
7438 setfattr --remove=$trusted.$name $file1 2> /dev/null
7441 # Get 'after' xattrs of file1.
7442 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7444 if ! diff $xattr0 $xattr1; then
7445 error "before and after xattrs of '$file1' differ"
7448 rm -rf $file0 $file1 $xattr0 $xattr1
7452 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7454 test_102p() { # LU-4703 setxattr did not check ownership
7455 local testfile=$DIR/$tfile
7457 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7458 skip "MDS needs to be at least 2.5.56" && return
7462 echo "setfacl as user..."
7463 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7464 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7466 echo "setfattr as user..."
7467 setfacl -m "u:$RUNAS_ID:---" $testfile
7468 $RUNAS setfattr -x system.posix_acl_access $testfile
7469 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7471 run_test 102p "check setxattr(2) correctly fails without permission"
7474 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7475 skip "MDS needs to be at least 2.6.92" && return
7476 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7478 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7481 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7482 skip "MDS needs to be at least 2.6.93" && return
7483 touch $DIR/$tfile || error "touch"
7484 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7485 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7486 rm $DIR/$tfile || error "rm"
7489 mkdir -p $DIR/$tdir || error "mkdir"
7490 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7491 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7492 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7493 error "$testfile error deleting user.author1"
7494 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7495 grep "user.$(basename $tdir)" &&
7496 error "$tdir did not delete user.$(basename $tdir)"
7497 rmdir $DIR/$tdir || error "rmdir"
7500 test_mkdir $DIR/$tdir
7501 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7502 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7503 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7504 error "$testfile error deleting user.author1"
7505 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7506 grep "user.$(basename $tdir)" &&
7507 error "$tdir did not delete user.$(basename $tdir)"
7508 rmdir $DIR/$tdir || error "rm striped dir"
7510 run_test 102r "set EAs with empty values"
7514 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7519 [ "$UID" != 0 ] && skip_env "must run as root" && return
7520 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7521 skip "must have acl enabled" && return
7522 [ -z "$(which setfacl 2>/dev/null)" ] &&
7523 skip_env "could not find setfacl" && return
7524 $GSS && skip "could not run under gss" && return
7525 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7527 gpasswd -a daemon bin # LU-5641
7528 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7530 declare -a identity_old
7532 for num in $(seq $MDSCOUNT); do
7533 switch_identity $num true || identity_old[$num]=$?
7541 echo "performing cp ..."
7542 run_acl_subtest cp || error "run_acl_subtest cp failed"
7543 echo "performing getfacl-noacl..."
7544 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7545 echo "performing misc..."
7546 run_acl_subtest misc || error "misc test failed"
7547 echo "performing permissions..."
7548 run_acl_subtest permissions || error "permissions failed"
7549 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7550 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7551 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7552 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7554 echo "performing permissions xattr..."
7555 run_acl_subtest permissions_xattr ||
7556 error "permissions_xattr failed"
7558 echo "performing setfacl..."
7559 run_acl_subtest setfacl || error "setfacl test failed"
7561 # inheritance test got from HP
7562 echo "performing inheritance..."
7563 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7564 chmod +x make-tree || error "chmod +x failed"
7565 run_acl_subtest inheritance || error "inheritance test failed"
7568 echo "LU-974 ignore umask when acl is enabled..."
7569 run_acl_subtest 974 || error "LU-974 umask test failed"
7570 if [ $MDSCOUNT -ge 2 ]; then
7571 run_acl_subtest 974_remote ||
7572 error "LU-974 umask test failed under remote dir"
7575 echo "LU-2561 newly created file is same size as directory..."
7576 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7577 run_acl_subtest 2561 || error "LU-2561 test failed"
7579 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7582 run_acl_subtest 4924 || error "LU-4924 test failed"
7587 for num in $(seq $MDSCOUNT); do
7588 if [ "${identity_old[$num]}" = 1 ]; then
7589 switch_identity $num false || identity_old[$num]=$?
7593 run_test 103a "acl test ========================================="
7597 cp -rp $DIR/$tdir $DIR/$tdir.bak
7599 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7600 error "$DIR/$tdir shouldn't contain default ACL"
7601 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7602 error "$DIR/$tdir.bak shouldn't contain default ACL"
7605 run_test 103c "'cp -rp' won't set empty acl"
7608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7610 lfs df || error "lfs df failed"
7611 lfs df -ih || error "lfs df -ih failed"
7612 lfs df -h $DIR || error "lfs df -h $DIR failed"
7613 lfs df -i $DIR || error "lfs df -i $DIR failed"
7614 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7615 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7617 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7618 lctl --device %$OSC deactivate
7619 lfs df || error "lfs df with deactivated OSC failed"
7620 lctl --device %$OSC activate
7621 # wait the osc back to normal
7622 wait_osc_import_state client ost FULL
7624 lfs df || error "lfs df with reactivated OSC failed"
7627 run_test 104a "lfs df [-ih] [path] test ========================="
7630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7631 [ $RUNAS_ID -eq $UID ] &&
7632 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7634 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7635 grep "Permission denied" | wc -l)))
7636 if [ $denied_cnt -ne 0 ]; then
7637 error "lfs check servers test failed"
7640 run_test 104b "$RUNAS lfs check servers test ===================="
7643 # doesn't work on 2.4 kernels
7645 if $(flock_is_enabled); then
7646 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7648 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7652 run_test 105a "flock when mounted without -o flock test ========"
7656 if $(flock_is_enabled); then
7657 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7659 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7663 run_test 105b "fcntl when mounted without -o flock test ========"
7667 if $(flock_is_enabled); then
7668 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7670 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7674 run_test 105c "lockf when mounted without -o flock test"
7676 test_105d() { # bug 15924
7677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7678 test_mkdir $DIR/$tdir
7679 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7680 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7681 $LCTL set_param fail_loc=0x80000315
7682 flocks_test 2 $DIR/$tdir
7684 run_test 105d "flock race (should not freeze) ========"
7686 test_105e() { # bug 22660 && 22040
7687 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7689 flocks_test 3 $DIR/$tfile
7691 run_test 105e "Two conflicting flocks from same process"
7693 test_106() { #bug 10921
7694 test_mkdir $DIR/$tdir
7695 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7696 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7698 run_test 106 "attempt exec of dir followed by chown of that dir"
7701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7708 local save_pattern=$(sysctl -n kernel.core_pattern)
7709 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7710 sysctl -w kernel.core_pattern=$file
7711 sysctl -w kernel.core_uses_pid=0
7719 kill -s 11 $SLEEPPID
7721 if [ -e $file ]; then
7722 size=`stat -c%s $file`
7723 [ $size -eq 0 ] && error "Fail to create core file $file"
7725 error "Fail to create core file $file"
7728 sysctl -w kernel.core_pattern=$save_pattern
7729 sysctl -w kernel.core_uses_pid=$save_uses_pid
7732 run_test 107 "Coredump on SIG"
7735 test_mkdir $DIR/$tdir
7736 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
7737 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
7738 error "mkdir with 256 char should fail, but did not"
7739 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7740 error "create with 255 char failed"
7741 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7742 error "create with 256 char should fail, but did not"
7747 run_test 110 "filename length checking"
7750 # Purpose: To verify dynamic thread (OSS) creation.
7753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7754 remote_ost_nodsh && skip "remote OST with nodsh" && return
7756 # Lustre does not stop service threads once they are started.
7757 # Reset number of running threads to default.
7762 local save_params="$TMP/sanity-$TESTNAME.parameters"
7764 # Get ll_ost_io count before I/O
7765 OSTIO_pre=$(do_facet ost1 \
7766 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7767 # Exit if lustre is not running (ll_ost_io not running).
7768 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7770 echo "Starting with $OSTIO_pre threads"
7771 local thread_max=$((OSTIO_pre * 2))
7772 local rpc_in_flight=$((thread_max * 2))
7773 # Number of I/O Process proposed to be started.
7775 local facets=$(get_facets OST)
7777 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
7778 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
7780 # Set in_flight to $rpc_in_flight
7781 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7782 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7783 nfiles=${rpc_in_flight}
7784 # Set ost thread_max to $thread_max
7785 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7787 # 5 Minutes should be sufficient for max number of OSS
7788 # threads(thread_max) to be created.
7792 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7793 test_mkdir $DIR/$tdir
7794 for i in $(seq $nfiles); do
7795 local file=$DIR/$tdir/${tfile}-$i
7796 $LFS setstripe -c -1 -i 0 $file
7797 ($WTL $file $timeout)&
7800 # I/O Started - Wait for thread_started to reach thread_max or report
7801 # error if thread_started is more than thread_max.
7802 echo "Waiting for thread_started to reach thread_max"
7803 local thread_started=0
7804 local end_time=$((SECONDS + timeout))
7806 while [ $SECONDS -le $end_time ] ; do
7808 # Get ost i/o thread_started count.
7809 thread_started=$(do_facet ost1 \
7811 ost.OSS.ost_io.threads_started | cut -d= -f2")
7812 # Break out if thread_started is equal/greater than thread_max
7813 if [[ $thread_started -ge $thread_max ]]; then
7814 echo ll_ost_io thread_started $thread_started, \
7815 equal/greater than thread_max $thread_max
7821 # Cleanup - We have the numbers, Kill i/o jobs if running.
7822 jobcount=($(jobs -p))
7823 for i in $(seq 0 $((${#jobcount[@]}-1)))
7825 kill -9 ${jobcount[$i]}
7826 if [ $? -ne 0 ] ; then
7828 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
7832 # Cleanup files left by WTL binary.
7833 for i in $(seq $nfiles); do
7834 local file=$DIR/$tdir/${tfile}-$i
7836 if [ $? -ne 0 ] ; then
7837 echo "Warning: Failed to delete file $file"
7841 restore_lustre_params <$save_params
7842 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
7844 # Error out if no new thread has started or Thread started is greater
7846 if [[ $thread_started -le $OSTIO_pre ||
7847 $thread_started -gt $thread_max ]]; then
7848 error "ll_ost_io: thread_started $thread_started" \
7849 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
7850 "No new thread started or thread started greater " \
7854 run_test 115 "verify dynamic thread creation===================="
7857 wait_delete_completed
7858 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7859 echo "OST kbytes available: ${AVAIL[@]}"
7864 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7865 #echo OST $i: ${AVAIL[i]}kb
7866 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7870 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7875 echo "Min free space: OST $MINI: $MINV"
7876 echo "Max free space: OST $MAXI: $MAXV"
7879 test_116a() { # was previously test_116()
7880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7881 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7883 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7885 echo -n "Free space priority "
7886 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7891 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7892 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7894 trap simple_cleanup_common EXIT
7897 # Check if we need to generate uneven OSTs
7898 test_mkdir -p $DIR/$tdir/OST${MINI}
7899 local FILL=$((MINV / 4))
7900 local DIFF=$((MAXV - MINV))
7901 local DIFF2=$((DIFF * 100 / MINV))
7903 local threshold=$(do_facet $SINGLEMDS \
7904 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7905 threshold=${threshold%%%}
7906 echo -n "Check for uneven OSTs: "
7907 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7909 if [[ $DIFF2 -gt $threshold ]]; then
7911 echo "Don't need to fill OST$MINI"
7913 # generate uneven OSTs. Write 2% over the QOS threshold value
7915 DIFF=$((threshold - DIFF2 + 2))
7916 DIFF2=$((MINV * DIFF / 100))
7917 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
7918 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7919 error "setstripe failed"
7920 DIFF=$((DIFF2 / 2048))
7922 while [ $i -lt $DIFF ]; do
7924 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7925 bs=2M count=1 2>/dev/null
7934 DIFF=$((MAXV - MINV))
7935 DIFF2=$((DIFF * 100 / MINV))
7936 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
7937 if [ $DIFF2 -gt $threshold ]; then
7940 echo "failed - QOS mode won't be used"
7941 skip "QOS imbalance criteria not met"
7942 simple_cleanup_common
7951 # now fill using QOS
7952 $SETSTRIPE -c 1 $DIR/$tdir
7953 FILL=$((FILL / 200))
7954 if [ $FILL -gt 600 ]; then
7957 echo "writing $FILL files to QOS-assigned OSTs"
7959 while [ $i -lt $FILL ]; do
7961 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7965 echo "wrote $i 200k files"
7969 echo "Note: free space may not be updated, so measurements might be off"
7971 DIFF2=$((MAXV - MINV))
7972 echo "free space delta: orig $DIFF final $DIFF2"
7973 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7974 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
7975 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7976 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
7977 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7978 if [[ $DIFF -gt 0 ]]; then
7979 FILL=$((DIFF2 * 100 / DIFF - 100))
7980 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7983 # Figure out which files were written where
7984 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7985 awk '/'$MINI1': / {print $2; exit}')
7987 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7988 echo "$MINC files created on smaller OST $MINI1"
7989 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7990 awk '/'$MAXI1': / {print $2; exit}')
7992 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7993 echo "$MAXC files created on larger OST $MAXI1"
7994 if [[ $MINC -gt 0 ]]; then
7995 FILL=$((MAXC * 100 / MINC - 100))
7996 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7998 [[ $MAXC -gt $MINC ]] ||
7999 error_ignore LU-9 "stripe QOS didn't balance free space"
8000 simple_cleanup_common
8002 run_test 116a "stripe QOS: free space balance ==================="
8004 test_116b() { # LU-2093
8005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8006 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8008 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8009 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8010 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8011 [ -z "$old_rr" ] && skip "no QOS" && return 0
8012 do_facet $SINGLEMDS lctl set_param \
8013 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8015 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8016 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8017 do_facet $SINGLEMDS lctl set_param fail_loc=0
8019 do_facet $SINGLEMDS lctl set_param \
8020 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8022 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8024 test_117() # bug 10891
8026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8027 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8028 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8029 lctl set_param fail_loc=0x21e
8030 > $DIR/$tfile || error "truncate failed"
8031 lctl set_param fail_loc=0
8032 echo "Truncate succeeded."
8035 run_test 117 "verify osd extend =========="
8037 NO_SLOW_RESENDCOUNT=4
8038 export OLD_RESENDCOUNT=""
8039 set_resend_count () {
8040 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8041 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8042 lctl set_param -n $PROC_RESENDCOUNT $1
8043 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8046 # for reduce test_118* time (b=14842)
8047 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8049 # Reset async IO behavior after error case
8051 FILE=$DIR/reset_async
8053 # Ensure all OSCs are cleared
8054 $SETSTRIPE -c -1 $FILE
8055 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8060 test_118a() #bug 11710
8062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8065 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8066 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8067 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8069 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8070 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8075 run_test 118a "verify O_SYNC works =========="
8079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8080 remote_ost_nodsh && skip "remote OST with nodsh" && return
8084 #define OBD_FAIL_SRV_ENOENT 0x217
8085 set_nodes_failloc "$(osts_nodes)" 0x217
8086 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8088 set_nodes_failloc "$(osts_nodes)" 0
8089 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8090 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8093 if [[ $RC -eq 0 ]]; then
8094 error "Must return error due to dropped pages, rc=$RC"
8098 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8099 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8103 echo "Dirty pages not leaked on ENOENT"
8105 # Due to the above error the OSC will issue all RPCs syncronously
8106 # until a subsequent RPC completes successfully without error.
8107 $MULTIOP $DIR/$tfile Ow4096yc
8112 run_test 118b "Reclaim dirty pages on fatal error =========="
8116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8118 # for 118c, restore the original resend count, LU-1940
8119 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8120 set_resend_count $OLD_RESENDCOUNT
8121 remote_ost_nodsh && skip "remote OST with nodsh" && return
8125 #define OBD_FAIL_OST_EROFS 0x216
8126 set_nodes_failloc "$(osts_nodes)" 0x216
8128 # multiop should block due to fsync until pages are written
8129 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8133 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8134 error "Multiop failed to block on fsync, pid=$MULTIPID"
8137 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8139 if [[ $WRITEBACK -eq 0 ]]; then
8140 error "No page in writeback, writeback=$WRITEBACK"
8143 set_nodes_failloc "$(osts_nodes)" 0
8146 if [[ $RC -ne 0 ]]; then
8147 error "Multiop fsync failed, rc=$RC"
8150 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8151 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8153 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8154 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8158 echo "Dirty pages flushed via fsync on EROFS"
8161 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8163 # continue to use small resend count to reduce test_118* time (b=14842)
8164 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8169 remote_ost_nodsh && skip "remote OST with nodsh" && return
8173 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8174 set_nodes_failloc "$(osts_nodes)" 0x214
8175 # multiop should block due to fsync until pages are written
8176 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8180 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8181 error "Multiop failed to block on fsync, pid=$MULTIPID"
8184 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8186 if [[ $WRITEBACK -eq 0 ]]; then
8187 error "No page in writeback, writeback=$WRITEBACK"
8190 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8191 set_nodes_failloc "$(osts_nodes)" 0
8193 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8194 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8196 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8197 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8201 echo "Dirty pages gaurenteed flushed via fsync"
8204 run_test 118d "Fsync validation inject a delay of the bulk =========="
8207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8210 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8211 lctl set_param fail_loc=0x8000040a
8213 # Should simulate EINVAL error which is fatal
8214 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8216 if [[ $RC -eq 0 ]]; then
8217 error "Must return error due to dropped pages, rc=$RC"
8220 lctl set_param fail_loc=0x0
8222 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8223 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8224 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8226 if [[ $LOCKED -ne 0 ]]; then
8227 error "Locked pages remain in cache, locked=$LOCKED"
8230 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8231 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8235 echo "No pages locked after fsync"
8240 run_test 118f "Simulate unrecoverable OSC side error =========="
8243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8246 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8247 lctl set_param fail_loc=0x406
8249 # simulate local -ENOMEM
8250 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8253 lctl set_param fail_loc=0
8254 if [[ $RC -eq 0 ]]; then
8255 error "Must return error due to dropped pages, rc=$RC"
8258 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8259 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8260 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8262 if [[ $LOCKED -ne 0 ]]; then
8263 error "Locked pages remain in cache, locked=$LOCKED"
8266 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8267 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8271 echo "No pages locked after fsync"
8276 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8280 remote_ost_nodsh && skip "remote OST with nodsh" && return
8284 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8285 set_nodes_failloc "$(osts_nodes)" 0x20e
8286 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8287 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8290 set_nodes_failloc "$(osts_nodes)" 0
8291 if [[ $RC -eq 0 ]]; then
8292 error "Must return error due to dropped pages, rc=$RC"
8295 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8296 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8297 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8299 if [[ $LOCKED -ne 0 ]]; then
8300 error "Locked pages remain in cache, locked=$LOCKED"
8303 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8304 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8308 echo "No pages locked after fsync"
8312 run_test 118h "Verify timeout in handling recoverables errors =========="
8314 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8318 remote_ost_nodsh && skip "remote OST with nodsh" && return
8322 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8323 set_nodes_failloc "$(osts_nodes)" 0x20e
8325 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8326 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8329 set_nodes_failloc "$(osts_nodes)" 0
8333 if [[ $RC -ne 0 ]]; then
8334 error "got error, but should be not, rc=$RC"
8337 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8338 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8339 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8340 if [[ $LOCKED -ne 0 ]]; then
8341 error "Locked pages remain in cache, locked=$LOCKED"
8344 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8345 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8349 echo "No pages locked after fsync"
8353 run_test 118i "Fix error before timeout in recoverable error =========="
8355 [ "$SLOW" = "no" ] && set_resend_count 4
8358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8359 remote_ost_nodsh && skip "remote OST with nodsh" && return
8363 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8364 set_nodes_failloc "$(osts_nodes)" 0x220
8366 # return -EIO from OST
8367 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8369 set_nodes_failloc "$(osts_nodes)" 0x0
8370 if [[ $RC -eq 0 ]]; then
8371 error "Must return error due to dropped pages, rc=$RC"
8374 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8375 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8376 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8377 if [[ $LOCKED -ne 0 ]]; then
8378 error "Locked pages remain in cache, locked=$LOCKED"
8381 # in recoverable error on OST we want resend and stay until it finished
8382 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8383 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8387 echo "No pages locked after fsync"
8391 run_test 118j "Simulate unrecoverable OST side error =========="
8395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8396 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8398 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8399 set_nodes_failloc "$(osts_nodes)" 0x20e
8400 test_mkdir $DIR/$tdir
8402 for ((i=0;i<10;i++)); do
8403 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8404 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8411 set_nodes_failloc "$(osts_nodes)" 0
8414 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8420 test_mkdir $DIR/$tdir
8421 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8424 run_test 118l "fsync dir"
8426 test_118m() # LU-3066
8428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8429 test_mkdir $DIR/$tdir
8430 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8433 run_test 118m "fdatasync dir ========="
8435 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8437 test_119a() # bug 11737
8439 BSIZE=$((512 * 1024))
8440 directio write $DIR/$tfile 0 1 $BSIZE
8441 # We ask to read two blocks, which is more than a file size.
8442 # directio will indicate an error when requested and actual
8443 # sizes aren't equeal (a normal situation in this case) and
8444 # print actual read amount.
8445 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8446 if [ "$NOB" != "$BSIZE" ]; then
8447 error "read $NOB bytes instead of $BSIZE"
8451 run_test 119a "Short directIO read must return actual read amount"
8453 test_119b() # bug 11737
8455 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8457 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8458 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8460 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8461 error "direct read failed"
8464 run_test 119b "Sparse directIO read must return actual read amount"
8466 test_119c() # bug 13099
8469 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8470 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8473 run_test 119c "Testing for direct read hitting hole"
8475 test_119d() # bug 15950
8477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8478 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8479 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8481 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8482 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8483 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8484 lctl set_param fail_loc=0x40d
8485 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8488 cat $DIR/$tfile > /dev/null &
8489 lctl set_param fail_loc=0
8492 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8494 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8495 error "the read rpcs have not completed in 2s"
8497 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8499 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8503 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8504 test_mkdir $DIR/$tdir
8505 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8506 { skip "no early lock cancel on server"; return 0; }
8508 lru_resize_disable mdc
8509 lru_resize_disable osc
8510 cancel_lru_locks mdc
8511 # asynchronous object destroy at MDT could cause bl ast to client
8512 cancel_lru_locks osc
8514 stat $DIR/$tdir > /dev/null
8515 can1=$(do_facet $SINGLEMDS \
8516 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8517 awk '/ldlm_cancel/ {print $2}')
8518 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8519 awk '/ldlm_bl_callback/ {print $2}')
8520 test_mkdir -c1 $DIR/$tdir/d1
8521 can2=$(do_facet $SINGLEMDS \
8522 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8523 awk '/ldlm_cancel/ {print $2}')
8524 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8525 awk '/ldlm_bl_callback/ {print $2}')
8526 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8527 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8528 lru_resize_enable mdc
8529 lru_resize_enable osc
8531 run_test 120a "Early Lock Cancel: mkdir test"
8534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8535 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8536 test_mkdir $DIR/$tdir
8537 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8538 { skip "no early lock cancel on server"; return 0; }
8539 lru_resize_disable mdc
8540 lru_resize_disable osc
8541 cancel_lru_locks mdc
8542 stat $DIR/$tdir > /dev/null
8543 can1=$(do_facet $SINGLEMDS \
8544 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8545 awk '/ldlm_cancel/ {print $2}')
8546 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8547 awk '/ldlm_bl_callback/ {print $2}')
8549 can2=$(do_facet $SINGLEMDS \
8550 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8551 awk '/ldlm_cancel/ {print $2}')
8552 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8553 awk '/ldlm_bl_callback/ {print $2}')
8554 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8555 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8556 lru_resize_enable mdc
8557 lru_resize_enable osc
8559 run_test 120b "Early Lock Cancel: create test"
8562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8563 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8564 test_mkdir -c1 $DIR/$tdir
8565 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8566 { skip "no early lock cancel on server"; return 0; }
8567 lru_resize_disable mdc
8568 lru_resize_disable osc
8569 test_mkdir -c1 $DIR/$tdir/d1
8570 test_mkdir -c1 $DIR/$tdir/d2
8571 touch $DIR/$tdir/d1/f1
8572 cancel_lru_locks mdc
8573 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8574 can1=$(do_facet $SINGLEMDS \
8575 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8576 awk '/ldlm_cancel/ {print $2}')
8577 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8578 awk '/ldlm_bl_callback/ {print $2}')
8579 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8580 can2=$(do_facet $SINGLEMDS \
8581 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8582 awk '/ldlm_cancel/ {print $2}')
8583 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8584 awk '/ldlm_bl_callback/ {print $2}')
8585 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8586 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8587 lru_resize_enable mdc
8588 lru_resize_enable osc
8590 run_test 120c "Early Lock Cancel: link test"
8593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8595 test_mkdir -c1 $DIR/$tdir
8596 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8597 { skip "no early lock cancel on server"; return 0; }
8598 lru_resize_disable mdc
8599 lru_resize_disable osc
8601 cancel_lru_locks mdc
8602 stat $DIR/$tdir > /dev/null
8603 can1=$(do_facet $SINGLEMDS \
8604 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8605 awk '/ldlm_cancel/ {print $2}')
8606 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8607 awk '/ldlm_bl_callback/ {print $2}')
8608 chmod a+x $DIR/$tdir
8609 can2=$(do_facet $SINGLEMDS \
8610 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8611 awk '/ldlm_cancel/ {print $2}')
8612 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8613 awk '/ldlm_bl_callback/ {print $2}')
8614 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8615 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8616 lru_resize_enable mdc
8617 lru_resize_enable osc
8619 run_test 120d "Early Lock Cancel: setattr test"
8622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8623 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8624 { skip "no early lock cancel on server"; return 0; }
8625 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8626 local dlmtrace_set=false
8628 test_mkdir -c1 $DIR/$tdir
8629 lru_resize_disable mdc
8630 lru_resize_disable osc
8631 ! $LCTL get_param debug | grep -q dlmtrace &&
8632 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8633 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8634 cancel_lru_locks mdc
8635 cancel_lru_locks osc
8636 dd if=$DIR/$tdir/f1 of=/dev/null
8637 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8638 # XXX client can not do early lock cancel of OST lock
8639 # during unlink (LU-4206), so cancel osc lock now.
8641 cancel_lru_locks osc
8642 can1=$(do_facet $SINGLEMDS \
8643 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8644 awk '/ldlm_cancel/ {print $2}')
8645 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8646 awk '/ldlm_bl_callback/ {print $2}')
8647 unlink $DIR/$tdir/f1
8649 can2=$(do_facet $SINGLEMDS \
8650 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8651 awk '/ldlm_cancel/ {print $2}')
8652 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8653 awk '/ldlm_bl_callback/ {print $2}')
8654 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8655 $LCTL dk $TMP/cancel.debug.txt
8656 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8657 $LCTL dk $TMP/blocking.debug.txt
8658 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8659 lru_resize_enable mdc
8660 lru_resize_enable osc
8662 run_test 120e "Early Lock Cancel: unlink test"
8665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8666 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8667 { skip "no early lock cancel on server"; return 0; }
8668 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8669 test_mkdir -c1 $DIR/$tdir
8670 lru_resize_disable mdc
8671 lru_resize_disable osc
8672 test_mkdir -c1 $DIR/$tdir/d1
8673 test_mkdir -c1 $DIR/$tdir/d2
8674 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8675 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8676 cancel_lru_locks mdc
8677 cancel_lru_locks osc
8678 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8679 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8680 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8681 # XXX client can not do early lock cancel of OST lock
8682 # during rename (LU-4206), so cancel osc lock now.
8684 cancel_lru_locks osc
8685 can1=$(do_facet $SINGLEMDS \
8686 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8687 awk '/ldlm_cancel/ {print $2}')
8688 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8689 awk '/ldlm_bl_callback/ {print $2}')
8690 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8692 can2=$(do_facet $SINGLEMDS \
8693 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8694 awk '/ldlm_cancel/ {print $2}')
8695 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8696 awk '/ldlm_bl_callback/ {print $2}')
8697 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8698 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8699 lru_resize_enable mdc
8700 lru_resize_enable osc
8702 run_test 120f "Early Lock Cancel: rename test"
8705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8706 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8707 { skip "no early lock cancel on server"; return 0; }
8708 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8709 lru_resize_disable mdc
8710 lru_resize_disable osc
8712 echo create $count files
8713 test_mkdir $DIR/$tdir
8714 cancel_lru_locks mdc
8715 cancel_lru_locks osc
8718 can0=$(do_facet $SINGLEMDS \
8719 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8720 awk '/ldlm_cancel/ {print $2}')
8721 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8722 awk '/ldlm_bl_callback/ {print $2}')
8723 createmany -o $DIR/$tdir/f $count
8725 can1=$(do_facet $SINGLEMDS \
8726 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8727 awk '/ldlm_cancel/ {print $2}')
8728 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8729 awk '/ldlm_bl_callback/ {print $2}')
8731 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8732 echo rm $count files
8735 can2=$(do_facet $SINGLEMDS \
8736 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8737 awk '/ldlm_cancel/ {print $2}')
8738 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8739 awk '/ldlm_bl_callback/ {print $2}')
8741 echo total: $count removes in $((t2-t1))
8742 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8744 # wait for commitment of removal
8745 lru_resize_enable mdc
8746 lru_resize_enable osc
8748 run_test 120g "Early Lock Cancel: performance test"
8750 test_121() { #bug #10589
8751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8753 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8754 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8755 lctl set_param fail_loc=0x310
8756 cancel_lru_locks osc > /dev/null
8757 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8758 lctl set_param fail_loc=0
8759 [[ $reads -eq $writes ]] ||
8760 error "read $reads blocks, must be $writes blocks"
8762 run_test 121 "read cancel race ========="
8764 test_123a() { # was test 123, statahead(bug 11401)
8765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8767 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
8768 log "testing UP system. Performance may be lower than expected."
8773 test_mkdir $DIR/$tdir
8774 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8775 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8777 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8778 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8780 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8781 lctl set_param -n llite.*.statahead_max 0
8782 lctl get_param llite.*.statahead_max
8783 cancel_lru_locks mdc
8784 cancel_lru_locks osc
8786 time ls -l $DIR/$tdir | wc -l
8788 delta=$((etime - stime))
8789 log "ls $i files without statahead: $delta sec"
8790 lctl set_param llite.*.statahead_max=$max
8792 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8793 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8794 cancel_lru_locks mdc
8795 cancel_lru_locks osc
8797 time ls -l $DIR/$tdir | wc -l
8799 delta_sa=$((etime - stime))
8800 log "ls $i files with statahead: $delta_sa sec"
8801 lctl get_param -n llite.*.statahead_stats
8802 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8804 [[ $swrong -lt $ewrong ]] &&
8805 log "statahead was stopped, maybe too many locks held!"
8806 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8808 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8809 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8810 lctl set_param -n llite.*.statahead_max 0
8811 lctl get_param llite.*.statahead_max
8812 cancel_lru_locks mdc
8813 cancel_lru_locks osc
8815 time ls -l $DIR/$tdir | wc -l
8817 delta=$((etime - stime))
8818 log "ls $i files again without statahead: $delta sec"
8819 lctl set_param llite.*.statahead_max=$max
8820 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8821 if [ $SLOWOK -eq 0 ]; then
8822 error "ls $i files is slower with statahead!"
8824 log "ls $i files is slower with statahead!"
8830 [ $delta -gt 20 ] && break
8831 [ $delta -gt 8 ] && MULT=$((50 / delta))
8832 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8840 delta=$((etime - stime))
8841 log "rm -r $DIR/$tdir/: $delta seconds"
8843 lctl get_param -n llite.*.statahead_stats
8845 run_test 123a "verify statahead work"
8847 test_123b () { # statahead(bug 15027)
8848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8849 test_mkdir $DIR/$tdir
8850 createmany -o $DIR/$tdir/$tfile-%d 1000
8852 cancel_lru_locks mdc
8853 cancel_lru_locks osc
8855 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8856 lctl set_param fail_loc=0x80000803
8857 ls -lR $DIR/$tdir > /dev/null
8859 lctl set_param fail_loc=0x0
8860 lctl get_param -n llite.*.statahead_stats
8865 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8869 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
8870 { skip "no lru resize on server"; return 0; }
8872 test_mkdir $DIR/$tdir
8874 log "create $NR files at $DIR/$tdir"
8875 createmany -o $DIR/$tdir/f $NR ||
8876 error "failed to create $NR files in $DIR/$tdir"
8878 cancel_lru_locks mdc
8879 ls -l $DIR/$tdir > /dev/null
8883 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8884 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8885 LRU_SIZE=$($LCTL get_param -n $PARAM)
8886 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8887 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8889 log "NS=$(basename $NSDIR)"
8894 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8895 skip "Not enough cached locks created!"
8902 # We know that lru resize allows one client to hold $LIMIT locks
8903 # for 10h. After that locks begin to be killed by client.
8905 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8907 if [ $LIMIT -lt $LRU_SIZE ]; then
8908 skip "Limit is too small $LIMIT"
8912 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8913 # killing locks. Some time was spent for creating locks. This means
8914 # that up to the moment of sleep finish we must have killed some of
8915 # them (10-100 locks). This depends on how fast ther were created.
8916 # Many of them were touched in almost the same moment and thus will
8917 # be killed in groups.
8918 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8920 # Use $LRU_SIZE_B here to take into account real number of locks
8921 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8922 local LRU_SIZE_B=$LRU_SIZE
8924 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8925 log "OLD_LVF=$OLD_LVF"
8926 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8928 # Let's make sure that we really have some margin. Client checks
8929 # cached locks every 10 sec.
8931 log "Sleep ${SLEEP} sec"
8933 while ((SEC<$SLEEP)); do
8937 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8941 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8942 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8944 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8945 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8946 unlinkmany $DIR/$tdir/f $NR
8950 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8951 log "unlink $NR files at $DIR/$tdir"
8952 unlinkmany $DIR/$tdir/f $NR
8954 run_test 124a "lru resize ======================================="
8956 get_max_pool_limit()
8958 local limit=$($LCTL get_param \
8959 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8962 if [[ $l -gt $max ]]; then
8970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8971 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
8972 { skip "no lru resize on server"; return 0; }
8974 LIMIT=$(get_max_pool_limit)
8976 NR=$(($(default_lru_size)*20))
8977 if [[ $NR -gt $LIMIT ]]; then
8978 log "Limit lock number by $LIMIT locks"
8982 IFree=$(mdsrate_inodes_available)
8983 if [ $IFree -lt $NR ]; then
8984 log "Limit lock number by $IFree inodes"
8988 lru_resize_disable mdc
8989 test_mkdir -p $DIR/$tdir/disable_lru_resize
8991 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8992 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8993 cancel_lru_locks mdc
8996 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8999 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9002 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9006 nolruresize_delta=$((etime-stime))
9007 log "ls -la time: $nolruresize_delta seconds"
9008 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9009 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9011 lru_resize_enable mdc
9012 test_mkdir -p $DIR/$tdir/enable_lru_resize
9014 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9015 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9016 cancel_lru_locks mdc
9019 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9022 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9025 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9029 lruresize_delta=$((etime-stime))
9030 log "ls -la time: $lruresize_delta seconds"
9031 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9033 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9034 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9035 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9036 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9038 log "lru resize performs the same with no lru resize"
9040 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9042 run_test 124b "lru resize (performance test) ======================="
9045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9046 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9047 { skip "no lru resize on server"; return 0; }
9049 # cache ununsed locks on client
9051 cancel_lru_locks mdc
9052 test_mkdir $DIR/$tdir
9053 createmany -o $DIR/$tdir/f $nr ||
9054 error "failed to create $nr files in $DIR/$tdir"
9055 ls -l $DIR/$tdir > /dev/null
9057 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9058 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9059 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9060 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9061 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9063 # set lru_max_age to 1 sec
9064 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9065 echo "sleep $((recalc_p * 2)) seconds..."
9066 sleep $((recalc_p * 2))
9068 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9069 # restore lru_max_age
9070 $LCTL set_param -n $nsdir.lru_max_age $max_age
9071 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9072 unlinkmany $DIR/$tdir/f $nr
9074 run_test 124c "LRUR cancel very aged locks"
9076 test_125() { # 13358
9077 $LCTL get_param -n llite.*.client_type | grep -q local ||
9078 { skip "must run as local client"; return; }
9079 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
9080 { skip "must have acl enabled"; return; }
9081 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9082 test_mkdir $DIR/$tdir
9083 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
9084 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
9085 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
9087 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9089 test_126() { # bug 12829/13455
9090 $LCTL get_param -n llite.*.client_type | grep -q local ||
9091 { skip "must run as local client"; return; }
9092 [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
9093 $GSS && skip "must run as gss disabled" && return
9095 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9096 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9098 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9100 run_test 126 "check that the fsgid provided by the client is taken into account"
9102 test_127a() { # bug 15521
9103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9104 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9105 $LCTL set_param osc.*.stats=0
9106 FSIZE=$((2048 * 1024))
9107 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9108 cancel_lru_locks osc
9109 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9111 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9112 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9113 echo "got $COUNT $NAME"
9114 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9115 eval $NAME=$COUNT || error "Wrong proc format"
9118 read_bytes|write_bytes)
9119 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9120 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9121 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9122 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9123 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9124 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9125 error "sumsquare is too small: $SUMSQ"
9126 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9127 error "sumsquare is too big: $SUMSQ"
9131 done < $DIR/${tfile}.tmp
9133 #check that we actually got some stats
9134 [ "$read_bytes" ] || error "Missing read_bytes stats"
9135 [ "$write_bytes" ] || error "Missing write_bytes stats"
9136 [ "$read_bytes" != 0 ] || error "no read done"
9137 [ "$write_bytes" != 0 ] || error "no write done"
9139 run_test 127a "verify the client stats are sane"
9141 test_127b() { # bug LU-333
9142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9143 $LCTL set_param llite.*.stats=0
9144 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9145 # perform 2 reads and writes so MAX is different from SUM.
9146 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9147 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9148 cancel_lru_locks osc
9149 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9150 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9152 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9153 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9154 echo "got $COUNT $NAME"
9155 eval $NAME=$COUNT || error "Wrong proc format"
9159 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9160 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9161 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9162 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9165 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9166 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9167 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9168 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9172 done < $TMP/${tfile}.tmp
9174 #check that we actually got some stats
9175 [ "$read_bytes" ] || error "Missing read_bytes stats"
9176 [ "$write_bytes" ] || error "Missing write_bytes stats"
9177 [ "$read_bytes" != 0 ] || error "no read done"
9178 [ "$write_bytes" != 0 ] || error "no write done"
9180 rm -f $TMP/${tfile}.tmp
9182 run_test 127b "verify the llite client stats are sane"
9184 test_128() { # bug 15212
9186 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9191 result=$(grep error $TMP/$tfile.log)
9192 rm -f $DIR/$tfile $TMP/$tfile.log
9194 error "consecutive find's under interactive lfs failed"
9196 run_test 128 "interactive lfs for 2 consecutive find's"
9203 local ldproc=/proc/fs/ldiskfs
9204 local facets=$(get_facets MDS)
9206 for facet in ${facets//,/ }; do
9207 canondev=$(ldiskfs_canon \
9208 *.$(convert_facet2label $facet).mntdev $facet)
9209 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9210 ldproc=/sys/fs/ldiskfs
9211 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9212 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9217 local facets=$(get_facets MDS)
9218 for facet in ${facets//,/ }; do
9219 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9225 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9226 { skip "Need MDS version with at least 2.5.56"; return 0; }
9228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9229 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9230 skip "ldiskfs only test"
9233 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9236 local has_warning=false
9241 # block size of mds1
9242 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9243 set_dir_limits $maxsize $maxsize
9244 local dirsize=$(stat -c%s "$DIR/$tdir")
9246 while [[ $dirsize -le $maxsize ]]; do
9247 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9249 if ! $has_warning; then
9250 check_mds_dmesg '"is approaching"' && has_warning=true
9253 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9254 # EFBIG for previous versions included in ldiskfs series
9255 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9257 echo "return code $rc received as expected"
9259 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9260 error_exit "create failed w/o dir size limit"
9262 check_mds_dmesg '"has reached"' ||
9263 error_exit "reached message should be output"
9265 [ $has_warning -eq 0 ] &&
9266 error_exit "warning message should be output"
9268 dirsize=$(stat -c%s "$DIR/$tdir")
9270 [[ $dirsize -ge $maxsize ]] && return 0
9271 error_exit "current dir size $dirsize, " \
9272 "previous limit $maxsize"
9273 elif [ $rc -ne 0 ]; then
9275 error_exit "return $rc received instead of expected " \
9276 "$EFBIG or $ENOSPC, files in dir $dirsize"
9278 nfiles=$((nfiles + 1))
9279 dirsize=$(stat -c%s "$DIR/$tdir")
9283 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9285 run_test 129 "test directory size limit ========================"
9294 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9295 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9298 trap cleanup_130 EXIT RETURN
9300 local fm_file=$DIR/$tfile
9301 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9302 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9303 error "dd failed for $fm_file"
9305 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9306 filefrag -ves $fm_file
9308 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9309 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9310 [ $RC != 0 ] && error "filefrag $fm_file failed"
9312 filefrag_op=$(filefrag -ve $fm_file |
9313 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9314 lun=$($GETSTRIPE -i $fm_file)
9316 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9319 for line in $filefrag_op
9321 frag_lun=`echo $line | cut -d: -f5`
9322 ext_len=`echo $line | cut -d: -f4`
9323 if (( $frag_lun != $lun )); then
9325 error "FIEMAP on 1-stripe file($fm_file) failed"
9328 (( tot_len += ext_len ))
9331 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9333 error "FIEMAP on 1-stripe file($fm_file) failed;"
9339 echo "FIEMAP on single striped file succeeded"
9341 run_test 130a "FIEMAP (1-stripe file)"
9344 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9346 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9347 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9350 trap cleanup_130 EXIT RETURN
9352 local fm_file=$DIR/$tfile
9353 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9354 error "setstripe on $fm_file"
9355 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9356 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9358 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9359 error "dd failed on $fm_file"
9361 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9362 filefrag_op=$(filefrag -ve $fm_file |
9363 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9365 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9366 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9371 for line in $filefrag_op
9373 frag_lun=$(echo $line | cut -d: -f5 |
9374 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9375 ext_len=$(echo $line | cut -d: -f4)
9376 if (( $frag_lun != $last_lun )); then
9377 if (( tot_len != 1024 )); then
9379 error "FIEMAP on $fm_file failed; returned " \
9380 "len $tot_len for OST $last_lun instead of 1024"
9387 (( tot_len += ext_len ))
9390 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9392 error "FIEMAP on $fm_file failed; returned wrong number of " \
9393 "luns or wrong len for OST $last_lun"
9399 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9401 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9404 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9406 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9407 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9410 trap cleanup_130 EXIT RETURN
9412 local fm_file=$DIR/$tfile
9413 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9414 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9415 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9417 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9418 error "dd failed on $fm_file"
9420 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9421 filefrag_op=$(filefrag -ve $fm_file |
9422 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9424 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9425 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9430 for line in $filefrag_op
9432 frag_lun=$(echo $line | cut -d: -f5 |
9433 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9434 ext_len=$(echo $line | cut -d: -f4)
9435 if (( $frag_lun != $last_lun )); then
9436 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9437 if (( logical != 512 )); then
9439 error "FIEMAP on $fm_file failed; returned " \
9440 "logical start for lun $logical instead of 512"
9443 if (( tot_len != 512 )); then
9445 error "FIEMAP on $fm_file failed; returned " \
9446 "len $tot_len for OST $last_lun instead of 1024"
9453 (( tot_len += ext_len ))
9456 if (( num_luns != 2 || tot_len != 512 )); then
9458 error "FIEMAP on $fm_file failed; returned wrong number of " \
9459 "luns or wrong len for OST $last_lun"
9465 echo "FIEMAP on 2-stripe file with hole succeeded"
9467 run_test 130c "FIEMAP (2-stripe file with hole)"
9470 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9472 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9473 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9476 trap cleanup_130 EXIT RETURN
9478 local fm_file=$DIR/$tfile
9479 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9480 error "setstripe on $fm_file"
9481 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9482 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9484 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9485 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9486 error "dd failed on $fm_file"
9488 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9489 filefrag_op=$(filefrag -ve $fm_file |
9490 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9492 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9493 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9498 for line in $filefrag_op
9500 frag_lun=$(echo $line | cut -d: -f5 |
9501 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9502 ext_len=$(echo $line | cut -d: -f4)
9503 if (( $frag_lun != $last_lun )); then
9504 if (( tot_len != 1024 )); then
9506 error "FIEMAP on $fm_file failed; returned " \
9507 "len $tot_len for OST $last_lun instead of 1024"
9514 (( tot_len += ext_len ))
9517 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9519 error "FIEMAP on $fm_file failed; returned wrong number of " \
9520 "luns or wrong len for OST $last_lun"
9526 echo "FIEMAP on N-stripe file succeeded"
9528 run_test 130d "FIEMAP (N-stripe file)"
9531 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9533 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9534 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9536 trap cleanup_130 EXIT RETURN
9538 local fm_file=$DIR/$tfile
9539 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9540 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9541 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9544 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9545 for ((i = 0; i < $NUM_BLKS; i++))
9547 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9550 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9551 filefrag_op=$(filefrag -ve $fm_file |
9552 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9554 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9555 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9560 for line in $filefrag_op
9562 frag_lun=$(echo $line | cut -d: -f5 |
9563 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9564 ext_len=$(echo $line | cut -d: -f4)
9565 if (( $frag_lun != $last_lun )); then
9566 if (( tot_len != $EXPECTED_LEN )); then
9568 error "FIEMAP on $fm_file failed; returned " \
9569 "len $tot_len for OST $last_lun instead " \
9577 (( tot_len += ext_len ))
9580 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9582 error "FIEMAP on $fm_file failed; returned wrong number " \
9583 "of luns or wrong len for OST $last_lun"
9589 echo "FIEMAP with continuation calls succeeded"
9591 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9593 # Test for writev/readv
9595 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9596 error "writev test failed"
9597 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9598 error "readv failed"
9601 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9604 local fsize=$((524288 + 1048576 + 1572864))
9605 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9606 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9607 error "append writev test failed"
9609 ((fsize += 1572864 + 1048576))
9610 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9611 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9612 error "append writev test failed"
9615 run_test 131b "test append writev"
9618 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9621 run_test 131c "test read/write on file w/o objects"
9624 rwv -f $DIR/$tfile -w -n 1 1572864
9625 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9626 if [ "$NOB" != 1572864 ]; then
9627 error "Short read filed: read $NOB bytes instead of 1572864"
9631 run_test 131d "test short read"
9634 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9635 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9636 error "read hitting hole failed"
9639 run_test 131e "test read hitting hole"
9648 mds*) res=$(do_facet $facet \
9649 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9651 ost*) res=$(do_facet $facet \
9652 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9654 *) error "Wrong facet '$facet'" ;;
9657 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9658 # if the argument $3 is zero, it means any stat increment is ok.
9659 if [[ $want -gt 0 ]]; then
9660 local count=$(echo $res | awk '{ print $2 }')
9661 [[ $count -ne $want ]] &&
9662 error "The $op counter on $facet is $count, not $want"
9667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9668 remote_ost_nodsh && skip "remote OST with nodsh" && return
9669 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9671 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9672 { skip "MDS doesn't support rename stats"; return; }
9673 local testdir=$DIR/${tdir}/stats_testdir
9674 mkdir -p $DIR/${tdir}
9677 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9678 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9680 # verify mdt stats first.
9681 mkdir ${testdir} || error "mkdir failed"
9682 check_stats $SINGLEMDS "mkdir" 1
9683 touch ${testdir}/${tfile} || error "touch failed"
9684 check_stats $SINGLEMDS "open" 1
9685 check_stats $SINGLEMDS "close" 1
9686 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9687 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9688 check_stats $SINGLEMDS "mknod" 2
9690 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9691 check_stats $SINGLEMDS "unlink" 1
9692 rm -f ${testdir}/${tfile} || error "file remove failed"
9693 check_stats $SINGLEMDS "unlink" 2
9695 # remove working dir and check mdt stats again.
9696 rmdir ${testdir} || error "rmdir failed"
9697 check_stats $SINGLEMDS "rmdir" 1
9699 local testdir1=$DIR/${tdir}/stats_testdir1
9701 mkdir -p ${testdir1}
9702 touch ${testdir1}/test1
9703 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9704 check_stats $SINGLEMDS "crossdir_rename" 1
9706 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9707 check_stats $SINGLEMDS "samedir_rename" 1
9711 run_test 133a "Verifying MDT stats ========================================"
9714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9715 remote_ost_nodsh && skip "remote OST with nodsh" && return
9716 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9717 local testdir=$DIR/${tdir}/stats_testdir
9718 mkdir -p ${testdir} || error "mkdir failed"
9719 touch ${testdir}/${tfile} || error "touch failed"
9720 cancel_lru_locks mdc
9723 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9724 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9726 # extra mdt stats verification.
9727 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9728 check_stats $SINGLEMDS "setattr" 1
9729 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9730 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9732 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9733 check_stats $SINGLEMDS "getattr" 1
9735 $LFS df || error "lfs failed"
9736 check_stats $SINGLEMDS "statfs" 1
9740 run_test 133b "Verifying extra MDT stats =================================="
9743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9744 remote_ost_nodsh && skip "remote OST with nodsh" && return
9745 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9746 local testdir=$DIR/$tdir/stats_testdir
9747 test_mkdir -p $testdir
9749 # verify obdfilter stats.
9750 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
9752 cancel_lru_locks osc
9753 wait_delete_completed
9756 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9757 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9759 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
9762 cancel_lru_locks osc
9763 check_stats ost1 "write" 1
9765 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
9766 check_stats ost1 "read" 1
9768 > $testdir/$tfile || error "truncate failed"
9769 check_stats ost1 "punch" 1
9771 rm -f $testdir/$tfile || error "file remove failed"
9772 wait_delete_completed
9773 check_stats ost1 "destroy" 1
9777 run_test 133c "Verifying OST stats ========================================"
9784 while [ $value -ge 2 ]; do
9789 if [ $orig -gt $order ]; then
9797 local size=('K' 'M' 'G' 'T');
9799 local size_string=$value
9801 while [ $value -ge 1024 ]; do
9802 if [ $i -gt 3 ]; then
9803 #T is the biggest unit we get here, if that is bigger,
9805 size_string=${value}T
9808 value=$((value >> 10))
9809 if [ $value -lt 1024 ]; then
9810 size_string=${value}${size[$i]}
9821 local context=${2:-.}
9822 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9824 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9830 remote_ost_nodsh && skip "remote OST with nodsh" && return
9831 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9832 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9833 { skip "MDS doesn't support rename stats"; return; }
9835 local testdir1=$DIR/${tdir}/stats_testdir1
9836 local testdir2=$DIR/${tdir}/stats_testdir2
9838 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9840 mkdir -p ${testdir1} || error "mkdir failed"
9841 mkdir -p ${testdir2} || error "mkdir failed"
9843 createmany -o $testdir1/test 512 || error "createmany failed"
9845 # check samedir rename size
9846 mv ${testdir1}/test0 ${testdir1}/test_0
9848 local testdir1_size=$(ls -l $DIR/${tdir} |
9849 awk '/stats_testdir1/ {print $5}')
9850 local testdir2_size=$(ls -l $DIR/${tdir} |
9851 awk '/stats_testdir2/ {print $5}')
9853 testdir1_size=$(order_2 $testdir1_size)
9854 testdir2_size=$(order_2 $testdir2_size)
9856 testdir1_size=$(size_in_KMGT $testdir1_size)
9857 testdir2_size=$(size_in_KMGT $testdir2_size)
9859 echo "source rename dir size: ${testdir1_size}"
9860 echo "target rename dir size: ${testdir2_size}"
9862 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9863 eval $cmd || error "$cmd failed"
9864 local samedir=$($cmd | grep 'same_dir')
9865 local same_sample=$(get_rename_size $testdir1_size)
9866 [ -z "$samedir" ] && error "samedir_rename_size count error"
9867 [[ $same_sample -eq 1 ]] ||
9868 error "samedir_rename_size error $same_sample"
9869 echo "Check same dir rename stats success"
9871 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9873 # check crossdir rename size
9874 mv ${testdir1}/test_0 ${testdir2}/test_0
9876 testdir1_size=$(ls -l $DIR/${tdir} |
9877 awk '/stats_testdir1/ {print $5}')
9878 testdir2_size=$(ls -l $DIR/${tdir} |
9879 awk '/stats_testdir2/ {print $5}')
9881 testdir1_size=$(order_2 $testdir1_size)
9882 testdir2_size=$(order_2 $testdir2_size)
9884 testdir1_size=$(size_in_KMGT $testdir1_size)
9885 testdir2_size=$(size_in_KMGT $testdir2_size)
9887 echo "source rename dir size: ${testdir1_size}"
9888 echo "target rename dir size: ${testdir2_size}"
9890 eval $cmd || error "$cmd failed"
9891 local crossdir=$($cmd | grep 'crossdir')
9892 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9893 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9894 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9895 [[ $src_sample -eq 1 ]] ||
9896 error "crossdir_rename_size error $src_sample"
9897 [[ $tgt_sample -eq 1 ]] ||
9898 error "crossdir_rename_size error $tgt_sample"
9899 echo "Check cross dir rename stats success"
9902 run_test 133d "Verifying rename_stats ========================================"
9905 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9906 remote_ost_nodsh && skip "remote OST with nodsh" && return
9907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9908 local testdir=$DIR/${tdir}/stats_testdir
9909 local ctr f0 f1 bs=32768 count=42 sum
9911 mkdir -p ${testdir} || error "mkdir failed"
9913 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9915 for ctr in {write,read}_bytes; do
9917 cancel_lru_locks osc
9919 do_facet ost1 $LCTL set_param -n \
9920 "obdfilter.*.exports.clear=clear"
9922 if [ $ctr = write_bytes ]; then
9924 f1=${testdir}/${tfile}
9926 f0=${testdir}/${tfile}
9930 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9933 cancel_lru_locks osc
9935 sum=$(do_facet ost1 $LCTL get_param \
9936 "obdfilter.*.exports.*.stats" |
9937 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9938 $1 == ctr { sum += $7 }
9939 END { printf("%0.0f", sum) }')
9941 if ((sum != bs * count)); then
9942 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9948 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9950 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
9953 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9954 remote_ost_nodsh && skip "remote OST with nodsh" && return
9955 # First without trusting modes.
9956 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9957 echo "proc_dirs='$proc_dirs'"
9958 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9959 find $proc_dirs -exec cat '{}' \; &> /dev/null
9961 # Second verifying readability.
9962 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9964 # eventually, this can also be replaced with "lctl get_param -R",
9965 # but not until that option is always available on the server
9967 for facet in mds1 ost1; do
9968 local facet_proc_dirs=$(do_facet $facet \
9969 \\\ls -d $proc_regexp 2>/dev/null)
9970 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9971 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9972 do_facet $facet find $facet_proc_dirs \
9973 ! -name req_history \
9974 -exec cat '{}' \\\; &> /dev/null
9976 do_facet $facet find $facet_proc_dirs \
9977 ! -name req_history \
9979 -exec cat '{}' \\\; &> /dev/null ||
9980 error "proc file read failed"
9983 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9986 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9987 remote_ost_nodsh && skip "remote OST with nodsh" && return
9988 # Second verifying writability.
9989 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9990 echo "proc_dirs='$proc_dirs'"
9991 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9994 -not -name force_lbug \
9995 -not -name changelog_mask \
9996 -exec badarea_io '{}' \; ||
9997 error "find $proc_dirs failed"
10000 for facet in mds1 ost1; do
10001 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10002 skip "Too old lustre on $facet" && continue
10003 local facet_proc_dirs=$(do_facet $facet \
10004 \\\ls -d $proc_regexp 2> /dev/null)
10005 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10006 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10007 do_facet $facet find $facet_proc_dirs \
10009 -not -name force_lbug \
10010 -not -name changelog_mask \
10011 -exec badarea_io '{}' \\\; ||
10012 error "$facet find $facet_proc_dirs failed"
10015 # remount the FS in case writes/reads /proc break the FS
10016 cleanup || error "failed to unmount"
10017 setup || error "failed to setup"
10020 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10023 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10024 remote_ost_nodsh && skip "remote OST with nodsh" && return
10025 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10026 skip "Need MDS version at least 2.9.54" && return
10029 for facet in client mds1 ost1; do
10030 local facet_proc_dirs=$(do_facet $facet \
10031 \\\ls -d $proc_regexp 2> /dev/null)
10032 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10033 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10034 # Get the list of files that are missing the terminating newline
10035 local missing=($(do_facet $facet \
10036 find ${facet_proc_dirs} -type f \| \
10037 while read F\; do \
10038 awk -v FS='\v' -v RS='\v\v' \
10039 "'END { if(NR>0 && \
10040 \\\$NF !~ /.*\\\n\$/) \
10041 print FILENAME}'" \
10044 [ ${#missing[*]} -eq 0 ] ||
10045 error "files do not end with newline: ${missing[*]}"
10048 run_test 133h "Proc files should end with newlines"
10051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10052 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10053 skip "Need MDS version at least 2.7.54" && return
10055 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10056 cancel_lru_locks mdc
10058 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10059 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10060 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10063 createmany -o $DIR/$tdir/f $nr ||
10064 error "failed to create $nr files in $DIR/$tdir"
10065 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10067 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10068 do_facet mds1 $LCTL set_param fail_loc=0x327
10069 do_facet mds1 $LCTL set_param fail_val=500
10072 echo "sleep 10 seconds ..."
10074 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10076 do_facet mds1 $LCTL set_param fail_loc=0
10077 do_facet mds1 $LCTL set_param fail_val=0
10078 [ $lck_cnt -lt $unused ] ||
10079 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10082 unlinkmany $DIR/$tdir/f $nr
10084 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10087 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10088 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10089 skip "Need MDS version at least 2.7.54" && return
10091 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10092 cancel_lru_locks mdc
10094 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10095 ldlm.lock_reclaim_threshold_mb)
10096 # disable reclaim temporarily
10097 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10099 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10100 do_facet mds1 $LCTL set_param fail_loc=0x328
10101 do_facet mds1 $LCTL set_param fail_val=500
10103 $LCTL set_param debug=+trace
10106 createmany -o $DIR/$tdir/f $nr &
10107 local create_pid=$!
10109 echo "Sleep $TIMEOUT seconds ..."
10111 if ! ps -p $create_pid > /dev/null 2>&1; then
10112 do_facet mds1 $LCTL set_param fail_loc=0
10113 do_facet mds1 $LCTL set_param fail_val=0
10114 do_facet mds1 $LCTL set_param \
10115 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10116 error "createmany finished incorrectly!"
10118 do_facet mds1 $LCTL set_param fail_loc=0
10119 do_facet mds1 $LCTL set_param fail_val=0
10120 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10121 wait $create_pid || return 1
10123 unlinkmany $DIR/$tdir/f $nr
10125 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10127 test_140() { #bug-17379
10128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10129 test_mkdir $DIR/$tdir
10130 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10131 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10133 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10134 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10136 while i=$((i + 1)); do
10138 cd $i || error "Changing to $i"
10139 ln -s ../stat stat || error "Creating stat symlink"
10140 # Read the symlink until ELOOP present,
10141 # not LBUGing the system is considered success,
10142 # we didn't overrun the stack.
10143 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10144 if [ $ret -ne 0 ]; then
10145 if [ $ret -eq 40 ]; then
10148 error "Open stat symlink"
10154 echo "The symlink depth = $i"
10155 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10156 error "Invalid symlink depth"
10158 # Test recursive symlink
10159 ln -s symlink_self symlink_self
10160 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10161 echo "open symlink_self returns $ret"
10162 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10164 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10168 local TF="$TMP/$tfile"
10170 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10172 cancel_lru_locks $OSC
10173 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10174 remount_client $MOUNT
10176 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10179 $TRUNCATE $DIR/$tfile 6000
10180 cancel_lru_locks $OSC
10181 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10184 echo "12345" >>$DIR/$tfile
10185 cancel_lru_locks $OSC
10186 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10189 echo "12345" >>$DIR/$tfile
10190 cancel_lru_locks $OSC
10191 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10196 run_test 150 "truncate/append tests"
10198 #LU-2902 roc_hit was not able to read all values from lproc
10199 function roc_hit_init() {
10200 local list=$(comma_list $(osts_nodes))
10201 local dir=$DIR/$tdir-check
10202 local file=$dir/$tfile
10208 #use setstripe to do a write to every ost
10209 for i in $(seq 0 $((OSTCOUNT-1))); do
10210 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10211 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10212 idx=$(printf %04x $i)
10213 BEFORE=$(get_osd_param $list *OST*$idx stats |
10214 awk '$1 == "cache_access" {sum += $7}
10215 END { printf("%0.0f", sum) }')
10217 cancel_lru_locks osc
10218 cat $file >/dev/null
10220 AFTER=$(get_osd_param $list *OST*$idx stats |
10221 awk '$1 == "cache_access" {sum += $7}
10222 END { printf("%0.0f", sum) }')
10224 echo BEFORE:$BEFORE AFTER:$AFTER
10225 if ! let "AFTER - BEFORE == 4"; then
10227 error "roc_hit is not safe to use"
10235 function roc_hit() {
10236 local list=$(comma_list $(osts_nodes))
10237 echo $(get_osd_param $list '' stats |
10238 awk '$1 == "cache_hit" {sum += $7}
10239 END { printf("%0.0f", sum) }')
10242 function set_cache() {
10245 if [ "$2" == "off" ]; then
10248 local list=$(comma_list $(osts_nodes))
10249 set_osd_param $list '' $1_cache_enable $on
10251 cancel_lru_locks osc
10255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10256 remote_ost_nodsh && skip "remote OST with nodsh" && return
10259 local list=$(comma_list $(osts_nodes))
10261 # check whether obdfilter is cache capable at all
10262 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10263 echo "not cache-capable obdfilter"
10267 # check cache is enabled on all obdfilters
10268 if get_osd_param $list '' read_cache_enable | grep 0; then
10269 echo "oss cache is disabled"
10273 set_osd_param $list '' writethrough_cache_enable 1
10275 # check write cache is enabled on all obdfilters
10276 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10277 echo "oss write cache is NOT enabled"
10283 #define OBD_FAIL_OBD_NO_LRU 0x609
10284 do_nodes $list $LCTL set_param fail_loc=0x609
10286 # pages should be in the case right after write
10287 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10290 local BEFORE=$(roc_hit)
10291 cancel_lru_locks osc
10292 cat $DIR/$tfile >/dev/null
10293 local AFTER=$(roc_hit)
10295 do_nodes $list $LCTL set_param fail_loc=0
10297 if ! let "AFTER - BEFORE == CPAGES"; then
10298 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10301 # the following read invalidates the cache
10302 cancel_lru_locks osc
10303 set_osd_param $list '' read_cache_enable 0
10304 cat $DIR/$tfile >/dev/null
10306 # now data shouldn't be found in the cache
10308 cancel_lru_locks osc
10309 cat $DIR/$tfile >/dev/null
10311 if let "AFTER - BEFORE != 0"; then
10312 error "IN CACHE: before: $BEFORE, after: $AFTER"
10315 set_osd_param $list '' read_cache_enable 1
10318 run_test 151 "test cache on oss and controls ==============================="
10321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10322 local TF="$TMP/$tfile"
10324 # simulate ENOMEM during write
10325 #define OBD_FAIL_OST_NOMEM 0x226
10326 lctl set_param fail_loc=0x80000226
10327 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10329 sync || error "sync failed"
10330 lctl set_param fail_loc=0
10332 # discard client's cache
10333 cancel_lru_locks osc
10335 # simulate ENOMEM during read
10336 lctl set_param fail_loc=0x80000226
10337 cmp $TF $DIR/$tfile || error "cmp failed"
10338 lctl set_param fail_loc=0
10342 run_test 152 "test read/write with enomem ============================"
10345 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10347 run_test 153 "test if fdatasync does not crash ======================="
10349 dot_lustre_fid_permission_check() {
10351 local ffid=$MOUNT/.lustre/fid/$fid
10354 echo "stat fid $fid"
10355 stat $ffid > /dev/null || error "stat $ffid failed."
10356 echo "touch fid $fid"
10357 touch $ffid || error "touch $ffid failed."
10358 echo "write to fid $fid"
10359 cat /etc/hosts > $ffid || error "write $ffid failed."
10360 echo "read fid $fid"
10361 diff /etc/hosts $ffid || error "read $ffid failed."
10362 echo "append write to fid $fid"
10363 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10364 echo "rename fid $fid"
10365 mv $ffid $test_dir/$tfile.1 &&
10366 error "rename $ffid to $tfile.1 should fail."
10367 touch $test_dir/$tfile.1
10368 mv $test_dir/$tfile.1 $ffid &&
10369 error "rename $tfile.1 to $ffid should fail."
10370 rm -f $test_dir/$tfile.1
10371 echo "truncate fid $fid"
10372 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10373 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10374 echo "link fid $fid"
10375 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10377 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10378 echo "setfacl fid $fid"
10379 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10380 echo "getfacl fid $fid"
10381 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10383 echo "unlink fid $fid"
10384 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10385 echo "mknod fid $fid"
10386 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10388 fid=[0xf00000400:0x1:0x0]
10389 ffid=$MOUNT/.lustre/fid/$fid
10391 echo "stat non-exist fid $fid"
10392 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10393 echo "write to non-exist fid $fid"
10394 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10395 echo "link new fid $fid"
10396 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10398 mkdir -p $test_dir/$tdir
10399 touch $test_dir/$tdir/$tfile
10400 fid=$($LFS path2fid $test_dir/$tdir)
10403 error "error: could not get fid for $test_dir/$dir/$tfile."
10405 ffid=$MOUNT/.lustre/fid/$fid
10408 ls $ffid > /dev/null || error "ls $ffid failed."
10409 echo "touch $fid/$tfile.1"
10410 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10412 echo "touch $MOUNT/.lustre/fid/$tfile"
10413 touch $MOUNT/.lustre/fid/$tfile && \
10414 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10416 echo "setxattr to $MOUNT/.lustre/fid"
10417 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10419 echo "listxattr for $MOUNT/.lustre/fid"
10420 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10422 echo "delxattr from $MOUNT/.lustre/fid"
10423 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10425 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10426 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10427 error "touch invalid fid should fail."
10429 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10430 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10431 error "touch non-normal fid should fail."
10433 echo "rename $tdir to $MOUNT/.lustre/fid"
10434 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10435 error "rename to $MOUNT/.lustre/fid should fail."
10437 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10439 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10440 local new_obf_mode=777
10442 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10443 chmod $new_obf_mode $DIR/.lustre/fid ||
10444 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10446 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10447 [ $obf_mode -eq $new_obf_mode ] ||
10448 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10450 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10451 chmod $old_obf_mode $DIR/.lustre/fid ||
10452 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10455 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10456 fid=$($LFS path2fid $test_dir/$tfile-2)
10458 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10460 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10461 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10462 error "create lov data thru .lustre failed"
10464 echo "cp /etc/passwd $test_dir/$tfile-2"
10465 cp /etc/passwd $test_dir/$tfile-2 ||
10466 error "copy to $test_dir/$tfile-2 failed."
10467 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10468 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10469 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10471 rm -rf $test_dir/tfile.lnk
10472 rm -rf $test_dir/$tfile-2
10476 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10477 skip "Need MDS version at least 2.4.1" && return
10479 local tf=$DIR/$tfile
10482 local fid=$($LFS path2fid $tf)
10483 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10485 # check that we get the same pathname back
10486 local found=$($LFS fid2path $MOUNT "$fid")
10487 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10488 [ "$found" == "$tf" ] ||
10489 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10491 run_test 154A "lfs path2fid and fid2path basic checks"
10494 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10495 skip "Need MDS version at least 2.4.1" && return
10497 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10498 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10499 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10500 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10502 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10503 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10505 # check that we get the same pathname
10506 echo "PFID: $PFID, name: $name"
10507 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10508 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10509 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10510 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10512 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10514 run_test 154B "verify the ll_decode_linkea tool"
10517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10518 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10519 { skip "Need MDS version at least 2.2.51"; return 0; }
10520 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10521 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10523 cp /etc/hosts $DIR/$tfile
10525 fid=$($LFS path2fid $DIR/$tfile)
10527 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10529 dot_lustre_fid_permission_check "$fid" $DIR ||
10530 error "dot lustre permission check $fid failed"
10532 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10534 touch $MOUNT/.lustre/file &&
10535 error "creation is not allowed under .lustre"
10537 mkdir $MOUNT/.lustre/dir &&
10538 error "mkdir is not allowed under .lustre"
10542 run_test 154a "Open-by-FID"
10545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10546 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10547 { skip "Need MDS version at least 2.2.51"; return 0; }
10548 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10550 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10552 local remote_dir=$DIR/$tdir/remote_dir
10556 mkdir -p $DIR/$tdir
10557 $LFS mkdir -i $MDTIDX $remote_dir ||
10558 error "create remote directory failed"
10560 cp /etc/hosts $remote_dir/$tfile
10562 fid=$($LFS path2fid $remote_dir/$tfile)
10564 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10566 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10567 error "dot lustre permission check $fid failed"
10570 run_test 154b "Open-by-FID for remote directory"
10573 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10574 skip "Need MDS version at least 2.4.1" && return
10576 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10577 local FID1=$($LFS path2fid $DIR/$tfile.1)
10578 local FID2=$($LFS path2fid $DIR/$tfile.2)
10579 local FID3=$($LFS path2fid $DIR/$tfile.3)
10582 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10583 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10584 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10586 [ "$FID" = "${!want}" ] ||
10587 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10591 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10593 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10594 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10598 run_test 154c "lfs path2fid and fid2path multiple arguments"
10601 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10602 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10603 skip "Need MDS version at least 2.5.53" && return
10605 if remote_mds; then
10606 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10610 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10617 local fid=$($LFS path2fid $DIR/$tfile)
10620 cmd="exec $fd<$DIR/$tfile"
10622 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10623 echo "$fid_list" | grep "$fid"
10626 cmd="exec $fd>/dev/null"
10628 if [ $rc -ne 0 ]; then
10629 error "FID $fid not found in open files list $fid_list"
10632 run_test 154d "Verify open file fid"
10636 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10637 skip "Need MDS version at least 2.6.50" && return
10639 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10640 error ".lustre returned by readdir"
10643 run_test 154e ".lustre is not returned by readdir"
10646 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10647 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10648 test_mkdir -p -c1 $DIR/$tdir/d
10649 # test dirs inherit from its stripe
10650 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10651 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10652 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10653 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10656 # get fid of parents
10657 local FID0=$($LFS path2fid $DIR/$tdir/d)
10658 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10659 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10660 local FID3=$($LFS path2fid $DIR)
10662 # check that path2fid --parents returns expected <parent_fid>/name
10663 # 1) test for a directory (single parent)
10664 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10665 [ "$parent" == "$FID0/foo1" ] ||
10666 error "expected parent: $FID0/foo1, got: $parent"
10668 # 2) test for a file with nlink > 1 (multiple parents)
10669 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10670 echo "$parent" | grep -F "$FID1/$tfile" ||
10671 error "$FID1/$tfile not returned in parent list"
10672 echo "$parent" | grep -F "$FID2/link" ||
10673 error "$FID2/link not returned in parent list"
10675 # 3) get parent by fid
10676 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10677 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10678 echo "$parent" | grep -F "$FID1/$tfile" ||
10679 error "$FID1/$tfile not returned in parent list (by fid)"
10680 echo "$parent" | grep -F "$FID2/link" ||
10681 error "$FID2/link not returned in parent list (by fid)"
10683 # 4) test for entry in root directory
10684 parent=$($LFS path2fid --parents $DIR/f)
10685 echo "$parent" | grep -F "$FID3/f" ||
10686 error "$FID3/f not returned in parent list"
10688 # 5) test it on root directory
10689 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10690 error "$MOUNT should not have parents"
10692 # enable xattr caching and check that linkea is correctly updated
10693 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10694 save_lustre_params client "llite.*.xattr_cache" > $save
10695 lctl set_param llite.*.xattr_cache 1
10697 # 6.1) linkea update on rename
10698 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10700 # get parents by fid
10701 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10702 # foo1 should no longer be returned in parent list
10703 echo "$parent" | grep -F "$FID1" &&
10704 error "$FID1 should no longer be in parent list"
10705 # the new path should appear
10706 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10707 error "$FID2/$tfile.moved is not in parent list"
10709 # 6.2) linkea update on unlink
10710 rm -f $DIR/$tdir/d/foo2/link
10711 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10712 # foo2/link should no longer be returned in parent list
10713 echo "$parent" | grep -F "$FID2/link" &&
10714 error "$FID2/link should no longer be in parent list"
10718 restore_lustre_params < $save
10721 run_test 154f "get parent fids by reading link ea"
10725 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
10726 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
10727 { skip "Need MDS version at least 2.6.92"; return 0; }
10728 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10730 mkdir -p $DIR/$tdir
10731 llapi_fid_test -d $DIR/$tdir
10733 run_test 154g "various llapi FID tests"
10735 test_155_small_load() {
10736 local temp=$TMP/$tfile
10737 local file=$DIR/$tfile
10739 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10740 error "dd of=$temp bs=6096 count=1 failed"
10742 cancel_lru_locks $OSC
10743 cmp $temp $file || error "$temp $file differ"
10745 $TRUNCATE $temp 6000
10746 $TRUNCATE $file 6000
10747 cmp $temp $file || error "$temp $file differ (truncate1)"
10749 echo "12345" >>$temp
10750 echo "12345" >>$file
10751 cmp $temp $file || error "$temp $file differ (append1)"
10753 echo "12345" >>$temp
10754 echo "12345" >>$file
10755 cmp $temp $file || error "$temp $file differ (append2)"
10761 test_155_big_load() {
10762 remote_ost_nodsh && skip "remote OST with nodsh" && return
10763 local temp=$TMP/$tfile
10764 local file=$DIR/$tfile
10767 local cache_size=$(do_facet ost$((MAXI+1)) \
10768 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10769 local large_file_size=$((cache_size * 2))
10771 echo "OSS cache size: $cache_size KB"
10772 echo "Large file size: $large_file_size KB"
10774 [ $MAXV -le $large_file_size ] && \
10775 skip_env "max available OST size needs > $large_file_size KB" && \
10778 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10780 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10781 error "dd of=$temp bs=$large_file_size count=1k failed"
10784 cancel_lru_locks osc
10785 cmp $temp $file || error "$temp $file differ"
10791 save_writethrough() {
10792 local facets=$(get_facets OST)
10794 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10795 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10800 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10801 save_writethrough $p
10804 set_cache writethrough on
10805 test_155_small_load
10806 restore_lustre_params < $p
10809 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10813 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10814 save_writethrough $p
10817 set_cache writethrough off
10818 test_155_small_load
10819 restore_lustre_params < $p
10822 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10826 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10827 save_writethrough $p
10830 set_cache writethrough on
10831 test_155_small_load
10832 restore_lustre_params < $p
10835 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10839 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10840 save_writethrough $p
10843 set_cache writethrough off
10844 test_155_small_load
10845 restore_lustre_params < $p
10848 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10852 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10853 save_writethrough $p
10856 set_cache writethrough on
10858 restore_lustre_params < $p
10861 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10865 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10866 save_writethrough $p
10869 set_cache writethrough off
10871 restore_lustre_params < $p
10874 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10878 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10879 save_writethrough $p
10882 set_cache writethrough on
10884 restore_lustre_params < $p
10887 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10891 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10892 save_writethrough $p
10895 set_cache writethrough off
10897 restore_lustre_params < $p
10900 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10903 remote_ost_nodsh && skip "remote OST with nodsh" && return
10904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10908 local file="$DIR/$tfile"
10909 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10911 [ "$(facet_fstype ost1)" = "zfs" -a \
10912 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10913 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10916 save_writethrough $p
10919 log "Turn on read and write cache"
10921 set_cache writethrough on
10923 log "Write data and read it back."
10924 log "Read should be satisfied from the cache."
10925 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10927 cancel_lru_locks osc
10928 cat $file >/dev/null
10930 if ! let "AFTER - BEFORE == CPAGES"; then
10931 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10933 log "cache hits:: before: $BEFORE, after: $AFTER"
10936 log "Read again; it should be satisfied from the cache."
10938 cancel_lru_locks osc
10939 cat $file >/dev/null
10941 if ! let "AFTER - BEFORE == CPAGES"; then
10942 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10944 log "cache hits:: before: $BEFORE, after: $AFTER"
10947 log "Turn off the read cache and turn on the write cache"
10949 set_cache writethrough on
10951 log "Read again; it should be satisfied from the cache."
10953 cancel_lru_locks osc
10954 cat $file >/dev/null
10956 if ! let "AFTER - BEFORE == CPAGES"; then
10957 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10959 log "cache hits:: before: $BEFORE, after: $AFTER"
10962 log "Read again; it should not be satisfied from the cache."
10964 cancel_lru_locks osc
10965 cat $file >/dev/null
10967 if ! let "AFTER - BEFORE == 0"; then
10968 error "IN CACHE: before: $BEFORE, after: $AFTER"
10970 log "cache hits:: before: $BEFORE, after: $AFTER"
10973 log "Write data and read it back."
10974 log "Read should be satisfied from the cache."
10975 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10977 cancel_lru_locks osc
10978 cat $file >/dev/null
10980 if ! let "AFTER - BEFORE == CPAGES"; then
10981 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10983 log "cache hits:: before: $BEFORE, after: $AFTER"
10986 log "Read again; it should not be satisfied from the cache."
10988 cancel_lru_locks osc
10989 cat $file >/dev/null
10991 if ! let "AFTER - BEFORE == 0"; then
10992 error "IN CACHE: before: $BEFORE, after: $AFTER"
10994 log "cache hits:: before: $BEFORE, after: $AFTER"
10997 log "Turn off read and write cache"
10999 set_cache writethrough off
11001 log "Write data and read it back"
11002 log "It should not be satisfied from the cache."
11004 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11005 cancel_lru_locks osc
11007 cat $file >/dev/null
11009 if ! let "AFTER - BEFORE == 0"; then
11010 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11012 log "cache hits:: before: $BEFORE, after: $AFTER"
11015 log "Turn on the read cache and turn off the write cache"
11017 set_cache writethrough off
11019 log "Write data and read it back"
11020 log "It should not be satisfied from the cache."
11022 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11024 cancel_lru_locks osc
11025 cat $file >/dev/null
11027 if ! let "AFTER - BEFORE == 0"; then
11028 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11030 log "cache hits:: before: $BEFORE, after: $AFTER"
11033 log "Read again; it should be satisfied from the cache."
11035 cancel_lru_locks osc
11036 cat $file >/dev/null
11038 if ! let "AFTER - BEFORE == CPAGES"; then
11039 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11041 log "cache hits:: before: $BEFORE, after: $AFTER"
11045 restore_lustre_params < $p
11048 run_test 156 "Verification of tunables"
11051 cleanup_changelog () {
11053 echo "Deregistering changelog client $CL_USER"
11054 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11058 if [[ $MDSCOUNT -gt 1 ]]; then
11059 error_ignore bz17935 $*
11067 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11069 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11071 if [ $MASK -eq 1 ]; then
11072 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11074 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11078 changelog_extract_field() {
11082 local identifier=$4
11084 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11085 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11091 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11092 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11093 { skip "Need MDS version at least 2.2.0"; return; }
11095 local CL_USERS="mdd.$MDT0.changelog_users"
11096 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11097 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11098 changelog_register -n)
11099 echo "Registered as changelog user $CL_USER"
11100 trap cleanup_changelog EXIT
11101 $GET_CL_USERS | grep -q $CL_USER ||
11102 error "User $CL_USER not found in changelog_users"
11105 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11106 touch $DIR/$tdir/pics/2008/zachy/timestamp
11107 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11108 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11109 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11110 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11111 rm $DIR/$tdir/pics/desktop.jpg
11113 $LFS changelog $MDT0 | tail -5
11115 echo "verifying changelog mask"
11116 changelog_chmask "MKDIR"
11117 changelog_chmask "CLOSE"
11119 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11120 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11122 changelog_chmask "MKDIR"
11123 changelog_chmask "CLOSE"
11125 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11126 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11128 $LFS changelog $MDT0
11129 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11130 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11131 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11132 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11135 echo "verifying target fid"
11136 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11137 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11138 [ "$fidc" == "$fidf" ] ||
11139 err17935 "fid in changelog $fidc != file fid $fidf"
11140 echo "verifying parent fid"
11141 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11142 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11143 [ "$fidc" == "$fidf" ] ||
11144 err17935 "pfid in changelog $fidc != dir fid $fidf"
11146 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11147 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11148 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11149 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11150 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11151 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11153 MIN_REC=$($GET_CL_USERS |
11154 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11155 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11156 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11157 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11158 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11160 # LU-3446 changelog index reset on MDT restart
11161 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11162 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11163 $LFS changelog_clear $MDT0 $CL_USER 0
11164 stop $SINGLEMDS || error "Fail to stop MDT."
11165 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11166 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11167 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11168 [ $CUR_REC1 == $CUR_REC2 ] ||
11169 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11171 echo "verifying user deregister"
11173 $GET_CL_USERS | grep -q $CL_USER &&
11174 error "User $CL_USER still in changelog_users"
11176 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11177 if [ $CL_USER -eq 0 ]; then
11178 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11179 touch $DIR/$tdir/chloe
11180 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11181 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11182 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11184 echo "$CL_USER other changelog users; can't verify off"
11187 run_test 160a "changelog sanity"
11189 test_160b() { # LU-3587
11190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11191 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11192 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11193 { skip "Need MDS version at least 2.2.0"; return; }
11195 local CL_USERS="mdd.$MDT0.changelog_users"
11196 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11197 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11198 changelog_register -n)
11199 echo "Registered as changelog user $CL_USER"
11200 trap cleanup_changelog EXIT
11201 $GET_CL_USERS | grep -q $CL_USER ||
11202 error "User $CL_USER not found in changelog_users"
11204 local LONGNAME1=$(str_repeat a 255)
11205 local LONGNAME2=$(str_repeat b 255)
11208 echo "creating very long named file"
11209 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11210 echo "moving very long named file"
11211 mv $LONGNAME1 $LONGNAME2
11213 $LFS changelog $MDT0 | grep RENME
11217 run_test 160b "Verify that very long rename doesn't crash in changelog"
11220 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11223 local server_version=$(lustre_version_code $SINGLEMDS)
11225 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11226 [[ $server_version -gt $(version_code 2.5.1) &&
11227 $server_version -lt $(version_code 2.5.50) ]] ||
11228 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11231 # Registration step
11232 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11233 changelog_register -n)
11234 trap cleanup_changelog EXIT
11237 mkdir -p $DIR/$tdir
11238 $MCREATE $DIR/$tdir/foo_160c
11239 changelog_chmask "TRUNC"
11240 $TRUNCATE $DIR/$tdir/foo_160c 200
11241 changelog_chmask "TRUNC"
11242 $TRUNCATE $DIR/$tdir/foo_160c 199
11243 $LFS changelog $MDT0
11244 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11245 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11246 $LFS changelog_clear $MDT0 $CL_USER 0
11248 # Deregistration step
11251 run_test 160c "verify that changelog log catch the truncate event"
11254 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11255 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11257 local server_version=$(lustre_version_code mds1)
11258 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11260 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11261 { skip "Need MDS version at least 2.7.60+"; return; }
11262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11264 # Registration step
11265 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11266 changelog_register -n)
11268 trap cleanup_changelog EXIT
11269 mkdir -p $DIR/$tdir/migrate_dir
11270 $LFS changelog_clear $MDT0 $CL_USER 0
11272 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11273 $LFS changelog $MDT0
11274 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11275 $LFS changelog_clear $MDT0 $CL_USER 0
11276 [ $MIGRATES -eq 1 ] ||
11277 error "MIGRATE changelog mask count $MIGRATES != 1"
11279 # Deregistration step
11282 run_test 160d "verify that changelog log catch the migrate event"
11285 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11288 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11289 changelog_register -n)
11290 echo "Registered as changelog user $CL_USER"
11291 trap cleanup_changelog EXIT
11293 # Delete a future user (expect fail)
11294 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11297 if [ $rc -eq 0 ]; then
11298 error "Deleted non-existant user cl77"
11299 elif [ $rc -ne 2 ]; then
11300 error "changelog_deregister failed with $rc, " \
11301 "expected 2 (ENOENT)"
11304 # Clear to a bad index (1 billion should be safe)
11305 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11308 if [ $rc -eq 0 ]; then
11309 error "Successfully cleared to invalid CL index"
11310 elif [ $rc -ne 22 ]; then
11311 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11314 run_test 160e "changelog negative testing"
11317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11318 test_mkdir -c1 $DIR/$tdir
11319 cp /etc/hosts $DIR/$tdir/$tfile
11320 test_mkdir -c1 $DIR/$tdir/foo1
11321 test_mkdir -c1 $DIR/$tdir/foo2
11322 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11323 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11324 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11325 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11326 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11327 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11328 $LFS fid2path $DIR $FID
11329 err17935 "bad link ea"
11332 rm $DIR/$tdir/foo2/zachary
11334 rm $DIR/$tdir/foo2/thor
11336 rm $DIR/$tdir/$tfile
11338 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11339 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11341 $LFS fid2path $DIR $FID
11342 err17935 "bad link rename"
11344 rm $DIR/$tdir/foo2/maggie
11347 local longname=filename_avg_len_is_thirty_two_
11348 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11349 error "failed to hardlink many files"
11350 links=$($LFS fid2path $DIR $FID | wc -l)
11351 echo -n "${links}/1000 links in link EA"
11352 [[ $links -gt 60 ]] ||
11353 err17935 "expected at least 60 links in link EA"
11354 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11355 error "failed to unlink many hardlinks"
11357 run_test 161a "link ea sanity"
11360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11361 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11363 local remote_dir=$DIR/$tdir/remote_dir
11365 mkdir -p $DIR/$tdir
11366 $LFS mkdir -i $MDTIDX $remote_dir ||
11367 error "create remote directory failed"
11369 cp /etc/hosts $remote_dir/$tfile
11370 mkdir -p $remote_dir/foo1
11371 mkdir -p $remote_dir/foo2
11372 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11373 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11374 ln $remote_dir/$tfile $remote_dir/foo1/luna
11375 ln $remote_dir/$tfile $remote_dir/foo2/thor
11377 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11379 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11380 $LFS fid2path $DIR $FID
11381 err17935 "bad link ea"
11384 rm $remote_dir/foo2/zachary
11386 rm $remote_dir/foo2/thor
11388 rm $remote_dir/$tfile
11390 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11391 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11392 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11393 $LFS fid2path $DIR $FID
11394 err17935 "bad link rename"
11396 rm $remote_dir/foo2/maggie
11399 local longname=filename_avg_len_is_thirty_two_
11400 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11401 error "failed to hardlink many files"
11402 links=$($LFS fid2path $DIR $FID | wc -l)
11403 echo -n "${links}/1000 links in link EA"
11404 [[ ${links} -gt 60 ]] ||
11405 err17935 "expected at least 60 links in link EA"
11406 unlinkmany $remote_dir/foo2/$longname 1000 ||
11407 error "failed to unlink many hardlinks"
11409 run_test 161b "link ea sanity under remote directory"
11412 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11414 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11415 skip "Need MDS version at least 2.1.5" && return
11417 # define CLF_RENAME_LAST 0x0001
11418 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11419 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11420 changelog_register -n)
11422 trap cleanup_changelog EXIT
11424 mkdir -p $DIR/$tdir
11425 touch $DIR/$tdir/foo_161c
11426 touch $DIR/$tdir/bar_161c
11427 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11428 $LFS changelog $MDT0 | grep RENME
11429 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11431 $LFS changelog_clear $MDT0 $CL_USER 0
11432 if [ x$flags != "x0x1" ]; then
11433 error "flag $flags is not 0x1"
11435 echo "rename overwrite a target having nlink = 1," \
11436 "changelog record has flags of $flags"
11438 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11439 touch $DIR/$tdir/foo_161c
11440 touch $DIR/$tdir/bar_161c
11441 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11442 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11443 $LFS changelog $MDT0 | grep RENME
11444 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11445 $LFS changelog_clear $MDT0 $CL_USER 0
11446 if [ x$flags != "x0x0" ]; then
11447 error "flag $flags is not 0x0"
11449 echo "rename overwrite a target having nlink > 1," \
11450 "changelog record has flags of $flags"
11452 # rename doesn't overwrite a target (changelog flag 0x0)
11453 touch $DIR/$tdir/foo_161c
11454 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11455 $LFS changelog $MDT0 | grep RENME
11456 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11457 $LFS changelog_clear $MDT0 $CL_USER 0
11458 if [ x$flags != "x0x0" ]; then
11459 error "flag $flags is not 0x0"
11461 echo "rename doesn't overwrite a target," \
11462 "changelog record has flags of $flags"
11464 # define CLF_UNLINK_LAST 0x0001
11465 # unlink a file having nlink = 1 (changelog flag 0x1)
11466 rm -f $DIR/$tdir/foo2_161c
11467 $LFS changelog $MDT0 | grep UNLNK
11468 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11469 $LFS changelog_clear $MDT0 $CL_USER 0
11470 if [ x$flags != "x0x1" ]; then
11471 error "flag $flags is not 0x1"
11473 echo "unlink a file having nlink = 1," \
11474 "changelog record has flags of $flags"
11476 # unlink a file having nlink > 1 (changelog flag 0x0)
11477 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11478 rm -f $DIR/$tdir/foobar_161c
11479 $LFS changelog $MDT0 | grep UNLNK
11480 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11481 $LFS changelog_clear $MDT0 $CL_USER 0
11482 if [ x$flags != "x0x0" ]; then
11483 error "flag $flags is not 0x0"
11485 echo "unlink a file having nlink > 1," \
11486 "changelog record has flags of $flags"
11489 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11496 # cleanup previous run
11497 rm -rf $DIR/$tdir/$tfile
11499 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11500 changelog_register -n)
11501 [[ $? -eq 0 ]] || error "changelog_register failed"
11503 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11504 # interfer with $MOUNT/.lustre/fid/ access
11506 [[ $? -eq 0 ]] || error "mkdir failed"
11508 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11509 $LCTL set_param fail_loc=0x8000140c
11511 $LCTL set_param fail_val=5
11514 echo foofoo > $DIR/$tdir/$tfile &
11517 # wait for create to be delayed
11521 [[ $? -eq 0 ]] || error "create should be blocked"
11523 local tempfile=$(mktemp)
11524 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11525 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11526 # some delay may occur during ChangeLog publishing and file read just
11527 # above, that could allow file write to happen finally
11528 [[ -s $tempfile ]] && echo "file should be empty"
11530 $LCTL set_param fail_loc=0
11533 [[ $? -eq 0 ]] || error "create failed"
11535 $LFS changelog_clear $MDT0 $user 0
11536 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11538 run_test 161d "create with concurrent .lustre/fid access"
11545 local path=$(${LFS} fid2path $*)
11546 # Remove the '//' indicating a remote directory
11547 path=$(echo $path | sed 's#//#/#g')
11550 if [ $RC -ne 0 ]; then
11551 err17935 "path looked up of $expected failed. Error $RC"
11553 elif [ "${path}" != "${expected}" ]; then
11554 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11557 echo "fid $fid resolves to path $path (expected $expected)"
11560 test_162a() { # was test_162
11561 # Make changes to filesystem
11562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11563 test_mkdir -p -c1 $DIR/$tdir/d2
11564 touch $DIR/$tdir/d2/$tfile
11565 touch $DIR/$tdir/d2/x1
11566 touch $DIR/$tdir/d2/x2
11567 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11568 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11570 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11571 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11572 error "check path $tdir/d2/$tfile failed"
11575 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11576 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11577 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11578 error "check path $tdir/d2/p/q/r/slink failed"
11580 # softlink to wrong file
11581 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11582 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11583 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11584 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11587 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11588 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11589 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11590 # fid2path dir/fsname should both work
11591 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11592 error "check path $tdir/d2/a/b/c/new_file failed"
11593 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11594 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11596 # hardlink count: check that there are 2 links
11597 # Doesnt work with CMD yet: 17935
11598 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11599 err17935 "expected 2 links"
11601 # hardlink indexing: remove the first link
11602 rm $DIR/$tdir/d2/p/q/r/hlink
11603 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11604 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11608 run_test 162a "path lookup sanity"
11611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11615 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11616 error "create striped dir failed"
11618 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11619 tail -n 1 | awk '{print $2}')
11620 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11622 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11623 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11626 for ((i=0;i<5;i++)); do
11627 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11628 error "get fid for f$i failed"
11629 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11630 error "check path $tdir/striped_dir/f$i failed"
11632 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11633 error "get fid for d$i failed"
11634 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11635 error "check path $tdir/striped_dir/d$i failed"
11640 run_test 162b "striped directory path lookup sanity"
11642 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11644 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11645 skip "Need MDS version at least 2.7.51" && return
11646 test_mkdir $DIR/$tdir.local
11647 test_mkdir $DIR/$tdir.remote
11648 local lpath=$tdir.local
11649 local rpath=$tdir.remote
11651 for ((i = 0; i <= 101; i++)); do
11654 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11655 error "get fid for local directory $DIR/$lpath failed"
11656 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11657 error "check path for local directory $DIR/$lpath failed"
11660 test_mkdir $DIR/$rpath
11661 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11662 error "get fid for remote directory $DIR/$rpath failed"
11663 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11664 error "check path for remote directory $DIR/$rpath failed"
11669 run_test 162c "fid2path works with paths 100 or more directories deep"
11672 # do directio so as not to populate the page cache
11673 log "creating a 10 Mb file"
11674 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11675 log "starting reads"
11676 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11677 log "truncating the file"
11678 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11680 kill %+ || true # reads might have finished
11681 echo "wait until dd is finished"
11683 log "removing the temporary file"
11684 rm -rf $DIR/$tfile || error "tmp file removal failed"
11686 run_test 169 "parallel read and truncate should not deadlock"
11689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11690 $LCTL clear # bug 18514
11691 $LCTL debug_daemon start $TMP/${tfile}_log_good
11693 $LCTL debug_daemon stop
11694 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11695 error "sed failed to read log_good"
11697 $LCTL debug_daemon start $TMP/${tfile}_log_good
11699 $LCTL debug_daemon stop
11701 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11702 error "lctl df log_bad failed"
11704 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11705 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11707 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11708 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11710 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11711 error "bad_line good_line1 good_line2 are empty"
11713 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11714 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11715 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11717 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11718 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11719 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11721 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11722 error "bad_line_new good_line_new are empty"
11724 local expected_good=$((good_line1 + good_line2*2))
11726 rm -f $TMP/${tfile}*
11727 # LU-231, short malformed line may not be counted into bad lines
11728 if [ $bad_line -ne $bad_line_new ] &&
11729 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11730 error "expected $bad_line bad lines, but got $bad_line_new"
11734 if [ $expected_good -ne $good_line_new ]; then
11735 error "expected $expected_good good lines, but got $good_line_new"
11740 run_test 170 "test lctl df to handle corrupted log ====================="
11742 test_171() { # bug20592
11743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11744 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11745 $LCTL set_param fail_loc=0x50e
11746 $LCTL set_param fail_val=3000
11747 multiop_bg_pause $DIR/$tfile O_s || true
11749 kill -USR1 $MULTIPID
11753 if dmesg | grep "recursive fault"; then
11754 error "caught a recursive fault"
11756 $LCTL set_param fail_loc=0
11759 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11761 # it would be good to share it with obdfilter-survey/iokit-libecho code
11762 setup_obdecho_osc () {
11765 local obdfilter_name=$2
11766 echo "Creating new osc for $obdfilter_name on $ost_nid"
11767 # make sure we can find loopback nid
11768 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11770 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11771 ${obdfilter_name}_osc_UUID || rc=2; }
11772 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11773 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11777 cleanup_obdecho_osc () {
11778 local obdfilter_name=$1
11779 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11780 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11787 local pages=${3:-64}
11792 local obd_size=$(get_obd_size $node $OBD)
11793 local page_size=$(get_page_size $node)
11794 if [[ -n "$obd_size" ]]; then
11795 local new_count=$((obd_size / (pages * page_size / 1024)))
11796 [[ $new_count -ge $count ]] || count=$new_count
11799 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11800 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11802 if [ $rc -eq 0 ]; then
11803 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11804 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11806 echo "New object id is $id"
11807 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11809 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11810 "test_brw $count w v $pages $id" || rc=4; }
11811 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11813 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11814 "cleanup" || rc=5; }
11815 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11816 "detach" || rc=6; }
11817 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11823 remote_ost_nodsh && skip "remote OST with nodsh" && return
11825 local rmmod_local=0
11827 if ! module_loaded obdecho; then
11828 load_module obdecho/obdecho
11832 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11833 local host=$(lctl get_param -n osc.$osc.import |
11834 awk '/current_connection:/ {print $2}' )
11835 local target=$(lctl get_param -n osc.$osc.import |
11836 awk '/target:/ {print $2}' )
11837 target=${target%_UUID}
11839 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11840 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11841 [[ -n $target ]] && cleanup_obdecho_osc $target
11842 [ $rmmod_local -eq 1 ] && rmmod obdecho
11845 run_test 180a "test obdecho on osc"
11848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11849 remote_ost_nodsh && skip "remote OST with nodsh" && return
11851 local rmmod_remote=0
11853 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11854 rmmod_remote=true || error "failed to load module obdecho"
11855 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11856 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11857 $rmmod_remote && do_facet ost1 "rmmod obdecho"
11860 run_test 180b "test obdecho directly on obdfilter"
11862 test_180c() { # LU-2598
11863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11864 remote_ost_nodsh && skip "remote OST with nodsh" && return
11865 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11866 skip "Need MDS version at least 2.4.0" && return
11869 local rmmod_remote=false
11870 local pages=16384 # 64MB bulk I/O RPC size
11873 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11874 rmmod_remote=true || error "failed to load module obdecho"
11876 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11878 if [ -n "$target" ]; then
11879 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11881 echo "there is no obdfilter target on ost1"
11884 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11887 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11889 test_181() { # bug 22177
11890 test_mkdir $DIR/$tdir
11891 # create enough files to index the directory
11892 createmany -o $DIR/$tdir/foobar 4000
11893 # print attributes for debug purpose
11896 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11898 # remove the files & current working dir
11899 unlinkmany $DIR/$tdir/foobar 4000
11901 kill -USR1 $MULTIPID
11903 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11906 run_test 181 "Test open-unlinked dir ========================"
11912 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11914 $LCTL set_param mdc.*.rpc_stats=clear
11916 for (( i = 0; i < $tcount; i++ )) ; do
11917 mkdir $DIR/$tdir/$i
11920 for (( i = 0; i < $tcount; i++ )) ; do
11921 createmany -o $DIR/$tdir/$i/f- $fcount &
11925 for (( i = 0; i < $tcount; i++ )) ; do
11926 unlinkmany $DIR/$tdir/$i/f- $fcount &
11930 $LCTL get_param mdc.*.rpc_stats
11934 run_test 182 "Test parallel modify metadata operations ================"
11936 test_183() { # LU-2275
11937 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11938 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11939 skip "Need MDS version at least 2.3.56" && return
11941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11942 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11943 echo aaa > $DIR/$tdir/$tfile
11945 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11946 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11948 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11949 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11951 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11953 # Flush negative dentry cache
11954 touch $DIR/$tdir/$tfile
11956 # We are not checking for any leaked references here, they'll
11957 # become evident next time we do cleanup with module unload.
11960 run_test 183 "No crash or request leak in case of strange dispositions ========"
11962 # test suite 184 is for LU-2016, LU-2017
11964 check_swap_layouts_support && return 0
11966 dir0=$DIR/$tdir/$testnum
11967 test_mkdir -p -c1 $dir0
11972 $SETSTRIPE -c1 $file1
11974 $SETSTRIPE -c2 $file2
11976 gen1=$($GETSTRIPE -g $file1)
11977 gen2=$($GETSTRIPE -g $file2)
11979 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11980 gen=$($GETSTRIPE -g $file1)
11981 [[ $gen1 != $gen ]] ||
11982 "Layout generation on $file1 does not change"
11983 gen=$($GETSTRIPE -g $file2)
11984 [[ $gen2 != $gen ]] ||
11985 "Layout generation on $file2 does not change"
11987 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11988 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11990 run_test 184a "Basic layout swap"
11993 check_swap_layouts_support && return 0
11995 dir0=$DIR/$tdir/$testnum
11996 mkdir -p $dir0 || error "creating dir $dir0"
12003 $SETSTRIPE -c1 $file1
12004 $SETSTRIPE -c2 $file2
12005 $SETSTRIPE -c1 $file3
12006 chown $RUNAS_ID $file3
12007 gen1=$($GETSTRIPE -g $file1)
12008 gen2=$($GETSTRIPE -g $file2)
12010 $LFS swap_layouts $dir1 $dir2 &&
12011 error "swap of directories layouts should fail"
12012 $LFS swap_layouts $dir1 $file1 &&
12013 error "swap of directory and file layouts should fail"
12014 $RUNAS $LFS swap_layouts $file1 $file2 &&
12015 error "swap of file we cannot write should fail"
12016 $LFS swap_layouts $file1 $file3 &&
12017 error "swap of file with different owner should fail"
12018 /bin/true # to clear error code
12020 run_test 184b "Forbidden layout swap (will generate errors)"
12023 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12024 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12025 check_swap_layouts_support && return 0
12027 local dir0=$DIR/$tdir/$testnum
12028 mkdir -p $dir0 || error "creating dir $dir0"
12030 local ref1=$dir0/ref1
12031 local ref2=$dir0/ref2
12032 local file1=$dir0/file1
12033 local file2=$dir0/file2
12034 # create a file large enough for the concurrent test
12035 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12036 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12037 echo "ref file size: ref1($(stat -c %s $ref1))," \
12038 "ref2($(stat -c %s $ref2))"
12041 dd if=$ref1 of=$file1 bs=16k &
12044 # Make sure dd starts to copy file
12045 while [ ! -f $file1 ]; do sleep 0.1; done
12047 $LFS swap_layouts $file1 $file2
12050 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12051 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12053 # how many bytes copied before swapping layout
12054 local copied=$(stat -c %s $file2)
12055 local remaining=$(stat -c %s $ref1)
12056 remaining=$((remaining - copied))
12057 echo "Copied $copied bytes before swapping layout..."
12059 cmp -n $copied $file1 $ref2 | grep differ &&
12060 error "Content mismatch [0, $copied) of ref2 and file1"
12061 cmp -n $copied $file2 $ref1 ||
12062 error "Content mismatch [0, $copied) of ref1 and file2"
12063 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12064 error "Content mismatch [$copied, EOF) of ref1 and file1"
12067 rm -f $ref1 $ref2 $file1 $file2
12069 run_test 184c "Concurrent write and layout swap"
12072 check_swap_layouts_support && return 0
12073 [ -z "$(which getfattr 2>/dev/null)" ] &&
12074 skip "no getfattr command" && return 0
12076 local file1=$DIR/$tdir/$tfile-1
12077 local file2=$DIR/$tdir/$tfile-2
12078 local file3=$DIR/$tdir/$tfile-3
12082 mkdir -p $DIR/$tdir
12083 touch $file1 || error "create $file1 failed"
12084 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12085 error "create $file2 failed"
12086 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12087 error "create $file3 failed"
12088 lovea1=$(get_layout_param $file1)
12090 $LFS swap_layouts $file2 $file3 ||
12091 error "swap $file2 $file3 layouts failed"
12092 $LFS swap_layouts $file1 $file2 ||
12093 error "swap $file1 $file2 layouts failed"
12095 lovea2=$(get_layout_param $file2)
12098 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12100 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12101 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12103 run_test 184d "allow stripeless layouts swap"
12106 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12107 { skip "Need MDS version at least 2.6.94"; return 0; }
12108 check_swap_layouts_support && return 0
12109 [ -z "$(which getfattr 2>/dev/null)" ] &&
12110 skip "no getfattr command" && return 0
12112 local file1=$DIR/$tdir/$tfile-1
12113 local file2=$DIR/$tdir/$tfile-2
12114 local file3=$DIR/$tdir/$tfile-3
12117 mkdir -p $DIR/$tdir
12118 touch $file1 || error "create $file1 failed"
12119 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12120 error "create $file2 failed"
12121 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12122 error "create $file3 failed"
12124 $LFS swap_layouts $file1 $file2 ||
12125 error "swap $file1 $file2 layouts failed"
12127 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12128 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12130 echo 123 > $file1 || error "Should be able to write into $file1"
12132 $LFS swap_layouts $file1 $file3 ||
12133 error "swap $file1 $file3 layouts failed"
12135 echo 123 > $file1 || error "Should be able to write into $file1"
12137 rm -rf $file1 $file2 $file3
12139 run_test 184e "Recreate layout after stripeless layout swaps"
12141 test_185() { # LU-2441
12142 # LU-3553 - no volatile file support in old servers
12143 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12144 { skip "Need MDS version at least 2.3.60"; return 0; }
12146 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12147 touch $DIR/$tdir/spoo
12148 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12149 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12150 error "cannot create/write a volatile file"
12151 [ "$FILESET" == "" ] &&
12152 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12153 error "FID is still valid after close"
12155 multiop_bg_pause $DIR/$tdir vVw4096_c
12162 # assume that the next FID for this client is sequential, since stdout
12163 # is unfortunately eaten by multiop_bg_pause
12164 local n=$((${fidv[1]} + 1))
12165 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12166 if [ "$FILESET" == "" ]; then
12167 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12168 error "FID is missing before close"
12170 kill -USR1 $multi_pid
12171 # 1 second delay, so if mtime change we will see it
12173 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12174 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12176 run_test 185 "Volatile file support"
12179 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12180 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12181 skip "Need MDS version at least 2.3.0" && return
12183 local dir0=$DIR/$tdir/$testnum
12184 mkdir -p $dir0 || error "creating dir $dir0"
12186 local file=$dir0/file1
12187 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12188 local dv1=$($LFS data_version $file)
12189 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12190 local dv2=$($LFS data_version $file)
12191 [[ $dv1 != $dv2 ]] ||
12192 error "data version did not change on write $dv1 == $dv2"
12197 run_test 187a "Test data version change"
12200 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12201 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12202 skip "Need MDS version at least 2.3.0" && return
12204 local dir0=$DIR/$tdir/$testnum
12205 mkdir -p $dir0 || error "creating dir $dir0"
12207 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12208 [[ ${DV[0]} != ${DV[1]} ]] ||
12209 error "data version did not change on write"\
12210 " ${DV[0]} == ${DV[1]}"
12215 run_test 187b "Test data version change on volatile file"
12218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12219 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12220 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12222 local POOL=${POOL:-cea1}
12223 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12224 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12227 local last_ost=$(($OSTCOUNT - 1))
12229 local ost_list=$(seq $first_ost $ost_step $last_ost)
12230 local ost_range="$first_ost $last_ost $ost_step"
12231 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12232 local file_dir=$POOL_ROOT/file_tst
12233 local subdir=$test_path/subdir
12237 # former test_200a test_200b
12238 pool_add $POOL || { rc=$? ; break; }
12239 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12240 # former test_200c test_200d
12241 mkdir -p $test_path
12242 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12243 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12245 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12246 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12247 || { rc=$? ; break; }
12248 # former test_200e test_200f
12249 local files=$((OSTCOUNT*3))
12250 pool_alloc_files $POOL $test_path $files "$ost_list" \
12251 || { rc=$? ; break; }
12252 pool_create_files $POOL $file_dir $files "$ost_list" \
12253 || { rc=$? ; break; }
12254 # former test_200g test_200h
12255 pool_lfs_df $POOL || { rc=$? ; break; }
12256 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12258 # former test_201a test_201b test_201c
12259 pool_remove_first_target $POOL || { rc=$? ; break; }
12261 local f=$test_path/$tfile
12262 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12263 pool_remove $POOL $f || { rc=$? ; break; }
12270 run_test 200 "OST pools"
12272 # usage: default_attr <count | size | offset>
12274 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12277 # usage: check_default_stripe_attr
12278 check_default_stripe_attr() {
12279 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12282 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12284 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12288 error "unknown getstripe attr '$1'"
12291 [ $ACTUAL == $EXPECTED ] ||
12292 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12296 test_mkdir $DIR/$tdir
12297 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12299 check_default_stripe_attr --stripe-count
12300 check_default_stripe_attr --stripe-size
12301 check_default_stripe_attr --stripe-index
12303 run_test 204a "Print default stripe attributes"
12306 test_mkdir $DIR/$tdir
12307 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12309 check_default_stripe_attr --stripe-size
12310 check_default_stripe_attr --stripe-index
12312 run_test 204b "Print default stripe size and offset"
12315 test_mkdir $DIR/$tdir
12316 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12318 check_default_stripe_attr --stripe-count
12319 check_default_stripe_attr --stripe-index
12321 run_test 204c "Print default stripe count and offset"
12324 test_mkdir $DIR/$tdir
12325 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12327 check_default_stripe_attr --stripe-count
12328 check_default_stripe_attr --stripe-size
12330 run_test 204d "Print default stripe count and size"
12333 test_mkdir $DIR/$tdir
12334 $SETSTRIPE -d $DIR/$tdir
12336 check_default_stripe_attr --stripe-count --raw
12337 check_default_stripe_attr --stripe-size --raw
12338 check_default_stripe_attr --stripe-index --raw
12340 run_test 204e "Print raw stripe attributes"
12343 test_mkdir $DIR/$tdir
12344 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12346 check_default_stripe_attr --stripe-size --raw
12347 check_default_stripe_attr --stripe-index --raw
12349 run_test 204f "Print raw stripe size and offset"
12352 test_mkdir $DIR/$tdir
12353 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12355 check_default_stripe_attr --stripe-count --raw
12356 check_default_stripe_attr --stripe-index --raw
12358 run_test 204g "Print raw stripe count and offset"
12361 test_mkdir $DIR/$tdir
12362 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12364 check_default_stripe_attr --stripe-count --raw
12365 check_default_stripe_attr --stripe-size --raw
12367 run_test 204h "Print raw stripe count and size"
12369 # Figure out which job scheduler is being used, if any,
12370 # or use a fake one
12371 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12372 JOBENV=SLURM_JOB_ID
12373 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12375 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12377 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12378 JOBENV=LOADL_STEP_ID
12379 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12382 $LCTL list_param jobid_name > /dev/null 2>&1
12383 if [ $? -eq 0 ]; then
12390 verify_jobstats() {
12395 # we don't really need to clear the stats for this test to work, since each
12396 # command has a unique jobid, but it makes debugging easier if needed.
12397 # for facet in $facets; do
12398 # local dev=$(convert_facet2label $facet)
12399 # # clear old jobstats
12400 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12403 # use a new JobID for each test, or we might see an old one
12404 [ "$JOBENV" = "FAKE_JOBID" ] &&
12405 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12409 [ "$JOBENV" = "nodelocal" ] && {
12410 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12411 $LCTL set_param jobid_name=$FAKE_JOBID
12415 log "Test: ${cmd[*]}"
12416 log "Using JobID environment variable $JOBENV=$JOBVAL"
12418 if [ $JOBENV = "FAKE_JOBID" ]; then
12419 FAKE_JOBID=$JOBVAL ${cmd[*]}
12424 # all files are created on OST0000
12425 for facet in $facets; do
12426 local stats="*.$(convert_facet2label $facet).job_stats"
12427 if [ $(do_facet $facet lctl get_param $stats |
12428 grep -c $JOBVAL) -ne 1 ]; then
12429 do_facet $facet lctl get_param $stats
12430 error "No jobstats for $JOBVAL found on $facet::$stats"
12437 NEW_JOBENV=${1:-$OLD_JOBENV}
12438 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12439 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12444 do_facet $SINGLEMDS \
12445 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12446 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12450 test_205() { # Job stats
12451 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12452 { skip "Need MDS version with at least 2.7.1"; return 0; }
12454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12455 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12457 remote_ost_nodsh && skip "remote OST with nodsh" && return
12459 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12460 skip "Server doesn't support jobstats" && return 0
12461 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12463 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12464 if [ $OLD_JOBENV != $JOBENV ]; then
12465 jobstats_set $JOBENV
12466 trap cleanup_205 EXIT
12469 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12470 echo "Registered as changelog user $CL_USER"
12472 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12473 lctl get_param -n mdt.*.job_cleanup_interval)
12474 local interval_new=5
12475 do_facet $SINGLEMDS \
12476 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12477 local start=$SECONDS
12481 cmd="mkdir $DIR/$tdir"
12482 verify_jobstats "$cmd" "$SINGLEMDS"
12484 cmd="rmdir $DIR/$tdir"
12485 verify_jobstats "$cmd" "$SINGLEMDS"
12486 # mkdir on secondary MDT
12487 if [ $MDSCOUNT -gt 1 ]; then
12488 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12489 verify_jobstats "$cmd" "mds2"
12492 cmd="mknod $DIR/$tfile c 1 3"
12493 verify_jobstats "$cmd" "$SINGLEMDS"
12495 cmd="rm -f $DIR/$tfile"
12496 verify_jobstats "$cmd" "$SINGLEMDS"
12497 # create all files on OST0000 so verify_jobstats can find OST stats
12499 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12500 verify_jobstats "$cmd" "$SINGLEMDS"
12502 cmd="touch $DIR/$tfile"
12503 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12505 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12506 verify_jobstats "$cmd" "ost1"
12508 cancel_lru_locks osc
12509 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12510 verify_jobstats "$cmd" "ost1"
12512 cmd="$TRUNCATE $DIR/$tfile 0"
12513 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12515 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12516 verify_jobstats "$cmd" "$SINGLEMDS"
12517 # jobstats expiry - sleep until old stats should be expired
12518 local left=$((interval_new + 5 - (SECONDS - start)))
12519 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12520 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12522 cmd="mkdir $DIR/$tdir.expire"
12523 verify_jobstats "$cmd" "$SINGLEMDS"
12524 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12525 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12527 # Ensure that jobid are present in changelog (if supported by MDS)
12528 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12530 $LFS changelog $MDT0 | tail -9
12531 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12532 [ $jobids -eq 9 ] ||
12533 error "Wrong changelog jobid count $jobids != 9"
12537 jobstats_set $JOBENV
12539 $LFS changelog $MDT0 | tail -1
12540 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12541 [ $jobids -eq 0 ] ||
12542 error "Unexpected jobids when jobid_var=$JOBENV"
12547 run_test 205 "Verify job stats"
12549 # LU-1480, LU-1773 and LU-1657
12551 mkdir -p $DIR/$tdir
12552 $SETSTRIPE -c -1 $DIR/$tdir
12553 #define OBD_FAIL_LOV_INIT 0x1403
12554 $LCTL set_param fail_loc=0xa0001403
12555 $LCTL set_param fail_val=1
12556 touch $DIR/$tdir/$tfile || true
12558 run_test 206 "fail lov_init_raid0() doesn't lbug"
12561 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12562 local fsz=`stat -c %s $DIR/$tfile`
12563 cancel_lru_locks mdc
12565 # do not return layout in getattr intent
12566 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12567 $LCTL set_param fail_loc=0x170
12568 local sz=`stat -c %s $DIR/$tfile`
12570 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12574 run_test 207a "can refresh layout at glimpse"
12577 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12578 local cksum=`md5sum $DIR/$tfile`
12579 local fsz=`stat -c %s $DIR/$tfile`
12580 cancel_lru_locks mdc
12581 cancel_lru_locks osc
12583 # do not return layout in getattr intent
12584 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12585 $LCTL set_param fail_loc=0x171
12587 # it will refresh layout after the file is opened but before read issues
12588 echo checksum is "$cksum"
12589 echo "$cksum" |md5sum -c --quiet || error "file differs"
12593 run_test 207b "can refresh layout at open"
12596 # FIXME: in this test suite, only RD lease is used. This is okay
12597 # for now as only exclusive open is supported. After generic lease
12598 # is done, this test suite should be revised. - Jinshan
12600 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12601 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12602 { skip "Need MDS version at least 2.4.52"; return 0; }
12604 echo "==== test 1: verify get lease work"
12605 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12607 echo "==== test 2: verify lease can be broken by upcoming open"
12608 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12612 $MULTIOP $DIR/$tfile oO_RDONLY:c
12613 kill -USR1 $PID && wait $PID || error "break lease error"
12615 echo "==== test 3: verify lease can't be granted if an open already exists"
12616 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12620 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12621 kill -USR1 $PID && wait $PID || error "open file error"
12623 echo "==== test 4: lease can sustain over recovery"
12624 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12630 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12632 echo "==== test 5: lease broken can't be regained by replay"
12633 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12637 # open file to break lease and then recovery
12638 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12641 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12645 run_test 208 "Exclusive open"
12648 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12649 skip_env "must have disp_stripe" && return
12652 sync; sleep 5; sync;
12654 echo 3 > /proc/sys/vm/drop_caches
12655 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12657 # open/close 500 times
12658 for i in $(seq 500); do
12662 echo 3 > /proc/sys/vm/drop_caches
12663 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12665 echo "before: $req_before, after: $req_after"
12666 [ $((req_after - req_before)) -ge 300 ] &&
12667 error "open/close requests are not freed"
12670 run_test 209 "read-only open/close requests should be freed promptly"
12674 size=$((size % 8192 + 1))
12675 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12676 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12677 rm -f $DIR/f212 $DIR/f212.xyz
12679 run_test 212 "Sendfile test ============================================"
12682 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12683 cancel_lru_locks osc
12684 lctl set_param fail_loc=0x8000040f
12685 # generate a read lock
12686 cat $DIR/$tfile > /dev/null
12687 # write to the file, it will try to cancel the above read lock.
12688 cat /etc/hosts >> $DIR/$tfile
12690 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12692 test_214() { # for bug 20133
12693 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12694 for (( i=0; i < 340; i++ )) ; do
12695 touch $DIR/$tdir/d214c/a$i
12698 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12699 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12700 ls $DIR/d214c || error "ls $DIR/d214c failed"
12701 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12702 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12704 run_test 214 "hash-indexed directory test - bug 20133"
12706 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12707 create_lnet_proc_files() {
12708 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
12711 # counterpart of create_lnet_proc_files
12712 remove_lnet_proc_files() {
12713 rm -f $TMP/lnet_$1.sys
12716 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12717 # 3rd arg as regexp for body
12718 check_lnet_proc_stats() {
12719 local l=$(cat "$TMP/lnet_$1" |wc -l)
12720 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12722 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12725 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12726 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12727 # optional and can be regexp for 2nd line (lnet.routes case)
12728 check_lnet_proc_entry() {
12729 local blp=2 # blp stands for 'position of 1st line of body'
12730 [ -z "$5" ] || blp=3 # lnet.routes case
12732 local l=$(cat "$TMP/lnet_$1" |wc -l)
12733 # subtracting one from $blp because the body can be empty
12734 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12736 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12737 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12739 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12740 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12742 # bail out if any unexpected line happened
12743 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12744 [ "$?" != 0 ] || error "$2 misformatted"
12747 test_215() { # for bugs 18102, 21079, 21517
12748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12749 local N='(0|[1-9][0-9]*)' # non-negative numeric
12750 local P='[1-9][0-9]*' # positive numeric
12751 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12752 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12753 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12754 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12756 local L1 # regexp for 1st line
12757 local L2 # regexp for 2nd line (optional)
12758 local BR # regexp for the rest (body)
12760 # lnet.stats should look as 11 space-separated non-negative numerics
12761 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12762 create_lnet_proc_files "stats"
12763 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12764 remove_lnet_proc_files "stats"
12766 # lnet.routes should look like this:
12767 # Routing disabled/enabled
12768 # net hops priority state router
12769 # where net is a string like tcp0, hops > 0, priority >= 0,
12770 # state is up/down,
12771 # router is a string like 192.168.1.1@tcp2
12772 L1="^Routing (disabled|enabled)$"
12773 L2="^net +hops +priority +state +router$"
12774 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12775 create_lnet_proc_files "routes"
12776 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12777 remove_lnet_proc_files "routes"
12779 # lnet.routers should look like this:
12780 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12781 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12782 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12783 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12784 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12785 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12786 create_lnet_proc_files "routers"
12787 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12788 remove_lnet_proc_files "routers"
12790 # lnet.peers should look like this:
12791 # nid refs state last max rtr min tx min queue
12792 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12793 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12794 # numeric (0 or >0 or <0), queue >= 0.
12795 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12796 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12797 create_lnet_proc_files "peers"
12798 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12799 remove_lnet_proc_files "peers"
12801 # lnet.buffers should look like this:
12802 # pages count credits min
12803 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12804 L1="^pages +count +credits +min$"
12805 BR="^ +$N +$N +$I +$I$"
12806 create_lnet_proc_files "buffers"
12807 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12808 remove_lnet_proc_files "buffers"
12810 # lnet.nis should look like this:
12811 # nid status alive refs peer rtr max tx min
12812 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12813 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12814 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12815 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12816 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12817 create_lnet_proc_files "nis"
12818 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12819 remove_lnet_proc_files "nis"
12821 # can we successfully write to lnet.stats?
12822 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12824 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12826 test_216() { # bug 20317
12827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12828 remote_ost_nodsh && skip "remote OST with nodsh" && return
12831 local facets=$(get_facets OST)
12832 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12834 save_lustre_params client "osc.*.contention_seconds" > $p
12835 save_lustre_params $facets \
12836 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12837 save_lustre_params $facets \
12838 "ldlm.namespaces.filter-*.contended_locks" >> $p
12839 save_lustre_params $facets \
12840 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12841 clear_stats osc.*.osc_stats
12843 # agressive lockless i/o settings
12844 do_nodes $(comma_list $(osts_nodes)) \
12845 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
12846 ldlm.namespaces.filter-*.contended_locks=0 \
12847 ldlm.namespaces.filter-*.contention_seconds=60"
12848 lctl set_param -n osc.*.contention_seconds=60
12850 $DIRECTIO write $DIR/$tfile 0 10 4096
12851 $CHECKSTAT -s 40960 $DIR/$tfile
12853 # disable lockless i/o
12854 do_nodes $(comma_list $(osts_nodes)) \
12855 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
12856 ldlm.namespaces.filter-*.contended_locks=32 \
12857 ldlm.namespaces.filter-*.contention_seconds=0"
12858 lctl set_param -n osc.*.contention_seconds=0
12859 clear_stats osc.*.osc_stats
12861 dd if=/dev/zero of=$DIR/$tfile count=0
12862 $CHECKSTAT -s 0 $DIR/$tfile
12864 restore_lustre_params <$p
12868 run_test 216 "check lockless direct write updates file size and kms correctly"
12870 test_217() { # bug 22430
12871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12875 for node in $(nodes_list); do
12876 nid=$(host_nids_address $node $NETTYPE)
12877 if [[ $nid = *-* ]] ; then
12878 echo "lctl ping $(h2nettype $nid)"
12879 lctl ping $(h2nettype $nid)
12881 echo "skipping $node (no hyphen detected)"
12885 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12888 # do directio so as not to populate the page cache
12889 log "creating a 10 Mb file"
12890 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12891 log "starting reads"
12892 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12893 log "truncating the file"
12894 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12896 kill %+ || true # reads might have finished
12897 echo "wait until dd is finished"
12899 log "removing the temporary file"
12900 rm -rf $DIR/$tfile || error "tmp file removal failed"
12902 run_test 218 "parallel read and truncate should not deadlock ======================="
12905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12906 # write one partial page
12907 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12908 # set no grant so vvp_io_commit_write will do sync write
12909 $LCTL set_param fail_loc=0x411
12910 # write a full page at the end of file
12911 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12913 $LCTL set_param fail_loc=0
12914 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12915 $LCTL set_param fail_loc=0x411
12916 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12919 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12920 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12922 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12924 test_220() { #LU-325
12925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12926 remote_ost_nodsh && skip "remote OST with nodsh" && return
12927 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12928 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12931 # create on MDT0000 so the last_id and next_id are correct
12933 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12937 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12938 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12939 osc.$mdtosc_proc1.prealloc_last_id)
12940 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12941 osc.$mdtosc_proc1.prealloc_next_id)
12945 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12946 #define OBD_FAIL_OST_ENOINO 0x229
12947 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12948 create_pool $FSNAME.$TESTNAME || return 1
12949 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12951 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12953 MDSOBJS=$((last_id - next_id))
12954 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12956 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12957 echo "OST still has $count kbytes free"
12959 echo "create $MDSOBJS files @next_id..."
12960 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12962 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12963 osc.$mdtosc_proc1.prealloc_last_id)
12964 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12965 osc.$mdtosc_proc1.prealloc_next_id)
12967 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12972 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12973 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12975 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12976 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12977 echo "unlink $MDSOBJS files @$next_id..."
12978 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12980 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12984 dd if=`which date` of=$MOUNT/date oflag=sync
12985 chmod +x $MOUNT/date
12987 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12988 $LCTL set_param fail_loc=0x80001401
12990 $MOUNT/date > /dev/null
12993 run_test 221 "make sure fault and truncate race to not cause OOM"
12996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12998 test_mkdir $DIR/$tdir
12999 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13000 createmany -o $DIR/$tdir/$tfile 10
13001 cancel_lru_locks mdc
13002 cancel_lru_locks osc
13003 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13004 $LCTL set_param fail_loc=0x31a
13005 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13006 $LCTL set_param fail_loc=0
13009 run_test 222a "AGL for ls should not trigger CLIO lock failure"
13012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13014 test_mkdir $DIR/$tdir
13015 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13016 createmany -o $DIR/$tdir/$tfile 10
13017 cancel_lru_locks mdc
13018 cancel_lru_locks osc
13019 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13020 $LCTL set_param fail_loc=0x31a
13021 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13022 $LCTL set_param fail_loc=0
13024 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
13027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13029 test_mkdir $DIR/$tdir
13030 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13031 createmany -o $DIR/$tdir/$tfile 10
13032 cancel_lru_locks mdc
13033 cancel_lru_locks osc
13034 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13035 $LCTL set_param fail_loc=0x31b
13036 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13037 $LCTL set_param fail_loc=0
13040 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13042 test_224a() { # LU-1039, MRP-303
13043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13044 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13045 $LCTL set_param fail_loc=0x508
13046 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13047 $LCTL set_param fail_loc=0
13050 run_test 224a "Don't panic on bulk IO failure"
13052 test_224b() { # LU-1039, MRP-303
13053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13054 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13055 cancel_lru_locks osc
13056 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13057 $LCTL set_param fail_loc=0x515
13058 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13059 $LCTL set_param fail_loc=0
13062 run_test 224b "Don't panic on bulk IO failure"
13064 test_224c() { # LU-6441
13065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13066 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13068 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13069 save_writethrough $p
13070 set_cache writethrough on
13072 local pages_per_rpc=$($LCTL get_param \
13073 osc.*.max_pages_per_rpc)
13074 local at_max=$($LCTL get_param -n at_max)
13075 local timeout=$($LCTL get_param -n timeout)
13076 local test_at="$LCTL get_param -n at_max"
13077 local param_at="$FSNAME.sys.at_max"
13078 local test_timeout="$LCTL get_param -n timeout"
13079 local param_timeout="$FSNAME.sys.timeout"
13081 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13083 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13084 error "conf_param at_max=0 failed"
13085 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13086 error "conf_param timeout=5 failed"
13088 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13089 do_facet ost1 $LCTL set_param fail_loc=0x520
13090 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13091 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13093 do_facet ost1 $LCTL set_param fail_loc=0
13095 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13096 error "conf_param at_max=$at_max failed"
13097 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13098 $timeout || error "conf_param timeout=$timeout failed"
13100 $LCTL set_param -n $pages_per_rpc
13101 restore_lustre_params < $p
13104 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13106 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13109 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13110 if [ -z ${MDSSURVEY} ]; then
13111 skip_env "mds-survey not found" && return
13114 [ $MDSCOUNT -ge 2 ] &&
13115 skip "skipping now for more than one MDT" && return
13117 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13118 { skip "Need MDS version at least 2.2.51"; return; }
13120 local mds=$(facet_host $SINGLEMDS)
13121 local target=$(do_nodes $mds 'lctl dl' | \
13122 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13124 local cmd1="file_count=1000 thrhi=4"
13125 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13126 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13127 local cmd="$cmd1 $cmd2 $cmd3"
13129 rm -f ${TMP}/mds_survey*
13131 eval $cmd || error "mds-survey with zero-stripe failed"
13132 cat ${TMP}/mds_survey*
13133 rm -f ${TMP}/mds_survey*
13135 run_test 225a "Metadata survey sanity with zero-stripe"
13138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13139 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13140 if [ -z ${MDSSURVEY} ]; then
13141 skip_env "mds-survey not found" && return
13143 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13144 { skip "Need MDS version at least 2.2.51"; return; }
13146 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13147 skip_env "Need to mount OST to test" && return
13150 [ $MDSCOUNT -ge 2 ] &&
13151 skip "skipping now for more than one MDT" && return
13152 local mds=$(facet_host $SINGLEMDS)
13153 local target=$(do_nodes $mds 'lctl dl' | \
13154 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13156 local cmd1="file_count=1000 thrhi=4"
13157 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13158 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13159 local cmd="$cmd1 $cmd2 $cmd3"
13161 rm -f ${TMP}/mds_survey*
13163 eval $cmd || error "mds-survey with stripe_count failed"
13164 cat ${TMP}/mds_survey*
13165 rm -f ${TMP}/mds_survey*
13167 run_test 225b "Metadata survey sanity with stripe_count = 1"
13169 mcreate_path2fid () {
13175 local path=$DIR/$tdir/$name
13180 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13181 error "cannot create $desc"
13183 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13185 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13187 fid_path=$($LFS fid2path $MOUNT $fid)
13189 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13191 [ "$path" == "$fid_path" ] ||
13192 error "fid2path returned $fid_path, expected $path"
13194 echo "pass with $path and $fid"
13199 mkdir -p $DIR/$tdir
13201 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13202 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13203 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13204 mcreate_path2fid 0040666 0 0 dir "directory"
13205 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13206 mcreate_path2fid 0100666 0 0 file "regular file"
13207 mcreate_path2fid 0120666 0 0 link "symbolic link"
13208 mcreate_path2fid 0140666 0 0 sock "socket"
13210 run_test 226a "call path2fid and fid2path on files of all type"
13213 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13217 mkdir -p $DIR/$tdir
13218 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13219 error "create remote directory failed"
13220 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13221 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13222 "character special file (null)"
13223 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13224 "character special file (no device)"
13225 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13226 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13227 "block special file (loop)"
13228 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13229 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13230 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13232 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13234 # LU-1299 Executing or running ldd on a truncated executable does not
13235 # cause an out-of-memory condition.
13237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13238 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13239 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13240 chmod +x $MOUNT/date
13242 $MOUNT/date > /dev/null
13243 ldd $MOUNT/date > /dev/null
13246 run_test 227 "running truncated executable does not cause OOM"
13248 # LU-1512 try to reuse idle OI blocks
13250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13251 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13252 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13253 skip "ldiskfs only test" && return
13255 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13256 local myDIR=$DIR/$tdir
13259 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13260 $LCTL set_param fail_loc=0x80001002
13261 createmany -o $myDIR/t- 10000
13262 $LCTL set_param fail_loc=0
13263 # The guard is current the largest FID holder
13265 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13267 local IDX=$(($SEQ % 64))
13269 do_facet $SINGLEMDS sync
13270 # Make sure journal flushed.
13272 local blk1=$(do_facet $SINGLEMDS \
13273 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13274 grep Blockcount | awk '{print $4}')
13276 # Remove old files, some OI blocks will become idle.
13277 unlinkmany $myDIR/t- 10000
13278 # Create new files, idle OI blocks should be reused.
13279 createmany -o $myDIR/t- 2000
13280 do_facet $SINGLEMDS sync
13281 # Make sure journal flushed.
13283 local blk2=$(do_facet $SINGLEMDS \
13284 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13285 grep Blockcount | awk '{print $4}')
13287 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13289 run_test 228a "try to reuse idle OI blocks"
13292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13293 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13294 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13295 skip "ldiskfs only test" && return
13297 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13298 local myDIR=$DIR/$tdir
13301 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13302 $LCTL set_param fail_loc=0x80001002
13303 createmany -o $myDIR/t- 10000
13304 $LCTL set_param fail_loc=0
13305 # The guard is current the largest FID holder
13307 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13309 local IDX=$(($SEQ % 64))
13311 do_facet $SINGLEMDS sync
13312 # Make sure journal flushed.
13314 local blk1=$(do_facet $SINGLEMDS \
13315 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13316 grep Blockcount | awk '{print $4}')
13318 # Remove old files, some OI blocks will become idle.
13319 unlinkmany $myDIR/t- 10000
13322 stop $SINGLEMDS || error "Fail to stop MDT."
13324 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13326 df $MOUNT || error "Fail to df."
13327 # Create new files, idle OI blocks should be reused.
13328 createmany -o $myDIR/t- 2000
13329 do_facet $SINGLEMDS sync
13330 # Make sure journal flushed.
13332 local blk2=$(do_facet $SINGLEMDS \
13333 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13334 grep Blockcount | awk '{print $4}')
13336 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13338 run_test 228b "idle OI blocks can be reused after MDT restart"
13342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13343 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13344 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13345 skip "ldiskfs only test" && return
13347 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13348 local myDIR=$DIR/$tdir
13351 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13352 $LCTL set_param fail_loc=0x80001002
13353 # 20000 files can guarantee there are index nodes in the OI file
13354 createmany -o $myDIR/t- 20000
13355 $LCTL set_param fail_loc=0
13356 # The guard is current the largest FID holder
13358 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13360 local IDX=$(($SEQ % 64))
13362 do_facet $SINGLEMDS sync
13363 # Make sure journal flushed.
13365 local blk1=$(do_facet $SINGLEMDS \
13366 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13367 grep Blockcount | awk '{print $4}')
13369 # Remove old files, some OI blocks will become idle.
13370 unlinkmany $myDIR/t- 20000
13372 # The OI file should become empty now
13374 # Create new files, idle OI blocks should be reused.
13375 createmany -o $myDIR/t- 2000
13376 do_facet $SINGLEMDS sync
13377 # Make sure journal flushed.
13379 local blk2=$(do_facet $SINGLEMDS \
13380 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13381 grep Blockcount | awk '{print $4}')
13383 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13385 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13387 test_229() { # LU-2482, LU-3448
13388 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13389 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13392 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13396 # Create a file with a released layout and stripe count 2.
13397 $MULTIOP $DIR/$tfile H2c ||
13398 error "failed to create file with released layout"
13400 $GETSTRIPE -v $DIR/$tfile
13402 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13403 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13405 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13406 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13407 stat $DIR/$tfile || error "failed to stat released file"
13409 chown $RUNAS_ID $DIR/$tfile ||
13410 error "chown $RUNAS_ID $DIR/$tfile failed"
13412 chgrp $RUNAS_ID $DIR/$tfile ||
13413 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13415 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13416 rm $DIR/$tfile || error "failed to remove released file"
13418 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13422 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13425 test_mkdir $DIR/$tdir
13426 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13427 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13428 [ $mdt_idx -ne 0 ] &&
13429 error "create local directory on wrong MDT $mdt_idx"
13431 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13432 error "create remote directory failed"
13433 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13434 [ $mdt_idx -ne $MDTIDX ] &&
13435 error "create remote directory on wrong MDT $mdt_idx"
13437 createmany -o $DIR/$tdir/test_230/t- 10 ||
13438 error "create files on remote directory failed"
13439 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13440 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13441 rm -r $DIR/$tdir || error "unlink remote directory failed"
13443 run_test 230a "Create remote directory and files under the remote directory"
13446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13454 local migrate_dir=$DIR/$tdir/migrate_dir
13455 local other_dir=$DIR/$tdir/other_dir
13457 test_mkdir $DIR/$tdir
13458 test_mkdir -i0 -c1 $migrate_dir
13459 test_mkdir -i0 -c1 $other_dir
13460 for ((i=0; i<10; i++)); do
13461 mkdir -p $migrate_dir/dir_${i}
13462 createmany -o $migrate_dir/dir_${i}/f 10 ||
13463 error "create files under remote dir failed $i"
13466 cp /etc/passwd $migrate_dir/$tfile
13467 cp /etc/passwd $other_dir/$tfile
13468 chattr +SAD $migrate_dir
13469 chattr +SAD $migrate_dir/$tfile
13471 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13472 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13473 local old_dir_mode=$(stat -c%f $migrate_dir)
13474 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13476 mkdir -p $migrate_dir/dir_default_stripe2
13477 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13478 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13480 mkdir -p $other_dir
13481 ln $migrate_dir/$tfile $other_dir/luna
13482 ln $migrate_dir/$tfile $migrate_dir/sofia
13483 ln $other_dir/$tfile $migrate_dir/david
13484 ln -s $migrate_dir/$tfile $other_dir/zachary
13485 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13486 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13488 $LFS migrate -m $MDTIDX $migrate_dir ||
13489 error "fails on migrating remote dir to MDT1"
13491 echo "migratate to MDT1, then checking.."
13492 for ((i = 0; i < 10; i++)); do
13493 for file in $(find $migrate_dir/dir_${i}); do
13494 mdt_index=$($LFS getstripe -M $file)
13495 [ $mdt_index == $MDTIDX ] ||
13496 error "$file is not on MDT${MDTIDX}"
13500 # the multiple link file should still in MDT0
13501 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13502 [ $mdt_index == 0 ] ||
13503 error "$file is not on MDT${MDTIDX}"
13505 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13506 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13507 error " expect $old_dir_flag get $new_dir_flag"
13509 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13510 [ "$old_file_flag" = "$new_file_flag" ] ||
13511 error " expect $old_file_flag get $new_file_flag"
13513 local new_dir_mode=$(stat -c%f $migrate_dir)
13514 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13515 error "expect mode $old_dir_mode get $new_dir_mode"
13517 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13518 [ "$old_file_mode" = "$new_file_mode" ] ||
13519 error "expect mode $old_file_mode get $new_file_mode"
13521 diff /etc/passwd $migrate_dir/$tfile ||
13522 error "$tfile different after migration"
13524 diff /etc/passwd $other_dir/luna ||
13525 error "luna different after migration"
13527 diff /etc/passwd $migrate_dir/sofia ||
13528 error "sofia different after migration"
13530 diff /etc/passwd $migrate_dir/david ||
13531 error "david different after migration"
13533 diff /etc/passwd $other_dir/zachary ||
13534 error "zachary different after migration"
13536 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13537 error "${tfile}_ln different after migration"
13539 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13540 error "${tfile}_ln_other different after migration"
13542 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13543 [ $stripe_count = 2 ] ||
13544 error "dir strpe_count $d != 2 after migration."
13546 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13547 [ $stripe_count = 2 ] ||
13548 error "file strpe_count $d != 2 after migration."
13550 #migrate back to MDT0
13553 $LFS migrate -m $MDTIDX $migrate_dir ||
13554 error "fails on migrating remote dir to MDT0"
13556 echo "migrate back to MDT0, checking.."
13557 for file in $(find $migrate_dir); do
13558 mdt_index=$($LFS getstripe -M $file)
13559 [ $mdt_index == $MDTIDX ] ||
13560 error "$file is not on MDT${MDTIDX}"
13563 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13564 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13565 error " expect $old_dir_flag get $new_dir_flag"
13567 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13568 [ "$old_file_flag" = "$new_file_flag" ] ||
13569 error " expect $old_file_flag get $new_file_flag"
13571 local new_dir_mode=$(stat -c%f $migrate_dir)
13572 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13573 error "expect mode $old_dir_mode get $new_dir_mode"
13575 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13576 [ "$old_file_mode" = "$new_file_mode" ] ||
13577 error "expect mode $old_file_mode get $new_file_mode"
13579 diff /etc/passwd ${migrate_dir}/$tfile ||
13580 error "$tfile different after migration"
13582 diff /etc/passwd ${other_dir}/luna ||
13583 error "luna different after migration"
13585 diff /etc/passwd ${migrate_dir}/sofia ||
13586 error "sofia different after migration"
13588 diff /etc/passwd ${other_dir}/zachary ||
13589 error "zachary different after migration"
13591 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13592 error "${tfile}_ln different after migration"
13594 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13595 error "${tfile}_ln_other different after migration"
13597 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13598 [ $stripe_count = 2 ] ||
13599 error "dir strpe_count $d != 2 after migration."
13601 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13602 [ $stripe_count = 2 ] ||
13603 error "file strpe_count $d != 2 after migration."
13605 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13607 run_test 230b "migrate directory"
13610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13611 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13616 local migrate_dir=$DIR/$tdir/migrate_dir
13618 #If migrating directory fails in the middle, all entries of
13619 #the directory is still accessiable.
13620 test_mkdir $DIR/$tdir
13621 test_mkdir -i0 -c1 $migrate_dir
13623 createmany -o $migrate_dir/f 10 ||
13624 error "create files under ${migrate_dir} failed"
13626 #failed after migrating 5 entries
13627 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13628 do_facet mds1 lctl set_param fail_loc=0x20001801
13629 do_facet mds1 lctl set_param fail_val=5
13630 local t=$(ls $migrate_dir | wc -l)
13631 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13632 error "migrate should fail after 5 entries"
13634 mkdir $migrate_dir/dir &&
13635 error "mkdir succeeds under migrating directory"
13636 touch $migrate_dir/file &&
13637 error "touch file succeeds under migrating directory"
13639 local u=$(ls $migrate_dir | wc -l)
13640 [ "$u" == "$t" ] || error "$u != $t during migration"
13642 for file in $(find $migrate_dir); do
13643 stat $file || error "stat $file failed"
13646 do_facet mds1 lctl set_param fail_loc=0
13647 do_facet mds1 lctl set_param fail_val=0
13649 $LFS migrate -m $MDTIDX $migrate_dir ||
13650 error "migrate open files should failed with open files"
13652 echo "Finish migration, then checking.."
13653 for file in $(find $migrate_dir); do
13654 mdt_index=$($LFS getstripe -M $file)
13655 [ $mdt_index == $MDTIDX ] ||
13656 error "$file is not on MDT${MDTIDX}"
13659 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13661 run_test 230c "check directory accessiblity if migration is failed"
13664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13665 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13668 local migrate_dir=$DIR/$tdir/migrate_dir
13672 test_mkdir $DIR/$tdir
13673 test_mkdir -i0 -c1 $migrate_dir
13675 for ((i=0; i<100; i++)); do
13676 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13677 createmany -o $migrate_dir/dir_${i}/f 100 ||
13678 error "create files under remote dir failed $i"
13681 $LFS migrate -m $MDTIDX $migrate_dir ||
13682 error "migrate remote dir error"
13684 echo "Finish migration, then checking.."
13685 for file in $(find $migrate_dir); do
13686 mdt_index=$($LFS getstripe -M $file)
13687 [ $mdt_index == $MDTIDX ] ||
13688 error "$file is not on MDT${MDTIDX}"
13691 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13693 run_test 230d "check migrate big directory"
13696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13697 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13703 mkdir -p $DIR/$tdir
13704 mkdir $DIR/$tdir/migrate_dir
13705 mkdir $DIR/$tdir/other_dir
13706 touch $DIR/$tdir/migrate_dir/a
13707 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13708 ls $DIR/$tdir/other_dir
13710 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13711 error "migrate dir fails"
13713 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13714 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13716 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13717 [ $mdt_index == 0 ] || error "a is not on MDT0"
13719 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13720 error "migrate dir fails"
13722 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13723 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13725 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13726 [ $mdt_index == 1 ] || error "a is not on MDT1"
13728 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13729 [ $mdt_index == 1 ] || error "b is not on MDT1"
13731 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13732 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13734 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13736 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13738 run_test 230e "migrate mulitple local link files"
13741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13742 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13746 mkdir -p $DIR/$tdir
13747 mkdir $DIR/$tdir/migrate_dir
13748 $LFS mkdir -i1 $DIR/$tdir/other_dir
13749 touch $DIR/$tdir/migrate_dir/a
13750 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13751 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13752 ls $DIR/$tdir/other_dir
13754 # a should be migrated to MDT1, since no other links on MDT0
13755 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13756 error "#1 migrate dir fails"
13757 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13758 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13759 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13760 [ $mdt_index == 1 ] || error "a is not on MDT1"
13762 # a should stay on MDT1, because it is a mulitple link file
13763 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13764 error "#2 migrate dir fails"
13765 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13766 [ $mdt_index == 1 ] || error "a is not on MDT1"
13768 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13769 error "#3 migrate dir fails"
13771 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13772 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13773 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13775 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13776 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13778 # a should be migrated to MDT0, since no other links on MDT1
13779 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13780 error "#4 migrate dir fails"
13781 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13782 [ $mdt_index == 0 ] || error "a is not on MDT0"
13784 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13786 run_test 230f "migrate mulitple remote link files"
13789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13790 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13792 mkdir -p $DIR/$tdir/migrate_dir
13794 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13795 error "migrating dir to non-exist MDT succeeds"
13798 run_test 230g "migrate dir to non-exist MDT"
13801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13802 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13803 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13804 skip "Need MDS version at least 2.7.64" && return
13807 mkdir -p $DIR/$tdir/migrate_dir
13809 $LFS migrate -m1 $DIR &&
13810 error "migrating mountpoint1 should fail"
13812 $LFS migrate -m1 $DIR/$tdir/.. &&
13813 error "migrating mountpoint2 should fail"
13815 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13816 error "migrating $tdir fail"
13818 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13819 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13821 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13822 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13825 run_test 230h "migrate .. and root"
13828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13829 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13831 mkdir -p $DIR/$tdir/migrate_dir
13833 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13834 error "migration fails with a tailing slash"
13836 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13837 error "migration fails with two tailing slashes"
13839 run_test 230i "lfs migrate -m tolerates trailing slashes"
13843 # For simplicity this test assumes that max_pages_per_rpc
13844 # is the same across all OSCs
13845 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13846 local bulk_size=$((max_pages * 4096))
13847 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
13850 mkdir -p $DIR/$tdir
13851 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
13852 error "failed to set stripe with -S ${brw_size}M option"
13854 # clear the OSC stats
13855 $LCTL set_param osc.*.stats=0 &>/dev/null
13858 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13859 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13860 oflag=direct &>/dev/null || error "dd failed"
13862 sync; sleep 1; sync # just to be safe
13863 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13864 if [ x$nrpcs != "x1" ]; then
13865 $LCTL get_param osc.*.stats
13866 error "found $nrpcs ost_write RPCs, not 1 as expected"
13870 # Drop the OSC cache, otherwise we will read from it
13871 cancel_lru_locks osc
13873 # clear the OSC stats
13874 $LCTL set_param osc.*.stats=0 &>/dev/null
13876 # Client reads $bulk_size.
13877 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13878 iflag=direct &>/dev/null || error "dd failed"
13880 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13881 if [ x$nrpcs != "x1" ]; then
13882 $LCTL get_param osc.*.stats
13883 error "found $nrpcs ost_read RPCs, not 1 as expected"
13886 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13889 mkdir -p $DIR/$tdir
13891 for i in {0..1023}; do
13892 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13893 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13894 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13898 run_test 231b "must not assert on fully utilized OST request buffer"
13901 mkdir -p $DIR/$tdir
13902 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13903 $LCTL set_param fail_loc=0x31c
13905 # ignore dd failure
13906 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13908 $LCTL set_param fail_loc=0
13909 umount_client $MOUNT || error "umount failed"
13910 mount_client $MOUNT || error "mount failed"
13912 run_test 232 "failed lock should not block umount"
13915 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13916 { skip "Need MDS version at least 2.3.64"; return; }
13917 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13919 local fid=$($LFS path2fid $MOUNT)
13920 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13921 error "cannot access $MOUNT using its FID '$fid'"
13923 run_test 233a "checking that OBF of the FS root succeeds"
13926 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13927 { skip "Need MDS version at least 2.5.90"; return; }
13928 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13930 local fid=$($LFS path2fid $MOUNT/.lustre)
13931 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13932 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13934 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13935 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13936 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13938 run_test 233b "checking that OBF of the FS .lustre succeeds"
13941 local p="$TMP/sanityN-$TESTNAME.parameters"
13942 save_lustre_params client "llite.*.xattr_cache" > $p
13943 lctl set_param llite.*.xattr_cache 1 ||
13944 { skip "xattr cache is not supported"; return 0; }
13946 mkdir -p $DIR/$tdir || error "mkdir failed"
13947 touch $DIR/$tdir/$tfile || error "touch failed"
13948 # OBD_FAIL_LLITE_XATTR_ENOMEM
13949 $LCTL set_param fail_loc=0x1405
13950 # output of the form: attr 2 4 44 3 fc13 x86_64
13951 V=($(IFS=".-" rpm -q attr))
13952 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13953 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13954 # attr pre-2.4.44-7 had a bug with rc
13955 # LU-3703 - SLES 11 and FC13 clients have older attr
13956 getfattr -n user.attr $DIR/$tdir/$tfile &&
13957 error "getfattr should have failed with ENOMEM"
13959 skip "LU-3703: attr version $(getfattr --version) too old"
13961 $LCTL set_param fail_loc=0x0
13964 restore_lustre_params < $p
13967 run_test 234 "xattr cache should not crash on ENOMEM"
13970 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13971 skip "Need MDS version at least 2.4.52" && return
13972 flock_deadlock $DIR/$tfile
13977 124) error "process hangs on a deadlock"
13979 *) error "error executing flock_deadlock $DIR/$tfile"
13983 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13987 check_swap_layouts_support && return 0
13988 test_mkdir -c1 $DIR/$tdir
13990 local ref1=/etc/passwd
13991 local ref2=/etc/group
13992 local file1=$DIR/$tdir/f1
13993 local file2=$DIR/$tdir/f2
13995 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13996 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13997 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13998 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13999 local fd=$(free_fd)
14000 local cmd="exec $fd<>$file2"
14003 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14004 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14007 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14012 run_test 236 "Layout swap on open unlinked file"
14014 # test to verify file handle related system calls
14015 # (name_to_handle_at/open_by_handle_at)
14016 # The new system calls are supported in glibc >= 2.14.
14019 echo "Test file_handle syscalls" > $DIR/$tfile ||
14020 error "write failed"
14021 check_fhandle_syscalls $DIR/$tfile ||
14022 error "check_fhandle_syscalls failed"
14024 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14026 # LU-4659 linkea consistency
14028 local server_version=$(lustre_version_code $SINGLEMDS)
14030 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14031 [[ $server_version -gt $(version_code 2.5.1) &&
14032 $server_version -lt $(version_code 2.5.50) ]] ||
14033 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14036 ln $DIR/$tfile $DIR/$tfile.lnk
14037 touch $DIR/$tfile.new
14038 mv $DIR/$tfile.new $DIR/$tfile
14039 local fid1=$($LFS path2fid $DIR/$tfile)
14040 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14041 local path1=$($LFS fid2path $FSNAME "$fid1")
14042 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14043 local path2=$($LFS fid2path $FSNAME "$fid2")
14044 [ $tfile.lnk == $path2 ] ||
14045 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14048 run_test 238 "Verify linkea consistency"
14051 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14052 skip "Need MDS version at least 2.5.60" && return
14053 local list=$(comma_list $(mdts_nodes))
14055 mkdir -p $DIR/$tdir
14056 createmany -o $DIR/$tdir/f- 5000
14057 unlinkmany $DIR/$tdir/f- 5000
14058 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
14059 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14060 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14061 osp.*MDT*.sync_in_flight" | calc_sum)
14062 [ "$changes" -eq 0 ] || error "$changes not synced"
14064 run_test 239 "osp_sync test"
14066 test_239a() { #LU-5297
14067 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14069 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14070 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14071 chgrp $RUNAS_GID $DIR/$tfile
14072 wait_delete_completed
14074 run_test 239a "process invalid osp sync record correctly"
14076 test_239b() { #LU-5297
14077 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14079 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14080 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14081 chgrp $RUNAS_GID $DIR/$tfile1
14082 wait_delete_completed
14083 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14085 chgrp $RUNAS_GID $DIR/$tfile2
14086 wait_delete_completed
14088 run_test 239b "process osp sync record with ENOMEM error correctly"
14091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14092 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14094 mkdir -p $DIR/$tdir
14096 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14097 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14098 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14099 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14101 umount_client $MOUNT || error "umount failed"
14102 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14103 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14104 mount_client $MOUNT || error "failed to mount client"
14106 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14107 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14109 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14112 for LOOP in $(seq $1); do
14113 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14114 cancel_lru_locks $OSC || true
14119 for LOOP in $(seq $1); do
14120 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14121 iflag=direct 2>/dev/null
14125 test_241a() { # was test_241
14126 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14128 cancel_lru_locks $OSC
14129 test_241_bio 1000 &
14134 run_test 241a "bio vs dio"
14137 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14139 test_241_dio 1000 &
14144 run_test 241b "dio vs dio"
14147 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14148 mkdir -p $DIR/$tdir
14149 touch $DIR/$tdir/$tfile
14151 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14152 do_facet mds1 lctl set_param fail_loc=0x105
14153 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14155 do_facet mds1 lctl set_param fail_loc=0
14156 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14158 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14162 test_mkdir $DIR/$tdir
14163 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14165 run_test 243 "various group lock tests"
14169 test_mkdir $DIR/$tdir
14170 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14171 sendfile_grouplock $DIR/$tdir/$tfile || \
14172 error "sendfile+grouplock failed"
14175 run_test 244 "sendfile with group lock tests"
14178 local flagname="multi_mod_rpcs"
14179 local connect_data_name="max_mod_rpcs"
14182 # check if multiple modify RPCs flag is set
14183 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14184 grep "connect_flags:")
14187 echo "$out" | grep -qw $flagname
14188 if [ $? -ne 0 ]; then
14189 echo "connect flag $flagname is not set"
14193 # check if multiple modify RPCs data is set
14194 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14197 echo "$out" | grep -qw $connect_data_name ||
14198 error "import should have connect data $connect_data_name"
14200 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14202 test_246() { # LU-7371
14203 remote_ost_nodsh && skip "remote OST with nodsh" && return
14204 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14205 skip "Need OST version >= 2.7.62" && return 0
14206 do_facet ost1 $LCTL set_param fail_val=4095
14207 #define OBD_FAIL_OST_READ_SIZE 0x234
14208 do_facet ost1 $LCTL set_param fail_loc=0x234
14209 $LFS setstripe $DIR/$tfile -i 0 -c 1
14210 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14211 cancel_lru_locks $FSNAME-OST0000
14212 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14214 run_test 246 "Read file of size 4095 should return right length"
14217 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14219 { skip "Fileset feature is not supported"; return; }
14221 local submount=${MOUNT}_$tdir
14224 mkdir -p $submount || error "mkdir $submount failed"
14225 FILESET="$FILESET/$tdir" mount_client $submount ||
14226 error "mount $submount failed"
14227 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14228 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14229 error "read $MOUNT/$tdir/$tfile failed"
14230 umount_client $submount || error "umount $submount failed"
14233 run_test 247a "mount subdir as fileset"
14236 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14237 { skip "Fileset feature is not supported"; return; }
14239 local submount=${MOUNT}_$tdir
14241 rm -rf $MOUNT/$tdir
14242 mkdir -p $submount || error "mkdir $submount failed"
14244 FILESET="$FILESET/$tdir" mount_client $submount &&
14245 error "mount $submount should fail"
14248 run_test 247b "mount subdir that dose not exist"
14251 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14252 { skip "Fileset feature is not supported"; return; }
14254 local submount=${MOUNT}_$tdir
14256 mkdir -p $MOUNT/$tdir/dir1
14257 mkdir -p $submount || error "mkdir $submount failed"
14258 FILESET="$FILESET/$tdir" mount_client $submount ||
14259 error "mount $submount failed"
14260 local fid=$($LFS path2fid $MOUNT/)
14261 $LFS fid2path $submount $fid && error "fid2path should fail"
14262 umount_client $submount || error "umount $submount failed"
14265 run_test 247c "running fid2path outside root"
14268 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14269 { skip "Fileset feature is not supported"; return; }
14271 local submount=${MOUNT}_$tdir
14273 mkdir -p $MOUNT/$tdir/dir1
14274 mkdir -p $submount || error "mkdir $submount failed"
14275 FILESET="$FILESET/$tdir" mount_client $submount ||
14276 error "mount $submount failed"
14277 local fid=$($LFS path2fid $submount/dir1)
14278 $LFS fid2path $submount $fid || error "fid2path should succeed"
14279 umount_client $submount || error "umount $submount failed"
14282 run_test 247d "running fid2path inside root"
14286 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14288 { skip "Fileset feature is not supported"; return; }
14290 local submount=${MOUNT}_$tdir
14293 mkdir -p $submount || error "mkdir $submount failed"
14294 FILESET="$FILESET/.." mount_client $submount &&
14295 error "mount $submount should fail"
14298 run_test 247e "mount .. as fileset"
14301 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14302 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14304 # create a large file for fast read verification
14305 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14307 # make sure the file is created correctly
14308 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14309 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14311 echo "Test 1: verify that fast read is 4 times faster on cache read"
14313 # small read with fast read enabled
14314 $LCTL set_param -n llite.*.fast_read=1
14315 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14316 awk '/copied/ { print $6 }')
14318 # small read with fast read disabled
14319 $LCTL set_param -n llite.*.fast_read=0
14320 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14321 awk '/copied/ { print $6 }')
14323 # verify that fast read is 4 times faster for cache read
14324 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14325 error_not_in_vm "fast read was not 4 times faster: " \
14326 "$t_fast vs $t_slow"
14328 echo "Test 2: verify the performance between big and small read"
14329 $LCTL set_param -n llite.*.fast_read=1
14331 # 1k non-cache read
14332 cancel_lru_locks osc
14333 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14334 awk '/copied/ { print $6 }')
14336 # 1M non-cache read
14337 cancel_lru_locks osc
14338 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14339 awk '/copied/ { print $6 }')
14341 # verify that big IO is not 4 times faster than small IO
14342 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14343 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14345 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14348 run_test 248 "fast read verification"
14350 test_249() { # LU-7890
14352 $SETSTRIPE -c 1 $DIR/$tfile
14354 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14355 skip "Need at least version 2.8.54"
14357 # Offset 2T == 4k * 512M
14358 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14359 error "dd to 2T offset failed"
14361 run_test 249 "Write above 2T file size"
14364 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14365 && skip "no 16TB file size limit on ZFS" && return
14367 $SETSTRIPE -c 1 $DIR/$tfile
14368 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14369 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14370 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14371 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14372 conv=notrunc,fsync && error "append succeeded"
14375 run_test 250 "Write above 16T limit"
14378 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14380 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14381 #Skip once - writing the first stripe will succeed
14382 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14383 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14384 error "short write happened"
14386 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14387 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14388 error "short read happened"
14392 run_test 251 "Handling short read and write correctly"
14402 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14403 remote_ost_nodsh && skip "remote OST with nodsh" && return
14404 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14405 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14406 skip "ldiskfs only test"
14410 # check lr_reader on OST0000
14412 dev=$(facet_device $tgt)
14413 out=$(do_facet $tgt $LR_READER $dev)
14414 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14416 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14417 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14418 error "Invalid uuid returned by $LR_READER on target $tgt"
14419 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14421 # check lr_reader -c on MDT0000
14423 dev=$(facet_device $tgt)
14424 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14425 echo "$LR_READER does not support additional options"
14428 out=$(do_facet $tgt $LR_READER -c $dev)
14429 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14431 num=$(echo "$out" | grep -c "mdtlov")
14432 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14433 error "Invalid number of mdtlov clients returned by $LR_READER"
14434 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14436 # check lr_reader -cr on MDT0000
14437 out=$(do_facet $tgt $LR_READER -cr $dev)
14438 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14440 echo "$out" | grep -q "^reply_data:$" ||
14441 error "$LR_READER should have returned 'reply_data' section"
14442 num=$(echo "$out" | grep -c "client_generation")
14443 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14445 run_test 252 "check lr_reader tool"
14447 test_253_fill_ost() {
14448 local size_mb #how many MB should we write to pass watermark
14449 local lwm=$3 #low watermark
14450 local free_10mb #10% of free space
14452 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14453 size_mb=$((free_kb / 1024 - lwm))
14454 free_10mb=$((free_kb / 10240))
14455 #If 10% of free space cross low watermark use it
14456 if (( free_10mb > size_mb )); then
14459 #At least we need to store 1.1 of difference between
14460 #free space and low watermark
14461 size_mb=$((size_mb + size_mb / 10))
14463 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14464 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14465 oflag=append conv=notrunc
14470 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14471 echo "OST still has $((free_kb / 1024)) mbytes free"
14478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14480 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14482 local ost_name=$($LFS osts |
14483 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14485 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14486 do_facet $SINGLEMDS $LCTL get_param -n \
14487 osp.$mdtosc_proc1.reserved_mb_high ||
14488 { skip "remote MDS does not support reserved_mb_high" &&
14493 wait_delete_completed
14496 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14497 osp.$mdtosc_proc1.reserved_mb_high)
14498 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14499 osp.$mdtosc_proc1.reserved_mb_low)
14500 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14502 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14503 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14504 error "Adding $ost_name to pool failed"
14506 # Wait for client to see a OST at pool
14507 wait_update $HOSTNAME "$LCTL get_param -n
14508 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14509 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14510 error "Client can not see the pool"
14511 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14512 error "Setstripe failed"
14514 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14515 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14516 echo "OST still has $((blocks/1024)) mbytes free"
14518 local new_lwm=$((blocks/1024-10))
14519 do_facet $SINGLEMDS $LCTL set_param \
14520 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14521 do_facet $SINGLEMDS $LCTL set_param \
14522 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14524 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14526 #First enospc could execute orphan deletion so repeat.
14527 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14529 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14530 osp.$mdtosc_proc1.prealloc_status)
14531 echo "prealloc_status $oa_status"
14533 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14534 error "File creation should fail"
14535 #object allocation was stopped, but we still able to append files
14536 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14537 error "Append failed"
14538 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14540 wait_delete_completed
14544 for i in $(seq 10 12); do
14545 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14546 error "File creation failed after rm";
14549 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14550 osp.$mdtosc_proc1.prealloc_status)
14551 echo "prealloc_status $oa_status"
14553 if (( oa_status != 0 )); then
14554 error "Object allocation still disable after rm"
14556 do_facet $SINGLEMDS $LCTL set_param \
14557 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14558 do_facet $SINGLEMDS $LCTL set_param \
14559 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14562 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14563 error "Remove $ost_name from pool failed"
14564 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14565 error "Pool destroy fialed"
14567 run_test 253 "Check object allocation limit"
14572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14573 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14574 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14575 { skip "MDS does not support changelog_size" && return; }
14577 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14578 echo "Registered as changelog user $cl_user"
14580 $LFS changelog_clear $MDT0 $cl_user 0
14582 local size1=$(do_facet mds1 \
14583 $LCTL get_param -n mdd.$MDT0.changelog_size)
14584 echo "Changelog size $size1"
14587 $LFS mkdir -i 0 $DIR/$tdir
14589 mkdir -p $DIR/$tdir/pics/2008/zachy
14590 touch $DIR/$tdir/pics/2008/zachy/timestamp
14591 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14592 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14593 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14594 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14595 rm $DIR/$tdir/pics/desktop.jpg
14597 local size2=$(do_facet mds1 \
14598 $LCTL get_param -n mdd.$MDT0.changelog_size)
14599 echo "Changelog size after work $size2"
14601 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14603 if (( size2 <= size1 )); then
14604 error "Changelog size after work should be greater than original"
14608 run_test 254 "Check changelog size"
14615 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14616 awk -F: '{print $2}' | grep $type > /dev/null
14617 if [ $? -ne 0 ]; then
14627 lfs ladvise -a willread $file > /dev/null 2>&1
14628 if [ $? -eq 0 ]; then
14632 lfs ladvise -a willread $file 2>&1 |
14633 grep "Inappropriate ioctl for device" > /dev/null
14634 if [ $? -eq 0 ]; then
14641 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14644 # run a random read IO workload
14645 # usage: random_read_iops <filename> <filesize> <iosize>
14646 random_read_iops() {
14649 local iosize=${3:-4096}
14651 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14652 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14655 drop_file_oss_cache() {
14659 $LFS ladvise -a dontneed $file 2>/dev/null ||
14660 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14663 ladvise_willread_performance()
14666 local average_origin=0
14667 local average_cache=0
14668 local average_ladvise=0
14670 for ((i = 1; i <= $repeat; i++)); do
14671 echo "Iter $i/$repeat: reading without willread hint"
14672 cancel_lru_locks osc
14673 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14674 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14675 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14676 average_origin=$(bc <<<"$average_origin + $speed_origin")
14678 cancel_lru_locks osc
14679 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14680 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14681 average_cache=$(bc <<<"$average_cache + $speed_cache")
14683 cancel_lru_locks osc
14684 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14685 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14686 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14687 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14688 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14690 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14691 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14692 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14694 speedup_cache=$(percent $average_cache $average_origin)
14695 speedup_ladvise=$(percent $average_ladvise $average_origin)
14697 echo "Average uncached read: $average_origin"
14698 echo "Average speedup with OSS cached read: " \
14699 "$average_cache = +$speedup_cache%"
14700 echo "Average speedup with ladvise willread: " \
14701 "$average_ladvise = +$speedup_ladvise%"
14703 local lowest_speedup=20
14704 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
14705 echo "Speedup with OSS cached read less than $lowest_speedup%, "
14706 "got $average_cache%. Skipping ladvise willread check."
14710 # the test won't work on ZFS until it supports 'ladvise dontneed', but
14711 # it is still good to run until then to exercise 'ladvise willread'
14712 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14713 [ "$(facet_fstype ost1)" = "zfs" ] &&
14714 echo "osd-zfs does not support dontneed or drop_caches" &&
14717 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
14718 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
14719 error_not_in_vm "Speedup with willread is less than " \
14720 "$lowest_speedup%, got $average_ladvise%"
14724 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14725 skip "lustre < 2.8.54 does not support ladvise " && return
14726 remote_ost_nodsh && skip "remote OST with nodsh" && return
14728 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14730 ladvise_no_type willread $DIR/$tfile &&
14731 skip "willread ladvise is not supported" && return
14733 ladvise_no_ioctl $DIR/$tfile &&
14734 skip "ladvise ioctl is not supported" && return
14737 local size=$((size_mb * 1048576))
14738 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14739 error "dd to $DIR/$tfile failed"
14741 lfs ladvise -a willread $DIR/$tfile ||
14742 error "Ladvise failed with no range argument"
14744 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14745 error "Ladvise failed with no -l or -e argument"
14747 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14748 error "Ladvise failed with only -e argument"
14750 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14751 error "Ladvise failed with only -l argument"
14753 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14754 error "End offset should not be smaller than start offset"
14756 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14757 error "End offset should not be equal to start offset"
14759 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14760 error "Ladvise failed with overflowing -s argument"
14762 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14763 error "Ladvise failed with overflowing -e argument"
14765 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14766 error "Ladvise failed with overflowing -l argument"
14768 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14769 error "Ladvise succeeded with conflicting -l and -e arguments"
14771 echo "Synchronous ladvise should wait"
14773 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14774 do_nodes $(comma_list $(osts_nodes)) \
14775 $LCTL set_param fail_val=$delay fail_loc=0x237
14777 local start_ts=$SECONDS
14778 lfs ladvise -a willread $DIR/$tfile ||
14779 error "Ladvise failed with no range argument"
14780 local end_ts=$SECONDS
14781 local inteval_ts=$((end_ts - start_ts))
14783 if [ $inteval_ts -lt $(($delay - 1)) ]; then
14784 error "Synchronous advice didn't wait reply"
14787 echo "Asynchronous ladvise shouldn't wait"
14788 local start_ts=$SECONDS
14789 lfs ladvise -a willread -b $DIR/$tfile ||
14790 error "Ladvise failed with no range argument"
14791 local end_ts=$SECONDS
14792 local inteval_ts=$((end_ts - start_ts))
14794 if [ $inteval_ts -gt $(($delay / 2)) ]; then
14795 error "Asynchronous advice blocked"
14798 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
14799 ladvise_willread_performance
14801 run_test 255a "check 'lfs ladvise -a willread'"
14807 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
14811 remote_ost_nodsh && skip "remote OST with nodsh" && return
14813 lfs setstripe -c 1 -i 0 $DIR/$tfile
14815 ladvise_no_type dontneed $DIR/$tfile &&
14816 skip "dontneed ladvise is not supported" && return
14818 ladvise_no_ioctl $DIR/$tfile &&
14819 skip "ladvise ioctl is not supported" && return
14821 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14822 skip "lustre < 2.8.54 does not support ladvise" && return
14824 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14825 [ "$(facet_fstype ost1)" = "zfs" ] &&
14826 skip "zfs-osd does not support 'ladvise dontneed'" && return
14829 local size=$((size_mb * 1048576))
14830 # In order to prevent disturbance of other processes, only check 3/4
14831 # of the memory usage
14832 local kibibytes=$((size_mb * 1024 * 3 / 4))
14834 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14835 error "dd to $DIR/$tfile failed"
14837 local total=$(facet_meminfo ost1 MemTotal)
14838 echo "Total memory: $total KiB"
14840 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
14841 local before_read=$(facet_meminfo ost1 Cached)
14842 echo "Cache used before read: $before_read KiB"
14844 lfs ladvise -a willread $DIR/$tfile ||
14845 error "Ladvise willread failed"
14846 local after_read=$(facet_meminfo ost1 Cached)
14847 echo "Cache used after read: $after_read KiB"
14849 lfs ladvise -a dontneed $DIR/$tfile ||
14850 error "Ladvise dontneed again failed"
14851 local no_read=$(facet_meminfo ost1 Cached)
14852 echo "Cache used after dontneed ladvise: $no_read KiB"
14854 if [ $total -lt $((before_read + kibibytes)) ]; then
14855 echo "Memory is too small, abort checking"
14859 if [ $((before_read + kibibytes)) -gt $after_read ]; then
14860 error "Ladvise willread should use more memory" \
14861 "than $kibibytes KiB"
14864 if [ $((no_read + kibibytes)) -gt $after_read ]; then
14865 error "Ladvise dontneed should release more memory" \
14866 "than $kibibytes KiB"
14869 run_test 255b "check 'lfs ladvise -a dontneed'"
14877 test_mkdir -p $DIR/$tdir
14878 $SETSTRIPE -i 0 $DIR/$tdir
14880 #test 10 returns only success/failure
14882 lockahead_test -d $DIR/$tdir -t $i
14884 if [ $rc -eq 255 ]; then
14885 error "Ladvise test${i} failed, ${rc}"
14888 #test 11 counts lock enqueue requests, all others count new locks
14890 count=$(do_facet ost1 \
14891 $LCTL get_param -n ost.OSS.ost.stats)
14892 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
14894 lockahead_test -d $DIR/$tdir -t $i
14896 if [ $rc -eq 255 ]; then
14897 error "Ladvise test${i} failed, ${rc}"
14900 new_count=$(do_facet ost1 \
14901 $LCTL get_param -n ost.OSS.ost.stats)
14902 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
14903 awk '{ print $2 }')
14905 difference="$((new_count - count))"
14906 if [ $difference -ne $rc ]; then
14907 error "Ladvise test${i}, bad enqueue count, returned " \
14908 "${rc}, actual ${difference}"
14911 for i in $(seq 12 21); do
14912 # If we do not do this, we run the risk of having too many
14913 # locks and starting lock cancellation while we are checking
14915 cancel_lru_locks osc
14917 count=$($LCTL get_param -n \
14918 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
14920 lockahead_test -d $DIR/$tdir -t $i
14922 if [ $rc -eq 255 ]; then
14923 error "Ladvise test ${i} failed, ${rc}"
14926 new_count=$($LCTL get_param -n \
14927 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
14928 difference="$((new_count - count))"
14930 # Test 15 output is divided by 1000 to map down to valid return
14931 if [ $i -eq 15 ]; then
14932 rc="$((rc * 1000))"
14935 if [ $difference -ne $rc ]; then
14936 error "Ladvise test ${i}, bad lock count, returned " \
14937 "${rc}, actual ${difference}"
14941 #test 22 returns only success/failure
14943 lockahead_test -d $DIR/$tdir -t $i
14945 if [ $rc -eq 255 ]; then
14946 error "Ladvise test${i} failed, ${rc}"
14950 run_test 255c "suite of ladvise lockahead tests"
14957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14958 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14959 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
14960 skip "ldiskfs only test" && return
14962 mdt_dev=$(mdsdevname 1)
14964 cl_user=$(do_facet mds1 \
14965 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
14966 if [[ -n $cl_user ]]; then
14967 skip "active changelog user"
14971 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14972 echo "Registered as changelog user $cl_user"
14975 mkdir -p $DIR/$tdir
14977 $LFS changelog_clear $MDT0 $cl_user 0
14980 touch $DIR/$tdir/{1..10}
14983 stop mds1 || error "Fail to stop MDT."
14986 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
14988 #after mount new plainllog is used
14989 touch $DIR/$tdir/{11..19}
14991 local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
14992 cat_sl=$(do_facet mds1 \
14993 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
14994 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
14995 do_facet mds1 rm $TEMP256FILE
14997 if (( cat_sl != 2 )); then
14998 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14999 error "Changelog catalog has wrong number of slots $cat_sl"
15002 $LFS changelog_clear $MDT0 $cl_user 0
15005 TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15006 cat_sl=$(do_facet mds1 \
15007 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15008 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15009 do_facet mds1 rm $TEMP256FILE
15011 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15013 if (( cat_sl == 2 )); then
15014 error "Empty plain llog was not deleted from changelog catalog"
15016 if (( cat_sl != 1 )); then
15017 error "Active plain llog shouldn\`t be deleted from catalog"
15020 run_test 256 "Check llog delete for empty and not full state"
15023 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15024 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15025 skip "Need MDS version at least 2.8.55" && return
15027 test_mkdir $DIR/$tdir
15029 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15030 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15033 #define OBD_FAIL_MDS_XATTR_REP 0x161
15034 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15035 local facet=mds$((mdtidx + 1))
15036 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15037 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15039 stop $facet || error "stop MDS failed"
15040 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15041 error "start MDS fail"
15043 run_test 257 "xattr locks are not lost"
15045 # Verify we take the i_mutex when security requires it
15047 #define OBD_FAIL_IMUTEX_SEC 0x141c
15048 $LCTL set_param fail_loc=0x141c
15050 chmod u+s $DIR/$tfile
15051 chmod a+rwx $DIR/$tfile
15052 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15054 if [ $RC -ne 0 ]; then
15055 error "error, failed to take i_mutex, rc=$?"
15061 # Verify we do NOT take the i_mutex in the normal case
15063 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15064 $LCTL set_param fail_loc=0x141d
15067 chmod a+rw $DIR/$tfile
15068 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15070 if [ $RC -ne 0 ]; then
15071 error "error, took i_mutex unnecessarily, rc=$?"
15076 run_test 258b "verify i_mutex security behavior"
15079 #define OBD_FAIL_MDC_CLOSE 0x806
15080 $LCTL set_param fail_loc=0x80000806
15084 run_test 260 "Check mdc_close fail"
15086 ### Data-on-MDT sanity tests ###
15089 local dom=$DIR/$tdir/dom_file
15090 local tmp=$DIR/$tdir/tmp_file
15092 mkdir -p $DIR/$tdir
15094 # basic checks for DoM component creation
15095 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
15096 error "Can set MDT layout to non-first entry"
15098 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
15099 error "Can define multiple entries as MDT layout"
15101 $LFS setstripe -E 1M -L mdt $dom ||
15102 error "Can't create DoM layout"
15104 [ $($LFS getstripe -L $dom) == 100 ] || error "bad pattern"
15105 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
15106 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
15108 local mdtidx=$($GETSTRIPE -M $dom)
15109 local mdtname=MDT$(printf %04x $mdtidx)
15110 local facet=mds$((mdtidx + 1))
15111 local space_check=1
15113 # Skip free space checks with ZFS
15114 if [ "$(facet_fstype $facet)" == "zfs" ]; then
15120 local mdtfree1=$(do_facet $facet \
15121 lctl get_param -n osd*.*$mdtname.kbytesfree)
15122 dd if=/dev/urandom of=$tmp bs=1024 count=100
15123 # check also direct IO along write
15124 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
15126 cmp $tmp $dom || error "file data is different"
15127 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
15128 if [ $space_check == 1 ]; then
15129 local mdtfree2=$(do_facet $facet \
15130 lctl get_param -n osd*.*$mdtname.kbytesfree)
15131 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15132 error "MDT free space is wrong after write"
15136 $TRUNCATE $dom 10000
15137 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
15138 if [ $space_check == 1 ]; then
15139 mdtfree1=$(do_facet $facet \
15140 lctl get_param -n osd*.*$mdtname.kbytesfree)
15141 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
15142 error "MDT free space is wrong after truncate"
15148 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
15149 if [ $space_check == 1 ]; then
15150 mdtfree2=$(do_facet $facet \
15151 lctl get_param -n osd*.*$mdtname.kbytesfree)
15152 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15153 error "MDT free space is wrong after append"
15158 if [ $space_check == 1 ]; then
15159 mdtfree1=$(do_facet $facet \
15160 lctl get_param -n osd*.*$mdtname.kbytesfree)
15161 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
15162 error "MDT free space is wrong after removal"
15165 # combined striping
15166 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
15167 error "Can't create DoM + OST striping"
15169 dd if=/dev/urandom of=$tmp bs=1024 count=2000
15170 # check also direct IO along write
15171 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
15173 cmp $tmp $dom || error "file data is different"
15174 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
15180 run_test 270a "DoM: basic functionality tests"
15183 local dom=$DIR/$tdir/dom_file
15184 local max_size=1048576
15186 mkdir -p $DIR/$tdir
15187 $LFS setstripe -E $max_size -L mdt $dom
15189 # truncate over the limit
15190 $TRUNCATE $dom $(($max_size + 1)) &&
15191 error "successful truncate over the maximum size"
15192 # write over the limit
15193 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
15194 error "successful write over the maximum size"
15195 # append over the limit
15196 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
15197 echo "12345" >> $dom && error "successful append over the maximum size"
15202 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
15205 mkdir -p $DIR/$tdir
15206 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15208 # check files inherit DoM EA
15209 touch $DIR/$tdir/first
15210 [ $($GETSTRIPE -L $DIR/$tdir/first) == 100 ] ||
15211 error "bad pattern"
15212 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
15213 error "bad stripe count"
15214 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
15215 error "bad stripe size"
15217 # check directory inherits DoM EA and uses it as default
15218 mkdir $DIR/$tdir/subdir
15219 touch $DIR/$tdir/subdir/second
15220 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == 100 ] ||
15221 error "bad pattern in sub-directory"
15222 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
15223 error "bad stripe count in sub-directory"
15224 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
15225 error "bad stripe size in sub-directory"
15228 run_test 270c "DoM: DoM EA inheritance tests"
15231 mkdir -p $DIR/$tdir
15232 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15234 # inherit default DoM striping
15235 mkdir $DIR/$tdir/subdir
15236 touch $DIR/$tdir/subdir/f1
15238 # change default directory striping
15239 $LFS setstripe -c 1 $DIR/$tdir/subdir
15240 touch $DIR/$tdir/subdir/f2
15241 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
15242 error "wrong default striping in file 2"
15243 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == 1 ] ||
15244 error "bad pattern in file 2"
15247 run_test 270d "DoM: change striping from DoM to RAID0"
15250 mkdir -p $DIR/$tdir/dom
15251 mkdir -p $DIR/$tdir/norm
15254 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
15255 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
15257 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
15258 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
15260 # find DoM files by layout
15261 NUM=$($LFIND -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
15262 [ $NUM -eq $DOMFILES ] ||
15263 error "lfs find -L: found $NUM, expected $DOMFILES"
15264 echo "Test 1: lfs find 20 DOM files by layout: OK"
15266 # there should be 1 dir with default DOM striping
15267 NUM=$($LFIND -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
15269 error "lfs find -L: found $NUM, expected 1 dir"
15270 echo "Test 2: lfs find 1 DOM dir by layout: OK"
15272 # find DoM files by stripe size
15273 NUM=$($LFIND -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
15274 [ $NUM -eq $DOMFILES ] ||
15275 error "lfs find -S: found $NUM, expected $DOMFILES"
15276 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
15278 # find files by stripe offset except DoM files
15279 NUM=$($LFIND -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
15280 [ $NUM -eq $NORMFILES ] ||
15281 error "lfs find -i: found $NUM, expected $NORMFILES"
15282 echo "Test 5: lfs find no DOM files by stripe index: OK"
15285 run_test 270e "DoM: lfs find with DoM files test"
15288 local mdtname=${FSNAME}-MDT0000-mdtlov
15289 local dom=$DIR/$tdir/dom_file
15290 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
15291 lod.$mdtname.dom_stripesize)
15292 local dom_limit=131072
15294 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
15295 local dom_current=$(do_facet mds1 $LCTL get_param -n \
15296 lod.$mdtname.dom_stripesize)
15297 [ ${dom_limit} -eq ${dom_current} ] ||
15298 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
15300 $LFS mkdir -i 0 -c 1 $DIR/$tdir
15301 $LFS setstripe -d $DIR/$tdir
15302 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
15303 error "Can't set directory default striping"
15305 # exceed maximum stripe size
15306 $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
15307 error "Able to create DoM component size more than LOD limit"
15309 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
15310 dom_current=$(do_facet mds1 $LCTL get_param -n \
15311 lod.$mdtname.dom_stripesize)
15312 [ 0 -eq ${dom_current} ] ||
15313 error "Can't set zero DoM stripe limit"
15315 # too low values to be aligned with smallest stripe size 64K
15316 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
15317 dom_current=$(do_facet mds1 $LCTL get_param -n \
15318 lod.$mdtname.dom_stripesize)
15319 [ 30000 -eq ${dom_current} ] &&
15320 error "Can set too small DoM stripe limit"
15322 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
15323 dom_current=$(do_facet mds1 $LCTL get_param -n \
15324 lod.$mdtname.dom_stripesize)
15326 [ 2147483648 -eq ${dom_current} ] &&
15327 error "Can set too large DoM stripe limit"
15329 do_facet mds1 $LCTL set_param -n \
15330 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
15331 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
15332 error "Can't create DoM component size after limit change"
15333 do_facet mds1 $LCTL set_param -n \
15334 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
15335 $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
15336 error "Can create big DoM component after limit decrease"
15337 touch ${dom}_def ||
15338 error "Can't create file with old default layout"
15340 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
15343 run_test 270f "DoM: maximum DoM stripe size checks"
15346 local dom=$DIR/$tdir/dom
15348 mkdir -p $DIR/$tdir
15350 $LFS setstripe -E 1024K -L mdt $dom
15352 lctl set_param -n mdc.*.stats=clear
15353 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
15354 cat $dom > /dev/null
15355 local reads=$(lctl get_param -n mdc.*.stats |
15356 awk '/ost_read/ {print $2}')
15357 [ -z $reads ] || error "Unexpected $reads READ RPCs"
15361 run_test 271a "DoM: data is cached for read after write"
15364 local dom=$DIR/$tdir/dom
15366 mkdir -p $DIR/$tdir
15368 $LFS setstripe -E 1024K -L mdt -E EOF $dom
15370 lctl set_param -n mdc.*.stats=clear
15371 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
15372 cancel_lru_locks mdc
15373 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
15374 # second stat to check size is cached on client
15375 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
15376 local gls=$(lctl get_param -n mdc.*.stats |
15377 awk '/ldlm_glimpse/ {print $2}')
15378 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
15381 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
15384 local dom=$DIR/$tdir/dom
15386 mkdir -p $DIR/$tdir
15388 $LFS setstripe -E 1024K -L mdt -E EOF $dom
15390 lctl set_param -n mdc.*.stats=clear
15391 lctl set_param -n osc.*.stats=clear
15392 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
15393 cancel_lru_locks mdc
15394 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
15395 # second stat to check size is cached on client
15396 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
15397 local gls=$(lctl get_param -n mdc.*.stats |
15398 awk '/ldlm_glimpse/ {print $2}')
15399 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
15400 local gls=$(lctl get_param -n osc.*.stats |
15401 awk '/ldlm_glimpse/ {print $2}')
15402 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
15405 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
15408 # test to be enabled with lock_convert
15409 skip "skipped until lock convert will be implemented" && return
15411 local dom=$DIR/$tdir/dom
15413 mkdir -p $DIR/$tdir
15415 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15417 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15418 local facet=mds$((mdtidx + 1))
15420 cancel_lru_locks mdc
15421 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
15422 createmany -o $dom 1000
15423 lctl set_param -n mdc.*.stats=clear
15424 smalliomany -w $dom 1000 200
15425 lctl get_param -n mdc.*.stats
15426 local enq=$(lctl get_param -n mdc.*.stats |
15427 awk '/ldlm_ibits_enqueue/ {print $2}')
15428 # Each file has 1 open, 1 IO enqueues, total 2000
15429 # but now we have also +1 getxattr for security.capability, total 3000
15430 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
15431 unlinkmany $dom 1000
15433 cancel_lru_locks mdc
15434 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
15435 createmany -o $dom 1000
15436 lctl set_param -n mdc.*.stats=clear
15437 smalliomany -w $dom 1000 200
15438 lctl get_param -n mdc.*.stats
15439 local enq_2=$(lctl get_param -n mdc.*.stats |
15440 awk '/ldlm_ibits_enqueue/ {print $2}')
15441 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
15442 # for OPEN and IO lock.
15443 [ $((enq - enq_2)) -ge 1000 ] ||
15444 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
15445 unlinkmany $dom 1000
15448 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
15450 cleanup_test_300() {
15454 test_striped_dir() {
15459 mkdir -p $DIR/$tdir
15461 SAVE_UMASK=$(umask)
15462 trap cleanup_test_300 RETURN EXIT
15464 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15465 $DIR/$tdir/striped_dir ||
15466 error "set striped dir error"
15468 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15469 [ "$mode" = "755" ] || error "expect 755 got $mode"
15471 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15472 error "getdirstripe failed"
15473 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15474 if [ "$stripe_count" != "2" ]; then
15475 error "1:stripe_count is $stripe_count, expect 2"
15477 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15478 if [ "$stripe_count" != "2" ]; then
15479 error "2:stripe_count is $stripe_count, expect 2"
15482 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15483 if [ "$stripe_index" != "$mdt_index" ]; then
15484 error "stripe_index is $stripe_index, expect $mdt_index"
15487 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15488 error "nlink error after create striped dir"
15490 mkdir $DIR/$tdir/striped_dir/a
15491 mkdir $DIR/$tdir/striped_dir/b
15493 stat $DIR/$tdir/striped_dir/a ||
15494 error "create dir under striped dir failed"
15495 stat $DIR/$tdir/striped_dir/b ||
15496 error "create dir under striped dir failed"
15498 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15499 error "nlink error after mkdir"
15501 rmdir $DIR/$tdir/striped_dir/a
15502 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15503 error "nlink error after rmdir"
15505 rmdir $DIR/$tdir/striped_dir/b
15506 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15507 error "nlink error after rmdir"
15509 chattr +i $DIR/$tdir/striped_dir
15510 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15511 error "immutable flags not working under striped dir!"
15512 chattr -i $DIR/$tdir/striped_dir
15514 rmdir $DIR/$tdir/striped_dir ||
15515 error "rmdir striped dir error"
15523 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15524 skip "skipped for lustre < 2.7.0" && return
15525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15526 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15528 test_striped_dir 0 || error "failed on striped dir on MDT0"
15529 test_striped_dir 1 || error "failed on striped dir on MDT0"
15531 run_test 300a "basic striped dir sanity test"
15534 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15535 skip "skipped for lustre < 2.7.0" && return
15536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15537 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15543 test_mkdir $DIR/$tdir
15544 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15545 error "set striped dir error"
15546 for ((i=0; i<10; i++)); do
15547 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15549 touch $DIR/$tdir/striped_dir/file_$i ||
15550 error "touch error $i"
15551 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15552 [ $mtime1 -eq $mtime2 ] &&
15553 error "mtime not change after create"
15555 rm -f $DIR/$tdir/striped_dir/file_$i ||
15556 error "unlink error $i"
15557 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15558 [ $mtime2 -eq $mtime3 ] &&
15559 error "mtime did not change after unlink"
15563 run_test 300b "check ctime/mtime for striped dir"
15566 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15567 skip "skipped for lustre < 2.7.0" && return
15568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15569 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15572 mkdir -p $DIR/$tdir
15573 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15574 error "set striped dir error"
15576 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15577 error "chown striped dir failed"
15579 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15580 error "create 5k files failed"
15582 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15584 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15588 run_test 300c "chown && check ls under striped directory"
15591 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15592 skip "skipped for lustre < 2.7.0" && return
15593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15598 mkdir -p $DIR/$tdir
15599 $SETSTRIPE -c 2 $DIR/$tdir
15601 #local striped directory
15602 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15603 error "set striped dir error"
15604 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15605 error "create 10 files failed"
15607 #remote striped directory
15608 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15609 error "set striped dir error"
15610 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15611 error "create 10 files failed"
15613 for file in $(find $DIR/$tdir); do
15614 stripe_count=$($GETSTRIPE -c $file)
15615 [ $stripe_count -eq 2 ] ||
15616 error "wrong stripe $stripe_count for $file"
15621 run_test 300d "check default stripe under striped directory"
15624 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15625 skip "Need MDS version at least 2.7.55" && return
15626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15631 mkdir -p $DIR/$tdir
15633 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15634 error "set striped dir error"
15636 touch $DIR/$tdir/striped_dir/a
15637 touch $DIR/$tdir/striped_dir/b
15638 touch $DIR/$tdir/striped_dir/c
15640 mkdir $DIR/$tdir/striped_dir/dir_a
15641 mkdir $DIR/$tdir/striped_dir/dir_b
15642 mkdir $DIR/$tdir/striped_dir/dir_c
15644 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15645 error "set striped adir under striped dir error"
15647 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15648 error "set striped bdir under striped dir error"
15650 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15651 error "set striped cdir under striped dir error"
15653 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15654 error "rename dir under striped dir fails"
15656 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15657 error "rename dir under different stripes fails"
15659 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15660 error "rename file under striped dir should succeed"
15662 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15663 error "rename dir under striped dir should succeed"
15667 run_test 300e "check rename under striped directory"
15670 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15671 skip "Need MDS version at least 2.7.55" && return
15672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15673 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15678 mkdir -p $DIR/$tdir
15680 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15681 error "set striped dir error"
15683 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15684 error "set striped dir error"
15686 touch $DIR/$tdir/striped_dir/a
15687 mkdir $DIR/$tdir/striped_dir/dir_a
15688 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15689 error "create striped dir under striped dir fails"
15691 touch $DIR/$tdir/striped_dir1/b
15692 mkdir $DIR/$tdir/striped_dir1/dir_b
15693 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15694 error "create striped dir under striped dir fails"
15696 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15697 error "rename dir under different striped dir should fail"
15699 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15700 error "rename striped dir under diff striped dir should fail"
15702 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15703 error "rename file under diff striped dirs fails"
15707 run_test 300f "check rename cross striped directory"
15709 test_300_check_default_striped_dir()
15712 local default_count=$2
15713 local default_index=$3
15716 local dir_stripe_index
15719 echo "checking $dirname $default_count $default_index"
15720 $LFS setdirstripe -D -c $default_count -i $default_index \
15721 -t all_char $DIR/$tdir/$dirname ||
15722 error "set default stripe on striped dir error"
15723 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15724 [ $stripe_count -eq $default_count ] ||
15725 error "expect $default_count get $stripe_count for $dirname"
15727 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15728 [ $stripe_index -eq $default_index ] ||
15729 error "expect $default_index get $stripe_index for $dirname"
15731 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15732 error "create dirs failed"
15734 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15735 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15736 for dir in $(find $DIR/$tdir/$dirname/*); do
15737 stripe_count=$($LFS getdirstripe -c $dir)
15738 [ $stripe_count -eq $default_count ] ||
15739 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15740 error "stripe count $default_count != $stripe_count for $dir"
15742 stripe_index=$($LFS getdirstripe -i $dir)
15743 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15744 error "$stripe_index != $default_index for $dir"
15746 #check default stripe
15747 stripe_count=$($LFS getdirstripe -D -c $dir)
15748 [ $stripe_count -eq $default_count ] ||
15749 error "default count $default_count != $stripe_count for $dir"
15751 stripe_index=$($LFS getdirstripe -D -i $dir)
15752 [ $stripe_index -eq $default_index ] ||
15753 error "default index $default_index != $stripe_index for $dir"
15755 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15759 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15760 skip "Need MDS version at least 2.7.55" && return
15761 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15767 mkdir $DIR/$tdir/normal_dir
15769 #Checking when client cache stripe index
15770 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15771 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15772 error "create striped_dir failed"
15774 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
15775 error "create dir0 fails"
15776 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
15777 [ $stripe_index -eq 0 ] ||
15778 error "dir0 expect index 0 got $stripe_index"
15780 mkdir $DIR/$tdir/striped_dir/dir1 ||
15781 error "create dir1 fails"
15782 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15783 [ $stripe_index -eq 1 ] ||
15784 error "dir1 expect index 1 got $stripe_index"
15786 #check default stripe count/stripe index
15787 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15788 test_300_check_default_striped_dir normal_dir 1 0
15789 test_300_check_default_striped_dir normal_dir 2 1
15790 test_300_check_default_striped_dir normal_dir 2 -1
15792 #delete default stripe information
15793 echo "delete default stripeEA"
15794 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15795 error "set default stripe on striped dir error"
15797 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15798 for dir in $(find $DIR/$tdir/normal_dir/*); do
15799 stripe_count=$($LFS getdirstripe -c $dir)
15800 [ $stripe_count -eq 0 ] ||
15801 error "expect 1 get $stripe_count for $dir"
15802 stripe_index=$($LFS getdirstripe -i $dir)
15803 [ $stripe_index -eq 0 ] ||
15804 error "expect 0 get $stripe_index for $dir"
15807 run_test 300g "check default striped directory for normal directory"
15810 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15811 skip "Need MDS version at least 2.7.55" && return
15812 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15817 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15818 $DIR/$tdir/striped_dir ||
15819 error "set striped dir error"
15821 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15822 test_300_check_default_striped_dir striped_dir 1 0
15823 test_300_check_default_striped_dir striped_dir 2 1
15824 test_300_check_default_striped_dir striped_dir 2 -1
15826 #delete default stripe information
15827 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15828 error "set default stripe on striped dir error"
15830 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15831 for dir in $(find $DIR/$tdir/striped_dir/*); do
15832 stripe_count=$($LFS getdirstripe -c $dir)
15833 [ $stripe_count -eq 0 ] ||
15834 error "expect 1 get $stripe_count for $dir"
15837 run_test 300h "check default striped directory for striped directory"
15840 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15841 skip "Need MDS version at least 2.7.55" && return
15842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15843 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15849 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15850 error "set striped dir error"
15852 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15853 error "create files under striped dir failed"
15855 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15856 error "set striped hashdir error"
15858 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15859 error "create dir0 under hash dir failed"
15860 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15861 error "create dir1 under hash dir failed"
15863 # unfortunately, we need to umount to clear dir layout cache for now
15864 # once we fully implement dir layout, we can drop this
15865 umount_client $MOUNT || error "umount failed"
15866 mount_client $MOUNT || error "mount failed"
15868 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15869 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15870 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15872 #set the stripe to be unknown hash type
15873 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15874 $LCTL set_param fail_loc=0x1901
15875 for ((i = 0; i < 10; i++)); do
15876 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15877 error "stat f-$i failed"
15878 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15881 touch $DIR/$tdir/striped_dir/f0 &&
15882 error "create under striped dir with unknown hash should fail"
15884 $LCTL set_param fail_loc=0
15886 umount_client $MOUNT || error "umount failed"
15887 mount_client $MOUNT || error "mount failed"
15891 run_test 300i "client handle unknown hash type striped directory"
15894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15895 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15896 skip "Need MDS version at least 2.7.55" && return
15897 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15903 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15904 $LCTL set_param fail_loc=0x1702
15905 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15906 error "set striped dir error"
15908 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15909 error "create files under striped dir failed"
15911 $LCTL set_param fail_loc=0
15913 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15917 run_test 300j "test large update record"
15920 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15921 skip "Need MDS version at least 2.7.55" && return
15922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15923 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15929 #define OBD_FAIL_LARGE_STRIPE 0x1703
15930 $LCTL set_param fail_loc=0x1703
15931 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15932 error "set striped dir error"
15933 $LCTL set_param fail_loc=0
15935 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15936 error "getstripeddir fails"
15937 rm -rf $DIR/$tdir/striped_dir ||
15938 error "unlink striped dir fails"
15942 run_test 300k "test large striped directory"
15945 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15946 skip "Need MDS version at least 2.7.55" && return
15947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15948 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15951 test_mkdir -p $DIR/$tdir/striped_dir
15952 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15953 error "chown $RUNAS_ID failed"
15954 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15955 error "set default striped dir failed"
15957 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15958 $LCTL set_param fail_loc=0x80000158
15959 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15961 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15962 [ $stripe_index -eq 1 ] ||
15963 error "expect 1 get $stripe_index for $dir"
15965 run_test 300l "non-root user to create dir under striped dir with stale layout"
15968 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15969 skip "Need MDS version at least 2.7.55" && return
15970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15971 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15973 mkdir -p $DIR/$tdir/striped_dir
15974 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15975 error "set default stripes dir error"
15977 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15979 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15980 [ $stripe_count -eq 0 ] ||
15981 error "expect 0 get $stripe_count for a"
15983 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15984 error "set default stripes dir error"
15986 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15988 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15989 [ $stripe_count -eq 0 ] ||
15990 error "expect 0 get $stripe_count for b"
15992 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15993 error "set default stripes dir error"
15995 mkdir $DIR/$tdir/striped_dir/c &&
15996 error "default stripe_index is invalid, mkdir c should fails"
15998 rm -rf $DIR/$tdir || error "rmdir fails"
16000 run_test 300m "setstriped directory on single MDT FS"
16003 local list=$(comma_list $(mdts_nodes))
16006 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16010 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16011 skip "Need MDS version at least 2.7.55" && return
16012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16014 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16017 local list=$(comma_list $(mdts_nodes))
16019 trap cleanup_300n RETURN EXIT
16020 mkdir -p $DIR/$tdir
16021 chmod 777 $DIR/$tdir
16022 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16023 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16024 error "create striped dir succeeds with gid=0"
16026 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16027 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16028 error "create striped dir fails with gid=-1"
16030 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16031 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16032 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16033 error "set default striped dir succeeds with gid=0"
16036 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16037 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16038 error "set default striped dir fails with gid=-1"
16041 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16042 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16043 error "create test_dir fails"
16044 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16045 error "create test_dir1 fails"
16046 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16047 error "create test_dir2 fails"
16050 run_test 300n "non-root user to create dir under striped dir with default EA"
16053 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16054 skip "Need MDS version at least 2.7.55" && return
16055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16056 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16060 mkdir -p $DIR/$tdir
16062 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16063 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16064 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16065 skip "not enough free inodes $numfree1 $numfree2"
16069 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16070 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16071 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16072 skip "not enough free space $numfree1 $numfree2"
16076 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16077 error "setdirstripe fails"
16079 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16080 error "create dirs fails"
16082 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16083 ls $DIR/$tdir/striped_dir > /dev/null ||
16084 error "ls striped dir fails"
16085 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16086 error "unlink big striped dir fails"
16088 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16092 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16093 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16095 mkdir -p $DIR/$tdir
16097 #define OBD_FAIL_OUT_ENOSPC 0x1704
16098 do_facet mds2 lctl set_param fail_loc=0x80001704
16099 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16100 error "create striped directory should fail"
16102 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16104 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16107 run_test 300p "create striped directory without space"
16110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16111 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16113 local fd=$(free_fd)
16114 local cmd="exec $fd<$tdir"
16116 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16119 trap "eval $cmd" EXIT
16120 cd $tdir || error "cd $tdir fails"
16121 rmdir ../$tdir || error "rmdir $tdir fails"
16122 mkdir local_dir && error "create dir succeeds"
16123 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16127 run_test 300q "create remote directory under orphan directory"
16129 prepare_remote_file() {
16130 mkdir $DIR/$tdir/src_dir ||
16131 error "create remote source failed"
16133 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16134 touch $DIR/$tdir/src_dir/a
16136 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16137 error "create remote target dir failed"
16139 touch $DIR/$tdir/tgt_dir/b
16141 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16142 error "rename dir cross MDT failed!"
16144 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16145 error "src_child still exists after rename"
16147 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16148 error "missing file(a) after rename"
16150 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16151 error "diff after rename"
16155 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16157 local remote_file=$DIR/$tdir/tgt_dir/b
16159 mkdir -p $DIR/$tdir
16161 prepare_remote_file || error "prepare remote file failed"
16164 $OPENUNLINK $remote_file $remote_file || error
16165 $CHECKSTAT -a $remote_file || error
16167 run_test 310a "open unlink remote file"
16170 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16172 local remote_file=$DIR/$tdir/tgt_dir/b
16174 mkdir -p $DIR/$tdir
16176 prepare_remote_file || error "prepare remote file failed"
16178 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16179 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16180 $CHECKSTAT -t file $remote_file || error "check file failed"
16182 run_test 310b "unlink remote file with multiple links while open"
16185 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16187 local remote_file=$DIR/$tdir/tgt_dir/b
16189 mkdir -p $DIR/$tdir
16191 prepare_remote_file || error "prepare remote file failed"
16193 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16194 multiop_bg_pause $remote_file O_uc ||
16195 error "mulitop failed for remote file"
16197 $MULTIOP $DIR/$tfile Ouc
16198 kill -USR1 $MULTIPID
16201 run_test 310c "open-unlink remote file with multiple links"
16205 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16206 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16208 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16210 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16212 mkdir -p $DIR/$tdir
16213 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16214 createmany -o $DIR/$tdir/$tfile. 1000
16216 # statfs data is not real time, let's just calculate it
16217 old_iused=$((old_iused + 1000))
16219 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16220 osp.*OST0000*MDT0000.create_count")
16221 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16222 osp.*OST0000*MDT0000.max_create_count")
16223 for idx in $(seq $MDSCOUNT); do
16224 do_facet mds$idx "lctl set_param -n \
16225 osp.*OST0000*MDT000?.max_create_count=0"
16228 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16229 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16230 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16232 unlinkmany $DIR/$tdir/$tfile. 1000
16234 for idx in $(seq $MDSCOUNT); do
16235 do_facet mds$idx "lctl set_param -n \
16236 osp.*OST0000*MDT000?.max_create_count=$max_count"
16237 do_facet mds$idx "lctl set_param -n \
16238 osp.*OST0000*MDT000?.create_count=$count"
16242 for i in $(seq 120); do
16243 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16244 # system may be too busy to destroy all objs in time, use
16245 # a somewhat small value to not fail autotest
16246 [ $((old_iused - new_iused)) -gt 400 ] && break
16250 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16251 [ $((old_iused - new_iused)) -gt 400 ] ||
16252 error "objs not destroyed after unlink"
16254 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16261 local vdevdir=$(dirname $(facet_vdevice $ost))
16262 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16263 local zfs_zapid=$(do_facet $ost $cmd |
16264 grep -w "/O/0/d$((objid%32))" -C 5 |
16265 awk '/Object/{getline; print $1}')
16266 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16267 awk "/$objid = /"'{printf $3}')
16272 zfs_object_blksz() {
16276 local vdevdir=$(dirname $(facet_vdevice $ost))
16277 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16278 local blksz=$(do_facet $ost $cmd $objid |
16279 awk '/dblk/{getline; printf $4}')
16281 case "${blksz: -1}" in
16282 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16283 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16290 test_312() { # LU-4856
16291 remote_ost_nodsh && skip "remote OST with nodsh" && return
16293 [ $(facet_fstype ost1) = "zfs" ] ||
16294 { skip "the test only applies to zfs" && return; }
16296 local max_blksz=$(do_facet ost1 \
16297 $ZFS get -p recordsize $(facet_device ost1) |
16298 awk '!/VALUE/{print $3}')
16299 local min_blksz=$(getconf PAGE_SIZE)
16301 # to make life a little bit easier
16302 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16303 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16305 local tf=$DIR/$tdir/$tfile
16307 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16309 # Get ZFS object id
16310 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16312 # block size change by sequential over write
16314 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16315 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16317 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16318 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16322 # block size change by sequential append write
16323 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16324 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16325 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16327 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16328 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16329 oflag=sync conv=notrunc
16331 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16332 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16333 error "blksz error, actual $blksz, " \
16334 "expected: 2 * $count * $min_blksz"
16340 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16341 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16343 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16344 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16345 [ $blksz -eq $min_blksz ] ||
16346 error "blksz error: $blksz, expected: $min_blksz"
16348 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16349 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16350 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16352 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16353 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16354 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16356 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16359 remote_ost_nodsh && skip "remote OST with nodsh" && return
16361 local file=$DIR/$tfile
16363 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16365 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16366 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16367 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16368 error "write should failed"
16369 do_facet ost1 "$LCTL set_param fail_loc=0"
16372 run_test 313 "io should fail after last_rcvd update fail"
16375 local read_write=$1
16376 if [ "$read_write" = "write" ]; then
16377 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16378 elif [ "$read_write" = "read" ]; then
16379 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16381 error "argument error"
16384 # turn off debug for performance testing
16385 local saved_debug=$($LCTL get_param -n debug)
16386 $LCTL set_param debug=0
16388 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16390 # get ost1 size - lustre-OST0000
16391 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16392 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16393 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16395 if [ "$read_write" = "read" ]; then
16396 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16399 local start_time=$(date +%s.%N)
16400 $dd_cmd bs=1M count=$blocks oflag=sync ||
16401 error "real dd $read_write error"
16402 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16404 if [ "$read_write" = "write" ]; then
16408 # define OBD_FAIL_OST_FAKE_RW 0x238
16409 do_facet ost1 $LCTL set_param fail_loc=0x238
16411 local start_time=$(date +%s.%N)
16412 $dd_cmd bs=1M count=$blocks oflag=sync ||
16413 error "fake dd $read_write error"
16414 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16416 if [ "$read_write" = "write" ]; then
16418 cancel_lru_locks osc
16419 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16420 error "$tfile size not $blocks MB"
16422 do_facet ost1 $LCTL set_param fail_loc=0
16424 echo "fake $read_write $duration_fake vs. normal $read_write" \
16425 "$duration in seconds"
16426 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16427 error_not_in_vm "fake write is slower"
16429 $LCTL set_param -n debug="$saved_debug"
16432 test_399a() { # LU-7655 for OST fake write
16433 remote_ost_nodsh && skip "remote OST with nodsh" && return
16437 run_test 399a "fake write should not be slower than normal write"
16439 test_399b() { # LU-8726 for OST fake read
16440 remote_ost_nodsh && skip "remote OST with nodsh" && return
16442 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16443 skip "ldiskfs only test" && return 0
16447 run_test 399b "fake read should not be slower than normal read"
16449 test_400a() { # LU-1606, was conf-sanity test_74
16450 local extra_flags=''
16451 local out=$TMP/$tfile
16452 local prefix=/usr/include/lustre
16455 if ! which $CC > /dev/null 2>&1; then
16456 skip_env "$CC is not installed"
16460 if ! [[ -d $prefix ]]; then
16461 # Assume we're running in tree and fixup the include path.
16462 extra_flags+=" -I$LUSTRE/include"
16463 extra_flags+=" -L$LUSTRE/utils"
16466 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16467 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16468 error "client api broken"
16472 run_test 400a "Lustre client api program can compile and link"
16474 test_400b() { # LU-1606, LU-5011
16476 local out=$TMP/$tfile
16477 local prefix=/usr/include/linux/lustre
16479 # We use a hard coded prefix so that this test will not fail
16480 # when run in tree. There are headers in lustre/include/lustre/
16481 # that are not packaged (like lustre_idl.h) and have more
16482 # complicated include dependencies (like config.h and lnet/types.h).
16483 # Since this test about correct packaging we just skip them when
16484 # they don't exist (see below) rather than try to fixup cppflags.
16486 if ! which $CC > /dev/null 2>&1; then
16487 skip_env "$CC is not installed"
16491 for header in $prefix/*.h; do
16492 if ! [[ -f "$header" ]]; then
16496 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
16497 continue # lustre_ioctl.h is internal header
16500 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16501 error "cannot compile '$header'"
16505 run_test 400b "packaged headers can be compiled"
16507 test_401a() { #LU-7437
16508 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16509 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16511 #count the number of parameters by "list_param -R"
16512 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16513 #count the number of parameters by listing proc files
16514 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16515 echo "proc_dirs='$proc_dirs'"
16516 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16517 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16520 [ $params -eq $procs ] ||
16521 error "found $params parameters vs. $procs proc files"
16523 # test the list_param -D option only returns directories
16524 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16525 #count the number of parameters by listing proc directories
16526 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16529 [ $params -eq $procs ] ||
16530 error "found $params parameters vs. $procs proc files"
16532 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16535 local save=$($LCTL get_param -n jobid_var)
16538 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16539 error "no error returned when setting bad parameters"
16541 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16542 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16544 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16545 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16546 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16548 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16551 local jobid_var_old=$($LCTL get_param -n jobid_var)
16552 local jobid_var_new
16554 $LCTL set_param jobid_var= &&
16555 error "no error returned for 'set_param a='"
16557 jobid_var_new=$($LCTL get_param -n jobid_var)
16558 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16559 error "jobid_var was changed by setting without value"
16561 $LCTL set_param jobid_var &&
16562 error "no error returned for 'set_param a'"
16564 jobid_var_new=$($LCTL get_param -n jobid_var)
16565 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16566 error "jobid_var was changed by setting without value"
16568 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16571 local jobid_var_old=$($LCTL get_param -n jobid_var)
16572 local jobid_var_new
16573 local new_value="foo=bar"
16575 $LCTL set_param jobid_var=$new_value ||
16576 error "'set_param a=b' did not accept a value containing '='"
16578 jobid_var_new=$($LCTL get_param -n jobid_var)
16579 [[ "$jobid_var_new" == "$new_value" ]] ||
16580 error "'set_param a=b' failed on a value containing '='"
16582 # Reset the jobid_var to test the other format
16583 $LCTL set_param jobid_var=$jobid_var_old
16584 jobid_var_new=$($LCTL get_param -n jobid_var)
16585 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16586 error "failed to reset jobid_var"
16588 $LCTL set_param jobid_var $new_value ||
16589 error "'set_param a b' did not accept a value containing '='"
16591 jobid_var_new=$($LCTL get_param -n jobid_var)
16592 [[ "$jobid_var_new" == "$new_value" ]] ||
16593 error "'set_param a b' failed on a value containing '='"
16595 $LCTL set_param jobid_var $jobid_var_old
16596 jobid_var_new=$($LCTL get_param -n jobid_var)
16597 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16598 error "failed to reset jobid_var"
16600 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16603 local server_version=$(lustre_version_code $SINGLEMDS)
16604 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16605 [[ $server_version -ge $(version_code 2.7.18.4) &&
16606 $server_version -lt $(version_code 2.7.50) ]] ||
16607 [[ $server_version -ge $(version_code 2.7.2) &&
16608 $server_version -lt $(version_code 2.7.11) ]] ||
16609 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16611 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16612 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16613 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16614 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16615 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16616 echo "Touch failed - OK"
16618 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16621 local file1=$DIR/$tfile.1
16622 local file2=$DIR/$tfile.2
16623 local tfile=$TMP/$tfile
16625 rm -f $file1 $file2 $tfile
16630 # 30 sec OBD_TIMEOUT in ll_getattr()
16631 # right before populating st_nlink
16632 $LCTL set_param fail_loc=0x80001409
16633 stat -c %h $file1 > $tfile &
16635 # create an alias, drop all locks and reclaim the dentry
16637 cancel_lru_locks mdc
16638 cancel_lru_locks osc
16639 sysctl -w vm.drop_caches=2
16643 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16645 rm -f $tfile $file1 $file2
16647 run_test 403 "i_nlink should not drop to zero due to aliasing"
16649 test_404() { # LU-6601
16650 local server_version=$(lustre_version_code $SINGLEMDS)
16651 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16652 { skip "Need server version newer than 2.8.52"; return 0; }
16654 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16655 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16656 awk '/osp .*-osc-MDT/ { print $4}')
16659 for osp in $mosps; do
16660 echo "Deactivate: " $osp
16661 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16662 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16663 awk -vp=$osp '$4 == p { print $2 }')
16664 [ $stat = IN ] || {
16665 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16666 error "deactivate error"
16668 echo "Activate: " $osp
16669 do_facet $SINGLEMDS $LCTL --device %$osp activate
16670 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16671 awk -vp=$osp '$4 == p { print $2 }')
16672 [ $stat = UP ] || {
16673 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16674 error "activate error"
16678 run_test 404 "validate manual {de}activated works properly for OSPs"
16681 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
16682 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
16683 skip "Layout swap lock is not supported" && return
16685 check_swap_layouts_support && return 0
16687 test_mkdir $DIR/$tdir
16688 swap_lock_test -d $DIR/$tdir ||
16689 error "One layout swap locked test failed"
16691 run_test 405 "Various layout swap lock tests"
16694 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16695 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16696 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16699 skip "Need MDS version at least 2.8.50" && return
16701 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
16702 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16703 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16704 local def_pool=$($GETSTRIPE -p $MOUNT)
16706 local test_pool=$TESTNAME
16707 pool_add $test_pool || error "pool_add failed"
16708 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16709 error "pool_add_targets failed"
16711 # parent set default stripe count only, child will stripe from both
16712 # parent and fs default
16713 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16714 error "setstripe $MOUNT failed"
16715 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16716 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16717 for i in $(seq 10); do
16718 local f=$DIR/$tdir/$tfile.$i
16719 touch $f || error "touch failed"
16720 local count=$($GETSTRIPE -c $f)
16721 [ $count -eq $OSTCOUNT ] ||
16722 error "$f stripe count $count != $OSTCOUNT"
16723 local offset=$($GETSTRIPE -i $f)
16724 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16725 local size=$($GETSTRIPE -S $f)
16726 [ $size -eq $((def_stripe_size * 2)) ] ||
16727 error "$f stripe size $size != $((def_stripe_size * 2))"
16728 local pool=$($GETSTRIPE -p $f)
16729 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16732 # change fs default striping, delete parent default striping, now child
16733 # will stripe from new fs default striping only
16734 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16735 error "change $MOUNT default stripe failed"
16736 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16737 for i in $(seq 11 20); do
16738 local f=$DIR/$tdir/$tfile.$i
16739 touch $f || error "touch $f failed"
16740 local count=$($GETSTRIPE -c $f)
16741 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16742 local offset=$($GETSTRIPE -i $f)
16743 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16744 local size=$($GETSTRIPE -S $f)
16745 [ $size -eq $def_stripe_size ] ||
16746 error "$f stripe size $size != $def_stripe_size"
16747 local pool=$($GETSTRIPE -p $f)
16748 [ "#$pool" == "#" ] || error "$f pool $pool is set"
16752 unlinkmany $DIR/$tdir/$tfile. 1 20
16754 # restore FS default striping
16755 if [ -z $def_pool ]; then
16756 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16757 -i $def_stripe_offset $MOUNT ||
16758 error "restore default striping failed"
16760 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16761 -i $def_stripe_offset -p $def_pool $MOUNT ||
16762 error "restore default striping with $def_pool failed"
16765 local f=$DIR/$tdir/$tfile
16766 pool_remove_all_targets $test_pool $f
16767 pool_remove $test_pool $f
16769 run_test 406 "DNE support fs default striping"
16772 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16773 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16774 skip "Need MDS version at least 2.8.55" && return
16775 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16777 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16778 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16779 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16780 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16781 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16783 #define OBD_FAIL_DT_TXN_STOP 0x2019
16784 for idx in $(seq $MDSCOUNT); do
16785 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16787 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16788 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16789 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16792 run_test 407 "transaction fail should cause operation fail"
16795 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16797 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16798 lctl set_param fail_loc=0x8000040a
16799 # let ll_prepare_partial_page() fail
16800 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16804 # create at least 100 unused inodes so that
16805 # shrink_icache_memory(0) should not return 0
16806 touch $DIR/$tfile-{0..100}
16807 rm -f $DIR/$tfile-{0..100}
16810 echo 2 > /proc/sys/vm/drop_caches
16812 run_test 408 "drop_caches should not hang due to page leaks"
16816 [ $MDSCOUNT -lt 2 ] &&
16817 skip "We need at least 2 MDTs for this test" && return
16819 check_mount_and_prep
16821 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16822 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16823 touch $DIR/$tdir/guard || error "(2) Fail to create"
16825 local PREFIX=$(str_repeat 'A' 128)
16826 echo "Create 1K hard links start at $(date)"
16827 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16828 error "(3) Fail to hard link"
16830 echo "Links count should be right although linkEA overflow"
16831 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16832 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16833 [ $linkcount -eq 1001 ] ||
16834 error "(5) Unexpected hard links count: $linkcount"
16836 echo "List all links start at $(date)"
16837 ls -l $DIR/$tdir/foo > /dev/null ||
16838 error "(6) Fail to list $DIR/$tdir/foo"
16840 echo "Unlink hard links start at $(date)"
16841 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16842 error "(7) Fail to unlink"
16844 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16848 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
16849 skip "Need client version at least 2.9.59" && return
16851 # Create a file, and stat it from the kernel
16852 local testfile=$DIR/$tfile
16855 local run_id=$RANDOM
16856 local my_ino=$(stat --format "%i" $testfile)
16858 # Try to insert the module. This will always fail as the
16859 # module is designed to not be inserted.
16860 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16863 # Anything but success is a test failure
16865 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16866 error "no inode match"
16868 run_test 410 "Test inode number returned from kernel thread"
16870 cleanup_test411_cgroup() {
16876 local cg_basedir=/sys/fs/cgroup/memory
16878 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
16879 { skip "no setup for cgroup"; return; }
16881 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
16882 error "test file creation failed"
16883 cancel_lru_locks osc
16885 # Create a very small memory cgroup to force a slab allocation error
16886 local cgdir=$cg_basedir/osc_slab_alloc
16887 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
16888 trap "cleanup_test411_cgroup $cgdir" EXIT
16889 echo 2M > $cgdir/memory.kmem.limit_in_bytes
16890 echo 1M > $cgdir/memory.limit_in_bytes
16892 # Should not LBUG, just be killed by oom-killer
16893 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
16894 error "fail to trigger a memory allocation error"
16896 cleanup_test411_cgroup $cgdir
16900 run_test 411 "Slab allocation error with cgroup does not LBUG"
16903 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16904 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16905 skip "Need server version at least 2.9.55" & exit 0
16906 start_full_debug_logging
16910 stop_full_debug_logging
16914 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16915 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16916 awk '/The barrier for/ { print $7 }')
16919 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16924 barrier_expired() {
16927 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16928 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16929 awk '/will be expired/ { print $7 }')
16931 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16940 echo "Start barrier_freeze at: $(date)"
16941 #define OBD_FAIL_BARRIER_DELAY 0x2202
16942 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16943 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16946 local b_status=$(barrier_stat)
16947 echo "Got barrier status at: $(date)"
16948 [ "$b_status" = "'freezing_p1'" ] ||
16949 error "(1) unexpected barrier status $b_status"
16951 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16953 b_status=$(barrier_stat)
16954 [ "$b_status" = "'frozen'" ] ||
16955 error "(2) unexpected barrier status $b_status"
16957 local expired=$(barrier_expired)
16958 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16959 sleep $((expired + 3))
16961 b_status=$(barrier_stat)
16962 [ "$b_status" = "'expired'" ] ||
16963 error "(3) unexpected barrier status $b_status"
16965 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16966 error "(4) fail to freeze barrier"
16968 b_status=$(barrier_stat)
16969 [ "$b_status" = "'frozen'" ] ||
16970 error "(5) unexpected barrier status $b_status"
16972 echo "Start barrier_thaw at: $(date)"
16973 #define OBD_FAIL_BARRIER_DELAY 0x2202
16974 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16975 do_facet mgs $LCTL barrier_thaw $FSNAME &
16978 b_status=$(barrier_stat)
16979 echo "Got barrier status at: $(date)"
16980 [ "$b_status" = "'thawing'" ] ||
16981 error "(6) unexpected barrier status $b_status"
16983 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16985 b_status=$(barrier_stat)
16986 [ "$b_status" = "'thawed'" ] ||
16987 error "(7) unexpected barrier status $b_status"
16989 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16990 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16991 do_facet mgs $LCTL barrier_freeze $FSNAME
16993 b_status=$(barrier_stat)
16994 [ "$b_status" = "'failed'" ] ||
16995 error "(8) unexpected barrier status $b_status"
16997 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16998 do_facet mgs $LCTL barrier_thaw $FSNAME
17002 run_test 801a "write barrier user interfaces and stat machine"
17007 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17008 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17009 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17010 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17011 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
17013 cancel_lru_locks mdc
17015 # 180 seconds should be long enough
17016 do_facet mgs $LCTL barrier_freeze $FSNAME 180
17018 local b_status=$(barrier_stat)
17019 [ "$b_status" = "'frozen'" ] ||
17020 error "(6) unexpected barrier status $b_status"
17022 mkdir $DIR/$tdir/d0/d10 &
17025 touch $DIR/$tdir/d1/f13 &
17028 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
17031 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
17034 rm -f $DIR/$tdir/d4/f12 &
17037 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
17039 # To guarantee taht the 'stat' is not blocked
17040 b_status=$(barrier_stat)
17041 [ "$b_status" = "'frozen'" ] ||
17042 error "(8) unexpected barrier status $b_status"
17044 # let above commands to run at background
17047 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
17048 ps -p $touch_pid || error "(10) touch should be blocked"
17049 ps -p $ln_pid || error "(11) link should be blocked"
17050 ps -p $mv_pid || error "(12) rename should be blocked"
17051 ps -p $rm_pid || error "(13) unlink should be blocked"
17053 b_status=$(barrier_stat)
17054 [ "$b_status" = "'frozen'" ] ||
17055 error "(14) unexpected barrier status $b_status"
17057 do_facet mgs $LCTL barrier_thaw $FSNAME
17058 b_status=$(barrier_stat)
17059 [ "$b_status" = "'thawed'" ] ||
17060 error "(15) unexpected barrier status $b_status"
17062 wait $mkdir_pid || error "(16) mkdir should succeed"
17063 wait $touch_pid || error "(17) touch should succeed"
17064 wait $ln_pid || error "(18) link should succeed"
17065 wait $mv_pid || error "(19) rename should succeed"
17066 wait $rm_pid || error "(20) unlink should succeed"
17070 run_test 801b "modification will be blocked by write barrier"
17073 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17077 stop mds2 || error "(1) Fail to stop mds2"
17079 do_facet mgs $LCTL barrier_freeze $FSNAME 30
17081 local b_status=$(barrier_stat)
17082 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17083 do_facet mgs $LCTL barrier_thaw $FSNAME
17084 error "(2) unexpected barrier status $b_status"
17087 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17088 error "(3) Fail to rescan barrier bitmap"
17090 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17092 b_status=$(barrier_stat)
17093 [ "$b_status" = "'frozen'" ] ||
17094 error "(4) unexpected barrier status $b_status"
17096 do_facet mgs $LCTL barrier_thaw $FSNAME
17097 b_status=$(barrier_stat)
17098 [ "$b_status" = "'thawed'" ] ||
17099 error "(5) unexpected barrier status $b_status"
17101 local devname=$(mdsdevname 2)
17103 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17105 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17106 error "(7) Fail to rescan barrier bitmap"
17110 run_test 801c "rescan barrier bitmap"
17112 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17113 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17114 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17120 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17121 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17122 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17128 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17129 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17130 skip "Need server version at least 2.9.55" & exit 0
17132 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17134 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17135 error "(2) Fail to copy"
17137 trap cleanup_802 EXIT
17139 # sync by force before remount as readonly
17140 sync; sync_all_data; sleep 3; sync_all_data
17144 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17145 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17146 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17148 echo "Mount the server as read only"
17149 setupall server_only || error "(3) Fail to start servers"
17151 echo "Mount client without ro should fail"
17152 mount_client $MOUNT &&
17153 error "(4) Mount client without 'ro' should fail"
17155 echo "Mount client with ro should succeed"
17156 mount_client $MOUNT ro ||
17157 error "(5) Mount client with 'ro' should succeed"
17159 echo "Modify should be refused"
17160 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17162 echo "Read should be allowed"
17163 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17164 error "(7) Read should succeed under ro mode"
17168 run_test 802 "simulate readonly device"
17171 # tests that do cleanup/setup should be run at the end
17175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17177 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
17178 $LCTL set_param fail_loc=0x903
17180 cancel_lru_locks MGC
17182 FAIL_ON_ERROR=true cleanup
17183 FAIL_ON_ERROR=true setup
17185 run_test 900 "umount should not race with any mgc requeue thread"
17188 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
17189 check_and_cleanup_lustre
17190 if [ "$I_MOUNTED" != "yes" ]; then
17191 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true