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
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054
16 ALWAYS_EXCEPT=" 407 253 312 $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"
21 SRCDIR=$(cd $(dirname $0); echo $PWD)
22 export PATH=$PATH:/sbin
28 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
29 CREATETEST=${CREATETEST:-createtest}
31 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
33 OPENFILE=${OPENFILE:-openfile}
34 OPENUNLINK=${OPENUNLINK:-openunlink}
35 export MULTIOP=${MULTIOP:-multiop}
36 READS=${READS:-"reads"}
37 MUNLINK=${MUNLINK:-munlink}
38 SOCKETSERVER=${SOCKETSERVER:-socketserver}
39 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
40 MEMHOG=${MEMHOG:-memhog}
41 DIRECTIO=${DIRECTIO:-directio}
42 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
57 . $LUSTRE/tests/test-framework.sh
59 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
63 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
65 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
66 # bug number for skipped test: LU-1957
67 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
69 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
72 # Get the SLES version so we can make decisions on if a test should be run
74 # Returns a version string that should only be used in comparing
75 # strings returned by version_code()
79 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
81 # All SuSE Linux versions have one decimal. version_code expects two
82 local sles_version=$version.0
83 version_code $sles_version
86 if [ -r /etc/SuSE-release ]; then
87 sles_version=$(sles_version_code)
88 [ $sles_version -lt $(version_code 11.4.0) ] &&
89 # bug number for skipped test: LU-4341
90 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
91 [ $sles_version -lt $(version_code 12.0.0) ] &&
92 # bug number for skipped test: LU-3703
93 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
100 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
101 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
110 check_swap_layouts_support()
112 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
113 { skip "Does not support layout lock."; return 0; }
117 check_and_setup_lustre
121 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
122 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
123 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
125 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
126 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
127 rm -rf $DIR/[Rdfs][0-9]*
129 # $RUNAS_ID may get set incorrectly somewhere else
130 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
132 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
136 if [ "${ONLY}" = "MOUNT" ] ; then
137 echo "Lustre is up, please go on"
141 echo "preparing for tests involving mounts"
142 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
144 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
145 echo # add a newline after mke2fs.
149 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
150 lctl set_param debug=-1 2> /dev/null || true
153 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
155 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
157 run_test 0a "touch; rm ====================="
160 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
161 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
163 run_test 0b "chmod 0755 $DIR ============================="
166 $LCTL get_param mdc.*.import | grep "state: FULL" ||
167 error "import not FULL"
168 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
171 run_test 0c "check import proc"
174 test_mkdir $DIR/$tdir
175 test_mkdir $DIR/$tdir/d2
176 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
177 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
180 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
182 run_test 1 "mkdir; remkdir; rmdir"
185 test_mkdir $DIR/$tdir
186 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
187 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
189 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
191 run_test 2 "mkdir; touch; rmdir; check file"
194 test_mkdir $DIR/$tdir
195 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
196 touch $DIR/$tdir/$tfile
197 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
199 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
201 run_test 3 "mkdir; touch; rmdir; check dir"
203 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
205 test_mkdir -i 1 $DIR/$tdir
207 touch $DIR/$tdir/$tfile ||
208 error "Create file under remote directory failed"
211 error "Expect error removing in-use dir $DIR/$tdir"
213 test -d $DIR/$tdir || error "Remote directory disappeared"
215 rm -rf $DIR/$tdir || error "remove remote dir error"
217 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
220 test_mkdir $DIR/$tdir
221 test_mkdir $DIR/$tdir/d2
222 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
223 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
224 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
226 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
229 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
230 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
231 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
232 error "$tfile does not have perm 0666 or UID $UID"
233 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
234 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
235 error "$tfile should be 0666 and owned by UID $UID"
237 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
240 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
242 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
243 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
244 error "$tfile should be owned by UID $RUNAS_ID"
245 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
246 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
247 error "$tfile should be owned by UID $RUNAS_ID"
249 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
252 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
255 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
256 error "$tfile should be owned by GID $UID"
257 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
258 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
261 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
265 test_mkdir $DIR/$tdir
266 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
267 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
268 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
269 test_mkdir $DIR/$tdir/d/subdir
270 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
271 error "$tdir/d/subdir should be GID $RUNAS_GID"
272 if [[ $MDSCOUNT -gt 1 ]]; then
273 # check remote dir sgid inherite
274 $LFS mkdir -i 0 $DIR/$tdir.local ||
275 error "mkdir $tdir.local failed"
276 chmod g+s $DIR/$tdir.local ||
277 error "chmod $tdir.local failed"
278 chgrp $RUNAS_GID $DIR/$tdir.local ||
279 error "chgrp $tdir.local failed"
280 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
281 error "mkdir $tdir.remote failed"
282 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
283 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
284 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
285 error "$tdir.remote should be mode 02755"
288 run_test 6g "verify new dir in sgid dir inherits group"
290 test_6h() { # bug 7331
291 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
292 touch $DIR/$tfile || error "touch failed"
293 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
294 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
295 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
296 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
297 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
299 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
302 test_mkdir $DIR/$tdir
303 $MCREATE $DIR/$tdir/$tfile
304 chmod 0666 $DIR/$tdir/$tfile
305 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
306 error "$tdir/$tfile should be mode 0666"
308 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
311 if [ ! -d $DIR/$tdir ]; then
312 test_mkdir $DIR/$tdir
314 $MCREATE $DIR/$tdir/$tfile
315 echo -n foo > $DIR/$tdir/$tfile
316 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
317 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
319 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
322 test_mkdir $DIR/$tdir
323 touch $DIR/$tdir/$tfile
324 chmod 0666 $DIR/$tdir/$tfile
325 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
326 error "$tfile mode not 0666"
328 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 test_mkdir $DIR/$tdir/d2/d3
334 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
336 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
339 test_mkdir $DIR/$tdir
340 test_mkdir $DIR/$tdir/d2
341 touch $DIR/$tdir/d2/$tfile
342 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
343 error "$tdir/d2/$tfile not a file"
345 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
348 test_mkdir $DIR/$tdir
349 test_mkdir $DIR/$tdir/d2
350 chmod 0666 $DIR/$tdir/d2
351 chmod 0705 $DIR/$tdir/d2
352 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
353 error "$tdir/d2 mode not 0705"
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
360 chmod 0666 $DIR/$tdir/$tfile
361 chmod 0654 $DIR/$tdir/$tfile
362 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
363 error "$tdir/d2 mode not 0654"
365 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 test_mkdir $DIR/$tdir
369 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
371 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
372 error "$tdir/$tfile size not 0 after truncate"
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
388 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
389 error "$tdir/${tfile_2} not a file after rename"
390 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
392 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
395 test_mkdir $DIR/$tdir
396 touch $DIR/$tdir/$tfile
397 rm -rf $DIR/$tdir/$tfile
398 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
400 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
403 test_mkdir $DIR/$tdir
404 touch $DIR/$tdir/$tfile
405 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
407 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
408 error "$tdir/l-exist not a symlink"
409 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
410 error "$tdir/l-exist not referencing a file"
411 rm -f $DIR/$tdir/l-exist
412 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
414 run_test 17a "symlinks: create, remove (real)"
417 test_mkdir $DIR/$tdir
418 ln -s no-such-file $DIR/$tdir/l-dangle
420 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
421 error "$tdir/l-dangle not referencing no-such-file"
422 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
423 error "$tdir/l-dangle not referencing non-existent file"
424 rm -f $DIR/$tdir/l-dangle
425 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
427 run_test 17b "symlinks: create, remove (dangling)"
429 test_17c() { # bug 3440 - don't save failed open RPC for replay
430 test_mkdir $DIR/$tdir
431 ln -s foo $DIR/$tdir/$tfile
432 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
434 run_test 17c "symlinks: open dangling (should return error)"
437 test_mkdir $DIR/$tdir
438 ln -s foo $DIR/$tdir/$tfile
439 touch $DIR/$tdir/$tfile || error "creating to new symlink"
441 run_test 17d "symlinks: create dangling"
444 test_mkdir $DIR/$tdir
445 local foo=$DIR/$tdir/$tfile
446 ln -s $foo $foo || error "create symlink failed"
447 ls -l $foo || error "ls -l failed"
448 ls $foo && error "ls not failed" || true
450 run_test 17e "symlinks: create recursive symlink (should return error)"
453 test_mkdir $DIR/$tdir
454 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
456 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
457 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
458 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
459 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
462 run_test 17f "symlinks: long and very long symlink name"
464 # str_repeat(S, N) generate a string that is string S repeated N times
469 while [ $((n -= 1)) -ge 0 ]; do
475 # Long symlinks and LU-2241
477 test_mkdir $DIR/$tdir
478 local TESTS="59 60 61 4094 4095"
480 # Fix for inode size boundary in 2.1.4
481 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
484 # Patch not applied to 2.2 or 2.3 branches
485 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
486 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
489 # skip long symlink name for rhel6.5.
490 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
491 grep -q '6.5' /etc/redhat-release &>/dev/null &&
492 TESTS="59 60 61 4062 4063"
495 local SYMNAME=$(str_repeat 'x' $i)
496 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
497 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
500 run_test 17g "symlinks: really long symlink name and inode boundaries"
502 test_17h() { #bug 17378
503 remote_mds_nodsh && skip "remote MDS with nodsh" && return
504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
506 test_mkdir $DIR/$tdir
507 if [[ $MDSCOUNT -gt 1 ]]; then
508 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
512 $LFS setstripe -c -1 $DIR/$tdir
513 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
514 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
515 touch $DIR/$tdir/$tfile || true
517 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
519 test_17i() { #bug 20018
520 remote_mds_nodsh && skip "remote MDS with nodsh" && return
521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
522 test_mkdir -c1 $DIR/$tdir
523 local foo=$DIR/$tdir/$tfile
525 if [[ $MDSCOUNT -gt 1 ]]; then
526 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
530 ln -s $foo $foo || error "create symlink failed"
531 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
532 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
533 ls -l $foo && error "error not detected"
536 run_test 17i "don't panic on short symlink"
538 test_17k() { #bug 22301
539 [[ -z "$(which rsync 2>/dev/null)" ]] &&
540 skip "no rsync command" && return 0
541 rsync --help | grep -q xattr ||
542 skip_env "$(rsync --version | head -n1) does not support xattrs"
543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
544 test_mkdir $DIR/$tdir
545 test_mkdir $DIR/$tdir.new
546 touch $DIR/$tdir/$tfile
547 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
548 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
549 error "rsync failed with xattrs enabled"
551 run_test 17k "symlinks: rsync with xattrs enabled"
553 test_17l() { # LU-279
554 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
555 skip "no getfattr command" && return 0
556 test_mkdir $DIR/$tdir
557 touch $DIR/$tdir/$tfile
558 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
559 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
560 # -h to not follow symlinks. -m '' to list all the xattrs.
561 # grep to remove first line: '# file: $path'.
562 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
564 lgetxattr_size_check $path $xattr ||
565 error "lgetxattr_size_check $path $xattr failed"
569 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
573 local short_sym="0123456789"
574 local wdir=$DIR/$tdir
577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
578 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
579 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
580 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
582 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
583 skip "ldiskfs only test" && return 0
585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
589 # create a long symlink file
590 for ((i = 0; i < 4; ++i)); do
591 long_sym=${long_sym}${long_sym}
594 echo "create 512 short and long symlink files under $wdir"
595 for ((i = 0; i < 256; ++i)); do
596 ln -sf ${long_sym}"a5a5" $wdir/long-$i
597 ln -sf ${short_sym}"a5a5" $wdir/short-$i
603 wait_delete_completed
605 echo "recreate the 512 symlink files with a shorter string"
606 for ((i = 0; i < 512; ++i)); do
607 # rewrite the symlink file with a shorter string
608 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
609 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
612 local mds_index=$(($($LFS getstripe -M $wdir) + 1))
613 local devname=$(mdsdevname $mds_index)
615 echo "stop and checking mds${mds_index}:"
616 # e2fsck should not return error
618 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
621 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
622 error "start mds${mds_index} failed"
623 df $MOUNT > /dev/null 2>&1
625 error "e2fsck detected error for short/long symlink: rc=$rc"
627 run_test 17m "run e2fsck against MDT which contains short/long symlink"
629 check_fs_consistency_17n() {
633 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
634 # so it only check MDT1/MDT2 instead of all of MDTs.
635 for mdt_index in 1 2; do
636 local devname=$(mdsdevname $mdt_index)
637 # e2fsck should not return error
639 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
642 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
643 error "mount mds$mdt_index failed"
644 df $MOUNT > /dev/null 2>&1
652 remote_mds_nodsh && skip "remote MDS with nodsh" && return
653 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
654 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
655 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
657 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
658 skip "ldiskfs only test" && return 0
660 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
664 test_mkdir $DIR/$tdir
665 for ((i=0; i<10; i++)); do
666 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
667 error "create remote dir error $i"
668 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
669 error "create files under remote dir failed $i"
672 check_fs_consistency_17n ||
673 error "e2fsck report error after create files under remote dir"
675 for ((i = 0; i < 10; i++)); do
676 rm -rf $DIR/$tdir/remote_dir_${i} ||
677 error "destroy remote dir error $i"
680 check_fs_consistency_17n ||
681 error "e2fsck report error after unlink files under remote dir"
683 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
684 skip "lustre < 2.4.50 does not support migrate mv " && return
686 for ((i = 0; i < 10; i++)); do
687 mkdir -p $DIR/$tdir/remote_dir_${i}
688 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
689 error "create files under remote dir failed $i"
690 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
691 error "migrate remote dir error $i"
693 check_fs_consistency_17n || error "e2fsck report error after migration"
695 for ((i = 0; i < 10; i++)); do
696 rm -rf $DIR/$tdir/remote_dir_${i} ||
697 error "destroy remote dir error $i"
700 check_fs_consistency_17n || error "e2fsck report error after unlink"
702 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
705 remote_mds_nodsh && skip "remote MDS with nodsh" && return
706 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
707 skip "Need MDS version at least 2.3.64" && return
709 local wdir=$DIR/${tdir}o
715 mdt_index=$($LFS getstripe -M $wdir/$tfile)
716 mdt_index=$((mdt_index + 1))
719 #fail mds will wait the failover finish then set
720 #following fail_loc to avoid interfer the recovery process.
723 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
724 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
725 ls -l $wdir/$tfile && rc=1
726 do_facet mds${mdt_index} lctl set_param fail_loc=0
727 [[ $rc -eq 0 ]] || error "stat file should fail"
729 run_test 17o "stat file with incompat LMA feature"
732 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
733 ls $DIR || error "Failed to ls $DIR: $?"
735 run_test 18 "touch .../f ; ls ... =============================="
741 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
743 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
746 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
748 run_test 19b "ls -l .../f19 (should return error) =============="
751 [ $RUNAS_ID -eq $UID ] &&
752 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
753 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
755 run_test 19c "$RUNAS touch .../f19 (should return error) =="
758 cat $DIR/f19 && error || true
760 run_test 19d "cat .../f19 (should return error) =============="
769 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
771 run_test 20 "touch .../f ; ls -l ..."
774 test_mkdir $DIR/$tdir
775 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
776 ln -s dangle $DIR/$tdir/link
777 echo foo >> $DIR/$tdir/link
778 cat $DIR/$tdir/dangle
779 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
780 $CHECKSTAT -f -t file $DIR/$tdir/link ||
781 error "$tdir/link not linked to a file"
783 run_test 21 "write to dangling link"
786 local wdir=$DIR/$tdir
788 chown $RUNAS_ID:$RUNAS_GID $wdir
789 (cd $wdir || error "cd $wdir failed";
790 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
792 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
793 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
794 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
795 error "checkstat -u failed"
797 run_test 22 "unpack tar archive as non-root user"
801 test_mkdir $DIR/$tdir
802 local file=$DIR/$tdir/$tfile
804 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
805 openfile -f O_CREAT:O_EXCL $file &&
806 error "$file recreate succeeded" || true
808 run_test 23a "O_CREAT|O_EXCL in subdir"
810 test_23b() { # bug 18988
811 test_mkdir $DIR/$tdir
812 local file=$DIR/$tdir/$tfile
815 echo foo > $file || error "write filed"
816 echo bar >> $file || error "append filed"
817 $CHECKSTAT -s 8 $file || error "wrong size"
820 run_test 23b "O_APPEND check"
824 echo '-- same directory rename'
825 test_mkdir $DIR/$tdir
826 touch $DIR/$tdir/$tfile.1
827 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
828 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
830 run_test 24a "rename file to non-existent target"
833 test_mkdir $DIR/$tdir
834 touch $DIR/$tdir/$tfile.{1,2}
835 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
836 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
837 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
839 run_test 24b "rename file to existing target"
842 test_mkdir $DIR/$tdir
843 test_mkdir $DIR/$tdir/d$testnum.1
844 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
845 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
846 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
848 run_test 24c "rename directory to non-existent target"
851 test_mkdir -c1 $DIR/$tdir
852 test_mkdir -c1 $DIR/$tdir/d$testnum.1
853 test_mkdir -c1 $DIR/$tdir/d$testnum.2
854 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
855 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
856 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
858 run_test 24d "rename directory to existing target"
861 echo '-- cross directory renames --'
865 mv $DIR/R5a/f $DIR/R5b/g
866 $CHECKSTAT -a $DIR/R5a/f || error
867 $CHECKSTAT -t file $DIR/R5b/g || error
869 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
874 touch $DIR/R6a/f $DIR/R6b/g
875 mv $DIR/R6a/f $DIR/R6b/g
876 $CHECKSTAT -a $DIR/R6a/f || error
877 $CHECKSTAT -t file $DIR/R6b/g || error
879 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
884 test_mkdir $DIR/R7a/d
885 mv $DIR/R7a/d $DIR/R7b/e
886 $CHECKSTAT -a $DIR/R7a/d || error
887 $CHECKSTAT -t dir $DIR/R7b/e || error
889 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
892 test_mkdir -c1 $DIR/R8a
893 test_mkdir -c1 $DIR/R8b
894 test_mkdir -c1 $DIR/R8a/d
895 test_mkdir -c1 $DIR/R8b/e
896 mrename $DIR/R8a/d $DIR/R8b/e
897 $CHECKSTAT -a $DIR/R8a/d || error
898 $CHECKSTAT -t dir $DIR/R8b/e || error
900 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
903 echo "-- rename error cases"
907 mrename $DIR/R9/f $DIR/R9/a
908 $CHECKSTAT -t file $DIR/R9/f || error
909 $CHECKSTAT -t dir $DIR/R9/a || error
910 $CHECKSTAT -a $DIR/R9/a/f || error
912 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
916 mrename $DIR/R10/f $DIR/R10/g
917 $CHECKSTAT -t dir $DIR/R10 || error
918 $CHECKSTAT -a $DIR/R10/f || error
919 $CHECKSTAT -a $DIR/R10/g || error
921 run_test 24j "source does not exist ============================"
925 test_mkdir $DIR/R11a/d
927 mv $DIR/R11a/f $DIR/R11a/d
928 $CHECKSTAT -a $DIR/R11a/f || error
929 $CHECKSTAT -t file $DIR/R11a/d/f || error
931 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
933 # bug 2429 - rename foo foo foo creates invalid file
936 $MULTIOP $f OcNs || error
938 run_test 24l "Renaming a file to itself ========================"
942 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
943 # on ext3 this does not remove either the source or target files
944 # though the "expected" operation would be to remove the source
945 $CHECKSTAT -t file ${f} || error "${f} missing"
946 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
948 run_test 24m "Renaming a file to a hard link to itself ========="
952 # this stats the old file after it was renamed, so it should fail
956 $CHECKSTAT ${f}.rename
959 run_test 24n "Statting the old file after renaming (Posix rename 2)"
962 test_mkdir $DIR/$tdir
963 rename_many -s random -v -n 10 $DIR/$tdir
965 run_test 24o "rename of files during htree split"
970 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
971 mrename $DIR/R12a $DIR/R12b
972 $CHECKSTAT -a $DIR/R12a || error
973 $CHECKSTAT -t dir $DIR/R12b || error
974 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
975 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
977 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
979 cleanup_multiop_pause() {
985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
988 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
989 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
992 trap cleanup_multiop_pause EXIT
993 mrename $DIR/R13a $DIR/R13b
994 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
995 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
996 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
997 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
998 cleanup_multiop_pause
999 wait $MULTIPID || error "multiop close failed"
1001 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1003 test_24r() { #bug 3789
1004 test_mkdir $DIR/R14a
1005 test_mkdir $DIR/R14a/b
1006 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1007 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1008 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1010 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1013 test_mkdir $DIR/R15a
1014 test_mkdir $DIR/R15a/b
1015 test_mkdir $DIR/R15a/b/c
1016 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1017 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1018 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1020 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1022 test_mkdir $DIR/R16a
1023 test_mkdir $DIR/R16a/b
1024 test_mkdir $DIR/R16a/b/c
1025 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1026 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1027 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1029 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1031 test_24u() { # bug12192
1032 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1033 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1035 run_test 24u "create stripe file"
1039 size=$(getconf PAGE_SIZE 2>/dev/null)
1040 echo -n ${size:-4096}
1043 simple_cleanup_common() {
1046 [ -z "$DIR" -o -z "$tdir" ] && return 0
1048 local start=$SECONDS
1051 wait_delete_completed
1052 echo "cleanup time $((SECONDS - start))"
1056 max_pages_per_rpc() {
1057 local mdtname="$(printf "MDT%04x" ${1:-0})"
1058 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1063 local nrfiles=${COUNT:-100000}
1064 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1065 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1067 local fname="$DIR/$tdir/$tfile"
1068 test_mkdir "$(dirname $fname)"
1069 # assume MDT0000 has the fewest inodes
1070 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1071 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1072 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1074 trap simple_cleanup_common EXIT
1076 createmany -m "$fname" $nrfiles
1078 cancel_lru_locks mdc
1079 lctl set_param mdc.*.stats clear
1081 # was previously test_24D: LU-6101
1082 # readdir() returns correct number of entries after cursor reload
1083 local num_ls=$(ls $DIR/$tdir | wc -l)
1084 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1085 local num_all=$(ls -a $DIR/$tdir | wc -l)
1086 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1087 $num_all -ne $((nrfiles + 2)) ]; then
1088 error "Expected $nrfiles files, got $num_ls " \
1089 "($num_uniq unique $num_all .&..)"
1091 # LU-5 large readdir
1092 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1093 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1094 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1095 # take into account of overhead in lu_dirpage header and end mark in
1096 # each page, plus one in rpc_num calculation.
1097 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1098 local page_entries=$((($(page_size) - 24) / dirent_size))
1099 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1100 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1101 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1102 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1103 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1104 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1105 error "large readdir doesn't take effect: " \
1106 "$mds_readpage should be about $rpc_max"
1108 simple_cleanup_common
1110 run_test 24v "list large directory (test hash collision, b=17560)"
1112 test_24w() { # bug21506
1114 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1115 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1116 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1117 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1118 [[ "$SZ1" -eq "$SZ2" ]] ||
1119 error "Error reading at the end of the file $tfile"
1121 run_test 24w "Reading a file larger than 4Gb"
1124 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1126 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1127 skip "Need MDS version at least 2.7.56" && return
1129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1131 local remote_dir=$DIR/$tdir/remote_dir
1133 test_mkdir $DIR/$tdir
1134 $LFS mkdir -i $MDTIDX $remote_dir ||
1135 error "create remote directory failed"
1137 test_mkdir $DIR/$tdir/src_dir
1138 touch $DIR/$tdir/src_file
1139 test_mkdir $remote_dir/tgt_dir
1140 touch $remote_dir/tgt_file
1142 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1143 error "rename dir cross MDT failed!"
1145 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1146 error "rename file cross MDT failed!"
1148 touch $DIR/$tdir/ln_file
1149 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1150 error "ln file cross MDT failed"
1152 rm -rf $DIR/$tdir || error "Can not delete directories"
1154 run_test 24x "cross MDT rename/link"
1157 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1158 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1159 local remote_dir=$DIR/$tdir/remote_dir
1162 test_mkdir $DIR/$tdir
1163 $LFS mkdir -i $mdtidx $remote_dir ||
1164 error "create remote directory failed"
1166 test_mkdir $remote_dir/src_dir
1167 touch $remote_dir/src_file
1168 test_mkdir $remote_dir/tgt_dir
1169 touch $remote_dir/tgt_file
1171 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1172 error "rename subdir in the same remote dir failed!"
1174 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1175 error "rename files in the same remote dir failed!"
1177 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1178 error "link files in the same remote dir failed!"
1180 rm -rf $DIR/$tdir || error "Can not delete directories"
1182 run_test 24y "rename/link on the same dir should succeed"
1184 test_24A() { # LU-3182
1188 test_mkdir $DIR/$tdir
1189 trap simple_cleanup_common EXIT
1190 createmany -m $DIR/$tdir/$tfile $NFILES
1191 local t=$(ls $DIR/$tdir | wc -l)
1192 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1193 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1194 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1195 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1198 simple_cleanup_common || error "Can not delete directories"
1200 run_test 24A "readdir() returns correct number of entries."
1202 test_24B() { # LU-4805
1203 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1206 test_mkdir $DIR/$tdir
1207 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1208 error "create striped dir failed"
1210 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1211 [ $count -eq 2 ] || error "Expected 2, got $count"
1213 touch $DIR/$tdir/striped_dir/a
1215 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1216 [ $count -eq 3 ] || error "Expected 3, got $count"
1218 touch $DIR/$tdir/striped_dir/.f
1220 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1221 [ $count -eq 4 ] || error "Expected 4, got $count"
1223 rm -rf $DIR/$tdir || error "Can not delete directories"
1225 run_test 24B "readdir for striped dir return correct number of entries"
1228 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1234 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1235 error "create striped dir failed"
1237 cd $DIR/$tdir/d0/striped_dir
1239 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1240 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1241 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1243 [ "$d0_ino" = "$parent_ino" ] ||
1244 error ".. wrong, expect $d0_ino, get $parent_ino"
1246 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1247 error "mv striped dir failed"
1249 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1251 [ "$d1_ino" = "$parent_ino" ] ||
1252 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1254 run_test 24C "check .. in striped dir"
1257 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1261 mkdir $DIR/$tdir/src_dir
1262 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1263 error "create remote source failed"
1265 touch $DIR/$tdir/src_dir/src_child/a
1267 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1268 error "create remote target dir failed"
1270 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1271 error "create remote target child failed"
1273 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1274 error "rename dir cross MDT failed!"
1278 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1279 error "src_child still exists after rename"
1281 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1282 error "missing file(a) after rename"
1284 rm -rf $DIR/$tdir || error "Can not delete directories"
1286 run_test 24E "cross MDT rename/link"
1289 echo '== symlink sanity ============================================='
1293 touch $DIR/s25/foo || error
1295 run_test 25a "create file in symlinked directory ==============="
1298 [ ! -d $DIR/d25 ] && test_25a
1299 $CHECKSTAT -t file $DIR/s25/foo || error
1301 run_test 25b "lookup file in symlinked directory ==============="
1305 test_mkdir $DIR/d26/d26-2
1306 ln -s d26/d26-2 $DIR/s26
1307 touch $DIR/s26/foo || error
1309 run_test 26a "multiple component symlink ======================="
1312 test_mkdir -p $DIR/$tdir/d26-2
1313 ln -s $tdir/d26-2/foo $DIR/s26-2
1314 touch $DIR/s26-2 || error
1316 run_test 26b "multiple component symlink at end of lookup ======"
1319 test_mkdir $DIR/d26.2
1320 touch $DIR/d26.2/foo
1321 ln -s d26.2 $DIR/s26.2-1
1322 ln -s s26.2-1 $DIR/s26.2-2
1323 ln -s s26.2-2 $DIR/s26.2-3
1324 chmod 0666 $DIR/s26.2-3/foo
1326 run_test 26c "chain of symlinks"
1328 # recursive symlinks (bug 439)
1330 ln -s d26-3/foo $DIR/d26-3
1332 run_test 26d "create multiple component recursive symlink"
1335 [ ! -h $DIR/d26-3 ] && test_26d
1338 run_test 26e "unlink multiple component recursive symlink"
1340 # recursive symlinks (bug 7022)
1342 test_mkdir $DIR/$tdir
1343 test_mkdir $DIR/$tdir/$tfile
1344 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1345 test_mkdir -p lndir/bar1
1346 test_mkdir $DIR/$tdir/$tfile/$tfile
1347 cd $tfile || error "cd $tfile failed"
1348 ln -s .. dotdot || error "ln dotdot failed"
1349 ln -s dotdot/lndir lndir || error "ln lndir failed"
1350 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1351 output=`ls $tfile/$tfile/lndir/bar1`
1352 [ "$output" = bar1 ] && error "unexpected output"
1353 rm -r $tfile || error "rm $tfile failed"
1354 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1356 run_test 26f "rm -r of a directory which has recursive symlink"
1359 test_mkdir $DIR/$tdir
1360 $LFS getstripe $DIR/$tdir
1361 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1362 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1363 cp /etc/hosts $DIR/$tdir/$tfile || error
1365 run_test 27a "one stripe file"
1368 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1369 test_mkdir $DIR/$tdir
1370 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1371 $LFS getstripe -c $DIR/$tdir/$tfile
1372 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1373 error "two-stripe file doesn't have two stripes"
1375 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1377 run_test 27b "create and write to two stripe file"
1380 test_mkdir $DIR/$tdir
1381 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1382 error "setstripe failed"
1383 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1384 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1386 run_test 27d "create file with default settings"
1389 # LU-5839 adds check for existed layout before setting it
1390 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1391 skip "Need MDS version at least 2.7.56" && return
1392 test_mkdir $DIR/$tdir
1393 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1394 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1395 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1397 run_test 27e "setstripe existing file (should return error)"
1400 test_mkdir $DIR/$tdir
1401 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1402 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1403 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1404 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1405 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1406 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1408 run_test 27f "setstripe with bad stripe size (should return error)"
1411 test_mkdir $DIR/$tdir
1412 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1413 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1414 error "$DIR/$tdir/$tfile has object"
1416 run_test 27g "$LFS getstripe with no objects"
1419 test_mkdir $DIR/$tdir
1420 touch $DIR/$tdir/$tfile || error "touch failed"
1421 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1422 error "missing objects"
1424 run_test 27i "$LFS getstripe with some objects"
1427 test_mkdir $DIR/$tdir
1428 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1429 error "setstripe failed" || true
1431 run_test 27j "setstripe with bad stripe offset (should return error)"
1433 test_27k() { # bug 2844
1434 test_mkdir $DIR/$tdir
1435 local file=$DIR/$tdir/$tfile
1436 local ll_max_blksize=$((4 * 1024 * 1024))
1437 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1438 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1439 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1440 dd if=/dev/zero of=$file bs=4k count=1
1441 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1442 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1444 run_test 27k "limit i_blksize for broken user apps"
1447 mcreate $DIR/$tfile || error "creating file"
1448 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1449 error "setstripe should have failed" || true
1451 run_test 27l "check setstripe permissions (should return error)"
1454 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1456 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1458 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1459 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1462 trap simple_cleanup_common EXIT
1463 test_mkdir $DIR/$tdir
1464 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1465 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1466 error "dd should fill OST0"
1468 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1470 [ $i -gt 256 ] && break
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"
1478 touch $DIR/$tdir/$tfile.$i
1479 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1480 awk '{print $1}'| grep -w "0") ] &&
1481 error "OST0 was full but new created file still use it"
1482 simple_cleanup_common
1484 run_test 27m "create file while OST0 was full"
1487 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1488 head -n 1 | awk '{ print $1 * 2 }')
1492 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1493 # if the OST isn't full anymore.
1495 local OSTIDX=${1:-""}
1497 local list=$(comma_list $(osts_nodes))
1498 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1500 do_nodes $list lctl set_param fail_loc=0
1501 sync # initiate all OST_DESTROYs from MDS to OST
1505 exhaust_precreations() {
1508 local FAILIDX=${3:-$OSTIDX}
1509 local ofacet=ost$((OSTIDX + 1))
1511 test_mkdir -p -c1 $DIR/$tdir
1512 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1513 local mfacet=mds$((mdtidx + 1))
1514 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1516 local OST=$(ostname_from_index $OSTIDX)
1519 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1520 local last_id=$(do_facet $mfacet lctl get_param -n \
1521 osc.$mdtosc_proc1.prealloc_last_id)
1522 local next_id=$(do_facet $mfacet lctl get_param -n \
1523 osc.$mdtosc_proc1.prealloc_next_id)
1525 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1526 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1528 test_mkdir -p $DIR/$tdir/${OST}
1529 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1530 #define OBD_FAIL_OST_ENOSPC 0x215
1531 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1532 echo "Creating to objid $last_id on ost $OST..."
1533 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1534 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1535 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1539 exhaust_all_precreations() {
1541 for (( i=0; i < OSTCOUNT; i++ )) ; do
1542 exhaust_precreations $i $1 -1
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 exhaust_precreations 0 0x80000215
1555 $LFS setstripe -c -1 $DIR/$tdir
1556 touch $DIR/$tdir/$tfile || error
1557 $LFS getstripe $DIR/$tdir/$tfile
1560 run_test 27n "create file with some full OSTs"
1563 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1566 remote_ost_nodsh && skip "remote OST with nodsh" && return
1569 rm -f $DIR/$tdir/$tfile
1570 exhaust_all_precreations 0x215
1572 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1577 run_test 27o "create file with all full OSTs (should error)"
1580 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1582 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1583 remote_ost_nodsh && skip "remote OST with nodsh" && return
1586 rm -f $DIR/$tdir/$tfile
1587 test_mkdir $DIR/$tdir
1589 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1590 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1591 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1593 exhaust_precreations 0 0x80000215
1594 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1595 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1596 $LFS getstripe $DIR/$tdir/$tfile
1600 run_test 27p "append to a truncated file with some full OSTs"
1603 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1606 remote_ost_nodsh && skip "remote OST with nodsh" && return
1609 rm -f $DIR/$tdir/$tfile
1611 test_mkdir $DIR/$tdir
1612 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1613 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1614 error "truncate $DIR/$tdir/$tfile failed"
1615 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1617 exhaust_all_precreations 0x215
1619 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1620 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1624 run_test 27q "append to truncated file with all OSTs full (should error)"
1627 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1630 remote_ost_nodsh && skip "remote OST with nodsh" && return
1633 rm -f $DIR/$tdir/$tfile
1634 exhaust_precreations 0 0x80000215
1636 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1640 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1642 test_27s() { # bug 10725
1643 test_mkdir $DIR/$tdir
1644 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1645 local stripe_count=0
1646 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1647 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1648 error "stripe width >= 2^32 succeeded" || true
1651 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1653 test_27t() { # bug 10864
1658 $WLFS getstripe $tfile
1661 run_test 27t "check that utils parse path correctly"
1663 test_27u() { # bug 4900
1664 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1665 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1667 local list=$(comma_list $(mdts_nodes))
1669 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1670 do_nodes $list $LCTL set_param fail_loc=0x139
1671 test_mkdir -p $DIR/$tdir
1672 trap simple_cleanup_common EXIT
1673 createmany -o $DIR/$tdir/t- 1000
1674 do_nodes $list $LCTL set_param fail_loc=0
1676 TLOG=$TMP/$tfile.getstripe
1677 $LFS getstripe $DIR/$tdir > $TLOG
1678 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1679 unlinkmany $DIR/$tdir/t- 1000
1681 [[ $OBJS -gt 0 ]] &&
1682 error "$OBJS objects created on OST-0. See $TLOG" ||
1685 run_test 27u "skip object creation on OSC w/o objects"
1687 test_27v() { # bug 4900
1688 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1690 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1691 remote_ost_nodsh && skip "remote OST with nodsh" && return
1693 exhaust_all_precreations 0x215
1696 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1698 touch $DIR/$tdir/$tfile
1699 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1701 for (( i=1; i < OSTCOUNT; i++ )); do
1702 do_facet ost$i lctl set_param fail_loc=0x705
1704 local START=`date +%s`
1705 createmany -o $DIR/$tdir/$tfile 32
1707 local FINISH=`date +%s`
1708 local TIMEOUT=`lctl get_param -n timeout`
1709 local PROCESS=$((FINISH - START))
1710 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1711 error "$FINISH - $START >= $TIMEOUT / 2"
1712 sleep $((TIMEOUT / 2 - PROCESS))
1715 run_test 27v "skip object creation on slow OST"
1717 test_27w() { # bug 10997
1718 test_mkdir $DIR/$tdir
1719 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1720 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1721 error "stripe size $size != 65536" || true
1722 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1723 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1725 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1728 [[ $OSTCOUNT -lt 2 ]] &&
1729 skip_env "skipping multiple stripe count/offset test" && return
1731 test_mkdir $DIR/$tdir
1732 for i in $(seq 1 $OSTCOUNT); do
1734 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1735 error "setstripe -c $i -i $offset failed"
1736 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1737 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1738 [ $count -ne $i ] && error "stripe count $count != $i" || true
1739 [ $index -ne $offset ] &&
1740 error "stripe offset $index != $offset" || true
1743 run_test 27wa "check $LFS setstripe -c -i options"
1746 remote_ost_nodsh && skip "remote OST with nodsh" && return
1747 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1749 OFFSET=$(($OSTCOUNT - 1))
1751 local OST=$(ostname_from_index $OSTIDX)
1753 test_mkdir $DIR/$tdir
1754 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1755 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1757 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1758 for i in $(seq 0 $OFFSET); do
1759 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1760 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1761 error "OST0 was degraded but new created file still use it"
1763 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1765 run_test 27x "create files while OST0 is degraded"
1768 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1769 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1770 remote_ost_nodsh && skip "remote OST with nodsh" && return
1771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1773 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1774 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1775 osc.$mdtosc.prealloc_last_id)
1776 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1777 osc.$mdtosc.prealloc_next_id)
1778 local fcount=$((last_id - next_id))
1779 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1780 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1782 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1783 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1784 local OST_DEACTIVE_IDX=-1
1789 for OSC in $MDS_OSCS; do
1790 OST=$(osc_to_ost $OSC)
1791 OSTIDX=$(index_from_ostuuid $OST)
1792 if [ $OST_DEACTIVE_IDX == -1 ]; then
1793 OST_DEACTIVE_IDX=$OSTIDX
1795 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1796 echo $OSC "is Deactivated:"
1797 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1801 OSTIDX=$(index_from_ostuuid $OST)
1802 test_mkdir $DIR/$tdir
1803 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1805 for OSC in $MDS_OSCS; do
1806 OST=$(osc_to_ost $OSC)
1807 OSTIDX=$(index_from_ostuuid $OST)
1808 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1809 echo $OST "is degraded:"
1810 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1811 obdfilter.$OST.degraded=1
1816 createmany -o $DIR/$tdir/$tfile $fcount
1818 for OSC in $MDS_OSCS; do
1819 OST=$(osc_to_ost $OSC)
1820 OSTIDX=$(index_from_ostuuid $OST)
1821 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1822 echo $OST "is recovered from degraded:"
1823 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1824 obdfilter.$OST.degraded=0
1826 do_facet $SINGLEMDS lctl --device %$OSC activate
1830 # all osp devices get activated, hence -1 stripe count restored
1831 local stripe_count=0
1833 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1834 # devices get activated.
1836 $LFS setstripe -c -1 $DIR/$tfile
1837 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1839 [ $stripe_count -ne $OSTCOUNT ] &&
1840 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1843 run_test 27y "create files while OST0 is degraded and the rest inactive"
1849 lmm_count=$($GETSTRIPE -c $1)
1850 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1851 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1853 local old_ifs="$IFS"
1855 fid=($($LFS path2fid $1))
1858 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1859 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1861 # compare lmm_seq and lu_fid->f_seq
1862 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1863 # compare lmm_object_id and lu_fid->oid
1864 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1866 # check the trusted.fid attribute of the OST objects of the file
1867 local have_obdidx=false
1869 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1870 # skip lines up to and including "obdidx"
1871 [ -z "$obdidx" ] && break
1872 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1873 $have_obdidx || continue
1875 local ost=$((obdidx + 1))
1876 local dev=$(ostdevname $ost)
1879 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1881 seq=$(echo $seq | sed -e "s/^0x//g")
1882 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1883 oid_hex=$(echo $oid)
1885 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1887 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1891 # Don't unmount/remount the OSTs if we don't need to do that.
1892 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1893 # update too, until that use mount/ll_decode_filter_fid/mount.
1894 # Re-enable when debugfs will understand new filter_fid.
1896 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1897 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1898 $dev 2>/dev/null" | grep "parent=")
1900 if [ -z "$ff" ]; then
1902 mount_fstype ost$ost
1903 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1904 $(facet_mntpt ost$ost)/$obj_file)
1905 unmount_fstype ost$ost
1906 start ost$ost $dev $OST_MOUNT_OPTS
1910 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1912 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1914 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1915 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1917 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1918 # stripe_size=1048576 component_id=1 component_start=0 \
1919 # component_end=33554432
1920 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1921 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1922 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1924 if grep -q 'stripe=' <<<$ff; then
1925 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1927 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1928 # into f_ver in this case. See comment on ff_parent.
1929 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1932 # compare lmm_seq and filter_fid->ff_parent.f_seq
1933 [ $ff_pseq = $lmm_seq ] ||
1934 error "FF parent SEQ $ff_pseq != $lmm_seq"
1935 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1936 [ $ff_poid = $lmm_oid ] ||
1937 error "FF parent OID $ff_poid != $lmm_oid"
1938 (($ff_pstripe == $stripe_nr)) ||
1939 error "FF stripe $ff_pstripe != $stripe_nr"
1941 stripe_nr=$((stripe_nr + 1))
1942 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1944 if grep -q 'stripe_count=' <<<$ff; then
1945 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1946 -e 's/ .*//' <<<$ff)
1947 [ $lmm_count = $ff_scnt ] ||
1948 error "FF stripe count $lmm_count != $ff_scnt"
1954 remote_ost_nodsh && skip "remote OST with nodsh" && return
1955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1956 test_mkdir $DIR/$tdir
1958 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1959 { error "setstripe -c -1 failed"; return 1; }
1960 # We need to send a write to every object to get parent FID info set.
1961 # This _should_ also work for setattr, but does not currently.
1962 # touch $DIR/$tdir/$tfile-1 ||
1963 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1964 { error "dd $tfile-1 failed"; return 2; }
1965 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1966 { error "setstripe -c -1 failed"; return 3; }
1967 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1968 { error "dd $tfile-2 failed"; return 4; }
1970 # make sure write RPCs have been sent to OSTs
1973 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1974 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1976 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1978 test_27A() { # b=19102
1979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1980 local restore_size=$($GETSTRIPE -S $MOUNT)
1981 local restore_count=$($GETSTRIPE -c $MOUNT)
1982 local restore_offset=$($GETSTRIPE -i $MOUNT)
1983 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1984 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1985 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1986 local default_size=$($GETSTRIPE -S $MOUNT)
1987 local default_offset=$($GETSTRIPE -i $MOUNT)
1988 local dsize=$((1024 * 1024))
1989 [ $default_size -eq $dsize ] ||
1990 error "stripe size $default_size != $dsize"
1991 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1992 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1994 run_test 27A "check filesystem-wide default LOV EA values"
1996 test_27B() { # LU-2523
1997 test_mkdir $DIR/$tdir
1998 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2000 # open f1 with O_LOV_DELAY_CREATE
2002 # call setstripe ioctl on open file descriptor for f1
2004 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2008 # open f1 with O_LOV_DELAY_CREATE
2010 # call setstripe ioctl on open file descriptor for f1
2012 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2014 # Allow multiop to fail in imitation of NFS's busted semantics.
2017 run_test 27B "call setstripe on open unlinked file/rename victim"
2019 test_27C() { #LU-2871
2020 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2028 test_mkdir $DIR/$tdir
2030 for i in $(seq 0 $((OSTCOUNT - 1))); do
2031 # set stripe across all OSTs starting from OST$i
2032 $SETSTRIPE -i $i -c -1 $tfile$i
2033 # get striping information
2034 ost_idx=($($GETSTRIPE $tfile$i |
2035 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2039 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2040 error "${#ost_idx[@]} != $OSTCOUNT"
2042 for index in $(seq 0 $((OSTCOUNT - 1))); do
2044 for j in $(echo ${ost_idx[@]}); do
2045 if [ $index -eq $j ]; then
2051 error "Can not find $index in ${ost_idx[@]}"
2055 run_test 27C "check full striping across all OSTs"
2058 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2059 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2060 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2061 local POOL=${POOL:-testpool}
2063 local last_ost=$(($OSTCOUNT - 1))
2065 local ost_list=$(seq $first_ost $ost_step $last_ost)
2066 local ost_range="$first_ost $last_ost $ost_step"
2068 if ! combined_mgs_mds ; then
2072 test_mkdir $DIR/$tdir
2073 pool_add $POOL || error "pool_add failed"
2074 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2077 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2079 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2080 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2081 skip27D += "-s 30,31"
2082 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2083 error "llapi_layout_test failed"
2085 destroy_test_pools || error "destroy test pools failed"
2087 if ! combined_mgs_mds ; then
2091 run_test 27D "validate llapi_layout API"
2093 # Verify that default_easize is increased from its initial value after
2094 # accessing a widely striped file.
2096 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2097 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2098 skip "client does not have LU-3338 fix" && return
2100 # 72 bytes is the minimum space required to store striping
2101 # information for a file striped across one OST:
2102 # (sizeof(struct lov_user_md_v3) +
2103 # sizeof(struct lov_user_ost_data_v1))
2105 $LCTL set_param -n llite.*.default_easize $min_easize ||
2106 error "lctl set_param failed"
2107 local easize=$($LCTL get_param -n llite.*.default_easize)
2109 [ $easize -eq $min_easize ] ||
2110 error "failed to set default_easize"
2112 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2113 error "setstripe failed"
2117 easize=$($LCTL get_param -n llite.*.default_easize)
2119 [ $easize -gt $min_easize ] ||
2120 error "default_easize not updated"
2122 run_test 27E "check that default extended attribute size properly increases"
2124 test_27F() { # LU-5346/LU-7975
2125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2126 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2127 skip "Need MDS version at least 2.8.51" && return
2128 remote_ost_nodsh && skip "remote OST with nodsh" && return
2130 test_mkdir $DIR/$tdir
2132 $SETSTRIPE -c 2 $DIR/$tdir
2134 # stop all OSTs to reproduce situation for LU-7975 ticket
2135 for num in $(seq $OSTCOUNT); do
2139 # open/create f0 with O_LOV_DELAY_CREATE
2140 # truncate f0 to a non-0 size
2142 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2144 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2145 # open/write it again to force delayed layout creation
2146 cat /etc/hosts > $DIR/$tdir/f0 &
2150 for num in $(seq $OSTCOUNT); do
2151 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2152 error "ost$num failed to start"
2155 wait $catpid || error "cat failed"
2157 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2158 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2161 run_test 27F "Client resend delayed layout creation with non-zero size"
2163 # createtest also checks that device nodes are created and
2164 # then visible correctly (#2091)
2165 test_28() { # bug 2091
2167 $CREATETEST $DIR/d28/ct || error
2169 run_test 28 "create/mknod/mkdir with bad file types ============"
2172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2173 sync; sleep 1; sync # flush out any dirty pages from previous tests
2180 declare -i LOCKCOUNTORIG=0
2181 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2182 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2184 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2186 declare -i LOCKUNUSEDCOUNTORIG=0
2187 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2188 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2195 declare -i LOCKCOUNTCURRENT=0
2196 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2197 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2200 declare -i LOCKUNUSEDCOUNTCURRENT=0
2201 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2202 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2205 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2206 $LCTL set_param -n ldlm.dump_namespaces ""
2207 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2208 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2209 log "dumped log to $TMP/test_29.dk (bug 5793)"
2212 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2213 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2214 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2215 log "dumped log to $TMP/test_29.dk (bug 5793)"
2219 run_test 29 "IT_GETATTR regression ============================"
2221 test_30a() { # was test_30
2222 cp $(which ls) $DIR || cp /bin/ls $DIR
2226 run_test 30a "execute binary from Lustre (execve) =============="
2229 cp `which ls` $DIR || cp /bin/ls $DIR
2231 $RUNAS $DIR/ls / || error
2234 run_test 30b "execute binary from Lustre as non-root ==========="
2236 test_30c() { # b=22376
2237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2238 cp `which ls` $DIR || cp /bin/ls $DIR
2240 cancel_lru_locks mdc
2241 cancel_lru_locks osc
2242 $RUNAS $DIR/ls / || error
2245 run_test 30c "execute binary from Lustre without read perms ===="
2248 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2249 $CHECKSTAT -a $DIR/f31 || error
2251 run_test 31a "open-unlink file =================================="
2254 touch $DIR/f31 || error
2255 ln $DIR/f31 $DIR/f31b || error
2256 $MULTIOP $DIR/f31b Ouc || error
2257 $CHECKSTAT -t file $DIR/f31 || error
2259 run_test 31b "unlink file with multiple links while open ======="
2262 touch $DIR/f31 || error
2263 ln $DIR/f31 $DIR/f31c || error
2264 multiop_bg_pause $DIR/f31 O_uc || return 1
2266 $MULTIOP $DIR/f31c Ouc
2267 kill -USR1 $MULTIPID
2270 run_test 31c "open-unlink file with multiple links ============="
2273 opendirunlink $DIR/d31d $DIR/d31d || error
2274 $CHECKSTAT -a $DIR/d31d || error
2276 run_test 31d "remove of open directory ========================="
2278 test_31e() { # bug 2904
2279 openfilleddirunlink $DIR/d31e || error
2281 run_test 31e "remove of open non-empty directory ==============="
2283 test_31f() { # bug 4554
2284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2286 test_mkdir $DIR/d31f
2287 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2288 cp /etc/hosts $DIR/d31f
2290 $GETSTRIPE $DIR/d31f/hosts
2291 multiop_bg_pause $DIR/d31f D_c || return 1
2294 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2295 test_mkdir $DIR/d31f
2296 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2297 cp /etc/hosts $DIR/d31f
2299 $GETSTRIPE $DIR/d31f/hosts
2300 multiop_bg_pause $DIR/d31f D_c || return 1
2303 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2304 wait $MULTIPID || error "first opendir $MULTIPID failed"
2308 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2309 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2312 run_test 31f "remove of open directory with open-unlink file ==="
2315 echo "-- cross directory link --"
2316 test_mkdir -c1 $DIR/${tdir}ga
2317 test_mkdir -c1 $DIR/${tdir}gb
2318 touch $DIR/${tdir}ga/f
2319 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2320 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2321 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2322 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2323 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2325 run_test 31g "cross directory link==============="
2328 echo "-- cross directory link --"
2329 test_mkdir -c1 $DIR/${tdir}
2330 test_mkdir -c1 $DIR/${tdir}/dir
2331 touch $DIR/${tdir}/f
2332 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2333 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2334 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2335 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2336 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2338 run_test 31h "cross directory link under child==============="
2341 echo "-- cross directory link --"
2342 test_mkdir -c1 $DIR/$tdir
2343 test_mkdir -c1 $DIR/$tdir/dir
2344 touch $DIR/$tdir/dir/f
2345 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2346 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2347 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2348 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2349 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2351 run_test 31i "cross directory link under parent==============="
2354 test_mkdir -c1 -p $DIR/$tdir
2355 test_mkdir -c1 -p $DIR/$tdir/dir1
2356 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2357 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2358 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2359 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2362 run_test 31j "link for directory==============="
2365 test_mkdir -c1 -p $DIR/$tdir
2367 touch $DIR/$tdir/exist
2368 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2369 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2370 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2371 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2372 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2373 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2374 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2377 run_test 31k "link to file: the same, non-existing, dir==============="
2383 touch $DIR/d31m2/exist
2384 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2385 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2386 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2387 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2388 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2389 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2392 run_test 31m "link to file: the same, non-existing, dir==============="
2395 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2396 nlink=$(stat --format=%h $DIR/$tfile)
2397 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2399 local cmd="exec $fd<$DIR/$tfile"
2402 trap "eval $cmd" EXIT
2403 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2404 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2405 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2406 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2407 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2410 run_test 31n "check link count of unlinked file"
2413 local TEMPNAME=$(mktemp $1_XXXXXX)
2414 mlink $TEMPNAME $1 2> /dev/null &&
2415 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2419 test_31o() { # LU-2901
2420 test_mkdir $DIR/$tdir
2421 for LOOP in $(seq 100); do
2422 rm -f $DIR/$tdir/$tfile*
2423 for THREAD in $(seq 8); do
2424 link_one $DIR/$tdir/$tfile.$LOOP &
2427 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2428 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2429 error "$LINKS duplicate links to $tfile.$LOOP" &&
2433 run_test 31o "duplicate hard links with same filename"
2436 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2438 test_mkdir $DIR/$tdir
2439 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2440 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2442 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2443 error "open unlink test1 failed"
2444 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2445 error "open unlink test2 failed"
2447 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2448 error "test1 still exists"
2449 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2450 error "test2 still exists"
2452 run_test 31p "remove of open striped directory"
2454 cleanup_test32_mount() {
2457 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2458 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2459 losetup -d $loopdev || true
2465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2466 echo "== more mountpoints and symlinks ================="
2467 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2471 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2472 cleanup_test32_mount
2474 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2478 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2479 trap cleanup_test32_mount EXIT
2480 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2481 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2482 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2483 cleanup_test32_mount
2485 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2489 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2490 trap cleanup_test32_mount EXIT
2491 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2492 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2493 test_mkdir -p $DIR/$tdir/d2/test_dir
2494 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2495 cleanup_test32_mount
2497 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2501 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2502 trap cleanup_test32_mount EXIT
2503 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2504 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2505 test_mkdir -p $DIR/$tdir/d2/test_dir
2506 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2507 cleanup_test32_mount
2509 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2513 test_mkdir -p $DIR/$tdir/tmp
2514 local tmp_dir=$DIR/$tdir/tmp
2515 ln -s $DIR/$tdir $tmp_dir/symlink11
2516 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2517 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2518 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2520 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2524 test_mkdir -p $DIR/$tdir/tmp
2525 local tmp_dir=$DIR/$tdir/tmp
2526 ln -s $DIR/$tdir $tmp_dir/symlink11
2527 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2528 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2529 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2531 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2534 local 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 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2540 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2541 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2542 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2544 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2547 rm -fr $DIR/$tdir $DIR/${tdir}2
2548 tmp_dir=$DIR/$tdir/tmp
2549 test_mkdir -p $tmp_dir
2550 test_mkdir $DIR/${tdir}2
2551 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2552 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2553 ls $tmp_dir/symlink12 || error "listing symlink12"
2554 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2556 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2560 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2561 trap cleanup_test32_mount EXIT
2562 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2563 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2564 touch $DIR/$tdir/test_file
2565 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2566 cleanup_test32_mount
2568 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2572 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2573 trap cleanup_test32_mount EXIT
2574 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2575 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2576 touch $DIR/$tdir/test_file
2577 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2578 cleanup_test32_mount
2580 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2585 trap cleanup_test32_mount EXIT
2586 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2587 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2588 test_mkdir -p $DIR/$tdir/d2
2589 touch $DIR/$tdir/d2/test_file || error
2590 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2591 cleanup_test32_mount
2593 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2598 trap cleanup_test32_mount EXIT
2599 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2600 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2601 test_mkdir -p $DIR/$tdir/d2
2602 touch $DIR/$tdir/d2/test_file
2603 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2604 cleanup_test32_mount
2606 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2610 test_mkdir -p $DIR/d32m/tmp
2611 TMP_DIR=$DIR/d32m/tmp
2612 ln -s $DIR $TMP_DIR/symlink11
2613 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2614 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2615 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2617 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2621 test_mkdir -p $DIR/d32n/tmp
2622 TMP_DIR=$DIR/d32n/tmp
2623 ln -s $DIR $TMP_DIR/symlink11
2624 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2625 ls -l $DIR/d32n/tmp/symlink11 || error
2626 ls -l $DIR/d32n/symlink01 || error
2628 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2632 test_mkdir -p $DIR/d32o/tmp
2633 TMP_DIR=$DIR/d32o/tmp
2634 ln -s $DIR/$tfile $TMP_DIR/symlink12
2635 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2636 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2637 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2638 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2639 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2641 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2651 test_mkdir -p $DIR/d32p/tmp
2653 TMP_DIR=$DIR/d32p/tmp
2655 ln -s $DIR/$tfile $TMP_DIR/symlink12
2657 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2659 cat $DIR/d32p/tmp/symlink12 || error
2661 cat $DIR/d32p/symlink02 || error
2664 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2668 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2669 trap cleanup_test32_mount EXIT
2670 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2671 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2672 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2673 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2674 cleanup_test32_mount
2676 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2680 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2681 trap cleanup_test32_mount EXIT
2682 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2683 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2684 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2685 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2686 cleanup_test32_mount
2688 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2693 chmod 444 $DIR/$tfile
2694 chown $RUNAS_ID $DIR/$tfile
2696 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2699 run_test 33aa "write file with mode 444 (should return error)"
2703 test_mkdir $DIR/$tdir
2704 chown $RUNAS_ID $DIR/$tdir
2705 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2706 error "$RUNAS create $tdir/$tfile failed"
2707 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2708 error "open RDWR" || true
2710 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2714 test_mkdir $DIR/$tdir
2715 chown $RUNAS_ID $DIR/$tdir
2716 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2718 run_test 33b "test open file with malformed flags (No panic)"
2721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2727 remote_ost_nodsh && skip "remote OST with nodsh" && return
2730 test_mkdir $DIR/$tdir
2731 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2734 for ostnum in $(seq $OSTCOUNT); do
2735 # test-framework's OST numbering is one-based, while Lustre's
2737 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2738 # Parsing llobdstat's output sucks; we could grep the /proc
2739 # path, but that's likely to not be as portable as using the
2740 # llobdstat utility. So we parse lctl output instead.
2741 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2742 obdfilter/$ostname/stats |
2743 awk '/^write_bytes/ {print $7}' )
2744 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2745 if (( ${write_bytes:-0} > 0 ))
2752 $all_zeros || return 0
2755 echo foo > $DIR/$tdir/bar
2759 # Total up write_bytes after writing. We'd better find non-zeros.
2760 for ostnum in $(seq $OSTCOUNT); do
2761 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2762 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2763 obdfilter/$ostname/stats |
2764 awk '/^write_bytes/ {print $7}' )
2765 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2766 if (( ${write_bytes:-0} > 0 ))
2775 for ostnum in $(seq $OSTCOUNT); do
2776 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2777 echo "Check that write_bytes is present in obdfilter/*/stats:"
2778 do_facet ost$ostnum lctl get_param -n \
2779 obdfilter/$ostname/stats
2781 error "OST not keeping write_bytes stats (b22312)"
2784 run_test 33c "test llobdstat and write_bytes"
2787 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2790 local remote_dir=$DIR/$tdir/remote_dir
2792 test_mkdir $DIR/$tdir
2793 $LFS mkdir -i $MDTIDX $remote_dir ||
2794 error "create remote directory failed"
2796 touch $remote_dir/$tfile
2797 chmod 444 $remote_dir/$tfile
2798 chown $RUNAS_ID $remote_dir/$tfile
2800 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2802 chown $RUNAS_ID $remote_dir
2803 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2804 error "create" || true
2805 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2806 error "open RDWR" || true
2807 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2809 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2812 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
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 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2821 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2822 local 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"
2827 rmdir $DIR/$tdir/* || error "rmdir 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 777"
2841 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2844 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2845 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2846 mkdir $DIR/$tdir/local_dir
2848 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2849 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2850 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2852 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2853 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2855 run_test 33e "mkdir and striped directory should have same mode"
2859 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2863 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2864 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2867 chmod go+rwx $DIR/$tdir
2868 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2869 trap cleanup_33f EXIT
2871 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2872 error "cannot create striped directory"
2874 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2875 error "cannot create files in striped directory"
2877 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2878 error "cannot remove files in striped directory"
2880 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2881 error "cannot remove striped directory"
2885 run_test 33f "nonroot user can create, access, and remove a striped directory"
2888 mkdir -p $DIR/$tdir/dir2
2890 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2892 [[ $err =~ "exists" ]] || error "Not exists error"
2894 run_test 33g "nonroot user create already existing root created file"
2896 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2899 $MCREATE $DIR/f34 || error
2900 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2901 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2902 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2903 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2905 run_test 34a "truncate file that has not been opened ==========="
2908 [ ! -f $DIR/f34 ] && test_34a
2909 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2910 $OPENFILE -f O_RDONLY $DIR/f34
2911 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2912 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2914 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2917 [ ! -f $DIR/f34 ] && test_34a
2918 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2919 $OPENFILE -f O_RDWR $DIR/f34
2920 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2921 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2923 run_test 34c "O_RDWR opening file-with-size works =============="
2926 [ ! -f $DIR/f34 ] && test_34a
2927 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2928 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2931 run_test 34d "write to sparse file ============================="
2935 $MCREATE $DIR/f34e || error
2936 $TRUNCATE $DIR/f34e 1000 || error
2937 $CHECKSTAT -s 1000 $DIR/f34e || error
2938 $OPENFILE -f O_RDWR $DIR/f34e
2939 $CHECKSTAT -s 1000 $DIR/f34e || error
2941 run_test 34e "create objects, some with size and some without =="
2943 test_34f() { # bug 6242, 6243
2944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2947 $MCREATE $DIR/f34f || error
2948 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2949 dd if=$DIR/f34f of=$TMP/f34f
2950 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2951 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2952 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2953 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2954 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2956 run_test 34f "read from a file with no objects until EOF ======="
2959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2960 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2961 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2962 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2963 cancel_lru_locks osc
2964 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2965 error "wrong size after lock cancel"
2967 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2968 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2969 error "expanding truncate failed"
2970 cancel_lru_locks osc
2971 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2972 error "wrong expanded size after lock cancel"
2974 run_test 34g "truncate long file ==============================="
2977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2981 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2982 sync # Flush the cache so that multiop below does not block on cache
2983 # flush when getting the group lock
2984 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2987 # Since just timed wait is not good enough, let's do a sync write
2988 # that way we are sure enough time for a roundtrip + processing
2989 # passed + 2 seconds of extra margin.
2990 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2994 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2995 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2999 local nsz=`stat -c %s $DIR/$tfile`
3000 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3002 run_test 34h "ftruncate file under grouplock should not block"
3005 cp /bin/sh $DIR/f35a
3007 chown $RUNAS_ID $DIR/f35a
3008 $RUNAS $DIR/f35a && error || true
3011 run_test 35a "exec file with mode 444 (should return and not leak)"
3015 utime $DIR/f36 || error
3017 run_test 36a "MDS utime check (mknod, utime)"
3021 utime $DIR/f36 || error
3023 run_test 36b "OST utime check (open, utime)"
3028 chown $RUNAS_ID $DIR/d36
3029 $RUNAS utime $DIR/d36/f36 || error
3031 run_test 36c "non-root MDS utime check (mknod, utime)"
3034 [ ! -d $DIR/d36 ] && test_36c
3035 echo "" > $DIR/d36/f36
3036 $RUNAS utime $DIR/d36/f36 || error
3038 run_test 36d "non-root OST utime check (open, utime)"
3041 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3042 test_mkdir $DIR/$tdir
3043 touch $DIR/$tdir/$tfile
3044 $RUNAS utime $DIR/$tdir/$tfile &&
3045 error "utime worked, expected failure" || true
3047 run_test 36e "utime on non-owned file (should return error)"
3051 local LANG_SAVE=$LANG
3052 local LC_LANG_SAVE=$LC_LANG
3053 export LANG=C LC_LANG=C # for date language
3055 DATESTR="Dec 20 2000"
3056 test_mkdir $DIR/$tdir
3057 lctl set_param fail_loc=$fl
3059 cp /etc/hosts $DIR/$tdir/$tfile
3060 sync & # write RPC generated with "current" inode timestamp, but delayed
3062 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3063 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3064 cancel_lru_locks osc
3065 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3067 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3068 echo "BEFORE: $LS_BEFORE" && \
3069 echo "AFTER : $LS_AFTER" && \
3070 echo "WANT : $DATESTR" && \
3071 error "$DIR/$tdir/$tfile timestamps changed" || true
3073 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3079 subr_36fh "0x80000214"
3081 run_test 36f "utime on file racing with OST BRW write =========="
3084 remote_ost_nodsh && skip "remote OST with nodsh" && return
3085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3090 test_mkdir $DIR/$tdir
3091 fmd_max_age=$(do_facet ost1 \
3092 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3095 fmd_before=$(do_facet ost1 \
3096 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3097 touch $DIR/$tdir/$tfile
3098 sleep $((fmd_max_age + 12))
3099 fmd_after=$(do_facet ost1 \
3100 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3102 echo "fmd_before: $fmd_before"
3103 echo "fmd_after: $fmd_after"
3104 [[ $fmd_after -gt $fmd_before ]] &&
3105 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3106 error "fmd didn't expire after ping" || true
3108 run_test 36g "filter mod data cache expiry ====================="
3111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3112 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3113 subr_36fh "0x80000227"
3115 run_test 36h "utime on file racing with OST BRW write =========="
3118 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3120 test_mkdir $DIR/$tdir
3121 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3123 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3124 local new_mtime=$((mtime + 200))
3126 #change Modify time of striped dir
3127 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3128 error "change mtime failed"
3130 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3132 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3134 run_test 36i "change mtime on striped directory"
3136 # test_37 - duplicate with tests 32q 32r
3139 local file=$DIR/$tfile
3141 openfile -f O_DIRECTORY $file
3144 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3145 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3147 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3149 test_39a() { # was test_39
3151 touch $DIR/${tfile}2
3152 # ls -l $DIR/$tfile $DIR/${tfile}2
3153 # ls -lu $DIR/$tfile $DIR/${tfile}2
3154 # ls -lc $DIR/$tfile $DIR/${tfile}2
3156 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3157 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3159 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3161 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3163 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3164 error "O_TRUNC didn't change timestamps"
3167 run_test 39a "mtime changed on create"
3170 test_mkdir -c1 $DIR/$tdir
3171 cp -p /etc/passwd $DIR/$tdir/fopen
3172 cp -p /etc/passwd $DIR/$tdir/flink
3173 cp -p /etc/passwd $DIR/$tdir/funlink
3174 cp -p /etc/passwd $DIR/$tdir/frename
3175 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3178 echo "aaaaaa" >> $DIR/$tdir/fopen
3179 echo "aaaaaa" >> $DIR/$tdir/flink
3180 echo "aaaaaa" >> $DIR/$tdir/funlink
3181 echo "aaaaaa" >> $DIR/$tdir/frename
3183 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3184 local link_new=`stat -c %Y $DIR/$tdir/flink`
3185 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3186 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3188 cat $DIR/$tdir/fopen > /dev/null
3189 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3190 rm -f $DIR/$tdir/funlink2
3191 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3193 for (( i=0; i < 2; i++ )) ; do
3194 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3195 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3196 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3197 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3199 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3200 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3201 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3202 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3204 cancel_lru_locks osc
3205 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3208 run_test 39b "mtime change on open, link, unlink, rename ======"
3210 # this should be set to past
3211 TEST_39_MTIME=`date -d "1 year ago" +%s`
3217 local mtime0=`stat -c %Y $DIR1/$tfile`
3219 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3220 local mtime1=`stat -c %Y $DIR1/$tfile`
3221 [ "$mtime1" = $TEST_39_MTIME ] || \
3222 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3225 echo hello >> $DIR1/$tfile
3227 local mtime2=`stat -c %Y $DIR1/$tfile`
3228 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3229 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3231 mv $DIR1/$tfile $DIR1/$tfile-1
3233 for (( i=0; i < 2; i++ )) ; do
3234 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3235 [ "$mtime2" = "$mtime3" ] || \
3236 error "mtime ($mtime2) changed (to $mtime3) on rename"
3238 cancel_lru_locks osc
3239 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3242 run_test 39c "mtime change on rename ==========================="
3246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3249 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3251 for (( i=0; i < 2; i++ )) ; do
3252 local mtime=`stat -c %Y $DIR1/$tfile`
3253 [ $mtime = $TEST_39_MTIME ] || \
3254 error "mtime($mtime) is not set to $TEST_39_MTIME"
3256 cancel_lru_locks osc
3257 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3260 run_test 39d "create, utime, stat =============================="
3264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3266 local mtime1=`stat -c %Y $DIR1/$tfile`
3268 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3270 for (( i=0; i < 2; i++ )) ; do
3271 local mtime2=`stat -c %Y $DIR1/$tfile`
3272 [ $mtime2 = $TEST_39_MTIME ] || \
3273 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3275 cancel_lru_locks osc
3276 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3279 run_test 39e "create, stat, utime, stat ========================"
3283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3285 mtime1=`stat -c %Y $DIR1/$tfile`
3288 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3290 for (( i=0; i < 2; i++ )) ; do
3291 local mtime2=`stat -c %Y $DIR1/$tfile`
3292 [ $mtime2 = $TEST_39_MTIME ] || \
3293 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3295 cancel_lru_locks osc
3296 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3299 run_test 39f "create, stat, sleep, utime, stat ================="
3303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3304 echo hello >> $DIR1/$tfile
3305 local mtime1=`stat -c %Y $DIR1/$tfile`
3308 chmod o+r $DIR1/$tfile
3310 for (( i=0; i < 2; i++ )) ; do
3311 local mtime2=`stat -c %Y $DIR1/$tfile`
3312 [ "$mtime1" = "$mtime2" ] || \
3313 error "lost mtime: $mtime2, should be $mtime1"
3315 cancel_lru_locks osc
3316 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3319 run_test 39g "write, chmod, stat ==============================="
3323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3328 echo hello >> $DIR1/$tfile
3329 local mtime1=`stat -c %Y $DIR1/$tfile`
3331 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3333 if [ "$d1" != "$d2" ]; then
3334 echo "write and touch not within one second"
3336 for (( i=0; i < 2; i++ )) ; do
3337 local mtime2=`stat -c %Y $DIR1/$tfile`
3338 [ "$mtime2" = $TEST_39_MTIME ] || \
3339 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3341 cancel_lru_locks osc
3342 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3346 run_test 39h "write, utime within one second, stat ============="
3349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3353 echo hello >> $DIR1/$tfile
3354 local mtime1=`stat -c %Y $DIR1/$tfile`
3356 mv $DIR1/$tfile $DIR1/$tfile-1
3358 for (( i=0; i < 2; i++ )) ; do
3359 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3361 [ "$mtime1" = "$mtime2" ] || \
3362 error "lost mtime: $mtime2, should be $mtime1"
3364 cancel_lru_locks osc
3365 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3368 run_test 39i "write, rename, stat =============================="
3371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3372 start_full_debug_logging
3376 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3377 lctl set_param fail_loc=0x80000412
3378 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3379 error "multiop failed"
3381 local mtime1=`stat -c %Y $DIR1/$tfile`
3383 mv $DIR1/$tfile $DIR1/$tfile-1
3385 kill -USR1 $multipid
3386 wait $multipid || error "multiop close failed"
3388 for (( i=0; i < 2; i++ )) ; do
3389 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3390 [ "$mtime1" = "$mtime2" ] ||
3391 error "mtime is lost on close: $mtime2, " \
3394 cancel_lru_locks osc
3395 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3397 lctl set_param fail_loc=0
3398 stop_full_debug_logging
3400 run_test 39j "write, rename, close, stat ======================="
3403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3407 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3409 local mtime1=`stat -c %Y $DIR1/$tfile`
3411 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3413 kill -USR1 $multipid
3414 wait $multipid || error "multiop close failed"
3416 for (( i=0; i < 2; i++ )) ; do
3417 local mtime2=`stat -c %Y $DIR1/$tfile`
3419 [ "$mtime2" = $TEST_39_MTIME ] || \
3420 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3422 cancel_lru_locks osc
3423 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3426 run_test 39k "write, utime, close, stat ========================"
3428 # this should be set to future
3429 TEST_39_ATIME=`date -d "1 year" +%s`
3432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3433 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3434 local atime_diff=$(do_facet $SINGLEMDS \
3435 lctl get_param -n mdd.*MDT0000*.atime_diff)
3439 # test setting directory atime to future
3440 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3441 local atime=$(stat -c %X $DIR/$tdir)
3442 [ "$atime" = $TEST_39_ATIME ] ||
3443 error "atime is not set to future: $atime, $TEST_39_ATIME"
3445 # test setting directory atime from future to now
3446 local now=$(date +%s)
3447 touch -a -d @$now $DIR/$tdir
3449 atime=$(stat -c %X $DIR/$tdir)
3450 [ "$atime" -eq "$now" ] ||
3451 error "atime is not updated from future: $atime, $now"
3453 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3456 # test setting directory atime when now > dir atime + atime_diff
3457 local d1=$(date +%s)
3459 local d2=$(date +%s)
3460 cancel_lru_locks mdc
3461 atime=$(stat -c %X $DIR/$tdir)
3462 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3463 error "atime is not updated : $atime, should be $d2"
3465 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3468 # test not setting directory atime when now < dir atime + atime_diff
3470 cancel_lru_locks mdc
3471 atime=$(stat -c %X $DIR/$tdir)
3472 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3473 error "atime is updated to $atime, should remain $d1<atime<$d2"
3475 do_facet $SINGLEMDS \
3476 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3478 run_test 39l "directory atime update ==========================="
3481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3484 local far_past_mtime=$(date -d "May 29 1953" +%s)
3485 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3487 touch -m -d @$far_past_mtime $DIR1/$tfile
3488 touch -a -d @$far_past_atime $DIR1/$tfile
3490 for (( i=0; i < 2; i++ )) ; do
3491 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3492 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3493 error "atime or mtime set incorrectly"
3495 cancel_lru_locks osc
3496 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3499 run_test 39m "test atime and mtime before 1970"
3501 test_39n() { # LU-3832
3502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3503 local atime_diff=$(do_facet $SINGLEMDS \
3504 lctl get_param -n mdd.*MDT0000*.atime_diff)
3509 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3512 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3513 atime0=$(stat -c %X $DIR/$tfile)
3516 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3517 atime1=$(stat -c %X $DIR/$tfile)
3520 cancel_lru_locks mdc
3521 cancel_lru_locks osc
3522 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3523 atime2=$(stat -c %X $DIR/$tfile)
3525 do_facet $SINGLEMDS \
3526 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3528 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3529 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3531 run_test 39n "check that O_NOATIME is honored"
3534 TESTDIR=$DIR/$tdir/$tfile
3535 [ -e $TESTDIR ] && rm -rf $TESTDIR
3542 links2=$(stat -c %h .)
3543 [ $(($links1 + 2)) != $links2 ] &&
3544 error "wrong links count $(($links1 + 2)) != $links2"
3546 links3=$(stat -c %h .)
3547 [ $(($links1 + 1)) != $links3 ] &&
3548 error "wrong links count $links1 != $links3"
3551 run_test 39o "directory cached attributes updated after create"
3554 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3556 TESTDIR=$DIR/$tdir/$tdir
3557 [ -e $TESTDIR ] && rm -rf $TESTDIR
3558 test_mkdir -p $TESTDIR
3562 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3563 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3565 links2=$(stat -c %h .)
3566 [ $(($links1 + 2)) != $links2 ] &&
3567 error "wrong links count $(($links1 + 2)) != $links2"
3569 links3=$(stat -c %h .)
3570 [ $(($links1 + 1)) != $links3 ] &&
3571 error "wrong links count $links1 != $links3"
3574 run_test 39p "remote directory cached attributes updated after create ========"
3577 test_39q() { # LU-8041
3578 local testdir=$DIR/$tdir
3580 multiop_bg_pause $testdir D_c || error "multiop failed"
3582 cancel_lru_locks mdc
3583 kill -USR1 $multipid
3584 local atime=$(stat -c %X $testdir)
3585 [ "$atime" -ne 0 ] || error "atime is zero"
3587 run_test 39q "close won't zero out atime"
3590 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3591 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3592 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3593 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3594 error "$tfile is not 4096 bytes in size"
3596 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3600 small_write $DIR/f41 18
3602 run_test 41 "test small file write + fstat ====================="
3604 count_ost_writes() {
3605 lctl get_param -n ${OSC}.*.stats |
3606 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3607 END { printf("%0.0f", writes) }'
3614 BG_DIRTY_RATIO_SAVE=10
3615 MAX_BG_DIRTY_RATIO=25
3619 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3620 # dirty_ratio, dirty_background_ratio
3621 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3622 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3623 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3624 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3626 # if file not here, we are a 2.4 kernel
3627 kill -CONT `pidof kupdated`
3632 # setup the trap first, so someone cannot exit the test at the
3633 # exact wrong time and mess up a machine
3634 trap start_writeback EXIT
3635 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3636 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3637 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3638 sysctl -w vm.dirty_writeback_centisecs=0
3639 sysctl -w vm.dirty_writeback_centisecs=0
3640 # save and increase /proc/sys/vm/dirty_ratio
3641 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3642 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3643 # save and increase /proc/sys/vm/dirty_background_ratio
3644 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3645 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3647 # if file not here, we are a 2.4 kernel
3648 kill -STOP `pidof kupdated`
3652 # ensure that all stripes have some grant before we test client-side cache
3654 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3655 dd if=/dev/zero of=$i bs=4k count=1
3660 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3661 # file truncation, and file removal.
3663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3665 cancel_lru_locks $OSC
3667 sync; sleep 1; sync # just to be safe
3668 BEFOREWRITES=`count_ost_writes`
3669 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3670 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3671 AFTERWRITES=`count_ost_writes`
3672 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3673 error "$BEFOREWRITES < $AFTERWRITES"
3676 run_test 42a "ensure that we don't flush on close"
3679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3681 cancel_lru_locks $OSC
3684 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3685 BEFOREWRITES=$(count_ost_writes)
3686 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3687 AFTERWRITES=$(count_ost_writes)
3688 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3689 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3691 BEFOREWRITES=$(count_ost_writes)
3692 sync || error "sync: $?"
3693 AFTERWRITES=$(count_ost_writes)
3694 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3695 error "$BEFOREWRITES < $AFTERWRITES on sync"
3697 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3701 run_test 42b "test destroy of file with cached dirty data ======"
3703 # if these tests just want to test the effect of truncation,
3704 # they have to be very careful. consider:
3705 # - the first open gets a {0,EOF}PR lock
3706 # - the first write conflicts and gets a {0, count-1}PW
3707 # - the rest of the writes are under {count,EOF}PW
3708 # - the open for truncate tries to match a {0,EOF}PR
3709 # for the filesize and cancels the PWs.
3710 # any number of fixes (don't get {0,EOF} on open, match
3711 # composite locks, do smarter file size management) fix
3712 # this, but for now we want these tests to verify that
3713 # the cancellation with truncate intent works, so we
3714 # start the file with a full-file pw lock to match against
3715 # until the truncate.
3720 cancel_lru_locks $OSC
3722 # prime the file with 0,EOF PW to match
3726 # now the real test..
3727 dd if=/dev/zero of=$file bs=1024 count=100
3728 BEFOREWRITES=`count_ost_writes`
3729 $TRUNCATE $file $offset
3730 cancel_lru_locks $OSC
3731 AFTERWRITES=`count_ost_writes`
3736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3738 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3739 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3742 run_test 42c "test partial truncate of file with cached dirty data"
3745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3747 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3748 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3751 run_test 42d "test complete truncate of file with cached dirty data"
3753 test_42e() { # bug22074
3754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3755 local TDIR=$DIR/${tdir}e
3756 local pagesz=$(page_size)
3757 local pages=16 # hardcoded 16 pages, don't change it.
3758 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3759 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3763 test_mkdir $DIR/${tdir}e
3764 $SETSTRIPE -c 1 $TDIR
3765 createmany -o $TDIR/f $files
3767 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3769 # we assume that with $OSTCOUNT files, at least one of them will
3770 # be allocated on OST0.
3771 warmup_files=$((OSTCOUNT * max_dirty_mb))
3772 createmany -o $TDIR/w $warmup_files
3774 # write a large amount of data into one file and sync, to get good
3775 # avail_grant number from OST.
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="$max_dirty_mb"M count=1
3782 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3784 $LCTL get_param $proc_osc0/cur_dirty_bytes
3785 $LCTL get_param $proc_osc0/cur_grant_bytes
3787 # create as much dirty pages as we can while not to trigger the actual
3788 # RPCs directly. but depends on the env, VFS may trigger flush during this
3789 # period, hopefully we are good.
3790 for ((i=0; i<$warmup_files; i++)); do
3791 idx=$($GETSTRIPE -i $TDIR/w$i)
3792 [ $idx -ne 0 ] && continue
3793 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3795 $LCTL get_param $proc_osc0/cur_dirty_bytes
3796 $LCTL get_param $proc_osc0/cur_grant_bytes
3798 # perform the real test
3799 $LCTL set_param $proc_osc0/rpc_stats 0
3800 for ((;i<$files; i++)); do
3801 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3802 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3805 $LCTL get_param $proc_osc0/rpc_stats
3808 local have_ppr=false
3809 $LCTL get_param $proc_osc0/rpc_stats |
3810 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3811 # skip lines until we are at the RPC histogram data
3812 [ "$PPR" == "pages" ] && have_ppr=true && continue
3813 $have_ppr || continue
3815 # we only want the percent stat for < 16 pages
3816 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3818 percent=$((percent + WPCT))
3819 if [[ $percent -gt 15 ]]; then
3820 error "less than 16-pages write RPCs" \
3827 run_test 42e "verify sub-RPC writes are not done synchronously"
3829 test_43A() { # was test_43
3830 test_mkdir $DIR/$tdir
3831 cp -p /bin/ls $DIR/$tdir/$tfile
3832 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3834 # give multiop a chance to open
3837 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3840 run_test 43A "execution of file opened for write should return -ETXTBSY"
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"
3848 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3850 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3851 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3852 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3854 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3858 test_mkdir $DIR/$tdir
3859 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3860 cp -p multiop $DIR/$tdir/multiop
3861 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3862 error "multiop open $TMP/$tfile.junk failed"
3863 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3865 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3866 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3867 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3869 run_test 43b "truncate of file being executed should return -ETXTBSY"
3872 local testdir="$DIR/$tdir"
3875 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3876 ( cd $testdir && md5sum -c )
3878 run_test 43c "md5sum of copy into lustre"
3880 test_44A() { # was test_44
3881 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3882 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3883 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3885 run_test 44A "zero length read from a sparse stripe"
3888 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3890 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3891 [[ $nstripe -gt $OSTCOUNT ]] &&
3892 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3894 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3896 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3897 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3901 OFFSETS="0 $((stride/2)) $((stride-1))"
3902 for offset in $OFFSETS; do
3903 for i in $(seq 0 $((nstripe-1))); do
3904 local GLOBALOFFSETS=""
3906 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3907 local myfn=$DIR/d44a-$size
3908 echo "--------writing $myfn at $size"
3909 ll_sparseness_write $myfn $size ||
3910 error "ll_sparseness_write"
3911 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3912 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3913 error "ll_sparseness_verify $GLOBALOFFSETS"
3915 for j in $(seq 0 $((nstripe-1))); do
3917 size=$((((j + $nstripe )*$stride + $offset)))
3918 ll_sparseness_write $myfn $size ||
3919 error "ll_sparseness_write"
3920 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3922 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3923 error "ll_sparseness_verify $GLOBALOFFSETS"
3928 run_test 44a "test sparse pwrite ==============================="
3932 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
3938 before=`dirty_osc_total`
3939 echo executing "\"$*\""
3941 after=`dirty_osc_total`
3942 echo before $before, after $after
3945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3947 # Obtain grants from OST if it supports it
3948 echo blah > ${f}_grant
3951 do_dirty_record "echo blah > $f"
3952 [[ $before -eq $after ]] && error "write wasn't cached"
3953 do_dirty_record "> $f"
3954 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3955 do_dirty_record "echo blah > $f"
3956 [[ $before -eq $after ]] && error "write wasn't cached"
3957 do_dirty_record "sync"
3958 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3959 do_dirty_record "echo blah > $f"
3960 [[ $before -eq $after ]] && error "write wasn't cached"
3961 do_dirty_record "cancel_lru_locks osc"
3962 [[ $before -gt $after ]] ||
3963 error "lock cancellation didn't lower dirty count"
3966 run_test 45 "osc io page accounting ============================"
3968 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3969 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3970 # objects offset and an assert hit when an rpc was built with 1023's mapped
3971 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3977 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3979 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3980 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3984 run_test 46 "dirtying a previously written page ================"
3986 # test_47 is removed "Device nodes check" is moved to test_28
3988 test_48a() { # bug 2399
3989 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3990 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3991 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3993 test_mkdir $DIR/$tdir
3995 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3996 test_mkdir $DIR/$tdir
3997 touch foo || error "'touch foo' failed after recreating cwd"
3999 touch .foo || error "'touch .foo' failed after recreating cwd"
4001 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4002 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4003 cd . || error "'cd .' failed after recreating cwd"
4004 mkdir . && error "'mkdir .' worked after recreating cwd"
4005 rmdir . && error "'rmdir .' worked after recreating cwd"
4006 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4007 cd .. || error "'cd ..' failed after recreating cwd"
4009 run_test 48a "Access renamed working dir (should return errors)="
4011 test_48b() { # bug 2399
4013 test_mkdir $DIR/$tdir
4015 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4016 touch foo && error "'touch foo' worked after removing cwd"
4017 mkdir foo && error "'mkdir foo' worked after removing cwd"
4018 touch .foo && error "'touch .foo' worked after removing cwd"
4019 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4020 ls . > /dev/null && error "'ls .' worked after removing cwd"
4021 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4022 mkdir . && error "'mkdir .' worked after removing cwd"
4023 rmdir . && error "'rmdir .' worked after removing cwd"
4024 ln -s . foo && error "'ln -s .' worked after removing cwd"
4025 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4027 run_test 48b "Access removed working dir (should return errors)="
4029 test_48c() { # bug 2350
4030 #lctl set_param debug=-1
4033 test_mkdir -p $DIR/$tdir/dir
4035 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4036 $TRACE touch foo && error "touch foo worked after removing cwd"
4037 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4038 touch .foo && error "touch .foo worked after removing cwd"
4039 mkdir .foo && error "mkdir .foo worked after removing cwd"
4040 $TRACE ls . && error "'ls .' worked after removing cwd"
4041 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4042 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4043 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4044 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4045 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4047 run_test 48c "Access removed working subdir (should return errors)"
4049 test_48d() { # bug 2350
4050 #lctl set_param debug=-1
4053 test_mkdir -p $DIR/$tdir/dir
4055 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4056 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4057 $TRACE touch foo && error "'touch foo' worked after removing parent"
4058 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4059 touch .foo && error "'touch .foo' worked after removing parent"
4060 mkdir .foo && error "mkdir .foo worked after removing parent"
4061 $TRACE ls . && error "'ls .' worked after removing parent"
4062 $TRACE ls .. && error "'ls ..' worked after removing parent"
4063 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4064 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4065 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4068 run_test 48d "Access removed parent subdir (should return errors)"
4070 test_48e() { # bug 4134
4071 #lctl set_param debug=-1
4074 test_mkdir -p $DIR/$tdir/dir
4076 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4077 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4078 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4079 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4080 # On a buggy kernel addition of "touch foo" after cd .. will
4081 # produce kernel oops in lookup_hash_it
4082 touch ../foo && error "'cd ..' worked after recreate parent"
4084 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4086 run_test 48e "Access to recreated parent subdir (should return errors)"
4088 test_49() { # LU-1030
4089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4090 remote_ost_nodsh && skip "remote OST with nodsh" && return
4091 # get ost1 size - lustre-OST0000
4092 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4094 # write 800M at maximum
4095 [[ $ost1_size -lt 2 ]] && ost1_size=2
4096 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4098 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4099 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4102 # change max_pages_per_rpc while writing the file
4103 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4104 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4105 # loop until dd process exits
4106 while ps ax -opid | grep -wq $dd_pid; do
4107 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4108 sleep $((RANDOM % 5 + 1))
4110 # restore original max_pages_per_rpc
4111 $LCTL set_param $osc1_mppc=$orig_mppc
4112 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4114 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4118 test_mkdir $DIR/$tdir
4120 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4122 run_test 50 "special situations: /proc symlinks ==============="
4124 test_51a() { # was test_51
4125 # bug 1516 - create an empty entry right after ".." then split dir
4126 test_mkdir -c1 $DIR/$tdir
4127 touch $DIR/$tdir/foo
4128 $MCREATE $DIR/$tdir/bar
4130 createmany -m $DIR/$tdir/longfile 201
4132 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4133 $MCREATE $DIR/$tdir/longfile$FNUM
4138 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4140 run_test 51a "special situations: split htree with empty entry =="
4142 cleanup_print_lfs_df () {
4149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4150 local dir=$DIR/$tdir
4152 local nrdirs=$((65536 + 100))
4154 # cleanup the directory
4161 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4162 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4163 [[ $numfree -lt $nrdirs ]] &&
4164 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4167 # need to check free space for the directories as well
4168 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4169 numfree=$(( blkfree / $(fs_inode_ksize) ))
4170 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4173 trap cleanup_print_lfs_df EXIT
4176 createmany -d $dir/d $nrdirs || {
4177 unlinkmany $dir/d $nrdirs
4178 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4182 nrdirs=$(ls -U $dir | wc -l)
4184 # unlink all but 100 subdirectories, then check it still works
4186 local delete=$((nrdirs - left))
4191 # for ldiskfs the nlink count should be 1, but this is OSD specific
4192 # and so this is listed for informational purposes only
4193 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4194 unlinkmany -d $dir/d $delete ||
4195 error "unlink of first $delete subdirs failed"
4197 echo "nlink between: $(stat -c %h $dir)"
4198 local found=$(ls -U $dir | wc -l)
4199 [ $found -ne $left ] &&
4200 error "can't find subdirs: found only $found, expected $left"
4202 unlinkmany -d $dir/d $delete $left ||
4203 error "unlink of second $left subdirs failed"
4204 # regardless of whether the backing filesystem tracks nlink accurately
4205 # or not, the nlink count shouldn't be more than "." and ".." here
4206 local after=$(stat -c %h $dir)
4207 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4208 echo "nlink after: $after"
4210 cleanup_print_lfs_df
4212 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4216 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4217 test_mkdir $DIR/$tdir
4218 createmany -o $DIR/$tdir/t- 1000
4219 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4220 for N in $(seq 0 $((OSTCOUNT - 1))); do
4221 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4222 END { printf("%0.0f", objs) }' $TMP/$tfile)
4223 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4224 '($1 == '$N') { objs += 1 } \
4225 END { printf("%0.0f", objs) }')
4226 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4228 unlinkmany $DIR/$tdir/t- 1000
4231 for N in $(seq 1 $((OSTCOUNT - 1))); do
4232 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4233 error "OST $N has less objects vs OST $NLAST" \
4234 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4235 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4236 error "OST $N has less objects vs OST $NLAST" \
4237 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4239 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4240 error "OST $N has less #0 objects vs OST $NLAST" \
4241 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4242 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4243 error "OST $N has less #0 objects vs OST $NLAST" \
4244 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4249 run_test 51d "check object distribution"
4252 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4253 skip "ldiskfs only test"
4257 test_mkdir -c1 $DIR/$tdir
4258 test_mkdir -c1 $DIR/$tdir/d0
4260 touch $DIR/$tdir/d0/foo
4261 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4262 error "file exceed 65000 nlink limit!"
4263 unlinkmany $DIR/$tdir/d0/f- 65001
4266 run_test 51e "check file nlink limit"
4269 test_mkdir $DIR/$tdir
4272 local ulimit_old=$(ulimit -n)
4273 local spare=20 # number of spare fd's for scripts/libraries, etc.
4274 local mdt=$(lfs getstripe -M $DIR/$tdir)
4275 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4277 echo "MDT$mdt numfree=$numfree, max=$max"
4278 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4279 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4280 while ! ulimit -n $((numfree + spare)); do
4281 numfree=$((numfree * 3 / 4))
4283 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4285 echo "left ulimit at $ulimit_old"
4288 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4289 unlinkmany $DIR/$tdir/f $numfree
4290 error "create+open $numfree files in $DIR/$tdir failed"
4292 ulimit -n $ulimit_old
4294 # if createmany exits at 120s there will be fewer than $numfree files
4295 unlinkmany $DIR/$tdir/f $numfree || true
4297 run_test 51f "check many open files limit"
4300 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4301 test_mkdir $DIR/$tdir
4302 touch $DIR/$tdir/foo
4303 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4304 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4305 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4306 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4307 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4309 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4310 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4311 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4313 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4314 cp -r $DIR/$tdir $TMP/
4315 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4317 run_test 52a "append-only flag test (should return errors)"
4320 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4321 test_mkdir $DIR/$tdir
4322 touch $DIR/$tdir/foo
4323 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4324 cat test > $DIR/$tdir/foo && error "cat test worked"
4325 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4326 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4327 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4329 echo foo >> $DIR/$tdir/foo && error "echo worked"
4330 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4331 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4332 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4333 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4335 chattr -i $DIR/$tdir/foo || error "chattr failed"
4337 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4339 run_test 52b "immutable flag test (should return errors) ======="
4342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4343 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4344 remote_ost_nodsh && skip "remote OST with nodsh" && return
4357 local support_last_seq=true
4359 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4360 support_last_seq=false
4363 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4365 for value in $(do_facet $SINGLEMDS \
4366 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4367 param=$(echo ${value[0]} | cut -d "=" -f1)
4368 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4370 if $support_last_seq; then
4371 param_seq=$(echo $param |
4372 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4373 mds_last_seq=$(do_facet $SINGLEMDS \
4374 $LCTL get_param -n $param_seq)
4376 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4378 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4379 node=$(facet_active_host ost$((ostnum+1)))
4380 param="obdfilter.$ostname.last_id"
4381 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4382 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4383 ost_last_id=$ost_last
4385 if $support_last_seq; then
4386 ost_last_id=$(echo $ost_last |
4387 awk -F':' '{print $2}' |
4389 ost_last_seq=$(echo $ost_last |
4390 awk -F':' '{print $1}')
4391 [[ $ost_last_seq = $mds_last_seq ]] || continue
4394 if [[ $ost_last_id != $mds_last ]]; then
4395 error "$ost_last_id != $mds_last"
4402 $found || error "can not match last_seq/last_id for $mdtosc"
4405 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4408 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4410 $SOCKETSERVER $DIR/socket ||
4411 error "$SOCKETSERVER $DIR/socket failed: $?"
4412 $SOCKETCLIENT $DIR/socket ||
4413 error "$SOCKETCLIENT $DIR/socket failed: $?"
4414 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4416 run_test 54a "unix domain socket test =========================="
4422 dd if=/dev/zero of=$f bs=$(page_size) count=1
4424 run_test 54b "char device works in lustre ======================"
4427 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4428 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4429 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4431 for i in $(seq 3 7); do
4432 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4441 loopdev="$DIR/loop54c"
4444 $UMOUNT $DIR/$tdir || rc=$?
4445 losetup -d $loopdev || true
4446 losetup -d $LOOPDEV || true
4447 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4453 loopdev="$DIR/loop54c"
4456 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4457 trap cleanup_54c EXIT
4458 mknod $loopdev b 7 $LOOPNUM
4459 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4460 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4461 losetup $loopdev $DIR/$tfile ||
4462 error "can't set up $loopdev for $DIR/$tfile"
4463 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4464 test_mkdir $DIR/$tdir
4465 mount -t ext2 $loopdev $DIR/$tdir ||
4466 error "error mounting $loopdev on $DIR/$tdir"
4467 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4470 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4474 run_test 54c "block device works in lustre ====================="
4480 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4482 run_test 54d "fifo device works in lustre ======================"
4487 cp -aL /dev/console $f
4488 echo $string > $f || error "echo $string to $f failed"
4490 run_test 54e "console/tty device works in lustre ======================"
4494 local dir=$DIR/$tdir
4497 test_mkdir -p $dir/dir
4498 for i in $(seq $numfiles); do
4500 touch $dir/dir/file$i
4503 local numcomp=$($LFS getstripe --component-count $dir)
4505 [[ $numcomp == 0 ]] && numcomp=1
4507 # test lfs getstripe with --recursive
4508 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4510 [[ $filenum -eq $((numfiles * 2)) ]] ||
4511 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4512 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4513 [[ $filenum -eq $numfiles ]] ||
4514 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4515 echo "$LFS getstripe showed obdidx or l_ost_idx"
4517 # test lfs getstripe with file instead of dir
4518 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4519 [[ $filenum -eq 1 ]] ||
4520 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4521 echo "$LFS getstripe file1 passed"
4523 #test lfs getstripe with --verbose
4524 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4525 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4526 error "$LFS getstripe --verbose $dir: "\
4527 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4528 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4529 error "$LFS getstripe $dir: showed lmm_magic"
4531 #test lfs getstripe with -v prints lmm_fid
4532 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4533 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4534 error "$LFS getstripe -v $dir: "\
4535 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4536 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4537 error "$LFS getstripe $dir: showed lmm_fid by default"
4538 echo "$LFS getstripe --verbose passed"
4540 #check for FID information
4541 local fid1=$($LFS getstripe --fid $dir/file1)
4542 local fid2=$($LFS getstripe --verbose $dir/file1 |
4543 awk '/lmm_fid: / { print $2; exit; }')
4544 local fid3=$($LFS path2fid $dir/file1)
4546 [ "$fid1" != "$fid2" ] &&
4547 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4548 [ "$fid1" != "$fid3" ] &&
4549 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4550 echo "$LFS getstripe --fid passed"
4552 #test lfs getstripe with --obd
4553 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4554 error "$LFS getstripe --obd wrong_uuid: should return error"
4556 [[ $OSTCOUNT -lt 2 ]] &&
4557 skip_env "skip '$LFS getstripe --obd' tests: $OSTCOUNT < 2" &&
4561 local obduuid=$(ostuuid_from_index $ostidx)
4562 local found=$($LFS getstripe -r --obd $obduuid $dir |
4563 egrep -c "obdidx|l_ost_idx")
4565 filenum=$($LFS getstripe -ir $dir | grep "^$ostidx\$" | wc -l)
4566 [[ $found -eq $filenum ]] ||
4567 error "$LFS getstripe --obd: found $found expect $filenum"
4568 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4569 sed '/^[ ]*'${ostidx}'[ ]/d' |
4570 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4571 error "$LFS getstripe --obd: should not show file on other obd"
4572 echo "$LFS getstripe --obd passed"
4574 run_test 56a "check $LFS getstripe"
4577 local dir=$DIR/$tdir
4581 for i in $(seq $numdirs); do
4582 test_mkdir $dir/dir$i
4585 # test lfs getdirstripe default mode is non-recursion, which is
4586 # different from lfs getstripe
4587 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4589 [[ $dircnt -eq 1 ]] ||
4590 error "$LFS getdirstripe: found $dircnt, not 1"
4591 dircnt=$($LFS getdirstripe --recursive $dir |
4592 grep -c lmv_stripe_count)
4593 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4594 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4596 run_test 56b "check $LFS getdirstripe"
4600 local ost_name=$(ostname_from_index $ost_idx)
4601 local old_status=$(ost_dev_status $ost_idx)
4603 [[ -z "$old_status" ]] ||
4604 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4606 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4609 local new_status=$(ost_dev_status $ost_idx)
4611 [[ "$new_status" = "D" ]] ||
4612 error "OST $ost_name is in status of '$new_status', not 'D'"
4614 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4617 new_status=$(ost_dev_status $ost_idx)
4618 [[ -z "$new_status" ]] ||
4619 error "OST $ost_name is in status of '$new_status', not ''"
4621 run_test 56c "check 'lfs df' showing device status"
4626 local local_tdir="$1"
4627 local local_numfiles="$2"
4628 local local_numdirs="$3"
4629 local dir_params="$4"
4630 local dir_stripe_params="$5"
4632 if [ ! -d "$local_tdir" ] ; then
4633 test_mkdir -p $dir_stripe_params $local_tdir
4634 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4635 for i in $(seq $local_numfiles) ; do
4636 touch $local_tdir/file$i
4638 for i in $(seq $local_numdirs) ; do
4639 test_mkdir $dir_stripe_params $local_tdir/dir$i
4640 for j in $(seq $local_numfiles) ; do
4641 touch $local_tdir/dir$i/file$j
4647 setup_56_special() {
4649 local local_numfiles=$2
4650 local local_numdirs=$3
4652 setup_56 $local_tdir $local_numfiles $local_numdirs
4654 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4655 for i in $(seq $local_numfiles) ; do
4656 mknod $local_tdir/loop${i}b b 7 $i
4657 mknod $local_tdir/null${i}c c 1 3
4658 ln -s $local_tdir/file1 $local_tdir/link${i}
4660 for i in $(seq $local_numdirs) ; do
4661 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4662 mknod $local_tdir/dir$i/null${i}c c 1 3
4663 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4669 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4670 local expected=$(($NUMDIRS + 2))
4672 setup_56 $dir $NUMFILES $NUMDIRS
4674 # test lfs find with -name
4675 for i in $(seq $NUMFILES) ; do
4676 local nums=$($LFS find -name "*$i" $dir | wc -l)
4678 [ $nums -eq $expected ] ||
4679 error "lfs find -name '*$i' $dir wrong: "\
4680 "found $nums, expected $expected"
4683 run_test 56g "check lfs find -name"
4686 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4687 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4689 setup_56 $dir $NUMFILES $NUMDIRS
4691 # test lfs find with ! -name
4692 for i in $(seq $NUMFILES) ; do
4693 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
4695 [ $nums -eq $expected ] ||
4696 error "lfs find ! -name '*$i' $dir wrong: "\
4697 "found $nums, expected $expected"
4700 run_test 56h "check lfs find ! -name"
4703 local dir=$DIR/$tdir
4707 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
4710 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
4712 run_test 56i "check 'lfs find -ost UUID' skips directories"
4715 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4717 setup_56_special $dir $NUMFILES $NUMDIRS
4719 local expected=$((NUMDIRS + 1))
4720 local cmd="$LFS find -type d $dir"
4721 local nums=$($cmd | wc -l)
4723 [ $nums -eq $expected ] ||
4724 error "'$cmd' wrong: found $nums, expected $expected"
4726 run_test 56j "check lfs find -type d"
4729 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4731 setup_56_special $dir $NUMFILES $NUMDIRS
4733 local expected=$(((NUMDIRS + 1) * NUMFILES))
4734 local cmd="$LFS find -type f $dir"
4735 local nums=$($cmd | wc -l)
4737 [ $nums -eq $expected ] ||
4738 error "'$cmd' wrong: found $nums, expected $expected"
4740 run_test 56k "check lfs find -type f"
4743 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4745 setup_56_special $dir $NUMFILES $NUMDIRS
4747 local expected=$((NUMDIRS + NUMFILES))
4748 local cmd="$LFS find -type b $dir"
4749 local nums=$($cmd | wc -l)
4751 [ $nums -eq $expected ] ||
4752 error "'$cmd' wrong: found $nums, expected $expected"
4754 run_test 56l "check lfs find -type b"
4757 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4759 setup_56_special $dir $NUMFILES $NUMDIRS
4761 local expected=$((NUMDIRS + NUMFILES))
4762 local cmd="$LFS find -type c $dir"
4763 local nums=$($cmd | wc -l)
4764 [ $nums -eq $expected ] ||
4765 error "'$cmd' wrong: found $nums, expected $expected"
4767 run_test 56m "check lfs find -type c"
4770 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4771 setup_56_special $dir $NUMFILES $NUMDIRS
4773 local expected=$((NUMDIRS + NUMFILES))
4774 local cmd="$LFS find -type l $dir"
4775 local nums=$($cmd | wc -l)
4777 [ $nums -eq $expected ] ||
4778 error "'$cmd' wrong: found $nums, expected $expected"
4780 run_test 56n "check lfs find -type l"
4783 local dir=$DIR/$tdir
4785 setup_56 $dir $NUMFILES $NUMDIRS
4786 utime $dir/file1 > /dev/null || error "utime (1)"
4787 utime $dir/file2 > /dev/null || error "utime (2)"
4788 utime $dir/dir1 > /dev/null || error "utime (3)"
4789 utime $dir/dir2 > /dev/null || error "utime (4)"
4790 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
4791 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
4794 local nums=$($LFS find -mtime +0 $dir | wc -l)
4796 [ $nums -eq $expected ] ||
4797 error "lfs find -mtime +0 $dir: found $nums expect $expected"
4800 cmd="$LFS find -mtime 0 $dir"
4801 nums=$($cmd | wc -l)
4802 [ $nums -eq $expected ] ||
4803 error "'$cmd' wrong: found $nums, expected $expected"
4805 run_test 56o "check lfs find -mtime for old files"
4808 [ $RUNAS_ID -eq $UID ] &&
4809 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4811 local dir=$DIR/$tdir
4813 setup_56 $dir $NUMFILES $NUMDIRS
4814 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
4816 local expected=$NUMFILES
4817 local cmd="$LFS find -uid $RUNAS_ID $dir"
4818 local nums=$($cmd | wc -l)
4820 [ $nums -eq $expected ] ||
4821 error "'$cmd' wrong: found $nums, expected $expected"
4823 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
4824 cmd="$LFS find ! -uid $RUNAS_ID $dir"
4825 nums=$($cmd | wc -l)
4826 [ $nums -eq $expected ] ||
4827 error "'$cmd' wrong: found $nums, expected $expected"
4829 run_test 56p "check lfs find -uid and ! -uid"
4832 [ $RUNAS_ID -eq $UID ] &&
4833 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4835 local dir=$DIR/$tdir
4837 setup_56 $dir $NUMFILES $NUMDIRS
4838 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
4840 local expected=$NUMFILES
4841 local cmd="$LFS find -gid $RUNAS_GID $dir"
4842 local nums=$($cmd | wc -l)
4844 [ $nums -eq $expected ] ||
4845 error "'$cmd' wrong: found $nums, expected $expected"
4847 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4848 cmd="$LFS find ! -gid $RUNAS_GID $dir"
4849 nums=$($cmd | wc -l)
4850 [ $nums -eq $expected ] ||
4851 error "'$cmd' wrong: found $nums, expected $expected"
4853 run_test 56q "check lfs find -gid and ! -gid"
4856 local dir=$DIR/$tdir
4858 setup_56 $dir $NUMFILES $NUMDIRS
4861 local cmd="$LFS find -size 0 -type f $dir"
4862 local nums=$($cmd | wc -l)
4864 [ $nums -eq $expected ] ||
4865 error "'$cmd' wrong: found $nums, expected $expected"
4867 cmd="$LFS find ! -size 0 -type f $dir"
4868 nums=$($cmd | wc -l)
4869 [ $nums -eq $expected ] ||
4870 error "'$cmd' wrong: found $nums, expected $expected"
4871 echo "test" > $dir/$tfile
4872 echo "test2" > $dir/$tfile.2 && sync
4874 cmd="$LFS find -size 5 -type f $dir"
4875 nums=$($cmd | wc -l)
4876 [ $nums -eq $expected ] ||
4877 error "'$cmd' wrong: found $nums, expected $expected"
4879 cmd="$LFS find -size +5 -type f $dir"
4880 nums=$($cmd | wc -l)
4881 [ $nums -eq $expected ] ||
4882 error "'$cmd' wrong: found $nums, expected $expected"
4884 cmd="$LFS find -size +0 -type f $dir"
4885 nums=$($cmd | wc -l)
4886 [ $nums -eq $expected ] ||
4887 error "'$cmd' wrong: found $nums, expected $expected"
4889 cmd="$LFS find ! -size -5 -type f $dir"
4890 nums=$($cmd | wc -l)
4891 [ $nums -eq $expected ] ||
4892 error "'$cmd' wrong: found $nums, expected $expected"
4894 cmd="$LFS find -size -5 -type f $dir"
4895 nums=$($cmd | wc -l)
4896 [ $nums -eq $expected ] ||
4897 error "'$cmd' wrong: found $nums, expected $expected"
4899 run_test 56r "check lfs find -size works"
4901 test_56s() { # LU-611 #LU-9369
4902 [[ $OSTCOUNT -lt 2 ]] && skip "need at least 2 OSTs" && return 0
4904 local dir=$DIR/$tdir
4905 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
4907 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
4908 for i in $(seq $NUMDIRS); do
4909 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
4912 local expected=$NUMDIRS
4913 local cmd="$LFS find -c $OSTCOUNT $dir"
4914 local nums=$($cmd | wc -l)
4916 [ $nums -eq $expected ] || {
4917 $LFS getstripe -R $dir
4918 error "'$cmd' wrong: found $nums, expected $expected"
4921 expected=$((NUMDIRS + onestripe))
4922 cmd="$LFS find -stripe-count +0 -type f $dir"
4923 nums=$($cmd | wc -l)
4924 [ $nums -eq $expected ] || {
4925 $LFS getstripe -R $dir
4926 error "'$cmd' wrong: found $nums, expected $expected"
4930 cmd="$LFS find -stripe-count 1 -type f $dir"
4931 nums=$($cmd | wc -l)
4932 [ $nums -eq $expected ] || {
4933 $LFS getstripe -R $dir
4934 error "'$cmd' wrong: found $nums, expected $expected"
4937 cmd="$LFS find -stripe-count -2 -type f $dir"
4938 nums=$($cmd | wc -l)
4939 [ $nums -eq $expected ] || {
4940 $LFS getstripe -R $dir
4941 error "'$cmd' wrong: found $nums, expected $expected"
4945 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
4946 nums=$($cmd | wc -l)
4947 [ $nums -eq $expected ] || {
4948 $LFS getstripe -R $dir
4949 error "'$cmd' wrong: found $nums, expected $expected"
4952 run_test 56s "check lfs find -stripe-count works"
4954 test_56t() { # LU-611 #LU-9369
4955 local dir=$DIR/$tdir
4957 setup_56 $dir 0 $NUMDIRS
4958 for i in $(seq $NUMDIRS); do
4959 $LFS setstripe -S 4M $dir/dir$i/$tfile
4962 local expected=$NUMDIRS
4963 local cmd="$LFS find -S 4M $dir"
4964 local nums=$($cmd | wc -l)
4966 [ $nums -eq $expected ] || {
4967 $LFS getstripe -R $dir
4968 error "'$cmd' wrong: found $nums, expected $expected"
4972 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
4974 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
4976 expected=$(((NUMDIRS + 1) * NUMFILES))
4977 cmd="$LFS find -stripe-size 512k -type f $dir"
4978 nums=$($cmd | wc -l)
4979 [ $nums -eq $expected ] ||
4980 error "'$cmd' wrong: found $nums, expected $expected"
4982 cmd="$LFS find -stripe-size +320k -type f $dir"
4983 nums=$($cmd | wc -l)
4984 [ $nums -eq $expected ] ||
4985 error "'$cmd' wrong: found $nums, expected $expected"
4987 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
4988 cmd="$LFS find -stripe-size +200k -type f $dir"
4989 nums=$($cmd | wc -l)
4990 [ $nums -eq $expected ] ||
4991 error "'$cmd' wrong: found $nums, expected $expected"
4993 cmd="$LFS find -stripe-size -640k -type f $dir"
4994 nums=$($cmd | wc -l)
4995 [ $nums -eq $expected ] ||
4996 error "'$cmd' wrong: found $nums, expected $expected"
4999 cmd="$LFS find -stripe-size 256k -type f $dir"
5000 nums=$($cmd | wc -l)
5001 [ $nums -eq $expected ] ||
5002 error "'$cmd' wrong: found $nums, expected $expected"
5004 cmd="$LFS find -stripe-size -320k -type f $dir"
5005 nums=$($cmd | wc -l)
5006 [ $nums -eq $expected ] ||
5007 error "'$cmd' wrong: found $nums, expected $expected"
5010 cmd="$LFS find -stripe-size 1024k -type f $dir"
5011 nums=$($cmd | wc -l)
5012 [ $nums -eq $expected ] ||
5013 error "'$cmd' wrong: found $nums, expected $expected"
5015 run_test 56t "check lfs find -stripe-size works"
5017 test_56u() { # LU-611
5018 local dir=$DIR/$tdir
5020 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5022 if [[ $OSTCOUNT -gt 1 ]]; then
5023 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5029 local expected=$(((NUMDIRS + 1) * NUMFILES))
5030 local cmd="$LFS find -stripe-index 0 -type f $dir"
5031 local nums=$($cmd | wc -l)
5033 [ $nums -eq $expected ] ||
5034 error "'$cmd' wrong: found $nums, expected $expected"
5037 cmd="$LFS find -stripe-index 1 -type f $dir"
5038 nums=$($cmd | wc -l)
5039 [ $nums -eq $expected ] ||
5040 error "'$cmd' wrong: found $nums, expected $expected"
5042 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5043 nums=$($cmd | wc -l)
5044 [ $nums -eq $expected ] ||
5045 error "'$cmd' wrong: found $nums, expected $expected"
5048 # This should produce an error and not return any files
5049 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5050 nums=$($cmd 2>/dev/null | wc -l)
5051 [ $nums -eq $expected ] ||
5052 error "'$cmd' wrong: found $nums, expected $expected"
5054 if [[ $OSTCOUNT -gt 1 ]]; then
5055 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5056 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5057 nums=$($cmd | wc -l)
5058 [ $nums -eq $expected ] ||
5059 error "'$cmd' wrong: found $nums, expected $expected"
5062 run_test 56u "check lfs find -stripe-index works"
5066 local dir=$DIR/$tdir
5068 setup_56 $dir $NUMFILES $NUMDIRS
5070 UUID=$(mdtuuid_from_index $MDT_IDX $dir)
5071 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $MDT_IDX"
5073 for file in $($LFS find -mdt $UUID $dir); do
5074 file_mdt_idx=$($LFS getstripe -M $file)
5075 [ $file_mdt_idx -eq $MDT_IDX ] ||
5076 error "lfind -mdt $UUID != getstripe -M $file_mdt_idx"
5079 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5082 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5084 local dir=$DIR/$tdir
5086 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5088 local stripe_size=$($LFS getstripe -S -d $dir) ||
5089 error "$LFS getstripe -S -d $dir failed"
5090 stripe_size=${stripe_size%% *}
5092 local file_size=$((stripe_size * OSTCOUNT))
5093 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5094 local required_space=$((file_num * file_size))
5095 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5097 [[ $free_space -le $((required_space / 1024)) ]] &&
5098 skip_env "need $required_space, have $free_space kbytes" &&
5102 local dd_count=$((file_size / dd_bs))
5104 # write data into the files
5109 for i in $(seq $NUMFILES); do
5111 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5112 error "write data into $file failed"
5114 for i in $(seq $NUMDIRS); do
5115 for j in $(seq $NUMFILES); do
5116 file=$dir/dir$i/file$j
5117 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5118 error "write data into $file failed"
5122 # $LFS_MIGRATE will fail if hard link migration is unsupported
5123 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5124 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5125 error "creating links to $dir/dir1/file1 failed"
5130 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5133 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5136 eval $cmd || error "$cmd failed"
5138 check_stripe_count $dir/file1 $expected
5140 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5142 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5143 # OST 1 if it is on OST 0. This file is small enough to
5144 # be on only one stripe.
5145 file=$dir/migr_1_ost
5146 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5147 error "write data into $file failed"
5148 local obdidx=$($LFS getstripe -i $file)
5149 local oldmd5=$(md5sum $file)
5152 [[ $obdidx -eq 0 ]] && newobdidx=1
5153 cmd="$LFS migrate -i $newobdidx $file"
5155 eval $cmd || error "$cmd failed"
5157 local realobdix=$($LFS getstripe -i $file)
5158 local newmd5=$(md5sum $file)
5160 [[ $newobdidx -ne $realobdix ]] &&
5161 error "new OST is different (was=$obdidx, "\
5162 "wanted=$newobdidx, got=$realobdix)"
5163 [[ "$oldmd5" != "$newmd5" ]] &&
5164 error "md5sum differ: $oldmd5, $newmd5"
5168 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5170 eval $cmd || error "$cmd failed"
5172 for j in $(seq $NUMFILES); do
5173 check_stripe_count $dir/dir1/file$j $expected
5176 # lfs_migrate works with lfs find
5177 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5178 $LFS_MIGRATE -y -c $expected"
5180 eval $cmd || error "$cmd failed"
5182 for i in $(seq 2 $NUMFILES); do
5183 check_stripe_count $dir/file$i $expected
5185 for i in $(seq 2 $NUMDIRS); do
5186 for j in $(seq $NUMFILES); do
5187 check_stripe_count $dir/dir$i/file$j $expected
5191 run_test 56w "check lfs_migrate -c stripe_count works"
5194 local file1=$DIR/$tdir/file1
5195 local create_pool=false
5196 local initial_pool=$($LFS getstripe -p $DIR)
5200 echo -n "Creating test dir..."
5201 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5204 echo -n "Creating test file..."
5205 touch $file1 || error "cannot create file"
5208 echo -n "Detecting existing pools..."
5209 while IFS='' read thispool; do
5210 pool_list+=("$thispool")
5211 done < <($LFS pool_list $MOUNT | awk -F '.' 'NR>=2 { print $2 }')
5213 if [ ${#pool_list[@]} -gt 0 ]; then
5214 echo "${pool_list[@]}"
5215 for thispool in "${pool_list[@]}"; do
5216 if [[ -z "$initial_pool" ||
5217 "$initial_pool" != "$thispool" ]]; then
5219 echo "Using existing pool '$pool'"
5224 echo "none detected."
5226 if [ -z "$pool" ]; then
5227 pool=${POOL:-testpool}
5228 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5229 echo -n "Creating pool '$pool'..."
5231 pool_add $pool &> /dev/null ||
5232 error "pool_add failed"
5235 echo -n "Adding target to pool..."
5236 pool_add_targets $pool 0 0 1 &> /dev/null ||
5237 error "pool_add_targets failed"
5241 echo -n "Setting pool using -p option..."
5242 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5243 error "migrate failed rc = $?"
5246 echo -n "Verifying test file is in pool after migrating..."
5247 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5248 error "file was not migrated to pool $pool"
5251 echo -n "Removing test file from pool '$pool'..."
5252 $LFS migrate $file1 &> /dev/null ||
5253 error "cannot remove from pool"
5254 [ "$($LFS getstripe -p $file1)" ] &&
5255 error "pool still set"
5258 echo -n "Setting pool using --pool option..."
5259 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5260 error "migrate failed rc = $?"
5265 if $create_pool; then
5266 destroy_test_pools 2> /dev/null ||
5267 error "destroy test pools failed"
5270 run_test 56wb "check lfs_migrate pool support"
5273 local file1="$DIR/$tdir/file 1"
5275 echo -n "Creating test dir..."
5276 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5277 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5278 error "cannot set stripe"
5281 echo -n "Setting initial stripe for test file..."
5282 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5283 error "cannot set stripe"
5284 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5285 error "stripe size not set"
5288 # File currently set to -S 512K -c 1
5290 # Ensure -c and -S options are rejected when -R is set
5291 echo -n "Verifying incompatible options are detected..."
5292 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5293 error "incompatible -c and -R options not detected"
5294 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5295 error "incompatible -S and -R options not detected"
5298 # Ensure unrecognized options are passed through to 'lfs migrate'
5299 echo -n "Verifying -S option is passed through to lfs migrate..."
5300 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5301 error "migration failed"
5302 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5303 error "file was not restriped"
5306 # File currently set to -S 1M -c 1
5308 # Ensure long options are supported
5309 echo -n "Verifying long options supported..."
5310 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5311 error "long option without argument not supported"
5312 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5313 error "long option with argument not supported"
5314 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5315 error "file not restriped with --stripe-size option"
5318 # File currently set to -S 512K -c 1
5320 if [ "$OSTCOUNT" -gt 1 ]; then
5321 echo -n "Verifying explicit stripe count can be set..."
5322 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5323 error "migrate failed"
5324 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5325 error "file not restriped to explicit count"
5329 # File currently set to -S 512K -c 1 or -S 512K -c 2
5331 # Ensure parent striping is used if -R is set, and no stripe
5332 # count or size is specified
5333 echo -n "Setting stripe for parent directory..."
5334 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5335 error "cannot set stripe"
5338 echo -n "Verifying restripe option uses parent stripe settings..."
5339 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5340 error "migrate failed"
5341 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5342 error "file not restriped to parent settings"
5343 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5344 error "file not restriped to parent settings"
5347 # File currently set to -S 1M -c 1
5349 # Ensure striping is preserved if -R is not set, and no stripe
5350 # count or size is specified
5351 echo -n "Verifying striping size preserved when not specified..."
5352 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5353 error "cannot set stripe on parent directory"
5354 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5355 error "migrate failed"
5356 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5357 error "file was restriped"
5360 # Ensure file name properly detected when final option has no argument
5361 echo -n "Verifying file name properly detected..."
5362 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5363 error "file name interpreted as option argument"
5369 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5372 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5373 local file1=$DIR/$tdir/file1
5375 echo -n "Creating test dir..."
5376 test_mkdir $DIR/$tdir || error "cannot create dir"
5379 echo -n "Creating test file..."
5383 # Ensure 'lfs migrate' will fail by using a non-existent option,
5384 # and make sure rsync is not called to recover
5385 echo -n "Make sure --no-rsync option works..."
5386 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5387 grep -q 'refusing to fall back to rsync' ||
5388 error "rsync was called with --no-rsync set"
5391 # Ensure rsync is called without trying 'lfs migrate' first
5392 echo -n "Make sure --rsync option works..."
5393 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5394 grep -q 'falling back to rsync' &&
5395 error "lfs migrate was called with --rsync set"
5398 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5399 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5400 grep -q 'at the same time' ||
5401 error "--rsync and --no-rsync accepted concurrently"
5407 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5410 check_swap_layouts_support && return 0
5411 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5413 local dir=$DIR/$tdir
5414 local ref1=/etc/passwd
5415 local file1=$dir/file1
5417 test_mkdir $dir || error "creating dir $dir"
5418 $LFS setstripe -c 2 $file1
5420 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5421 stripe=$($LFS getstripe -c $file1)
5422 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5423 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5428 run_test 56x "lfs migration support"
5431 check_swap_layouts_support && return 0
5432 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5434 local dir=$DIR/$tdir/$testnum
5438 local ref1=/etc/passwd
5439 local file1=$dir/file1
5441 $LFS setstripe -c 2 $file1
5443 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5445 local stripe=$($LFS getstripe -c $file1)
5447 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5448 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5453 run_test 56xa "lfs migration --block support"
5455 check_migrate_links() {
5457 local file1="$dir/file1"
5460 local total_count=$(($begin + $count - 1))
5461 local symlink_count=10
5464 if [ ! -f "$file1" ]; then
5465 echo -n "creating initial file..."
5466 $LFS setstripe -c 1 -S "512k" "$file1" ||
5467 error "cannot setstripe initial file"
5470 echo -n "creating symlinks..."
5471 for s in $(seq 1 $symlink_count); do
5472 ln -s "$file1" "$dir/slink$s" ||
5473 error "cannot create symlinks"
5477 echo -n "creating nonlinked files..."
5478 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5479 error "cannot create nonlinked files"
5484 if [ ! -f "$dir/file$total_count" ]; then
5485 echo -n "creating hard links $begin:$total_count..."
5486 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5487 /dev/null || error "cannot create hard links"
5491 echo -n "checking number of hard links listed in xattrs..."
5492 local fid=$($LFS getstripe -F "$file1")
5493 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5496 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5497 echo "hard link list has unexpected size, skipping test"
5500 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5501 error "link names should exceed xattrs size"
5504 echo -n "migrating files..."
5505 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5507 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5510 # make sure all links have been properly migrated
5511 echo -n "verifying files..."
5512 fid=$($LFS getstripe -F "$file1") ||
5513 error "cannot get fid for file $file1"
5514 for i in $(seq 2 $total_count); do
5515 local fid2=$($LFS getstripe -F $dir/file$i)
5517 [ "$fid2" == "$fid" ] ||
5518 error "migrated hard link has mismatched FID"
5521 # make sure hard links were properly detected, and migration was
5522 # performed only once for the entire link set; nonlinked files should
5524 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5525 local expected=$(($uniq_count + 1))
5527 [ "$actual" -eq "$expected" ] ||
5528 error "hard links individually migrated ($actual != $expected)"
5530 # make sure the correct number of hard links are present
5531 local hardlinks=$(stat -c '%h' "$file1")
5533 [ $hardlinks -eq $total_count ] ||
5534 error "num hard links $hardlinks != $total_count"
5541 local dir="$DIR/$tdir"
5543 test_mkdir "$dir" || error "cannot create dir $dir"
5545 echo "testing lfs migrate mode when all links fit within xattrs"
5546 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
5548 echo "testing rsync mode when all links fit within xattrs"
5549 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
5551 echo "testing lfs migrate mode when all links do not fit within xattrs"
5552 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
5554 echo "testing rsync mode when all links do not fit within xattrs"
5555 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
5560 run_test 56xb "lfs migration hard link support"
5563 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5564 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5568 local dir=$DIR/$tdir
5572 test_mkdir -p $dir || error "creating dir $dir"
5573 touch $f1 || error "creating std file $f1"
5574 $MULTIOP $f2 H2c || error "creating released file $f2"
5576 # a directory can be raid0, so ask only for files
5577 res=$($LFS find $dir -L raid0 -type f | wc -l)
5578 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5580 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5581 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5583 # only files can be released, so no need to force file search
5584 res=$($LFS find $dir -L released)
5585 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5587 res=$($LFS find $dir -type f \! -L released)
5588 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5590 run_test 56y "lfs find -L raid0|released"
5592 test_56z() { # LU-4824
5593 # This checks to make sure 'lfs find' continues after errors
5594 # There are two classes of errors that should be caught:
5595 # - If multiple paths are provided, all should be searched even if one
5597 # - If errors are encountered during the search, it should not terminate
5599 local dir=$DIR/$tdir
5603 for i in d{0..9}; do
5606 touch $dir/d{0..9}/$tfile
5607 $LFS find $DIR/non_existent_dir $dir &&
5608 error "$LFS find did not return an error"
5609 # Make a directory unsearchable. This should NOT be the last entry in
5610 # directory order. Arbitrarily pick the 6th entry
5611 chmod 700 $($LFS find $dir -type d | sed '6!d')
5613 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5615 # The user should be able to see 10 directories and 9 files
5616 [ $count == 19 ] || error "$LFS find did not continue after error"
5618 run_test 56z "lfs find should continue after an error"
5620 test_56aa() { # LU-5937
5621 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5623 local dir=$DIR/$tdir
5626 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5628 createmany -o $dir/striped_dir/${tfile}- 1024
5629 local dirs=$(lfs find --size +8k $dir/)
5631 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5633 run_test 56aa "lfs find --size under striped dir"
5636 # Create composite files with one component
5637 local dir=$DIR/$tdir
5639 setup_56 $dir/1Mfiles 5 1 "--component-end 1M"
5640 # Create composite files with three components
5641 setup_56 $dir/2Mfiles 5 2 "-E 2M -E 4M -E 6M"
5642 # Create non-composite files
5643 createmany -o $dir/${tfile}- 10
5645 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
5647 [[ $nfiles == 10 ]] ||
5648 error "lfs find -E 1M found $nfiles != 10 files"
5650 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
5651 [[ $nfiles == 25 ]] ||
5652 error "lfs find ! -E 1M found $nfiles != 25 files"
5654 # All files have a component that starts at 0
5655 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
5656 [[ $nfiles == 35 ]] ||
5657 error "lfs find --component-start 0 - $nfiles != 35 files"
5659 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
5660 [[ $nfiles == 15 ]] ||
5661 error "lfs find --component-start 2M - $nfiles != 15 files"
5663 # All files created here have a componenet that does not starts at 2M
5664 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
5665 [[ $nfiles == 35 ]] ||
5666 error "lfs find ! --component-start 2M - $nfiles != 35 files"
5668 # Find files with a specified number of components
5669 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
5670 [[ $nfiles == 15 ]] ||
5671 error "lfs find --component-count 3 - $nfiles != 15 files"
5673 # Remember non-composite files have a component count of zero
5674 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
5675 [[ $nfiles == 10 ]] ||
5676 error "lfs find --component-count 0 - $nfiles != 10 files"
5678 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
5679 [[ $nfiles == 20 ]] ||
5680 error "lfs find ! --component-count 3 - $nfiles != 20 files"
5682 # All files have a flag called "init"
5683 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
5684 [[ $nfiles == 35 ]] ||
5685 error "lfs find --component-flags init - $nfiles != 35 files"
5687 # Multi-component files will have a component not initialized
5688 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
5689 [[ $nfiles == 15 ]] ||
5690 error "lfs find !--component-flags init - $nfiles != 15 files"
5695 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
5698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5699 # note test will not do anything if MDS is not local
5700 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5701 skip "ldiskfs only test"
5705 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5706 local MNTDEV="osd*.*MDT*.mntdev"
5707 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5708 [ -z "$DEV" ] && error "can't access $MNTDEV"
5709 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5710 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5711 error "can't access $DEV"
5712 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5713 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5717 run_test 57a "verify MDS filesystem created with large inodes =="
5720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5722 skip "ldiskfs only test"
5726 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5727 local dir=$DIR/$tdir
5731 local FILEN=$dir/f$FILECOUNT
5733 rm -rf $dir || error "removing $dir"
5735 local mdtidx=$($LFS getstripe -M $dir)
5736 local mdtname=MDT$(printf %04x $mdtidx)
5737 local facet=mds$((mdtidx + 1))
5739 echo "mcreating $FILECOUNT files"
5740 createmany -m $dir/f 1 $FILECOUNT || \
5741 error "creating files in $dir"
5743 # verify that files do not have EAs yet
5744 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5745 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5749 df $dir #make sure we get new statfs data
5750 local MDSFREE=$(do_facet $facet \
5751 lctl get_param -n osd*.*$mdtname.kbytesfree)
5752 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5753 echo "opening files to create objects/EAs"
5755 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5756 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5759 # verify that files have EAs now
5760 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5761 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5763 sleep 1 #make sure we get new statfs data
5765 local MDSFREE2=$(do_facet $facet \
5766 lctl get_param -n osd*.*$mdtname.kbytesfree)
5767 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5768 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5769 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5770 error "MDC before $MDCFREE != after $MDCFREE2"
5772 echo "MDC before $MDCFREE != after $MDCFREE2"
5773 echo "unable to confirm if MDS has large inodes"
5778 run_test 57b "default LOV EAs are stored inside large inodes ==="
5781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5782 [ -z "$(which wiretest 2>/dev/null)" ] &&
5783 skip_env "could not find wiretest" && return
5786 run_test 58 "verify cross-platform wire constants =============="
5789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5790 echo "touch 130 files"
5791 createmany -o $DIR/f59- 130
5793 unlinkmany $DIR/f59- 130
5795 # wait for commitment of removal
5796 wait_delete_completed
5798 run_test 59 "verify cancellation of llog records async ========="
5800 TEST60_HEAD="test_60 run $RANDOM"
5802 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5803 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5804 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5805 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5806 skip_env "missing subtest run-llog.sh" && return
5808 log "$TEST60_HEAD - from kernel mode"
5809 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5810 do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
5811 do_facet mgs $LCTL dk > $TMP/$tfile
5813 # LU-6388: test llog_reader
5814 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5815 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5816 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5817 skip_env "missing llog_reader" && return
5818 local fstype=$(facet_fstype mgs)
5819 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5820 skip_env "Only for ldiskfs or zfs type mgs" && return
5822 local mntpt=$(facet_mntpt mgs)
5823 local mgsdev=$(mgsdevname 1)
5835 #get fid and record list
5836 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5838 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5840 #remount mgs as ldiskfs or zfs type
5841 stop mgs || error "stop mgs failed"
5842 mount_fstype mgs || error "remount mgs failed"
5843 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5846 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5847 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5852 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5854 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5856 echo "obj_file is $obj_file"
5857 do_facet mgs $llog_reader $obj_file
5859 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5860 awk '{ print $3 }' | sed -e "s/^type=//g")
5861 if [ $rec_type != $rec ]; then
5862 echo "FAILED test_60a wrong record type $rec_type," \
5868 #check obj path if record type is LLOG_LOGID_MAGIC
5869 if [ "$rec" == "1064553b" ]; then
5870 path=$(do_facet mgs $llog_reader $obj_file |
5871 grep "path=" | awk '{ print $NF }' |
5872 sed -e "s/^path=//g")
5873 if [ $obj_file != $mntpt/$path ]; then
5874 echo "FAILED test_60a wrong obj path" \
5875 "$montpt/$path, should be $obj_file"
5882 #restart mgs before "error", otherwise it will block the next test
5883 stop mgs || error "stop mgs failed"
5884 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5885 $pass || error "test failed, see FAILED test_60a messages for specifics"
5887 run_test 60a "llog_test run from kernel module and test llog_reader"
5890 # test old logid format
5891 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5892 do_facet mgs $LCTL dl | grep MGS
5893 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5894 error "old llog_print failed"
5897 # test new logid format
5898 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5899 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5900 error "new llog_print failed"
5903 run_test 60aa "llog_print works with FIDs and simple names"
5905 test_60b() { # bug 6411
5906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5908 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5920 [[ $LLOG_COUNT -gt 100 ]] &&
5921 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5923 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5927 echo "create 5000 files"
5928 createmany -o $DIR/f60c- 5000
5929 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5930 lctl set_param fail_loc=0x80000137
5931 unlinkmany $DIR/f60c- 5000
5932 lctl set_param fail_loc=0
5934 run_test 60c "unlink file when mds full"
5937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5938 SAVEPRINTK=$(lctl get_param -n printk)
5940 # verify "lctl mark" is even working"
5941 MESSAGE="test message ID $RANDOM $$"
5942 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5943 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5945 lctl set_param printk=0 || error "set lnet.printk failed"
5946 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5947 MESSAGE="new test message ID $RANDOM $$"
5948 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5949 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5950 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5952 lctl set_param -n printk="$SAVEPRINTK"
5954 run_test 60d "test printk console message masking"
5957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5958 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5960 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5961 do_facet mds1 lctl set_param fail_loc=0x15b
5964 run_test 60e "no space while new llog is being created"
5967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5969 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5970 cancel_lru_locks osc
5971 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5974 run_test 61 "mmap() writes don't make sync hang ================"
5976 # bug 2330 - insufficient obd_match error checking causes LBUG
5978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5981 cancel_lru_locks osc
5982 lctl set_param fail_loc=0x405
5983 cat $f && error "cat succeeded, expect -EIO"
5984 lctl set_param fail_loc=0
5986 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5987 # match every page all of the time.
5988 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5990 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5991 # Though this test is irrelevant anymore, it helped to reveal some
5992 # other grant bugs (LU-4482), let's keep it.
5993 test_63a() { # was test_63
5994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5995 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5996 for i in `seq 10` ; do
5997 dd if=/dev/zero of=$DIR/f63 bs=8k &
6003 rm -f $DIR/f63 || true
6005 run_test 63a "Verify oig_wait interruption does not crash ======="
6007 # bug 2248 - async write errors didn't return to application on sync
6008 # bug 3677 - async write errors left page locked
6010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6012 lctl set_param debug=-1
6014 # ensure we have a grant to do async writes
6015 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6018 sync # sync lest earlier test intercept the fail_loc
6020 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6021 lctl set_param fail_loc=0x80000406
6022 $MULTIOP $DIR/$tfile Owy && \
6023 error "sync didn't return ENOMEM"
6024 sync; sleep 2; sync # do a real sync this time to flush page
6025 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6026 error "locked page left in cache after async error" || true
6029 run_test 63b "async write errors should be returned to fsync ==="
6032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6034 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6036 run_test 64a "verify filter grant calculations (in kernel) ====="
6039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6040 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6042 run_test 64b "check out-of-space detection on client"
6045 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6047 run_test 64c "verify grant shrink"
6049 # this does exactly what osc_request.c:osc_announce_cached() does in
6050 # order to calculate max amount of grants to ask from server
6054 local page_size=$(get_page_size client)
6056 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6057 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6059 ((rpc_in_flight ++));
6060 nrpages=$((nrpages * rpc_in_flight))
6062 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6064 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
6066 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6067 local undirty=$((nrpages * page_size))
6069 local max_extent_pages
6070 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6071 grep grant_max_extent_size | awk '{print $2}')
6072 max_extent_pages=$((max_extent_pages / page_size))
6073 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6074 local grant_extent_tax
6075 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6076 grep grant_extent_tax | awk '{print $2}')
6078 undirty=$((undirty + nrextents * grant_extent_tax))
6083 # this is size of unit for grant allocation. It should be equal to
6084 # what tgt_grant.c:tgt_grant_chunk() calculates
6088 local grant_extent_tax
6090 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6091 grep max_brw_size | awk '{print $2}')
6093 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6094 grep grant_extent_tax | awk '{print $2}')
6096 echo $(((max_brw_size + grant_extent_tax) * 2))
6100 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
6101 skip "OST < 2.10.55 doesn't limit grants enough" && return 0
6103 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6105 [[ $($LCTL get_param osc.${tgt}.import |
6106 grep "connect_flags:.*grant_param") ]] || \
6107 { skip "no grant_param connect flag"; return; }
6109 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6111 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6113 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6115 $SETSTRIPE $DIR/$tfile -i 0 -c 1
6116 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
6121 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6122 if [[ $cur_grant -gt $max_cur_granted ]]
6125 error "cur_grant $cur_grant > $max_cur_granted"
6128 [[ $? -ne 0 ]] && break;
6131 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6133 run_test 64d "check grant limit exceed"
6135 # bug 1414 - set/get directories' stripe info
6137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6138 test_mkdir $DIR/$tdir
6140 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6142 run_test 65a "directory with no stripe info"
6145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6146 test_mkdir $DIR/$tdir
6147 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6149 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6152 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6154 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6158 [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
6159 test_mkdir $DIR/$tdir
6160 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
6162 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6163 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6165 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6167 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6171 test_mkdir $DIR/$tdir
6172 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
6173 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6175 if [[ $STRIPECOUNT -le 0 ]]; then
6177 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6178 #LOV_MAX_STRIPE_COUNT is 2000
6179 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6181 sc=$(($STRIPECOUNT - 1))
6183 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6184 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6185 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6186 error "lverify failed"
6188 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6192 test_mkdir $DIR/$tdir
6194 $SETSTRIPE $DIR/$tdir || error "setstripe"
6195 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
6196 error "no stripe info failed"
6198 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6200 run_test 65e "directory setstripe defaults"
6203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6204 test_mkdir $DIR/${tdir}f
6205 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
6207 run_test 65f "dir setstripe permission (should return error) ==="
6210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6211 test_mkdir $DIR/$tdir
6212 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6214 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6215 error "setstripe -S failed"
6216 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6217 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6218 error "delete default stripe failed"
6220 run_test 65g "directory setstripe -d"
6223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6224 test_mkdir $DIR/$tdir
6225 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6227 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6228 error "setstripe -S failed"
6229 test_mkdir $DIR/$tdir/dd1
6230 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
6231 error "stripe info inherit failed"
6233 run_test 65h "directory stripe info inherit ===================="
6235 test_65i() { # bug6367
6236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6237 $SETSTRIPE -S 65536 -c -1 $MOUNT
6239 run_test 65i "set non-default striping on root directory (bug 6367)="
6241 test_65ia() { # bug12836
6242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6243 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
6245 run_test 65ia "getstripe on -1 default directory striping"
6247 test_65ib() { # bug12836
6248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6249 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
6251 run_test 65ib "getstripe -v on -1 default directory striping"
6253 test_65ic() { # bug12836
6254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6255 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6257 run_test 65ic "new find on -1 default directory striping"
6259 test_65j() { # bug6367
6260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6261 [ $($LFS getstripe --component-count $MOUNT) -gt 1 ] &&
6262 skip "don't delete default PFL layout" && return
6264 # if we aren't already remounting for each test, do so for this test
6265 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6266 cleanup || error "failed to unmount"
6269 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6271 run_test 65j "set default striping on root directory (bug 6367)="
6273 test_65k() { # bug11679
6274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6275 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6276 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6278 local disable_precreate=true
6279 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6280 disable_precreate=false
6282 echo "Check OST status: "
6283 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6284 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6286 for OSC in $MDS_OSCS; do
6287 echo $OSC "is active"
6288 do_facet $SINGLEMDS lctl --device %$OSC activate
6291 for INACTIVE_OSC in $MDS_OSCS; do
6292 local ost=$(osc_to_ost $INACTIVE_OSC)
6293 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6294 lov.*md*.target_obd |
6295 awk -F: /$ost/'{ print $1 }' | head -n 1)
6298 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6299 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6301 echo "Deactivate: " $INACTIVE_OSC
6302 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6304 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6305 osp.$ost*MDT0000.create_count")
6306 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6307 osp.$ost*MDT0000.max_create_count")
6308 $disable_precreate &&
6309 do_facet $SINGLEMDS "lctl set_param -n \
6310 osp.$ost*MDT0000.max_create_count=0"
6312 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6313 [ -f $DIR/$tdir/$idx ] && continue
6314 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6315 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6316 error "setstripe $idx should succeed"
6317 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6319 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6322 do_facet $SINGLEMDS "lctl set_param -n \
6323 osp.$ost*MDT0000.max_create_count=$max_count"
6324 do_facet $SINGLEMDS "lctl set_param -n \
6325 osp.$ost*MDT0000.create_count=$count"
6326 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6327 echo $INACTIVE_OSC "is Activate"
6329 wait_osc_import_state mds ost$ostnum FULL
6332 run_test 65k "validate manual striping works properly with deactivated OSCs"
6334 test_65l() { # bug 12836
6335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6336 test_mkdir -p $DIR/$tdir/test_dir
6337 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6338 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6340 run_test 65l "lfs find on -1 stripe dir ========================"
6343 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
6346 run_test 65m "normal user can't set filesystem default stripe"
6348 # bug 2543 - update blocks count on client
6350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6352 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6353 sync; sync_all_data; sync; sync_all_data
6354 cancel_lru_locks osc
6355 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6356 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6358 run_test 66 "update inode blocks count on client ==============="
6361 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6365 swapon -s | awk '($1 == "'$1'") { print $4 }'
6368 # bug5265, obdfilter oa2dentry return -ENOENT
6369 # #define OBD_FAIL_SRV_ENOENT 0x217
6371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6372 remote_ost_nodsh && skip "remote OST with nodsh" && return
6375 $SETSTRIPE -c 1 -i 0 $f
6377 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6379 do_facet ost1 lctl set_param fail_loc=0x217
6380 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6381 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6383 do_facet ost1 lctl set_param fail_loc=0
6384 $DIRECTIO write $f 0 2 || error "write error"
6386 cancel_lru_locks osc
6387 $DIRECTIO read $f 0 1 || error "read error"
6389 do_facet ost1 lctl set_param fail_loc=0x217
6390 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6392 do_facet ost1 lctl set_param fail_loc=0
6395 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6398 test_mkdir $DIR/$tdir
6399 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6400 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6402 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6404 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6406 [ "$RUNAS_ID" = "$UID" ] &&
6407 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6409 # Check that testing environment is properly set up. Skip if not
6410 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6411 skip_env "User $RUNAS_ID does not exist - skipping"
6415 chmod 777 $DIR/$tfile
6416 chmod ug+s $DIR/$tfile
6417 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6418 error "$RUNAS dd $DIR/$tfile failed"
6419 # See if we are still setuid/sgid
6420 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6421 error "S/gid is not dropped on write"
6422 # Now test that MDS is updated too
6423 cancel_lru_locks mdc
6424 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6425 error "S/gid is not dropped on MDS"
6428 run_test 72a "Test that remove suid works properly (bug5695) ===="
6430 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6433 [ "$RUNAS_ID" = "$UID" ] && \
6434 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6435 [ "$RUNAS_ID" -eq 0 ] && \
6436 skip_env "RUNAS_ID = 0 -- skipping" && return
6438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6439 # Check that testing environment is properly set up. Skip if not
6440 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6441 skip_env "User $RUNAS_ID does not exist - skipping"
6444 touch $DIR/${tfile}-f{g,u}
6445 test_mkdir $DIR/${tfile}-dg
6446 test_mkdir $DIR/${tfile}-du
6447 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6448 chmod g+s $DIR/${tfile}-{f,d}g
6449 chmod u+s $DIR/${tfile}-{f,d}u
6450 for perm in 777 2777 4777; do
6451 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6452 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6453 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6454 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6458 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6460 # bug 3462 - multiple simultaneous MDC requests
6462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6463 test_mkdir $DIR/d73-1
6464 test_mkdir $DIR/d73-2
6465 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6468 lctl set_param fail_loc=0x80000129
6469 $MULTIOP $DIR/d73-1/f73-2 Oc &
6471 lctl set_param fail_loc=0
6473 $MULTIOP $DIR/d73-2/f73-3 Oc &
6477 wait $pid1 || return 1
6481 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6482 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6483 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6487 run_test 73 "multiple MDC requests (should not deadlock)"
6489 test_74a() { # bug 6149, 6184
6490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6491 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6493 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6494 # will spin in a tight reconnection loop
6496 $LCTL set_param fail_loc=0x8000030e
6497 # get any lock that won't be difficult - lookup works.
6499 $LCTL set_param fail_loc=0
6503 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6505 test_74b() { # bug 13310
6506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6507 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6509 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6510 # will spin in a tight reconnection loop
6511 $LCTL set_param fail_loc=0x8000030e
6512 # get a "difficult" lock
6514 $LCTL set_param fail_loc=0
6518 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6522 #define OBD_FAIL_LDLM_NEW_LOCK
6523 $LCTL set_param fail_loc=0x319
6524 touch $DIR/$tfile && error "touch successful"
6525 $LCTL set_param fail_loc=0
6528 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6531 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6534 test_76() { # Now for bug 20433, added originally in bug 1443
6535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6536 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6537 cancel_lru_locks osc
6538 BEFORE_INODES=$(num_inodes)
6539 echo "before inodes: $BEFORE_INODES"
6541 [ "$SLOW" = "no" ] && COUNT=100
6542 for i in $(seq $COUNT); do
6546 cancel_lru_locks osc
6547 AFTER_INODES=$(num_inodes)
6548 echo "after inodes: $AFTER_INODES"
6550 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6552 AFTER_INODES=$(num_inodes)
6554 echo "wait $wait seconds inodes: $AFTER_INODES"
6555 if [ $wait -gt 30 ]; then
6556 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6560 run_test 76 "confirm clients recycle inodes properly ===="
6566 # Note: in sptlrpc modes which enable its own bulk checksum, the
6567 # original crc32_le bulk checksum will be automatically disabled,
6568 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6569 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6570 # In this case set_checksums() will not be no-op, because sptlrpc
6571 # bulk checksum will be enabled all through the test.
6573 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6574 lctl set_param -n osc.*.checksums $1
6578 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6579 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6580 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6581 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6584 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6585 log "set checksum type to $1"
6588 F77_TMP=$TMP/f77-temp
6591 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6592 error "error writing to $F77_TMP"
6595 test_77a() { # bug 10889
6596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6597 $GSS && skip "could not run with gss" && return
6598 [ ! -f $F77_TMP ] && setup_f77
6600 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6604 run_test 77a "normal checksum read/write operation"
6606 test_77b() { # bug 10889
6607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6608 $GSS && skip "could not run with gss" && return
6609 [ ! -f $F77_TMP ] && setup_f77
6610 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6611 $LCTL set_param fail_loc=0x80000409
6614 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6615 error "dd error: $?"
6616 $LCTL set_param fail_loc=0
6618 for algo in $CKSUM_TYPES; do
6619 cancel_lru_locks osc
6620 set_checksum_type $algo
6621 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6622 $LCTL set_param fail_loc=0x80000408
6623 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6624 $LCTL set_param fail_loc=0
6627 set_checksum_type $ORIG_CSUM_TYPE
6630 run_test 77b "checksum error on client write, read"
6635 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6637 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6638 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6639 $check_ost && [ -n $ost_file_prefix ] &&
6640 do_facet ost1 rm -f ${ost_file_prefix}\*
6644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6645 $GSS && skip "could not run with gss" && return
6648 local osc_file_prefix
6650 local check_ost=false
6651 local ost_file_prefix
6657 # ensure corruption will occur on first OSS/OST
6658 $LFS setstripe -i 0 $DIR/$tfile
6660 [ ! -f $F77_TMP ] && setup_f77
6661 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6662 error "dd write error: $?"
6663 fid=$($LFS path2fid $DIR/$tfile)
6665 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6668 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6669 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6671 echo "OSS do not support bulk pages dump upon error"
6674 osc_file_prefix=$($LCTL get_param -n debug_path)
6675 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6677 trap cleanup_77c EXIT
6680 # enable bulk pages dump upon error on Client
6681 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6682 # enable bulk pages dump upon error on OSS
6684 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6686 # flush Client cache to allow next read to reach OSS
6687 cancel_lru_locks osc
6689 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6690 $LCTL set_param fail_loc=0x80000408
6691 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6692 $LCTL set_param fail_loc=0
6696 # check cksum dump on Client
6697 osc_file=$(ls ${osc_file_prefix}*)
6698 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6699 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6700 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6701 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6702 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6704 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6705 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6706 error "dump content does not match on Client"
6708 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6710 # check cksum dump on OSS
6711 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6712 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6713 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6714 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6715 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6716 error "dump content does not match on OSS"
6720 run_test 77c "checksum error on client read with debug"
6722 test_77d() { # bug 10889
6723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6724 $GSS && skip "could not run with gss" && return
6725 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6726 $LCTL set_param fail_loc=0x80000409
6728 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6729 error "direct write: rc=$?"
6730 $LCTL set_param fail_loc=0
6733 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6734 $LCTL set_param fail_loc=0x80000408
6736 cancel_lru_locks osc
6737 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6738 error "direct read: rc=$?"
6739 $LCTL set_param fail_loc=0
6742 run_test 77d "checksum error on OST direct write, read"
6744 test_77f() { # bug 10889
6745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6746 $GSS && skip "could not run with gss" && return
6748 for algo in $CKSUM_TYPES; do
6749 cancel_lru_locks osc
6750 set_checksum_type $algo
6751 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6752 $LCTL set_param fail_loc=0x409
6753 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6754 error "direct write succeeded"
6755 $LCTL set_param fail_loc=0
6757 set_checksum_type $ORIG_CSUM_TYPE
6760 run_test 77f "repeat checksum error on write (expect error)"
6762 test_77g() { # bug 10889
6763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6764 $GSS && skip "could not run with gss" && return
6765 remote_ost_nodsh && skip "remote OST with nodsh" && return
6767 [ ! -f $F77_TMP ] && setup_f77
6769 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6770 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6771 do_facet ost1 lctl set_param fail_loc=0x8000021a
6773 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6774 error "write error: rc=$?"
6775 do_facet ost1 lctl set_param fail_loc=0
6778 cancel_lru_locks osc
6779 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6780 do_facet ost1 lctl set_param fail_loc=0x8000021b
6782 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6783 do_facet ost1 lctl set_param fail_loc=0
6786 run_test 77g "checksum error on OST write, read"
6788 test_77j() { # bug 13805
6789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6790 $GSS && skip "could not run with gss" && return
6791 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6792 lctl set_param fail_loc=0x40c
6793 remount_client $MOUNT
6794 lctl set_param fail_loc=0
6795 # wait async osc connect to finish and reflect updated state value
6797 for (( i=0; i < OSTCOUNT; i++ )) ; do
6798 wait_osc_import_state client ost$((i+1)) FULL
6801 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6802 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6803 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6804 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6806 remount_client $MOUNT
6808 run_test 77j "client only supporting ADLER32"
6810 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6819 test_78() { # bug 10901
6820 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6821 remote_ost || { skip_env "local OST" && return; }
6824 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6825 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6826 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6827 echo "MemTotal: $MEMTOTAL"
6829 # reserve 256MB of memory for the kernel and other running processes,
6830 # and then take 1/2 of the remaining memory for the read/write buffers.
6831 if [ $MEMTOTAL -gt 512 ] ;then
6832 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6834 # for those poor memory-starved high-end clusters...
6835 MEMTOTAL=$((MEMTOTAL / 2))
6837 echo "Mem to use for directio: $MEMTOTAL"
6839 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6840 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6841 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6842 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6844 echo "Smallest OST: $SMALLESTOST"
6845 [[ $SMALLESTOST -lt 10240 ]] &&
6846 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6848 trap cleanup_test_78 EXIT
6850 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6851 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6853 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6854 echo "File size: $F78SIZE"
6855 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6856 for i in $(seq 1 $NSEQ); do
6857 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6858 echo directIO rdwr round $i of $NSEQ
6859 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6864 run_test 78 "handle large O_DIRECT writes correctly ============"
6866 test_79() { # bug 12743
6867 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6868 wait_delete_completed
6870 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6871 BKFREE=$(calc_osc_kbytes kbytesfree)
6872 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6874 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6875 DFTOTAL=`echo $STRING | cut -d, -f1`
6876 DFUSED=`echo $STRING | cut -d, -f2`
6877 DFAVAIL=`echo $STRING | cut -d, -f3`
6878 DFFREE=$(($DFTOTAL - $DFUSED))
6880 ALLOWANCE=$((64 * $OSTCOUNT))
6882 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6883 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6884 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6886 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6887 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6888 error "df free($DFFREE) mismatch OST free($BKFREE)"
6890 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6891 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6892 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6895 run_test 79 "df report consistency check ======================="
6897 test_80() { # bug 10718
6898 remote_ost_nodsh && skip "remote OST with nodsh" && return
6899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6900 # relax strong synchronous semantics for slow backends like ZFS
6901 local soc="obdfilter.*.sync_on_lock_cancel"
6902 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6904 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6905 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6906 facet_active_host $host; done | sort -u)
6907 do_nodes $hosts lctl set_param $soc=never
6910 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6912 local BEFORE=`date +%s`
6913 cancel_lru_locks osc
6914 local AFTER=`date +%s`
6915 local DIFF=$((AFTER-BEFORE))
6916 if [ $DIFF -gt 1 ] ; then
6917 error "elapsed for 1M@1T = $DIFF"
6920 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6924 run_test 80 "Page eviction is equally fast at high offsets too ===="
6926 test_81a() { # LU-456
6927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6928 remote_ost_nodsh && skip "remote OST with nodsh" && return
6929 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6930 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6931 do_facet ost1 lctl set_param fail_loc=0x80000228
6933 # write should trigger a retry and success
6934 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6935 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6937 if [ $RC -ne 0 ] ; then
6938 error "write should success, but failed for $RC"
6941 run_test 81a "OST should retry write when get -ENOSPC ==============="
6943 test_81b() { # LU-456
6944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6945 remote_ost_nodsh && skip "remote OST with nodsh" && return
6946 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6947 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6948 do_facet ost1 lctl set_param fail_loc=0x228
6950 # write should retry several times and return -ENOSPC finally
6951 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6952 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6955 if [ $RC -ne $ENOSPC ] ; then
6956 error "dd should fail for -ENOSPC, but succeed."
6959 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6961 test_82() { # LU-1031
6962 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6966 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6968 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6970 kill -USR1 $MULTIPID2
6972 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6973 error "First grouplock does not block second one"
6975 echo "Second grouplock blocks first one"
6977 kill -USR1 $MULTIPID1
6981 run_test 82 "Basic grouplock test"
6984 local sfile="/boot/System.map-$(uname -r)"
6985 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6986 $LCTL set_param fail_loc=0x140d
6987 cp $sfile $DIR/$tfile || error "write failed"
6988 diff -c $sfile $DIR/$tfile || error "files are different"
6989 $LCTL set_param fail_loc=0
6992 run_test 83 "Short write in ptask ==============================="
6995 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6997 test_mkdir $DIR/$tdir.cvsroot
6998 chown $RUNAS_ID $DIR/$tdir.cvsroot
7001 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7004 # some versions of cvs import exit(1) when asked to import links or
7005 # files they can't read. ignore those files.
7006 local toignore=$(find . -type l -printf '-I %f\n' -o \
7007 ! -perm /4 -printf '-I %f\n')
7008 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7009 $tdir.reposname vtag rtag
7012 test_mkdir $DIR/$tdir.reposname
7013 chown $RUNAS_ID $DIR/$tdir.reposname
7014 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7016 cd $DIR/$tdir.reposname
7018 $RUNAS cvs add -m 'addmsg' foo99
7020 $RUNAS cvs commit -m 'nomsg' foo99
7021 rm -fr $DIR/$tdir.cvsroot
7023 run_test 99 "cvs strange file/directory operations"
7026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7027 [[ "$NETTYPE" =~ tcp ]] ||
7028 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
7031 remote_ost_nodsh && skip "remote OST with nodsh" && return
7032 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7034 { skip "useless for local single node setup" && return; }
7036 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7037 [ "$PROT" != "tcp" ] && continue
7038 RPORT=$(echo $REMOTE | cut -d: -f2)
7039 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7042 LPORT=`echo $LOCAL | cut -d: -f2`
7043 if [ $LPORT -ge 1024 ]; then
7044 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7046 error_exit "local: $LPORT > 1024, remote: $RPORT"
7049 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7051 run_test 100 "check local port using privileged port ==========="
7053 function get_named_value()
7062 echo $line | sed "s/^$tag[ ]*//"
7069 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7070 awk '/^max_cached_mb/ { print $2 }')
7073 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7079 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
7083 local cache_limit=32
7085 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7086 trap cleanup_101a EXIT
7087 $LCTL set_param -n llite.*.read_ahead_stats 0
7088 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7091 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7093 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7094 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7097 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7098 get_named_value 'read but discarded' | cut -d" " -f1); do
7099 discard=$(($discard + $s))
7103 if [[ $(($discard * 10)) -gt $nreads ]]; then
7104 $LCTL get_param osc.*-osc*.rpc_stats
7105 $LCTL get_param llite.*.read_ahead_stats
7106 error "too many ($discard) discarded pages"
7108 rm -f $DIR/$tfile || true
7110 run_test 101a "check read-ahead for random reads"
7113 test_mkdir $DIR/$tdir
7114 local STRIPE_SIZE=$1
7115 local FILE_LENGTH=$2
7118 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
7120 local list=$(comma_list $(osts_nodes))
7121 set_osd_param $list '' read_cache_enable 0
7122 set_osd_param $list '' writethrough_cache_enable 0
7124 trap cleanup_test101bc EXIT
7125 # prepare the read-ahead file
7126 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7128 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
7129 count=$FILE_SIZE_MB 2> /dev/null
7133 cleanup_test101bc() {
7138 local list=$(comma_list $(osts_nodes))
7139 set_osd_param $list '' read_cache_enable 1
7140 set_osd_param $list '' writethrough_cache_enable 1
7144 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7149 local STRIPE_SIZE=$2
7150 local FILE_LENGTH=$3
7151 local RA_INC=1048576
7152 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7153 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7154 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7155 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7156 get_named_value 'read but discarded' |
7157 cut -d" " -f1 | calc_total)
7158 if [[ $DISCARD -gt $discard_limit ]]; then
7159 $LCTL get_param llite.*.read_ahead_stats
7160 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7162 echo "Read-ahead success for size ${READ_SIZE}"
7167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7168 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7169 local STRIPE_SIZE=1048576
7170 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7171 if [ $SLOW == "yes" ]; then
7172 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7174 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7177 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7179 # prepare the read-ahead file
7180 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7181 cancel_lru_locks osc
7182 for BIDX in 2 4 8 16 32 64 128 256
7184 local BSIZE=$((BIDX*4096))
7185 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7186 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7187 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7188 $LCTL set_param -n llite.*.read_ahead_stats 0
7189 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7190 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7191 cancel_lru_locks osc
7192 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7197 run_test 101b "check stride-io mode read-ahead ================="
7200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7201 local STRIPE_SIZE=1048576
7202 local FILE_LENGTH=$((STRIPE_SIZE*100))
7206 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7208 cancel_lru_locks osc
7209 $LCTL set_param osc.*.rpc_stats 0
7210 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7211 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7212 local stats=$($LCTL get_param -n $osc_rpc_stats)
7213 local lines=$(echo "$stats" | awk 'END {print NR;}')
7216 if [ $lines -le 20 ]; then
7219 for size in 1 2 4 8; do
7220 local rpc=$(echo "$stats" |
7221 awk '($1 == "'$size':") {print $2; exit; }')
7223 error "Small $((size*4))k read IO $rpc !"
7225 echo "$osc_rpc_stats check passed!"
7230 run_test 101c "check stripe_size aligned read-ahead ================="
7233 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7234 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7239 local file=$DIR/$tfile
7240 local sz_MB=${FILESIZE_101d:-500}
7241 local ra_MB=${READAHEAD_MB:-40}
7243 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7244 [ $free_MB -lt $sz_MB ] &&
7245 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
7247 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7248 $SETSTRIPE -c -1 $file || error "setstripe failed"
7250 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7251 echo Cancel LRU locks on lustre client to flush the client cache
7252 cancel_lru_locks osc
7254 echo Disable read-ahead
7255 local old_READAHEAD=$(set_read_ahead 0)
7257 echo Reading the test file $file with read-ahead disabled
7258 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7260 echo Cancel LRU locks on lustre client to flush the client cache
7261 cancel_lru_locks osc
7262 echo Enable read-ahead with ${ra_MB}MB
7263 set_read_ahead $ra_MB
7265 echo Reading the test file $file with read-ahead enabled
7266 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7268 echo "read-ahead disabled time read $raOFF"
7269 echo "read-ahead enabled time read $raON"
7271 set_read_ahead $old_READAHEAD
7273 wait_delete_completed
7275 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7276 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7278 run_test 101d "file read with and without read-ahead enabled"
7281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7282 local file=$DIR/$tfile
7283 local size_KB=500 #KB
7287 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7288 local need_KB=$((count * size_KB))
7289 [[ $free_KB -le $need_KB ]] &&
7290 skip_env "Need free space $need_KB, have $free_KB" && return
7292 echo "Creating $count ${size_KB}K test files"
7293 for ((i = 0; i < $count; i++)); do
7294 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7297 echo "Cancel LRU locks on lustre client to flush the client cache"
7298 cancel_lru_locks $OSC
7300 echo "Reset readahead stats"
7301 $LCTL set_param -n llite.*.read_ahead_stats 0
7303 for ((i = 0; i < $count; i++)); do
7304 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7307 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7308 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7310 for ((i = 0; i < $count; i++)); do
7311 rm -rf $file.$i 2>/dev/null
7314 #10000 means 20% reads are missing in readahead
7315 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7317 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7320 which iozone || { skip "no iozone installed" && return; }
7322 local old_debug=$($LCTL get_param debug)
7323 old_debug=${old_debug#*=}
7324 $LCTL set_param debug="reada mmap"
7326 # create a test file
7327 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7329 echo Cancel LRU locks on lustre client to flush the client cache
7330 cancel_lru_locks osc
7332 echo Reset readahead stats
7333 $LCTL set_param -n llite.*.read_ahead_stats 0
7335 echo mmap read the file with small block size
7336 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7339 echo checking missing pages
7340 $LCTL get_param llite.*.read_ahead_stats
7341 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7342 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7344 $LCTL set_param debug="$old_debug"
7345 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7348 run_test 101f "check mmap read performance"
7350 test_101g_brw_size_test() {
7352 local pages=$((mb * 1048576 / $(page_size)))
7354 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7355 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7356 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7357 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7361 $LCTL set_param -n osc.*.rpc_stats=0
7363 # 10 RPCs should be enough for the test
7365 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7366 { error "dd write ${mb} MB blocks failed"; return 3; }
7367 cancel_lru_locks osc
7368 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7369 { error "dd write ${mb} MB blocks failed"; return 4; }
7371 # calculate number of full-sized read and write RPCs
7372 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7373 sed -n '/pages per rpc/,/^$/p' |
7374 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7375 END { print reads,writes }'))
7376 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7378 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7386 local osts=$(get_facets OST)
7387 local list=$(comma_list $(osts_nodes))
7388 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7389 local brw_size="obdfilter.*.brw_size"
7390 local ostver=$(lustre_version_code ost1)
7391 local cliver=$(lustre_version_code client)
7393 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7395 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7396 if [ $ostver -ge $(version_code 2.8.52) -o \
7397 \( $ostver -ge $(version_code 2.7.17) -a \
7398 $ostver -lt $(version_code 2.7.50) \) ] &&
7399 [ $cliver -ge $(version_code 2.8.52) -o \
7400 \( $cliver -ge $(version_code 2.7.17) -a \
7401 $cliver -lt $(version_code 2.7.50) \) ]; then
7402 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7403 if [[ $orig_mb -lt 16 ]]; then
7404 save_lustre_params $osts "$brw_size" > $p
7405 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7406 error "set 16MB RPC size failed"
7408 echo "remount client to enable new RPC size"
7409 remount_client $MOUNT || error "remount_client failed"
7412 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7413 # should be able to set brw_size=12, but no rpc_stats for that
7414 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7417 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7419 if [[ $orig_mb -lt 16 ]]; then
7420 restore_lustre_params < $p
7421 remount_client $MOUNT || error "remount_client restore failed"
7424 rm -f $p $DIR/$tfile
7426 run_test 101g "Big bulk(4/16 MiB) readahead"
7429 test_mkdir $DIR/$tdir
7430 chown $RUNAS_ID $DIR/$tdir
7433 STRIPE_COUNT=$OSTCOUNT
7434 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7436 trap cleanup_test102 EXIT
7438 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7440 for num in 1 2 3 4; do
7441 for count in $(seq 1 $STRIPE_COUNT); do
7442 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7443 local size=`expr $STRIPE_SIZE \* $num`
7444 local file=file"$num-$idx-$count"
7445 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7451 $1 tar cf $TMP/f102.tar $tdir --xattrs
7457 rm -rf $DIR/d0.sanity/d102
7461 local testfile=$DIR/$tfile
7465 [ "$UID" != 0 ] && skip_env "must run as root" && return
7466 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7467 skip_env "must have user_xattr" && return
7469 [ -z "$(which setfattr 2>/dev/null)" ] &&
7470 skip_env "could not find setfattr" && return
7472 echo "set/get xattr..."
7473 setfattr -n trusted.name1 -v value1 $testfile ||
7474 error "setfattr -n trusted.name1=value1 $testfile failed"
7475 getfattr -n trusted.name1 $testfile 2> /dev/null |
7476 grep "trusted.name1=.value1" ||
7477 error "$testfile missing trusted.name1=value1"
7479 setfattr -n user.author1 -v author1 $testfile ||
7480 error "setfattr -n user.author1=author1 $testfile failed"
7481 getfattr -n user.author1 $testfile 2> /dev/null |
7482 grep "user.author1=.author1" ||
7483 error "$testfile missing trusted.author1=author1"
7486 setfattr -n trusted.name2 -v value2 $testfile ||
7487 error "$testfile unable to set trusted.name2"
7488 setfattr -n trusted.name3 -v value3 $testfile ||
7489 error "$testfile unable to set trusted.name3"
7490 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7491 grep "trusted.name" | wc -l) -eq 3 ] ||
7492 error "$testfile missing 3 trusted.name xattrs"
7494 setfattr -n user.author2 -v author2 $testfile ||
7495 error "$testfile unable to set user.author2"
7496 setfattr -n user.author3 -v author3 $testfile ||
7497 error "$testfile unable to set user.author3"
7498 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7499 grep "user.author" | wc -l) -eq 3 ] ||
7500 error "$testfile missing 3 user.author xattrs"
7502 echo "remove xattr..."
7503 setfattr -x trusted.name1 $testfile ||
7504 error "$testfile error deleting trusted.name1"
7505 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7506 error "$testfile did not delete trusted.name1 xattr"
7508 setfattr -x user.author1 $testfile ||
7509 error "$testfile error deleting user.author1"
7510 echo "set lustre special xattr ..."
7511 $LFS setstripe -c1 $testfile
7512 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7513 awk -F "=" '/trusted.lov/ { print $2 }' )
7514 setfattr -n "trusted.lov" -v $lovea $testfile ||
7515 error "$testfile doesn't ignore setting trusted.lov again"
7516 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7517 error "$testfile allow setting invalid trusted.lov"
7520 run_test 102a "user xattr test =================================="
7523 [ -z "$(which setfattr 2>/dev/null)" ] &&
7524 skip_env "could not find setfattr" && return
7526 # b10930: get/set/list trusted.lov xattr
7527 echo "get/set/list trusted.lov xattr ..."
7528 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7529 local testfile=$DIR/$tfile
7530 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7531 error "setstripe failed"
7532 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7533 error "getstripe failed"
7534 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7535 error "can't get trusted.lov from $testfile"
7537 local testfile2=${testfile}2
7538 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7539 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7542 setfattr -n trusted.lov -v $value $testfile2
7543 local stripe_size=$($GETSTRIPE -S $testfile2)
7544 local stripe_count=$($GETSTRIPE -c $testfile2)
7545 [[ $stripe_size -eq 65536 ]] ||
7546 error "stripe size $stripe_size != 65536"
7547 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7548 error "stripe count $stripe_count != $STRIPECOUNT"
7551 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7554 [ -z "$(which setfattr 2>/dev/null)" ] &&
7555 skip_env "could not find setfattr" && return
7557 # b10930: get/set/list lustre.lov xattr
7558 echo "get/set/list lustre.lov xattr ..."
7559 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7560 test_mkdir $DIR/$tdir
7561 chown $RUNAS_ID $DIR/$tdir
7562 local testfile=$DIR/$tdir/$tfile
7563 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7564 error "setstripe failed"
7565 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7566 error "getstripe failed"
7567 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7568 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7570 local testfile2=${testfile}2
7571 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7572 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7574 $RUNAS $MCREATE $testfile2
7575 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7576 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7577 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7578 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7579 [ $stripe_count -eq $STRIPECOUNT ] ||
7580 error "stripe count $stripe_count != $STRIPECOUNT"
7582 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7584 compare_stripe_info1() {
7585 local stripe_index_all_zero=true
7587 for num in 1 2 3 4; do
7588 for count in $(seq 1 $STRIPE_COUNT); do
7589 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7590 local size=$((STRIPE_SIZE * num))
7591 local file=file"$num-$offset-$count"
7592 stripe_size=$($LFS getstripe -S $PWD/$file)
7593 [[ $stripe_size -ne $size ]] &&
7594 error "$file: size $stripe_size != $size"
7595 stripe_count=$($LFS getstripe -c $PWD/$file)
7596 # allow fewer stripes to be created, ORI-601
7597 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7598 error "$file: count $stripe_count != $count"
7599 stripe_index=$($LFS getstripe -i $PWD/$file)
7600 [[ $stripe_index -ne 0 ]] &&
7601 stripe_index_all_zero=false
7605 $stripe_index_all_zero &&
7606 error "all files are being extracted starting from OST index 0"
7610 have_xattrs_include() {
7611 tar --help | grep -q xattrs-include &&
7612 echo --xattrs-include="lustre.*"
7616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7617 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7618 XINC=$(have_xattrs_include)
7620 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7622 compare_stripe_info1
7624 run_test 102d "tar restore stripe info from tarfile,not keep osts"
7627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7628 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7629 XINC=$(have_xattrs_include)
7631 test_mkdir $DIR/$tdir.restore
7633 tar cf - --xattrs $tdir | tar xf - \
7634 -C $DIR/$tdir.restore --xattrs $XINC
7635 cd $DIR/$tdir.restore/$tdir
7636 compare_stripe_info1
7638 run_test 102f "tar copy files, not keep osts"
7641 local xsize=${1:-1024} # in bytes
7642 local file=$DIR/$tfile
7644 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7645 skip "must have user_xattr" && return 0
7646 [ -z "$(which setfattr 2>/dev/null)" ] &&
7647 skip_env "could not find setfattr" && return 0
7648 [ -z "$(which getfattr 2>/dev/null)" ] &&
7649 skip_env "could not find getfattr" && return 0
7653 local value="$(generate_string $xsize)"
7655 local xbig=trusted.big
7656 log "save $xbig on $file"
7657 setfattr -n $xbig -v $value $file ||
7658 error "saving $xbig on $file failed"
7660 local orig=$(get_xattr_value $xbig $file)
7661 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7663 local xsml=trusted.sml
7664 log "save $xsml on $file"
7665 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7667 local new=$(get_xattr_value $xbig $file)
7668 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7670 log "grow $xsml on $file"
7671 setfattr -n $xsml -v "$value" $file ||
7672 error "growing $xsml on $file failed"
7674 new=$(get_xattr_value $xbig $file)
7675 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7676 log "$xbig still valid after growing $xsml"
7681 test_102h() { # bug 15777
7684 run_test 102h "grow xattr from inside inode to external block"
7687 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7688 grow_xattr $(max_xattr_size)
7690 run_test 102ha "grow xattr from inside inode to external inode"
7692 test_102i() { # bug 17038
7693 [ -z "$(which getfattr 2>/dev/null)" ] &&
7694 skip "could not find getfattr" && return
7696 ln -s $DIR/$tfile $DIR/${tfile}link
7697 getfattr -n trusted.lov $DIR/$tfile ||
7698 error "lgetxattr on $DIR/$tfile failed"
7699 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7700 grep -i "no such attr" ||
7701 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7702 rm -f $DIR/$tfile $DIR/${tfile}link
7704 run_test 102i "lgetxattr test on symbolic link ============"
7707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7708 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7709 XINC=$(have_xattrs_include)
7710 setup_test102 "$RUNAS"
7711 chown $RUNAS_ID $DIR/$tdir
7712 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7714 compare_stripe_info1 "$RUNAS"
7716 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7719 [ -z "$(which setfattr 2>/dev/null)" ] &&
7720 skip "could not find setfattr" && return
7722 # b22187 just check that does not crash for regular file.
7723 setfattr -n trusted.lov $DIR/$tfile
7724 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
7725 local test_kdir=$DIR/$tdir
7726 test_mkdir $test_kdir
7727 local default_size=$($LFS getstripe -S $test_kdir)
7728 local default_count=$($LFS getstripe -c $test_kdir)
7729 local default_offset=$($LFS getstripe -i $test_kdir)
7730 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7731 error 'dir setstripe failed'
7732 setfattr -n trusted.lov $test_kdir
7733 local stripe_size=$($LFS getstripe -S $test_kdir)
7734 local stripe_count=$($LFS getstripe -c $test_kdir)
7735 local stripe_offset=$($LFS getstripe -i $test_kdir)
7736 [ $stripe_size -eq $default_size ] ||
7737 error "stripe size $stripe_size != $default_size"
7738 [ $stripe_count -eq $default_count ] ||
7739 error "stripe count $stripe_count != $default_count"
7740 [ $stripe_offset -eq $default_offset ] ||
7741 error "stripe offset $stripe_offset != $default_offset"
7742 rm -rf $DIR/$tfile $test_kdir
7744 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7747 [ -z "$(which getfattr 2>/dev/null)" ] &&
7748 skip "could not find getfattr" && return
7750 # LU-532 trusted. xattr is invisible to non-root
7751 local testfile=$DIR/$tfile
7755 echo "listxattr as user..."
7756 chown $RUNAS_ID $testfile
7757 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7758 grep -q "trusted" &&
7759 error "$testfile trusted xattrs are user visible"
7763 run_test 102l "listxattr size test =================================="
7765 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7766 local path=$DIR/$tfile
7769 listxattr_size_check $path || error "listattr_size_check $path failed"
7771 run_test 102m "Ensure listxattr fails on small bufffer ========"
7775 getxattr() { # getxattr path name
7776 # Return the base64 encoding of the value of xattr name on path.
7780 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7782 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7784 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7786 getfattr --absolute-names --encoding=base64 --name=$name $path |
7787 awk -F= -v name=$name '$1 == name {
7788 print substr($0, index($0, "=") + 1);
7792 test_102n() { # LU-4101 mdt: protect internal xattrs
7793 [ -z "$(which setfattr 2>/dev/null)" ] &&
7794 skip "could not find setfattr" && return
7795 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7797 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7801 local file0=$DIR/$tfile.0
7802 local file1=$DIR/$tfile.1
7803 local xattr0=$TMP/$tfile.0
7804 local xattr1=$TMP/$tfile.1
7805 local namelist="lov lma lmv link fid version som hsm"
7809 rm -rf $file0 $file1 $xattr0 $xattr1
7812 # Get 'before' xattrs of $file1.
7813 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7815 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7816 namelist+=" lfsck_namespace"
7817 for name in $namelist; do
7818 # Try to copy xattr from $file0 to $file1.
7819 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7821 setfattr --name=trusted.$name --value="$value" $file1 ||
7822 error "setxattr 'trusted.$name' failed"
7824 # Try to set a garbage xattr.
7825 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7827 if [[ x$name == "xlov" ]]; then
7828 setfattr --name=trusted.lov --value="$value" $file1 &&
7829 error "setxattr invalid 'trusted.lov' success"
7831 setfattr --name=trusted.$name --value="$value" $file1 ||
7832 error "setxattr invalid 'trusted.$name' failed"
7835 # Try to remove the xattr from $file1. We don't care if this
7836 # appears to succeed or fail, we just don't want there to be
7837 # any changes or crashes.
7838 setfattr --remove=$trusted.$name $file1 2> /dev/null
7841 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7844 # Try to copy xattr from $file0 to $file1.
7845 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7847 setfattr --name=trusted.$name --value="$value" $file1 ||
7848 error "setxattr 'trusted.$name' failed"
7850 # Try to set a garbage xattr.
7851 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7853 setfattr --name=trusted.$name --value="$value" $file1 ||
7854 error "setxattr 'trusted.$name' failed"
7856 # Try to remove the xattr from $file1. We don't care if this
7857 # appears to succeed or fail, we just don't want there to be
7858 # any changes or crashes.
7859 setfattr --remove=$trusted.$name $file1 2> /dev/null
7862 # Get 'after' xattrs of file1.
7863 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7865 if ! diff $xattr0 $xattr1; then
7866 error "before and after xattrs of '$file1' differ"
7869 rm -rf $file0 $file1 $xattr0 $xattr1
7873 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7875 test_102p() { # LU-4703 setxattr did not check ownership
7876 local testfile=$DIR/$tfile
7878 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7879 skip "MDS needs to be at least 2.5.56" && return
7883 echo "setfacl as user..."
7884 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7885 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7887 echo "setfattr as user..."
7888 setfacl -m "u:$RUNAS_ID:---" $testfile
7889 $RUNAS setfattr -x system.posix_acl_access $testfile
7890 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7892 run_test 102p "check setxattr(2) correctly fails without permission"
7895 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7896 skip "MDS needs to be at least 2.6.92" && return
7897 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7899 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7902 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7903 skip "MDS needs to be at least 2.6.93" && return
7904 touch $DIR/$tfile || error "touch"
7905 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7906 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7907 rm $DIR/$tfile || error "rm"
7910 mkdir -p $DIR/$tdir || error "mkdir"
7911 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7912 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7913 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7914 error "$testfile error deleting user.author1"
7915 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7916 grep "user.$(basename $tdir)" &&
7917 error "$tdir did not delete user.$(basename $tdir)"
7918 rmdir $DIR/$tdir || error "rmdir"
7921 test_mkdir $DIR/$tdir
7922 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7923 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7924 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7925 error "$testfile error deleting user.author1"
7926 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7927 grep "user.$(basename $tdir)" &&
7928 error "$tdir did not delete user.$(basename $tdir)"
7929 rmdir $DIR/$tdir || error "rm striped dir"
7931 run_test 102r "set EAs with empty values"
7935 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7940 [ "$UID" != 0 ] && skip_env "must run as root" && return
7941 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7942 skip "must have acl enabled" && return
7943 [ -z "$(which setfacl 2>/dev/null)" ] &&
7944 skip_env "could not find setfacl" && return
7945 $GSS && skip "could not run under gss" && return
7946 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7948 gpasswd -a daemon bin # LU-5641
7949 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7951 declare -a identity_old
7953 for num in $(seq $MDSCOUNT); do
7954 switch_identity $num true || identity_old[$num]=$?
7962 echo "performing cp ..."
7963 run_acl_subtest cp || error "run_acl_subtest cp failed"
7964 echo "performing getfacl-noacl..."
7965 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7966 echo "performing misc..."
7967 run_acl_subtest misc || error "misc test failed"
7968 echo "performing permissions..."
7969 run_acl_subtest permissions || error "permissions failed"
7970 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7971 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7972 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7973 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7975 echo "performing permissions xattr..."
7976 run_acl_subtest permissions_xattr ||
7977 error "permissions_xattr failed"
7979 echo "performing setfacl..."
7980 run_acl_subtest setfacl || error "setfacl test failed"
7982 # inheritance test got from HP
7983 echo "performing inheritance..."
7984 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7985 chmod +x make-tree || error "chmod +x failed"
7986 run_acl_subtest inheritance || error "inheritance test failed"
7989 echo "LU-974 ignore umask when acl is enabled..."
7990 run_acl_subtest 974 || error "LU-974 umask test failed"
7991 if [ $MDSCOUNT -ge 2 ]; then
7992 run_acl_subtest 974_remote ||
7993 error "LU-974 umask test failed under remote dir"
7996 echo "LU-2561 newly created file is same size as directory..."
7997 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7998 run_acl_subtest 2561 || error "LU-2561 test failed"
8000 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8003 run_acl_subtest 4924 || error "LU-4924 test failed"
8008 for num in $(seq $MDSCOUNT); do
8009 if [ "${identity_old[$num]}" = 1 ]; then
8010 switch_identity $num false || identity_old[$num]=$?
8014 run_test 103a "acl test ========================================="
8018 cp -rp $DIR/$tdir $DIR/$tdir.bak
8020 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8021 error "$DIR/$tdir shouldn't contain default ACL"
8022 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8023 error "$DIR/$tdir.bak shouldn't contain default ACL"
8026 run_test 103c "'cp -rp' won't set empty acl"
8029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8031 lfs df || error "lfs df failed"
8032 lfs df -ih || error "lfs df -ih failed"
8033 lfs df -h $DIR || error "lfs df -h $DIR failed"
8034 lfs df -i $DIR || error "lfs df -i $DIR failed"
8035 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8036 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8038 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8039 lctl --device %$OSC deactivate
8040 lfs df || error "lfs df with deactivated OSC failed"
8041 lctl --device %$OSC activate
8042 # wait the osc back to normal
8043 wait_osc_import_state client ost FULL
8045 lfs df || error "lfs df with reactivated OSC failed"
8048 run_test 104a "lfs df [-ih] [path] test ========================="
8051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8052 [ $RUNAS_ID -eq $UID ] &&
8053 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
8055 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8056 grep "Permission denied" | wc -l)))
8057 if [ $denied_cnt -ne 0 ]; then
8058 error "lfs check servers test failed"
8061 run_test 104b "$RUNAS lfs check servers test ===================="
8064 # doesn't work on 2.4 kernels
8066 if $(flock_is_enabled); then
8067 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8069 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8073 run_test 105a "flock when mounted without -o flock test ========"
8077 if $(flock_is_enabled); then
8078 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8080 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8084 run_test 105b "fcntl when mounted without -o flock test ========"
8088 if $(flock_is_enabled); then
8089 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8091 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8095 run_test 105c "lockf when mounted without -o flock test"
8097 test_105d() { # bug 15924
8098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8099 test_mkdir $DIR/$tdir
8100 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8101 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8102 $LCTL set_param fail_loc=0x80000315
8103 flocks_test 2 $DIR/$tdir
8105 run_test 105d "flock race (should not freeze) ========"
8107 test_105e() { # bug 22660 && 22040
8108 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8110 flocks_test 3 $DIR/$tfile
8112 run_test 105e "Two conflicting flocks from same process"
8114 test_106() { #bug 10921
8115 test_mkdir $DIR/$tdir
8116 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8117 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8119 run_test 106 "attempt exec of dir followed by chown of that dir"
8122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8129 local save_pattern=$(sysctl -n kernel.core_pattern)
8130 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8131 sysctl -w kernel.core_pattern=$file
8132 sysctl -w kernel.core_uses_pid=0
8140 kill -s 11 $SLEEPPID
8142 if [ -e $file ]; then
8143 size=`stat -c%s $file`
8144 [ $size -eq 0 ] && error "Fail to create core file $file"
8146 error "Fail to create core file $file"
8149 sysctl -w kernel.core_pattern=$save_pattern
8150 sysctl -w kernel.core_uses_pid=$save_uses_pid
8153 run_test 107 "Coredump on SIG"
8156 test_mkdir $DIR/$tdir
8157 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8158 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8159 error "mkdir with 256 char should fail, but did not"
8160 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8161 error "create with 255 char failed"
8162 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8163 error "create with 256 char should fail, but did not"
8168 run_test 110 "filename length checking"
8171 # Purpose: To verify dynamic thread (OSS) creation.
8174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8175 remote_ost_nodsh && skip "remote OST with nodsh" && return
8177 # Lustre does not stop service threads once they are started.
8178 # Reset number of running threads to default.
8183 local save_params="$TMP/sanity-$TESTNAME.parameters"
8185 # Get ll_ost_io count before I/O
8186 OSTIO_pre=$(do_facet ost1 \
8187 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8188 # Exit if lustre is not running (ll_ost_io not running).
8189 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8191 echo "Starting with $OSTIO_pre threads"
8192 local thread_max=$((OSTIO_pre * 2))
8193 local rpc_in_flight=$((thread_max * 2))
8194 # Number of I/O Process proposed to be started.
8196 local facets=$(get_facets OST)
8198 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8199 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8201 # Set in_flight to $rpc_in_flight
8202 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8203 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8204 nfiles=${rpc_in_flight}
8205 # Set ost thread_max to $thread_max
8206 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8208 # 5 Minutes should be sufficient for max number of OSS
8209 # threads(thread_max) to be created.
8213 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8214 test_mkdir $DIR/$tdir
8215 for i in $(seq $nfiles); do
8216 local file=$DIR/$tdir/${tfile}-$i
8217 $LFS setstripe -c -1 -i 0 $file
8218 ($WTL $file $timeout)&
8221 # I/O Started - Wait for thread_started to reach thread_max or report
8222 # error if thread_started is more than thread_max.
8223 echo "Waiting for thread_started to reach thread_max"
8224 local thread_started=0
8225 local end_time=$((SECONDS + timeout))
8227 while [ $SECONDS -le $end_time ] ; do
8229 # Get ost i/o thread_started count.
8230 thread_started=$(do_facet ost1 \
8232 ost.OSS.ost_io.threads_started | cut -d= -f2")
8233 # Break out if thread_started is equal/greater than thread_max
8234 if [[ $thread_started -ge $thread_max ]]; then
8235 echo ll_ost_io thread_started $thread_started, \
8236 equal/greater than thread_max $thread_max
8242 # Cleanup - We have the numbers, Kill i/o jobs if running.
8243 jobcount=($(jobs -p))
8244 for i in $(seq 0 $((${#jobcount[@]}-1)))
8246 kill -9 ${jobcount[$i]}
8247 if [ $? -ne 0 ] ; then
8249 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8253 # Cleanup files left by WTL binary.
8254 for i in $(seq $nfiles); do
8255 local file=$DIR/$tdir/${tfile}-$i
8257 if [ $? -ne 0 ] ; then
8258 echo "Warning: Failed to delete file $file"
8262 restore_lustre_params <$save_params
8263 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8265 # Error out if no new thread has started or Thread started is greater
8267 if [[ $thread_started -le $OSTIO_pre ||
8268 $thread_started -gt $thread_max ]]; then
8269 error "ll_ost_io: thread_started $thread_started" \
8270 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8271 "No new thread started or thread started greater " \
8275 run_test 115 "verify dynamic thread creation===================="
8278 wait_delete_completed
8279 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8280 echo "OST kbytes available: ${AVAIL[@]}"
8285 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8286 #echo OST $i: ${AVAIL[i]}kb
8287 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8291 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8296 echo "Min free space: OST $MINI: $MINV"
8297 echo "Max free space: OST $MAXI: $MAXV"
8300 test_116a() { # was previously test_116()
8301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8302 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8304 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8306 echo -n "Free space priority "
8307 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8312 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8313 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8315 trap simple_cleanup_common EXIT
8318 # Check if we need to generate uneven OSTs
8319 test_mkdir -p $DIR/$tdir/OST${MINI}
8320 local FILL=$((MINV / 4))
8321 local DIFF=$((MAXV - MINV))
8322 local DIFF2=$((DIFF * 100 / MINV))
8324 local threshold=$(do_facet $SINGLEMDS \
8325 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8326 threshold=${threshold%%%}
8327 echo -n "Check for uneven OSTs: "
8328 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8330 if [[ $DIFF2 -gt $threshold ]]; then
8332 echo "Don't need to fill OST$MINI"
8334 # generate uneven OSTs. Write 2% over the QOS threshold value
8336 DIFF=$((threshold - DIFF2 + 2))
8337 DIFF2=$((MINV * DIFF / 100))
8338 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8339 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8340 error "setstripe failed"
8341 DIFF=$((DIFF2 / 2048))
8343 while [ $i -lt $DIFF ]; do
8345 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8346 bs=2M count=1 2>/dev/null
8355 DIFF=$((MAXV - MINV))
8356 DIFF2=$((DIFF * 100 / MINV))
8357 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8358 if [ $DIFF2 -gt $threshold ]; then
8361 echo "failed - QOS mode won't be used"
8362 skip "QOS imbalance criteria not met"
8363 simple_cleanup_common
8372 # now fill using QOS
8373 $SETSTRIPE -c 1 $DIR/$tdir
8374 FILL=$((FILL / 200))
8375 if [ $FILL -gt 600 ]; then
8378 echo "writing $FILL files to QOS-assigned OSTs"
8380 while [ $i -lt $FILL ]; do
8382 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8386 echo "wrote $i 200k files"
8390 echo "Note: free space may not be updated, so measurements might be off"
8392 DIFF2=$((MAXV - MINV))
8393 echo "free space delta: orig $DIFF final $DIFF2"
8394 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8395 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8396 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8397 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8398 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8399 if [[ $DIFF -gt 0 ]]; then
8400 FILL=$((DIFF2 * 100 / DIFF - 100))
8401 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8404 # Figure out which files were written where
8405 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8406 awk '/'$MINI1': / {print $2; exit}')
8408 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8409 echo "$MINC files created on smaller OST $MINI1"
8410 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8411 awk '/'$MAXI1': / {print $2; exit}')
8413 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8414 echo "$MAXC files created on larger OST $MAXI1"
8415 if [[ $MINC -gt 0 ]]; then
8416 FILL=$((MAXC * 100 / MINC - 100))
8417 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8419 [[ $MAXC -gt $MINC ]] ||
8420 error_ignore LU-9 "stripe QOS didn't balance free space"
8421 simple_cleanup_common
8423 run_test 116a "stripe QOS: free space balance ==================="
8425 test_116b() { # LU-2093
8426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8427 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8429 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8430 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8431 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8432 [ -z "$old_rr" ] && skip "no QOS" && return 0
8433 do_facet $SINGLEMDS lctl set_param \
8434 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8436 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8437 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8438 do_facet $SINGLEMDS lctl set_param fail_loc=0
8440 do_facet $SINGLEMDS lctl set_param \
8441 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8443 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8445 test_117() # bug 10891
8447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8448 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8449 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8450 lctl set_param fail_loc=0x21e
8451 > $DIR/$tfile || error "truncate failed"
8452 lctl set_param fail_loc=0
8453 echo "Truncate succeeded."
8456 run_test 117 "verify osd extend =========="
8458 NO_SLOW_RESENDCOUNT=4
8459 export OLD_RESENDCOUNT=""
8460 set_resend_count () {
8461 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8462 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8463 lctl set_param -n $PROC_RESENDCOUNT $1
8464 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8467 # for reduce test_118* time (b=14842)
8468 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8470 # Reset async IO behavior after error case
8472 FILE=$DIR/reset_async
8474 # Ensure all OSCs are cleared
8475 $SETSTRIPE -c -1 $FILE
8476 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8481 test_118a() #bug 11710
8483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8486 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8487 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8488 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8490 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8491 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8496 run_test 118a "verify O_SYNC works =========="
8500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8501 remote_ost_nodsh && skip "remote OST with nodsh" && return
8505 #define OBD_FAIL_SRV_ENOENT 0x217
8506 set_nodes_failloc "$(osts_nodes)" 0x217
8507 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8509 set_nodes_failloc "$(osts_nodes)" 0
8510 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8511 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8514 if [[ $RC -eq 0 ]]; then
8515 error "Must return error due to dropped pages, rc=$RC"
8519 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8520 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8524 echo "Dirty pages not leaked on ENOENT"
8526 # Due to the above error the OSC will issue all RPCs syncronously
8527 # until a subsequent RPC completes successfully without error.
8528 $MULTIOP $DIR/$tfile Ow4096yc
8533 run_test 118b "Reclaim dirty pages on fatal error =========="
8537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8539 # for 118c, restore the original resend count, LU-1940
8540 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8541 set_resend_count $OLD_RESENDCOUNT
8542 remote_ost_nodsh && skip "remote OST with nodsh" && return
8546 #define OBD_FAIL_OST_EROFS 0x216
8547 set_nodes_failloc "$(osts_nodes)" 0x216
8549 # multiop should block due to fsync until pages are written
8550 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8554 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8555 error "Multiop failed to block on fsync, pid=$MULTIPID"
8558 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8560 if [[ $WRITEBACK -eq 0 ]]; then
8561 error "No page in writeback, writeback=$WRITEBACK"
8564 set_nodes_failloc "$(osts_nodes)" 0
8567 if [[ $RC -ne 0 ]]; then
8568 error "Multiop fsync failed, rc=$RC"
8571 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8572 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8574 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8575 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8579 echo "Dirty pages flushed via fsync on EROFS"
8582 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8584 # continue to use small resend count to reduce test_118* time (b=14842)
8585 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8590 remote_ost_nodsh && skip "remote OST with nodsh" && return
8594 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8595 set_nodes_failloc "$(osts_nodes)" 0x214
8596 # multiop should block due to fsync until pages are written
8597 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8601 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8602 error "Multiop failed to block on fsync, pid=$MULTIPID"
8605 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8607 if [[ $WRITEBACK -eq 0 ]]; then
8608 error "No page in writeback, writeback=$WRITEBACK"
8611 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8612 set_nodes_failloc "$(osts_nodes)" 0
8614 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8615 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8617 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8618 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8622 echo "Dirty pages gaurenteed flushed via fsync"
8625 run_test 118d "Fsync validation inject a delay of the bulk =========="
8628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8631 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8632 lctl set_param fail_loc=0x8000040a
8634 # Should simulate EINVAL error which is fatal
8635 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8637 if [[ $RC -eq 0 ]]; then
8638 error "Must return error due to dropped pages, rc=$RC"
8641 lctl set_param fail_loc=0x0
8643 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8644 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8645 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8647 if [[ $LOCKED -ne 0 ]]; then
8648 error "Locked pages remain in cache, locked=$LOCKED"
8651 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8652 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8656 echo "No pages locked after fsync"
8661 run_test 118f "Simulate unrecoverable OSC side error =========="
8664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8667 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8668 lctl set_param fail_loc=0x406
8670 # simulate local -ENOMEM
8671 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8674 lctl set_param fail_loc=0
8675 if [[ $RC -eq 0 ]]; then
8676 error "Must return error due to dropped pages, rc=$RC"
8679 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8680 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8681 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8683 if [[ $LOCKED -ne 0 ]]; then
8684 error "Locked pages remain in cache, locked=$LOCKED"
8687 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8688 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8692 echo "No pages locked after fsync"
8697 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8701 remote_ost_nodsh && skip "remote OST with nodsh" && return
8705 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8706 set_nodes_failloc "$(osts_nodes)" 0x20e
8707 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8708 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8711 set_nodes_failloc "$(osts_nodes)" 0
8712 if [[ $RC -eq 0 ]]; then
8713 error "Must return error due to dropped pages, rc=$RC"
8716 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8717 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8718 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8720 if [[ $LOCKED -ne 0 ]]; then
8721 error "Locked pages remain in cache, locked=$LOCKED"
8724 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8725 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8729 echo "No pages locked after fsync"
8733 run_test 118h "Verify timeout in handling recoverables errors =========="
8735 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8739 remote_ost_nodsh && skip "remote OST with nodsh" && return
8743 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8744 set_nodes_failloc "$(osts_nodes)" 0x20e
8746 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8747 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8750 set_nodes_failloc "$(osts_nodes)" 0
8754 if [[ $RC -ne 0 ]]; then
8755 error "got error, but should be not, rc=$RC"
8758 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8759 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8760 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8761 if [[ $LOCKED -ne 0 ]]; then
8762 error "Locked pages remain in cache, locked=$LOCKED"
8765 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8766 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8770 echo "No pages locked after fsync"
8774 run_test 118i "Fix error before timeout in recoverable error =========="
8776 [ "$SLOW" = "no" ] && set_resend_count 4
8779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8780 remote_ost_nodsh && skip "remote OST with nodsh" && return
8784 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8785 set_nodes_failloc "$(osts_nodes)" 0x220
8787 # return -EIO from OST
8788 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8790 set_nodes_failloc "$(osts_nodes)" 0x0
8791 if [[ $RC -eq 0 ]]; then
8792 error "Must return error due to dropped pages, rc=$RC"
8795 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8796 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8797 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8798 if [[ $LOCKED -ne 0 ]]; then
8799 error "Locked pages remain in cache, locked=$LOCKED"
8802 # in recoverable error on OST we want resend and stay until it finished
8803 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8804 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8808 echo "No pages locked after fsync"
8812 run_test 118j "Simulate unrecoverable OST side error =========="
8816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8817 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8819 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8820 set_nodes_failloc "$(osts_nodes)" 0x20e
8821 test_mkdir $DIR/$tdir
8823 for ((i=0;i<10;i++)); do
8824 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8825 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8832 set_nodes_failloc "$(osts_nodes)" 0
8835 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8841 test_mkdir $DIR/$tdir
8842 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8845 run_test 118l "fsync dir"
8847 test_118m() # LU-3066
8849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8850 test_mkdir $DIR/$tdir
8851 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8854 run_test 118m "fdatasync dir ========="
8856 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8864 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8866 # Sleep to avoid a cached response.
8867 #define OBD_STATFS_CACHE_SECONDS 1
8870 # Inject a 10 second delay in the OST_STATFS handler.
8871 #define OBD_FAIL_OST_STATFS_DELAY 0x242
8872 set_nodes_failloc "$(osts_nodes)" 0x242
8875 stat --file-system $MOUNT > /dev/null
8878 set_nodes_failloc "$(osts_nodes)" 0
8880 if ((end - begin > 20)); then
8881 error "statfs took $((end - begin)) seconds, expected 10"
8884 run_test 118n "statfs() sends OST_STATFS requests in parallel"
8886 test_119a() # bug 11737
8888 BSIZE=$((512 * 1024))
8889 directio write $DIR/$tfile 0 1 $BSIZE
8890 # We ask to read two blocks, which is more than a file size.
8891 # directio will indicate an error when requested and actual
8892 # sizes aren't equeal (a normal situation in this case) and
8893 # print actual read amount.
8894 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8895 if [ "$NOB" != "$BSIZE" ]; then
8896 error "read $NOB bytes instead of $BSIZE"
8900 run_test 119a "Short directIO read must return actual read amount"
8902 test_119b() # bug 11737
8904 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8906 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8907 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8909 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8910 error "direct read failed"
8913 run_test 119b "Sparse directIO read must return actual read amount"
8915 test_119c() # bug 13099
8918 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8919 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8922 run_test 119c "Testing for direct read hitting hole"
8924 test_119d() # bug 15950
8926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8927 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8928 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8930 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8931 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8932 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8933 lctl set_param fail_loc=0x40d
8934 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8937 cat $DIR/$tfile > /dev/null &
8938 lctl set_param fail_loc=0
8941 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8943 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8944 error "the read rpcs have not completed in 2s"
8946 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8948 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8952 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8953 test_mkdir $DIR/$tdir
8954 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8955 { skip "no early lock cancel on server"; return 0; }
8957 lru_resize_disable mdc
8958 lru_resize_disable osc
8959 cancel_lru_locks mdc
8960 # asynchronous object destroy at MDT could cause bl ast to client
8961 cancel_lru_locks osc
8963 stat $DIR/$tdir > /dev/null
8964 can1=$(do_facet $SINGLEMDS \
8965 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8966 awk '/ldlm_cancel/ {print $2}')
8967 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8968 awk '/ldlm_bl_callback/ {print $2}')
8969 test_mkdir -c1 $DIR/$tdir/d1
8970 can2=$(do_facet $SINGLEMDS \
8971 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8972 awk '/ldlm_cancel/ {print $2}')
8973 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8974 awk '/ldlm_bl_callback/ {print $2}')
8975 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8976 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8977 lru_resize_enable mdc
8978 lru_resize_enable osc
8980 run_test 120a "Early Lock Cancel: mkdir test"
8983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8984 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8985 test_mkdir $DIR/$tdir
8986 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8987 { skip "no early lock cancel on server"; return 0; }
8988 lru_resize_disable mdc
8989 lru_resize_disable osc
8990 cancel_lru_locks mdc
8991 stat $DIR/$tdir > /dev/null
8992 can1=$(do_facet $SINGLEMDS \
8993 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8994 awk '/ldlm_cancel/ {print $2}')
8995 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8996 awk '/ldlm_bl_callback/ {print $2}')
8998 can2=$(do_facet $SINGLEMDS \
8999 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9000 awk '/ldlm_cancel/ {print $2}')
9001 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9002 awk '/ldlm_bl_callback/ {print $2}')
9003 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9004 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9005 lru_resize_enable mdc
9006 lru_resize_enable osc
9008 run_test 120b "Early Lock Cancel: create test"
9011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9012 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9013 test_mkdir -c1 $DIR/$tdir
9014 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9015 { skip "no early lock cancel on server"; return 0; }
9016 lru_resize_disable mdc
9017 lru_resize_disable osc
9018 test_mkdir -c1 $DIR/$tdir/d1
9019 test_mkdir -c1 $DIR/$tdir/d2
9020 touch $DIR/$tdir/d1/f1
9021 cancel_lru_locks mdc
9022 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9023 can1=$(do_facet $SINGLEMDS \
9024 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9025 awk '/ldlm_cancel/ {print $2}')
9026 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9027 awk '/ldlm_bl_callback/ {print $2}')
9028 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9029 can2=$(do_facet $SINGLEMDS \
9030 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9031 awk '/ldlm_cancel/ {print $2}')
9032 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9033 awk '/ldlm_bl_callback/ {print $2}')
9034 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9035 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9036 lru_resize_enable mdc
9037 lru_resize_enable osc
9039 run_test 120c "Early Lock Cancel: link test"
9042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9043 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9044 test_mkdir -c1 $DIR/$tdir
9045 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9046 { skip "no early lock cancel on server"; return 0; }
9047 lru_resize_disable mdc
9048 lru_resize_disable osc
9050 cancel_lru_locks mdc
9051 stat $DIR/$tdir > /dev/null
9052 can1=$(do_facet $SINGLEMDS \
9053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9054 awk '/ldlm_cancel/ {print $2}')
9055 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9056 awk '/ldlm_bl_callback/ {print $2}')
9057 chmod a+x $DIR/$tdir
9058 can2=$(do_facet $SINGLEMDS \
9059 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9060 awk '/ldlm_cancel/ {print $2}')
9061 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9062 awk '/ldlm_bl_callback/ {print $2}')
9063 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9064 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9065 lru_resize_enable mdc
9066 lru_resize_enable osc
9068 run_test 120d "Early Lock Cancel: setattr test"
9071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9072 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9073 { skip "no early lock cancel on server"; return 0; }
9074 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9075 local dlmtrace_set=false
9077 test_mkdir -c1 $DIR/$tdir
9078 lru_resize_disable mdc
9079 lru_resize_disable osc
9080 ! $LCTL get_param debug | grep -q dlmtrace &&
9081 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9082 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9083 cancel_lru_locks mdc
9084 cancel_lru_locks osc
9085 dd if=$DIR/$tdir/f1 of=/dev/null
9086 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9087 # XXX client can not do early lock cancel of OST lock
9088 # during unlink (LU-4206), so cancel osc lock now.
9090 cancel_lru_locks osc
9091 can1=$(do_facet $SINGLEMDS \
9092 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9093 awk '/ldlm_cancel/ {print $2}')
9094 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9095 awk '/ldlm_bl_callback/ {print $2}')
9096 unlink $DIR/$tdir/f1
9098 can2=$(do_facet $SINGLEMDS \
9099 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9100 awk '/ldlm_cancel/ {print $2}')
9101 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9102 awk '/ldlm_bl_callback/ {print $2}')
9103 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9104 $LCTL dk $TMP/cancel.debug.txt
9105 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9106 $LCTL dk $TMP/blocking.debug.txt
9107 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9108 lru_resize_enable mdc
9109 lru_resize_enable osc
9111 run_test 120e "Early Lock Cancel: unlink test"
9114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9115 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9116 { skip "no early lock cancel on server"; return 0; }
9117 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9118 test_mkdir -c1 $DIR/$tdir
9119 lru_resize_disable mdc
9120 lru_resize_disable osc
9121 test_mkdir -c1 $DIR/$tdir/d1
9122 test_mkdir -c1 $DIR/$tdir/d2
9123 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9124 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9125 cancel_lru_locks mdc
9126 cancel_lru_locks osc
9127 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9128 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9129 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9130 # XXX client can not do early lock cancel of OST lock
9131 # during rename (LU-4206), so cancel osc lock now.
9133 cancel_lru_locks osc
9134 can1=$(do_facet $SINGLEMDS \
9135 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9136 awk '/ldlm_cancel/ {print $2}')
9137 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9138 awk '/ldlm_bl_callback/ {print $2}')
9139 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9141 can2=$(do_facet $SINGLEMDS \
9142 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9143 awk '/ldlm_cancel/ {print $2}')
9144 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9145 awk '/ldlm_bl_callback/ {print $2}')
9146 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9147 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9148 lru_resize_enable mdc
9149 lru_resize_enable osc
9151 run_test 120f "Early Lock Cancel: rename test"
9154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9155 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9156 { skip "no early lock cancel on server"; return 0; }
9157 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9158 lru_resize_disable mdc
9159 lru_resize_disable osc
9161 echo create $count files
9162 test_mkdir $DIR/$tdir
9163 cancel_lru_locks mdc
9164 cancel_lru_locks osc
9167 can0=$(do_facet $SINGLEMDS \
9168 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9169 awk '/ldlm_cancel/ {print $2}')
9170 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9171 awk '/ldlm_bl_callback/ {print $2}')
9172 createmany -o $DIR/$tdir/f $count
9174 can1=$(do_facet $SINGLEMDS \
9175 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9176 awk '/ldlm_cancel/ {print $2}')
9177 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9178 awk '/ldlm_bl_callback/ {print $2}')
9180 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9181 echo rm $count files
9184 can2=$(do_facet $SINGLEMDS \
9185 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9186 awk '/ldlm_cancel/ {print $2}')
9187 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9188 awk '/ldlm_bl_callback/ {print $2}')
9190 echo total: $count removes in $((t2-t1))
9191 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9193 # wait for commitment of removal
9194 lru_resize_enable mdc
9195 lru_resize_enable osc
9197 run_test 120g "Early Lock Cancel: performance test"
9199 test_121() { #bug #10589
9200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9202 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9203 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9204 lctl set_param fail_loc=0x310
9205 cancel_lru_locks osc > /dev/null
9206 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9207 lctl set_param fail_loc=0
9208 [[ $reads -eq $writes ]] ||
9209 error "read $reads blocks, must be $writes blocks"
9211 run_test 121 "read cancel race ========="
9213 test_123a() { # was test 123, statahead(bug 11401)
9214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9216 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9217 log "testing UP system. Performance may be lower than expected."
9222 test_mkdir $DIR/$tdir
9223 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9224 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9226 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9227 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9229 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9230 lctl set_param -n llite.*.statahead_max 0
9231 lctl get_param llite.*.statahead_max
9232 cancel_lru_locks mdc
9233 cancel_lru_locks osc
9235 time ls -l $DIR/$tdir | wc -l
9237 delta=$((etime - stime))
9238 log "ls $i files without statahead: $delta sec"
9239 lctl set_param llite.*.statahead_max=$max
9241 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9242 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9243 cancel_lru_locks mdc
9244 cancel_lru_locks osc
9246 time ls -l $DIR/$tdir | wc -l
9248 delta_sa=$((etime - stime))
9249 log "ls $i files with statahead: $delta_sa sec"
9250 lctl get_param -n llite.*.statahead_stats
9251 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9253 [[ $swrong -lt $ewrong ]] &&
9254 log "statahead was stopped, maybe too many locks held!"
9255 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9257 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9258 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9259 lctl set_param -n llite.*.statahead_max 0
9260 lctl get_param llite.*.statahead_max
9261 cancel_lru_locks mdc
9262 cancel_lru_locks osc
9264 time ls -l $DIR/$tdir | wc -l
9266 delta=$((etime - stime))
9267 log "ls $i files again without statahead: $delta sec"
9268 lctl set_param llite.*.statahead_max=$max
9269 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9270 if [ $SLOWOK -eq 0 ]; then
9271 error "ls $i files is slower with statahead!"
9273 log "ls $i files is slower with statahead!"
9279 [ $delta -gt 20 ] && break
9280 [ $delta -gt 8 ] && MULT=$((50 / delta))
9281 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9289 delta=$((etime - stime))
9290 log "rm -r $DIR/$tdir/: $delta seconds"
9292 lctl get_param -n llite.*.statahead_stats
9294 run_test 123a "verify statahead work"
9296 test_123b () { # statahead(bug 15027)
9297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9298 test_mkdir $DIR/$tdir
9299 createmany -o $DIR/$tdir/$tfile-%d 1000
9301 cancel_lru_locks mdc
9302 cancel_lru_locks osc
9304 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9305 lctl set_param fail_loc=0x80000803
9306 ls -lR $DIR/$tdir > /dev/null
9308 lctl set_param fail_loc=0x0
9309 lctl get_param -n llite.*.statahead_stats
9314 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9318 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9319 { skip "no lru resize on server"; return 0; }
9321 test_mkdir $DIR/$tdir
9323 log "create $NR files at $DIR/$tdir"
9324 createmany -o $DIR/$tdir/f $NR ||
9325 error "failed to create $NR files in $DIR/$tdir"
9327 cancel_lru_locks mdc
9328 ls -l $DIR/$tdir > /dev/null
9332 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9333 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9334 LRU_SIZE=$($LCTL get_param -n $PARAM)
9335 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9336 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9338 log "NS=$(basename $NSDIR)"
9343 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9344 skip "Not enough cached locks created!"
9351 # We know that lru resize allows one client to hold $LIMIT locks
9352 # for 10h. After that locks begin to be killed by client.
9354 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9356 if [ $LIMIT -lt $LRU_SIZE ]; then
9357 skip "Limit is too small $LIMIT"
9361 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9362 # killing locks. Some time was spent for creating locks. This means
9363 # that up to the moment of sleep finish we must have killed some of
9364 # them (10-100 locks). This depends on how fast ther were created.
9365 # Many of them were touched in almost the same moment and thus will
9366 # be killed in groups.
9367 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9369 # Use $LRU_SIZE_B here to take into account real number of locks
9370 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9371 local LRU_SIZE_B=$LRU_SIZE
9373 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9374 log "OLD_LVF=$OLD_LVF"
9375 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9377 # Let's make sure that we really have some margin. Client checks
9378 # cached locks every 10 sec.
9380 log "Sleep ${SLEEP} sec"
9382 while ((SEC<$SLEEP)); do
9386 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9390 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9391 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9393 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9394 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9395 unlinkmany $DIR/$tdir/f $NR
9399 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9400 log "unlink $NR files at $DIR/$tdir"
9401 unlinkmany $DIR/$tdir/f $NR
9403 run_test 124a "lru resize ======================================="
9405 get_max_pool_limit()
9407 local limit=$($LCTL get_param \
9408 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9411 if [[ $l -gt $max ]]; then
9419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9420 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9421 { skip "no lru resize on server"; return 0; }
9423 LIMIT=$(get_max_pool_limit)
9425 NR=$(($(default_lru_size)*20))
9426 if [[ $NR -gt $LIMIT ]]; then
9427 log "Limit lock number by $LIMIT locks"
9431 IFree=$(mdsrate_inodes_available)
9432 if [ $IFree -lt $NR ]; then
9433 log "Limit lock number by $IFree inodes"
9437 lru_resize_disable mdc
9438 test_mkdir -p $DIR/$tdir/disable_lru_resize
9440 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9441 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9442 cancel_lru_locks mdc
9445 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9448 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9451 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9455 nolruresize_delta=$((etime-stime))
9456 log "ls -la time: $nolruresize_delta seconds"
9457 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9458 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9460 lru_resize_enable mdc
9461 test_mkdir -p $DIR/$tdir/enable_lru_resize
9463 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9464 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9465 cancel_lru_locks mdc
9468 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9471 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9474 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9478 lruresize_delta=$((etime-stime))
9479 log "ls -la time: $lruresize_delta seconds"
9480 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9482 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9483 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9484 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9485 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9487 log "lru resize performs the same with no lru resize"
9489 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9491 run_test 124b "lru resize (performance test) ======================="
9494 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9495 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9496 { skip "no lru resize on server"; return 0; }
9498 # cache ununsed locks on client
9500 cancel_lru_locks mdc
9501 test_mkdir $DIR/$tdir
9502 createmany -o $DIR/$tdir/f $nr ||
9503 error "failed to create $nr files in $DIR/$tdir"
9504 ls -l $DIR/$tdir > /dev/null
9506 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9507 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9508 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9509 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9510 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9512 # set lru_max_age to 1 sec
9513 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9514 echo "sleep $((recalc_p * 2)) seconds..."
9515 sleep $((recalc_p * 2))
9517 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9518 # restore lru_max_age
9519 $LCTL set_param -n $nsdir.lru_max_age $max_age
9520 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9521 unlinkmany $DIR/$tdir/f $nr
9523 run_test 124c "LRUR cancel very aged locks"
9525 test_125() { # 13358
9526 $LCTL get_param -n llite.*.client_type | grep -q local ||
9527 { skip "must run as local client"; return; }
9528 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
9529 { skip "must have acl enabled"; return; }
9530 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9531 test_mkdir $DIR/$tdir
9532 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
9533 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
9534 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
9536 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9538 test_126() { # bug 12829/13455
9539 $LCTL get_param -n llite.*.client_type | grep -q local ||
9540 { skip "must run as local client"; return; }
9541 [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
9542 $GSS && skip "must run as gss disabled" && return
9544 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9545 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9547 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9549 run_test 126 "check that the fsgid provided by the client is taken into account"
9551 test_127a() { # bug 15521
9552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9553 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9554 $LCTL set_param osc.*.stats=0
9555 FSIZE=$((2048 * 1024))
9556 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9557 cancel_lru_locks osc
9558 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9560 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9561 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9562 echo "got $COUNT $NAME"
9563 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9564 eval $NAME=$COUNT || error "Wrong proc format"
9567 read_bytes|write_bytes)
9568 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9569 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9570 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9571 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9572 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9573 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9574 error "sumsquare is too small: $SUMSQ"
9575 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9576 error "sumsquare is too big: $SUMSQ"
9580 done < $DIR/${tfile}.tmp
9582 #check that we actually got some stats
9583 [ "$read_bytes" ] || error "Missing read_bytes stats"
9584 [ "$write_bytes" ] || error "Missing write_bytes stats"
9585 [ "$read_bytes" != 0 ] || error "no read done"
9586 [ "$write_bytes" != 0 ] || error "no write done"
9588 run_test 127a "verify the client stats are sane"
9590 test_127b() { # bug LU-333
9591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9592 $LCTL set_param llite.*.stats=0
9593 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9594 # perform 2 reads and writes so MAX is different from SUM.
9595 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9596 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9597 cancel_lru_locks osc
9598 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9599 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9601 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9602 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9603 echo "got $COUNT $NAME"
9604 eval $NAME=$COUNT || error "Wrong proc format"
9608 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9609 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9610 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9611 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9614 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9615 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9616 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9617 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9621 done < $TMP/${tfile}.tmp
9623 #check that we actually got some stats
9624 [ "$read_bytes" ] || error "Missing read_bytes stats"
9625 [ "$write_bytes" ] || error "Missing write_bytes stats"
9626 [ "$read_bytes" != 0 ] || error "no read done"
9627 [ "$write_bytes" != 0 ] || error "no write done"
9629 rm -f $TMP/${tfile}.tmp
9631 run_test 127b "verify the llite client stats are sane"
9633 test_128() { # bug 15212
9635 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9640 result=$(grep error $TMP/$tfile.log)
9641 rm -f $DIR/$tfile $TMP/$tfile.log
9643 error "consecutive find's under interactive lfs failed"
9645 run_test 128 "interactive lfs for 2 consecutive find's"
9652 local ldproc=/proc/fs/ldiskfs
9653 local facets=$(get_facets MDS)
9655 for facet in ${facets//,/ }; do
9656 canondev=$(ldiskfs_canon \
9657 *.$(convert_facet2label $facet).mntdev $facet)
9658 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9659 ldproc=/sys/fs/ldiskfs
9660 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9661 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9666 local facets=$(get_facets MDS)
9667 for facet in ${facets//,/ }; do
9668 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9674 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9675 { skip "Need MDS version with at least 2.5.56"; return 0; }
9677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9678 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9679 skip "ldiskfs only test"
9682 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9685 local has_warning=false
9690 # block size of mds1
9691 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9692 set_dir_limits $maxsize $maxsize
9693 local dirsize=$(stat -c%s "$DIR/$tdir")
9695 while [[ $dirsize -le $maxsize ]]; do
9696 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9698 if ! $has_warning; then
9699 check_mds_dmesg '"is approaching"' && has_warning=true
9702 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9703 # EFBIG for previous versions included in ldiskfs series
9704 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9706 echo "return code $rc received as expected"
9708 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9709 error_exit "create failed w/o dir size limit"
9711 check_mds_dmesg '"has reached"' ||
9712 error_exit "reached message should be output"
9714 [ $has_warning = "false" ] &&
9715 error_exit "warning message should be output"
9717 dirsize=$(stat -c%s "$DIR/$tdir")
9719 [[ $dirsize -ge $maxsize ]] && return 0
9720 error_exit "current dir size $dirsize, " \
9721 "previous limit $maxsize"
9722 elif [ $rc -ne 0 ]; then
9724 error_exit "return $rc received instead of expected " \
9725 "$EFBIG or $ENOSPC, files in dir $dirsize"
9727 nfiles=$((nfiles + 1))
9728 dirsize=$(stat -c%s "$DIR/$tdir")
9732 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9734 run_test 129 "test directory size limit ========================"
9743 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9744 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9747 trap cleanup_130 EXIT RETURN
9749 local fm_file=$DIR/$tfile
9750 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9751 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9752 error "dd failed for $fm_file"
9754 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9755 filefrag -ves $fm_file
9757 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9758 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9759 [ $RC != 0 ] && error "filefrag $fm_file failed"
9761 filefrag_op=$(filefrag -ve -k $fm_file |
9762 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9763 lun=$($GETSTRIPE -i $fm_file)
9765 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9768 for line in $filefrag_op
9770 frag_lun=`echo $line | cut -d: -f5`
9771 ext_len=`echo $line | cut -d: -f4`
9772 if (( $frag_lun != $lun )); then
9774 error "FIEMAP on 1-stripe file($fm_file) failed"
9777 (( tot_len += ext_len ))
9780 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9782 error "FIEMAP on 1-stripe file($fm_file) failed;"
9788 echo "FIEMAP on single striped file succeeded"
9790 run_test 130a "FIEMAP (1-stripe file)"
9793 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9795 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9796 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9799 trap cleanup_130 EXIT RETURN
9801 local fm_file=$DIR/$tfile
9802 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9803 error "setstripe on $fm_file"
9804 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9805 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9807 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9808 error "dd failed on $fm_file"
9810 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9811 filefrag_op=$(filefrag -ve -k $fm_file |
9812 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9814 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9815 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9820 for line in $filefrag_op
9822 frag_lun=$(echo $line | cut -d: -f5 |
9823 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9824 ext_len=$(echo $line | cut -d: -f4)
9825 if (( $frag_lun != $last_lun )); then
9826 if (( tot_len != 1024 )); then
9828 error "FIEMAP on $fm_file failed; returned " \
9829 "len $tot_len for OST $last_lun instead of 1024"
9836 (( tot_len += ext_len ))
9839 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9841 error "FIEMAP on $fm_file failed; returned wrong number of " \
9842 "luns or wrong len for OST $last_lun"
9848 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9850 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9855 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9856 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9859 trap cleanup_130 EXIT RETURN
9861 local fm_file=$DIR/$tfile
9862 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9863 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9864 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9866 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9867 error "dd failed on $fm_file"
9869 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9870 filefrag_op=$(filefrag -ve -k $fm_file |
9871 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9873 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9874 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9879 for line in $filefrag_op
9881 frag_lun=$(echo $line | cut -d: -f5 |
9882 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9883 ext_len=$(echo $line | cut -d: -f4)
9884 if (( $frag_lun != $last_lun )); then
9885 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9886 if (( logical != 512 )); then
9888 error "FIEMAP on $fm_file failed; returned " \
9889 "logical start for lun $logical instead of 512"
9892 if (( tot_len != 512 )); then
9894 error "FIEMAP on $fm_file failed; returned " \
9895 "len $tot_len for OST $last_lun instead of 1024"
9902 (( tot_len += ext_len ))
9905 if (( num_luns != 2 || tot_len != 512 )); then
9907 error "FIEMAP on $fm_file failed; returned wrong number of " \
9908 "luns or wrong len for OST $last_lun"
9914 echo "FIEMAP on 2-stripe file with hole succeeded"
9916 run_test 130c "FIEMAP (2-stripe file with hole)"
9919 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9921 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9922 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9925 trap cleanup_130 EXIT RETURN
9927 local fm_file=$DIR/$tfile
9928 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9929 error "setstripe on $fm_file"
9930 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9931 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9933 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9934 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9935 error "dd failed on $fm_file"
9937 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9938 filefrag_op=$(filefrag -ve -k $fm_file |
9939 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9941 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9942 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9947 for line in $filefrag_op
9949 frag_lun=$(echo $line | cut -d: -f5 |
9950 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9951 ext_len=$(echo $line | cut -d: -f4)
9952 if (( $frag_lun != $last_lun )); then
9953 if (( tot_len != 1024 )); then
9955 error "FIEMAP on $fm_file failed; returned " \
9956 "len $tot_len for OST $last_lun instead of 1024"
9963 (( tot_len += ext_len ))
9966 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9968 error "FIEMAP on $fm_file failed; returned wrong number of " \
9969 "luns or wrong len for OST $last_lun"
9975 echo "FIEMAP on N-stripe file succeeded"
9977 run_test 130d "FIEMAP (N-stripe file)"
9980 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9982 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9983 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9985 trap cleanup_130 EXIT RETURN
9987 local fm_file=$DIR/$tfile
9988 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9989 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9990 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9993 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9994 for ((i = 0; i < $NUM_BLKS; i++))
9996 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9999 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10000 filefrag_op=$(filefrag -ve -k $fm_file |
10001 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10003 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10004 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10009 for line in $filefrag_op
10011 frag_lun=$(echo $line | cut -d: -f5 |
10012 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10013 ext_len=$(echo $line | cut -d: -f4)
10014 if (( $frag_lun != $last_lun )); then
10015 if (( tot_len != $EXPECTED_LEN )); then
10017 error "FIEMAP on $fm_file failed; returned " \
10018 "len $tot_len for OST $last_lun instead " \
10022 (( num_luns += 1 ))
10026 (( tot_len += ext_len ))
10029 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10031 error "FIEMAP on $fm_file failed; returned wrong number " \
10032 "of luns or wrong len for OST $last_lun"
10038 echo "FIEMAP with continuation calls succeeded"
10040 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10042 # Test for writev/readv
10044 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10045 error "writev test failed"
10046 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10047 error "readv failed"
10050 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10053 local fsize=$((524288 + 1048576 + 1572864))
10054 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10055 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10056 error "append writev test failed"
10058 ((fsize += 1572864 + 1048576))
10059 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10060 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10061 error "append writev test failed"
10064 run_test 131b "test append writev"
10067 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10070 run_test 131c "test read/write on file w/o objects"
10073 rwv -f $DIR/$tfile -w -n 1 1572864
10074 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10075 if [ "$NOB" != 1572864 ]; then
10076 error "Short read filed: read $NOB bytes instead of 1572864"
10080 run_test 131d "test short read"
10083 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10084 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10085 error "read hitting hole failed"
10088 run_test 131e "test read hitting hole"
10097 mds*) res=$(do_facet $facet \
10098 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10100 ost*) res=$(do_facet $facet \
10101 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10103 *) error "Wrong facet '$facet'" ;;
10106 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10107 # if the argument $3 is zero, it means any stat increment is ok.
10108 if [[ $want -gt 0 ]]; then
10109 local count=$(echo $res | awk '{ print $2 }')
10110 [[ $count -ne $want ]] &&
10111 error "The $op counter on $facet is $count, not $want"
10116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10117 remote_ost_nodsh && skip "remote OST with nodsh" && return
10118 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10120 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10121 { skip "MDS doesn't support rename stats"; return; }
10122 local testdir=$DIR/${tdir}/stats_testdir
10123 mkdir -p $DIR/${tdir}
10126 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10127 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10129 # verify mdt stats first.
10130 mkdir ${testdir} || error "mkdir failed"
10131 check_stats $SINGLEMDS "mkdir" 1
10132 touch ${testdir}/${tfile} || error "touch failed"
10133 check_stats $SINGLEMDS "open" 1
10134 check_stats $SINGLEMDS "close" 1
10135 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10136 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10137 check_stats $SINGLEMDS "mknod" 2
10139 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10140 check_stats $SINGLEMDS "unlink" 1
10141 rm -f ${testdir}/${tfile} || error "file remove failed"
10142 check_stats $SINGLEMDS "unlink" 2
10144 # remove working dir and check mdt stats again.
10145 rmdir ${testdir} || error "rmdir failed"
10146 check_stats $SINGLEMDS "rmdir" 1
10148 local testdir1=$DIR/${tdir}/stats_testdir1
10149 mkdir -p ${testdir}
10150 mkdir -p ${testdir1}
10151 touch ${testdir1}/test1
10152 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10153 check_stats $SINGLEMDS "crossdir_rename" 1
10155 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10156 check_stats $SINGLEMDS "samedir_rename" 1
10158 rm -rf $DIR/${tdir}
10160 run_test 133a "Verifying MDT stats ========================================"
10163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10164 remote_ost_nodsh && skip "remote OST with nodsh" && return
10165 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10166 local testdir=$DIR/${tdir}/stats_testdir
10167 mkdir -p ${testdir} || error "mkdir failed"
10168 touch ${testdir}/${tfile} || error "touch failed"
10169 cancel_lru_locks mdc
10172 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10173 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10175 # extra mdt stats verification.
10176 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10177 check_stats $SINGLEMDS "setattr" 1
10178 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10179 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10181 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10182 check_stats $SINGLEMDS "getattr" 1
10184 $LFS df || error "lfs failed"
10185 check_stats $SINGLEMDS "statfs" 1
10187 rm -rf $DIR/${tdir}
10189 run_test 133b "Verifying extra MDT stats =================================="
10192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10193 remote_ost_nodsh && skip "remote OST with nodsh" && return
10194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10195 local testdir=$DIR/$tdir/stats_testdir
10196 test_mkdir -p $testdir
10198 # verify obdfilter stats.
10199 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10201 cancel_lru_locks osc
10202 wait_delete_completed
10205 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10206 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10208 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10211 cancel_lru_locks osc
10212 check_stats ost1 "write" 1
10214 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10215 check_stats ost1 "read" 1
10217 > $testdir/$tfile || error "truncate failed"
10218 check_stats ost1 "punch" 1
10220 rm -f $testdir/$tfile || error "file remove failed"
10221 wait_delete_completed
10222 check_stats ost1 "destroy" 1
10226 run_test 133c "Verifying OST stats ========================================"
10233 while [ $value -ge 2 ]; do
10238 if [ $orig -gt $order ]; then
10246 local size=('K' 'M' 'G' 'T');
10248 local size_string=$value
10250 while [ $value -ge 1024 ]; do
10251 if [ $i -gt 3 ]; then
10252 #T is the biggest unit we get here, if that is bigger,
10254 size_string=${value}T
10257 value=$((value >> 10))
10258 if [ $value -lt 1024 ]; then
10259 size_string=${value}${size[$i]}
10268 get_rename_size() {
10270 local context=${2:-.}
10271 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
10272 grep -A1 $context |
10273 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10279 remote_ost_nodsh && skip "remote OST with nodsh" && return
10280 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10281 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10282 { skip "MDS doesn't support rename stats"; return; }
10284 local testdir1=$DIR/${tdir}/stats_testdir1
10285 local testdir2=$DIR/${tdir}/stats_testdir2
10287 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10289 mkdir -p ${testdir1} || error "mkdir failed"
10290 mkdir -p ${testdir2} || error "mkdir failed"
10292 createmany -o $testdir1/test 512 || error "createmany failed"
10294 # check samedir rename size
10295 mv ${testdir1}/test0 ${testdir1}/test_0
10297 local testdir1_size=$(ls -l $DIR/${tdir} |
10298 awk '/stats_testdir1/ {print $5}')
10299 local testdir2_size=$(ls -l $DIR/${tdir} |
10300 awk '/stats_testdir2/ {print $5}')
10302 testdir1_size=$(order_2 $testdir1_size)
10303 testdir2_size=$(order_2 $testdir2_size)
10305 testdir1_size=$(size_in_KMGT $testdir1_size)
10306 testdir2_size=$(size_in_KMGT $testdir2_size)
10308 echo "source rename dir size: ${testdir1_size}"
10309 echo "target rename dir size: ${testdir2_size}"
10311 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
10312 eval $cmd || error "$cmd failed"
10313 local samedir=$($cmd | grep 'same_dir')
10314 local same_sample=$(get_rename_size $testdir1_size)
10315 [ -z "$samedir" ] && error "samedir_rename_size count error"
10316 [[ $same_sample -eq 1 ]] ||
10317 error "samedir_rename_size error $same_sample"
10318 echo "Check same dir rename stats success"
10320 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10322 # check crossdir rename size
10323 mv ${testdir1}/test_0 ${testdir2}/test_0
10325 testdir1_size=$(ls -l $DIR/${tdir} |
10326 awk '/stats_testdir1/ {print $5}')
10327 testdir2_size=$(ls -l $DIR/${tdir} |
10328 awk '/stats_testdir2/ {print $5}')
10330 testdir1_size=$(order_2 $testdir1_size)
10331 testdir2_size=$(order_2 $testdir2_size)
10333 testdir1_size=$(size_in_KMGT $testdir1_size)
10334 testdir2_size=$(size_in_KMGT $testdir2_size)
10336 echo "source rename dir size: ${testdir1_size}"
10337 echo "target rename dir size: ${testdir2_size}"
10339 eval $cmd || error "$cmd failed"
10340 local crossdir=$($cmd | grep 'crossdir')
10341 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10342 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10343 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10344 [[ $src_sample -eq 1 ]] ||
10345 error "crossdir_rename_size error $src_sample"
10346 [[ $tgt_sample -eq 1 ]] ||
10347 error "crossdir_rename_size error $tgt_sample"
10348 echo "Check cross dir rename stats success"
10349 rm -rf $DIR/${tdir}
10351 run_test 133d "Verifying rename_stats ========================================"
10354 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10355 remote_ost_nodsh && skip "remote OST with nodsh" && return
10356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10357 local testdir=$DIR/${tdir}/stats_testdir
10358 local ctr f0 f1 bs=32768 count=42 sum
10360 mkdir -p ${testdir} || error "mkdir failed"
10362 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10364 for ctr in {write,read}_bytes; do
10366 cancel_lru_locks osc
10368 do_facet ost1 $LCTL set_param -n \
10369 "obdfilter.*.exports.clear=clear"
10371 if [ $ctr = write_bytes ]; then
10373 f1=${testdir}/${tfile}
10375 f0=${testdir}/${tfile}
10379 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10382 cancel_lru_locks osc
10384 sum=$(do_facet ost1 $LCTL get_param \
10385 "obdfilter.*.exports.*.stats" |
10386 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10387 $1 == ctr { sum += $7 }
10388 END { printf("%0.0f", sum) }')
10390 if ((sum != bs * count)); then
10391 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10395 rm -rf $DIR/${tdir}
10397 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10399 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10402 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10403 remote_ost_nodsh && skip "remote OST with nodsh" && return
10404 # First without trusting modes.
10405 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10406 echo "proc_dirs='$proc_dirs'"
10407 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10408 find $proc_dirs -exec cat '{}' \; &> /dev/null
10410 # Second verifying readability.
10411 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10413 # eventually, this can also be replaced with "lctl get_param -R",
10414 # but not until that option is always available on the server
10416 for facet in mds1 ost1; do
10417 local facet_proc_dirs=$(do_facet $facet \
10418 \\\ls -d $proc_regexp 2>/dev/null)
10419 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10420 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10421 do_facet $facet find $facet_proc_dirs \
10422 ! -name req_history \
10423 -exec cat '{}' \\\; &> /dev/null
10425 do_facet $facet find $facet_proc_dirs \
10426 ! -name req_history \
10428 -exec cat '{}' \\\; &> /dev/null ||
10429 error "proc file read failed"
10432 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10435 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10436 remote_ost_nodsh && skip "remote OST with nodsh" && return
10437 # Second verifying writability.
10438 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10439 echo "proc_dirs='$proc_dirs'"
10440 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10442 -ignore_readdir_race \
10444 -not -name force_lbug \
10445 -not -name changelog_mask \
10446 -exec badarea_io '{}' \; ||
10447 error "find $proc_dirs failed"
10450 for facet in mds1 ost1; do
10451 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10452 skip "Too old lustre on $facet" && continue
10453 local facet_proc_dirs=$(do_facet $facet \
10454 \\\ls -d $proc_regexp 2> /dev/null)
10455 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10456 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10457 do_facet $facet find $facet_proc_dirs \
10458 -ignore_readdir_race \
10460 -not -name force_lbug \
10461 -not -name changelog_mask \
10462 -exec badarea_io '{}' \\\; ||
10463 error "$facet find $facet_proc_dirs failed"
10466 # remount the FS in case writes/reads /proc break the FS
10467 cleanup || error "failed to unmount"
10468 setup || error "failed to setup"
10471 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10474 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10475 remote_ost_nodsh && skip "remote OST with nodsh" && return
10476 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10477 skip "Need MDS version at least 2.9.54" && return
10480 for facet in client mds1 ost1; do
10481 local facet_proc_dirs=$(do_facet $facet \
10482 \\\ls -d $proc_regexp 2> /dev/null)
10483 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10484 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10485 # Get the list of files that are missing the terminating newline
10486 local missing=($(do_facet $facet \
10487 find ${facet_proc_dirs} -type f \| \
10488 while read F\; do \
10489 awk -v FS='\v' -v RS='\v\v' \
10490 "'END { if(NR>0 && \
10491 \\\$NF !~ /.*\\\n\$/) \
10492 print FILENAME}'" \
10495 [ ${#missing[*]} -eq 0 ] ||
10496 error "files do not end with newline: ${missing[*]}"
10499 run_test 133h "Proc files should end with newlines"
10502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10503 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10504 skip "Need MDS version at least 2.7.54" && return
10506 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10507 cancel_lru_locks mdc
10509 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10510 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10511 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10514 createmany -o $DIR/$tdir/f $nr ||
10515 error "failed to create $nr files in $DIR/$tdir"
10516 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10518 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10519 do_facet mds1 $LCTL set_param fail_loc=0x327
10520 do_facet mds1 $LCTL set_param fail_val=500
10523 echo "sleep 10 seconds ..."
10525 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10527 do_facet mds1 $LCTL set_param fail_loc=0
10528 do_facet mds1 $LCTL set_param fail_val=0
10529 [ $lck_cnt -lt $unused ] ||
10530 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10533 unlinkmany $DIR/$tdir/f $nr
10535 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10538 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10539 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10540 skip "Need MDS version at least 2.7.54" && return
10542 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10543 cancel_lru_locks mdc
10545 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10546 ldlm.lock_reclaim_threshold_mb)
10547 # disable reclaim temporarily
10548 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10550 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10551 do_facet mds1 $LCTL set_param fail_loc=0x328
10552 do_facet mds1 $LCTL set_param fail_val=500
10554 $LCTL set_param debug=+trace
10557 createmany -o $DIR/$tdir/f $nr &
10558 local create_pid=$!
10560 echo "Sleep $TIMEOUT seconds ..."
10562 if ! ps -p $create_pid > /dev/null 2>&1; then
10563 do_facet mds1 $LCTL set_param fail_loc=0
10564 do_facet mds1 $LCTL set_param fail_val=0
10565 do_facet mds1 $LCTL set_param \
10566 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10567 error "createmany finished incorrectly!"
10569 do_facet mds1 $LCTL set_param fail_loc=0
10570 do_facet mds1 $LCTL set_param fail_val=0
10571 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10572 wait $create_pid || return 1
10574 unlinkmany $DIR/$tdir/f $nr
10576 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10578 test_140() { #bug-17379
10579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10580 test_mkdir $DIR/$tdir
10581 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10582 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10584 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10585 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10587 while i=$((i + 1)); do
10589 cd $i || error "Changing to $i"
10590 ln -s ../stat stat || error "Creating stat symlink"
10591 # Read the symlink until ELOOP present,
10592 # not LBUGing the system is considered success,
10593 # we didn't overrun the stack.
10594 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10595 if [ $ret -ne 0 ]; then
10596 if [ $ret -eq 40 ]; then
10599 error "Open stat symlink"
10605 echo "The symlink depth = $i"
10606 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10607 error "Invalid symlink depth"
10609 # Test recursive symlink
10610 ln -s symlink_self symlink_self
10611 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10612 echo "open symlink_self returns $ret"
10613 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10615 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10619 local TF="$TMP/$tfile"
10621 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10623 cancel_lru_locks $OSC
10624 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10625 remount_client $MOUNT
10627 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10630 $TRUNCATE $DIR/$tfile 6000
10631 cancel_lru_locks $OSC
10632 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10635 echo "12345" >>$DIR/$tfile
10636 cancel_lru_locks $OSC
10637 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10640 echo "12345" >>$DIR/$tfile
10641 cancel_lru_locks $OSC
10642 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10647 run_test 150 "truncate/append tests"
10649 #LU-2902 roc_hit was not able to read all values from lproc
10650 function roc_hit_init() {
10651 local list=$(comma_list $(osts_nodes))
10652 local dir=$DIR/$tdir-check
10653 local file=$dir/$tfile
10659 #use setstripe to do a write to every ost
10660 for i in $(seq 0 $((OSTCOUNT-1))); do
10661 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10662 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10663 idx=$(printf %04x $i)
10664 BEFORE=$(get_osd_param $list *OST*$idx stats |
10665 awk '$1 == "cache_access" {sum += $7}
10666 END { printf("%0.0f", sum) }')
10668 cancel_lru_locks osc
10669 cat $file >/dev/null
10671 AFTER=$(get_osd_param $list *OST*$idx stats |
10672 awk '$1 == "cache_access" {sum += $7}
10673 END { printf("%0.0f", sum) }')
10675 echo BEFORE:$BEFORE AFTER:$AFTER
10676 if ! let "AFTER - BEFORE == 4"; then
10678 error "roc_hit is not safe to use"
10686 function roc_hit() {
10687 local list=$(comma_list $(osts_nodes))
10688 echo $(get_osd_param $list '' stats |
10689 awk '$1 == "cache_hit" {sum += $7}
10690 END { printf("%0.0f", sum) }')
10693 function set_cache() {
10696 if [ "$2" == "off" ]; then
10699 local list=$(comma_list $(osts_nodes))
10700 set_osd_param $list '' $1_cache_enable $on
10702 cancel_lru_locks osc
10706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10707 remote_ost_nodsh && skip "remote OST with nodsh" && return
10710 local list=$(comma_list $(osts_nodes))
10712 # check whether obdfilter is cache capable at all
10713 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10714 echo "not cache-capable obdfilter"
10718 # check cache is enabled on all obdfilters
10719 if get_osd_param $list '' read_cache_enable | grep 0; then
10720 echo "oss cache is disabled"
10724 set_osd_param $list '' writethrough_cache_enable 1
10726 # check write cache is enabled on all obdfilters
10727 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10728 echo "oss write cache is NOT enabled"
10734 #define OBD_FAIL_OBD_NO_LRU 0x609
10735 do_nodes $list $LCTL set_param fail_loc=0x609
10737 # pages should be in the case right after write
10738 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10741 local BEFORE=$(roc_hit)
10742 cancel_lru_locks osc
10743 cat $DIR/$tfile >/dev/null
10744 local AFTER=$(roc_hit)
10746 do_nodes $list $LCTL set_param fail_loc=0
10748 if ! let "AFTER - BEFORE == CPAGES"; then
10749 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10752 # the following read invalidates the cache
10753 cancel_lru_locks osc
10754 set_osd_param $list '' read_cache_enable 0
10755 cat $DIR/$tfile >/dev/null
10757 # now data shouldn't be found in the cache
10759 cancel_lru_locks osc
10760 cat $DIR/$tfile >/dev/null
10762 if let "AFTER - BEFORE != 0"; then
10763 error "IN CACHE: before: $BEFORE, after: $AFTER"
10766 set_osd_param $list '' read_cache_enable 1
10769 run_test 151 "test cache on oss and controls ==============================="
10772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10773 local TF="$TMP/$tfile"
10775 # simulate ENOMEM during write
10776 #define OBD_FAIL_OST_NOMEM 0x226
10777 lctl set_param fail_loc=0x80000226
10778 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10780 sync || error "sync failed"
10781 lctl set_param fail_loc=0
10783 # discard client's cache
10784 cancel_lru_locks osc
10786 # simulate ENOMEM during read
10787 lctl set_param fail_loc=0x80000226
10788 cmp $TF $DIR/$tfile || error "cmp failed"
10789 lctl set_param fail_loc=0
10793 run_test 152 "test read/write with enomem ============================"
10796 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10798 run_test 153 "test if fdatasync does not crash ======================="
10800 dot_lustre_fid_permission_check() {
10802 local ffid=$MOUNT/.lustre/fid/$fid
10805 echo "stat fid $fid"
10806 stat $ffid > /dev/null || error "stat $ffid failed."
10807 echo "touch fid $fid"
10808 touch $ffid || error "touch $ffid failed."
10809 echo "write to fid $fid"
10810 cat /etc/hosts > $ffid || error "write $ffid failed."
10811 echo "read fid $fid"
10812 diff /etc/hosts $ffid || error "read $ffid failed."
10813 echo "append write to fid $fid"
10814 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10815 echo "rename fid $fid"
10816 mv $ffid $test_dir/$tfile.1 &&
10817 error "rename $ffid to $tfile.1 should fail."
10818 touch $test_dir/$tfile.1
10819 mv $test_dir/$tfile.1 $ffid &&
10820 error "rename $tfile.1 to $ffid should fail."
10821 rm -f $test_dir/$tfile.1
10822 echo "truncate fid $fid"
10823 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10824 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10825 echo "link fid $fid"
10826 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10828 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10829 echo "setfacl fid $fid"
10830 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10831 echo "getfacl fid $fid"
10832 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10834 echo "unlink fid $fid"
10835 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10836 echo "mknod fid $fid"
10837 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10839 fid=[0xf00000400:0x1:0x0]
10840 ffid=$MOUNT/.lustre/fid/$fid
10842 echo "stat non-exist fid $fid"
10843 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10844 echo "write to non-exist fid $fid"
10845 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10846 echo "link new fid $fid"
10847 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10849 mkdir -p $test_dir/$tdir
10850 touch $test_dir/$tdir/$tfile
10851 fid=$($LFS path2fid $test_dir/$tdir)
10854 error "error: could not get fid for $test_dir/$dir/$tfile."
10856 ffid=$MOUNT/.lustre/fid/$fid
10859 ls $ffid > /dev/null || error "ls $ffid failed."
10860 echo "touch $fid/$tfile.1"
10861 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10863 echo "touch $MOUNT/.lustre/fid/$tfile"
10864 touch $MOUNT/.lustre/fid/$tfile && \
10865 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10867 echo "setxattr to $MOUNT/.lustre/fid"
10868 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10870 echo "listxattr for $MOUNT/.lustre/fid"
10871 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10873 echo "delxattr from $MOUNT/.lustre/fid"
10874 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10876 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10877 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10878 error "touch invalid fid should fail."
10880 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10881 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10882 error "touch non-normal fid should fail."
10884 echo "rename $tdir to $MOUNT/.lustre/fid"
10885 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10886 error "rename to $MOUNT/.lustre/fid should fail."
10888 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10890 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10891 local new_obf_mode=777
10893 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10894 chmod $new_obf_mode $DIR/.lustre/fid ||
10895 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10897 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10898 [ $obf_mode -eq $new_obf_mode ] ||
10899 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10901 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10902 chmod $old_obf_mode $DIR/.lustre/fid ||
10903 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10906 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10907 fid=$($LFS path2fid $test_dir/$tfile-2)
10909 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10911 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10912 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10913 error "create lov data thru .lustre failed"
10915 echo "cp /etc/passwd $test_dir/$tfile-2"
10916 cp /etc/passwd $test_dir/$tfile-2 ||
10917 error "copy to $test_dir/$tfile-2 failed."
10918 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10919 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10920 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10922 rm -rf $test_dir/tfile.lnk
10923 rm -rf $test_dir/$tfile-2
10927 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10928 skip "Need MDS version at least 2.4.1" && return
10930 local tf=$DIR/$tfile
10933 local fid=$($LFS path2fid $tf)
10934 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10936 # check that we get the same pathname back
10937 local found=$($LFS fid2path $MOUNT "$fid")
10938 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10939 [ "$found" == "$tf" ] ||
10940 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10942 run_test 154A "lfs path2fid and fid2path basic checks"
10945 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10946 skip "Need MDS version at least 2.4.1" && return
10948 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10949 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10950 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10951 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10953 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10954 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10956 # check that we get the same pathname
10957 echo "PFID: $PFID, name: $name"
10958 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10959 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10960 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10961 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10963 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10965 run_test 154B "verify the ll_decode_linkea tool"
10968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10969 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10970 { skip "Need MDS version at least 2.2.51"; return 0; }
10971 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10972 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10974 cp /etc/hosts $DIR/$tfile
10976 fid=$($LFS path2fid $DIR/$tfile)
10978 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10980 dot_lustre_fid_permission_check "$fid" $DIR ||
10981 error "dot lustre permission check $fid failed"
10983 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
10985 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10987 touch $MOUNT/.lustre/file &&
10988 error "creation is not allowed under .lustre"
10990 mkdir $MOUNT/.lustre/dir &&
10991 error "mkdir is not allowed under .lustre"
10995 run_test 154a "Open-by-FID"
10998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10999 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11000 { skip "Need MDS version at least 2.2.51"; return 0; }
11001 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11005 local remote_dir=$DIR/$tdir/remote_dir
11009 mkdir -p $DIR/$tdir
11010 $LFS mkdir -i $MDTIDX $remote_dir ||
11011 error "create remote directory failed"
11013 cp /etc/hosts $remote_dir/$tfile
11015 fid=$($LFS path2fid $remote_dir/$tfile)
11017 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11019 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11020 error "dot lustre permission check $fid failed"
11023 run_test 154b "Open-by-FID for remote directory"
11026 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11027 skip "Need MDS version at least 2.4.1" && return
11029 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11030 local FID1=$($LFS path2fid $DIR/$tfile.1)
11031 local FID2=$($LFS path2fid $DIR/$tfile.2)
11032 local FID3=$($LFS path2fid $DIR/$tfile.3)
11035 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11036 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11037 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11039 [ "$FID" = "${!want}" ] ||
11040 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11044 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11046 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11047 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11051 run_test 154c "lfs path2fid and fid2path multiple arguments"
11054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11055 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
11056 skip "Need MDS version at least 2.5.53" && return
11058 if remote_mds; then
11059 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11063 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11070 local fid=$($LFS path2fid $DIR/$tfile)
11073 cmd="exec $fd<$DIR/$tfile"
11075 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11076 echo "$fid_list" | grep "$fid"
11079 cmd="exec $fd>/dev/null"
11081 if [ $rc -ne 0 ]; then
11082 error "FID $fid not found in open files list $fid_list"
11085 run_test 154d "Verify open file fid"
11089 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
11090 skip "Need MDS version at least 2.6.50" && return
11092 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11093 error ".lustre returned by readdir"
11096 run_test 154e ".lustre is not returned by readdir"
11099 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11100 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11101 test_mkdir -p -c1 $DIR/$tdir/d
11102 # test dirs inherit from its stripe
11103 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11104 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11105 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11106 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11109 # get fid of parents
11110 local FID0=$($LFS path2fid $DIR/$tdir/d)
11111 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11112 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11113 local FID3=$($LFS path2fid $DIR)
11115 # check that path2fid --parents returns expected <parent_fid>/name
11116 # 1) test for a directory (single parent)
11117 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11118 [ "$parent" == "$FID0/foo1" ] ||
11119 error "expected parent: $FID0/foo1, got: $parent"
11121 # 2) test for a file with nlink > 1 (multiple parents)
11122 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11123 echo "$parent" | grep -F "$FID1/$tfile" ||
11124 error "$FID1/$tfile not returned in parent list"
11125 echo "$parent" | grep -F "$FID2/link" ||
11126 error "$FID2/link not returned in parent list"
11128 # 3) get parent by fid
11129 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11130 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11131 echo "$parent" | grep -F "$FID1/$tfile" ||
11132 error "$FID1/$tfile not returned in parent list (by fid)"
11133 echo "$parent" | grep -F "$FID2/link" ||
11134 error "$FID2/link not returned in parent list (by fid)"
11136 # 4) test for entry in root directory
11137 parent=$($LFS path2fid --parents $DIR/f)
11138 echo "$parent" | grep -F "$FID3/f" ||
11139 error "$FID3/f not returned in parent list"
11141 # 5) test it on root directory
11142 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11143 error "$MOUNT should not have parents"
11145 # enable xattr caching and check that linkea is correctly updated
11146 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11147 save_lustre_params client "llite.*.xattr_cache" > $save
11148 lctl set_param llite.*.xattr_cache 1
11150 # 6.1) linkea update on rename
11151 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11153 # get parents by fid
11154 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11155 # foo1 should no longer be returned in parent list
11156 echo "$parent" | grep -F "$FID1" &&
11157 error "$FID1 should no longer be in parent list"
11158 # the new path should appear
11159 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11160 error "$FID2/$tfile.moved is not in parent list"
11162 # 6.2) linkea update on unlink
11163 rm -f $DIR/$tdir/d/foo2/link
11164 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11165 # foo2/link should no longer be returned in parent list
11166 echo "$parent" | grep -F "$FID2/link" &&
11167 error "$FID2/link should no longer be in parent list"
11171 restore_lustre_params < $save
11174 run_test 154f "get parent fids by reading link ea"
11178 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11179 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11180 { skip "Need MDS version at least 2.6.92"; return 0; }
11181 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11183 mkdir -p $DIR/$tdir
11184 llapi_fid_test -d $DIR/$tdir
11186 run_test 154g "various llapi FID tests"
11188 test_155_small_load() {
11189 local temp=$TMP/$tfile
11190 local file=$DIR/$tfile
11192 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11193 error "dd of=$temp bs=6096 count=1 failed"
11195 cancel_lru_locks $OSC
11196 cmp $temp $file || error "$temp $file differ"
11198 $TRUNCATE $temp 6000
11199 $TRUNCATE $file 6000
11200 cmp $temp $file || error "$temp $file differ (truncate1)"
11202 echo "12345" >>$temp
11203 echo "12345" >>$file
11204 cmp $temp $file || error "$temp $file differ (append1)"
11206 echo "12345" >>$temp
11207 echo "12345" >>$file
11208 cmp $temp $file || error "$temp $file differ (append2)"
11214 test_155_big_load() {
11215 remote_ost_nodsh && skip "remote OST with nodsh" && return
11216 local temp=$TMP/$tfile
11217 local file=$DIR/$tfile
11220 local cache_size=$(do_facet ost$((MAXI+1)) \
11221 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11222 local large_file_size=$((cache_size * 2))
11224 echo "OSS cache size: $cache_size KB"
11225 echo "Large file size: $large_file_size KB"
11227 [ $MAXV -le $large_file_size ] && \
11228 skip_env "max available OST size needs > $large_file_size KB" && \
11231 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11233 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
11234 error "dd of=$temp bs=$large_file_size count=1k failed"
11237 cancel_lru_locks osc
11238 cmp $temp $file || error "$temp $file differ"
11244 save_writethrough() {
11245 local facets=$(get_facets OST)
11247 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11248 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11253 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11254 save_writethrough $p
11257 set_cache writethrough on
11258 test_155_small_load
11259 restore_lustre_params < $p
11262 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11266 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11267 save_writethrough $p
11270 set_cache writethrough off
11271 test_155_small_load
11272 restore_lustre_params < $p
11275 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11279 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11280 save_writethrough $p
11283 set_cache writethrough on
11284 test_155_small_load
11285 restore_lustre_params < $p
11288 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11292 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11293 save_writethrough $p
11296 set_cache writethrough off
11297 test_155_small_load
11298 restore_lustre_params < $p
11301 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11305 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11306 save_writethrough $p
11309 set_cache writethrough on
11311 restore_lustre_params < $p
11314 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11318 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11319 save_writethrough $p
11322 set_cache writethrough off
11324 restore_lustre_params < $p
11327 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11331 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11332 save_writethrough $p
11335 set_cache writethrough on
11337 restore_lustre_params < $p
11340 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11344 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11345 save_writethrough $p
11348 set_cache writethrough off
11350 restore_lustre_params < $p
11353 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11356 remote_ost_nodsh && skip "remote OST with nodsh" && return
11357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11361 local file="$DIR/$tfile"
11362 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11364 [ "$(facet_fstype ost1)" = "zfs" -a \
11365 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11366 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11369 save_writethrough $p
11372 log "Turn on read and write cache"
11374 set_cache writethrough on
11376 log "Write data and read it back."
11377 log "Read should be satisfied from the cache."
11378 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11380 cancel_lru_locks osc
11381 cat $file >/dev/null
11383 if ! let "AFTER - BEFORE == CPAGES"; then
11384 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11386 log "cache hits:: before: $BEFORE, after: $AFTER"
11389 log "Read again; it should be satisfied from the cache."
11391 cancel_lru_locks osc
11392 cat $file >/dev/null
11394 if ! let "AFTER - BEFORE == CPAGES"; then
11395 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11397 log "cache hits:: before: $BEFORE, after: $AFTER"
11400 log "Turn off the read cache and turn on the write cache"
11402 set_cache writethrough on
11404 log "Read again; it should be satisfied from the cache."
11406 cancel_lru_locks osc
11407 cat $file >/dev/null
11409 if ! let "AFTER - BEFORE == CPAGES"; then
11410 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11412 log "cache hits:: before: $BEFORE, after: $AFTER"
11415 log "Read again; it should not be satisfied from the cache."
11417 cancel_lru_locks osc
11418 cat $file >/dev/null
11420 if ! let "AFTER - BEFORE == 0"; then
11421 error "IN CACHE: before: $BEFORE, after: $AFTER"
11423 log "cache hits:: before: $BEFORE, after: $AFTER"
11426 log "Write data and read it back."
11427 log "Read should be satisfied from the cache."
11428 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11430 cancel_lru_locks osc
11431 cat $file >/dev/null
11433 if ! let "AFTER - BEFORE == CPAGES"; then
11434 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11436 log "cache hits:: before: $BEFORE, after: $AFTER"
11439 log "Read again; it should not be satisfied from the cache."
11441 cancel_lru_locks osc
11442 cat $file >/dev/null
11444 if ! let "AFTER - BEFORE == 0"; then
11445 error "IN CACHE: before: $BEFORE, after: $AFTER"
11447 log "cache hits:: before: $BEFORE, after: $AFTER"
11450 log "Turn off read and write cache"
11452 set_cache writethrough off
11454 log "Write data and read it back"
11455 log "It should not be satisfied from the cache."
11457 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11458 cancel_lru_locks osc
11460 cat $file >/dev/null
11462 if ! let "AFTER - BEFORE == 0"; then
11463 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11465 log "cache hits:: before: $BEFORE, after: $AFTER"
11468 log "Turn on the read cache and turn off the write cache"
11470 set_cache writethrough off
11472 log "Write data and read it back"
11473 log "It should not be satisfied from the cache."
11475 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11477 cancel_lru_locks osc
11478 cat $file >/dev/null
11480 if ! let "AFTER - BEFORE == 0"; then
11481 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11483 log "cache hits:: before: $BEFORE, after: $AFTER"
11486 log "Read again; it should be satisfied from the cache."
11488 cancel_lru_locks osc
11489 cat $file >/dev/null
11491 if ! let "AFTER - BEFORE == CPAGES"; then
11492 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11494 log "cache hits:: before: $BEFORE, after: $AFTER"
11497 restore_lustre_params < $p
11500 run_test 156 "Verification of tunables"
11503 cleanup_changelog () {
11505 echo "Deregistering changelog client $CL_USER"
11506 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11510 if [[ $MDSCOUNT -gt 1 ]]; then
11511 error_ignore bz17935 $*
11519 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11521 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11523 if [ $MASK -eq 1 ]; then
11524 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11526 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11530 changelog_extract_field() {
11534 local identifier=$4
11536 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11537 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11543 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11544 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11545 { skip "Need MDS version at least 2.2.0"; return; }
11547 local CL_USERS="mdd.$MDT0.changelog_users"
11548 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11549 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11550 changelog_register -n)
11551 echo "Registered as changelog user $CL_USER"
11552 trap cleanup_changelog EXIT
11553 $GET_CL_USERS | grep -q $CL_USER ||
11554 error "User $CL_USER not found in changelog_users"
11557 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11558 touch $DIR/$tdir/pics/2008/zachy/timestamp
11559 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11560 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11561 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11562 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11563 rm $DIR/$tdir/pics/desktop.jpg
11565 $LFS changelog $MDT0 | tail -5
11567 echo "verifying changelog mask"
11568 changelog_chmask "MKDIR"
11569 changelog_chmask "CLOSE"
11571 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11572 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11574 changelog_chmask "MKDIR"
11575 changelog_chmask "CLOSE"
11577 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11578 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11580 $LFS changelog $MDT0
11581 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11582 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11583 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11584 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11587 echo "verifying target fid"
11588 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11589 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11590 [ "$fidc" == "$fidf" ] ||
11591 err17935 "fid in changelog $fidc != file fid $fidf"
11592 echo "verifying parent fid"
11593 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11594 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11595 [ "$fidc" == "$fidf" ] ||
11596 err17935 "pfid in changelog $fidc != dir fid $fidf"
11598 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11599 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11600 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11601 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11602 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11603 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11605 MIN_REC=$($GET_CL_USERS |
11606 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11607 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11608 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11609 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11610 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11612 # LU-3446 changelog index reset on MDT restart
11613 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11614 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11615 $LFS changelog_clear $MDT0 $CL_USER 0
11616 stop $SINGLEMDS || error "Fail to stop MDT."
11617 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11618 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11619 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11620 [ $CUR_REC1 == $CUR_REC2 ] ||
11621 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11623 echo "verifying user deregister"
11625 $GET_CL_USERS | grep -q $CL_USER &&
11626 error "User $CL_USER still in changelog_users"
11628 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11629 if [ $CL_USER -eq 0 ]; then
11630 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11631 touch $DIR/$tdir/chloe
11632 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11633 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11634 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11636 echo "$CL_USER other changelog users; can't verify off"
11639 run_test 160a "changelog sanity"
11641 test_160b() { # LU-3587
11642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11643 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11644 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11645 { skip "Need MDS version at least 2.2.0"; return; }
11647 local CL_USERS="mdd.$MDT0.changelog_users"
11648 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11649 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11650 changelog_register -n)
11651 echo "Registered as changelog user $CL_USER"
11652 trap cleanup_changelog EXIT
11653 $GET_CL_USERS | grep -q $CL_USER ||
11654 error "User $CL_USER not found in changelog_users"
11656 local LONGNAME1=$(str_repeat a 255)
11657 local LONGNAME2=$(str_repeat b 255)
11660 echo "creating very long named file"
11661 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11662 echo "moving very long named file"
11663 mv $LONGNAME1 $LONGNAME2
11665 $LFS changelog $MDT0 | grep RENME
11669 run_test 160b "Verify that very long rename doesn't crash in changelog"
11672 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11675 local server_version=$(lustre_version_code $SINGLEMDS)
11677 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11678 [[ $server_version -gt $(version_code 2.5.1) &&
11679 $server_version -lt $(version_code 2.5.50) ]] ||
11680 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11683 # Registration step
11684 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11685 changelog_register -n)
11686 trap cleanup_changelog EXIT
11689 mkdir -p $DIR/$tdir
11690 $MCREATE $DIR/$tdir/foo_160c
11691 changelog_chmask "TRUNC"
11692 $TRUNCATE $DIR/$tdir/foo_160c 200
11693 changelog_chmask "TRUNC"
11694 $TRUNCATE $DIR/$tdir/foo_160c 199
11695 $LFS changelog $MDT0
11696 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11697 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11698 $LFS changelog_clear $MDT0 $CL_USER 0
11700 # Deregistration step
11703 run_test 160c "verify that changelog log catch the truncate event"
11706 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11709 local server_version=$(lustre_version_code mds1)
11710 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11712 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11713 { skip "Need MDS version at least 2.7.60+"; return; }
11714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11716 # Registration step
11717 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11718 changelog_register -n)
11720 trap cleanup_changelog EXIT
11721 mkdir -p $DIR/$tdir/migrate_dir
11722 $LFS changelog_clear $MDT0 $CL_USER 0
11724 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11725 $LFS changelog $MDT0
11726 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11727 $LFS changelog_clear $MDT0 $CL_USER 0
11728 [ $MIGRATES -eq 1 ] ||
11729 error "MIGRATE changelog mask count $MIGRATES != 1"
11731 # Deregistration step
11734 run_test 160d "verify that changelog log catch the migrate event"
11737 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11740 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11741 changelog_register -n)
11742 echo "Registered as changelog user $CL_USER"
11743 trap cleanup_changelog EXIT
11745 # Delete a future user (expect fail)
11746 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11749 if [ $rc -eq 0 ]; then
11750 error "Deleted non-existant user cl77"
11751 elif [ $rc -ne 2 ]; then
11752 error "changelog_deregister failed with $rc, " \
11753 "expected 2 (ENOENT)"
11756 # Clear to a bad index (1 billion should be safe)
11757 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11760 if [ $rc -eq 0 ]; then
11761 error "Successfully cleared to invalid CL index"
11762 elif [ $rc -ne 22 ]; then
11763 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11766 run_test 160e "changelog negative testing"
11770 do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
11771 echo "Deregistering changelog client $CL_USER"
11772 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11773 echo "Deregistering changelog client $CL_USER2"
11774 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
11775 restore_lustre_params < $save_params
11780 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11781 # should be set by default
11783 local CL_USERS="mdd.$MDT0.changelog_users"
11784 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11785 local save_params="$TMP/sanity-$TESTNAME.parameters"
11787 save_lustre_params $SINGLEMDS \
11788 "mdd.$MDT0.changelog_max_idle_time" > $save_params
11789 save_lustre_params $SINGLEMDS \
11790 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11791 save_lustre_params $SINGLEMDS \
11792 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11794 trap cleanup_160f EXIT
11797 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11798 changelog_register -n)
11799 echo "Registered as changelog user $CL_USER"
11800 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11801 changelog_register -n)
11802 echo "Registered as changelog user $CL_USER2"
11803 $GET_CL_USERS | grep -q $CL_USER ||
11804 error "User $CL_USER not found in changelog_users"
11805 $GET_CL_USERS | grep -q $CL_USER2 ||
11806 error "User $CL_USER2 not found in changelog_users"
11808 # generate some changelogs to accumulate
11809 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11810 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11811 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11812 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11814 # check changelogs have been generated
11815 nbcl=$($LFS changelog $MDT0 | wc -l)
11816 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11818 do_facet $SINGLEMDS $LCTL set_param \
11819 mdd.$MDT0.changelog_max_idle_time=10
11820 do_facet $SINGLEMDS $LCTL set_param \
11821 mdd.$MDT0.changelog_min_gc_interval=2
11822 do_facet $SINGLEMDS $LCTL set_param \
11823 mdd.$MDT0.changelog_min_free_cat_entries=3
11825 # simulate changelog catalog almost full
11826 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11827 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11828 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11831 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11832 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
11833 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11834 echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
11835 [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
11836 error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
11839 # generate one more changelog to trigger fail_loc
11840 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11842 # ensure gc thread is done
11843 wait_update_facet $SINGLEMDS \
11844 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11846 # check user still registered
11847 $GET_CL_USERS | grep -q $CL_USER ||
11848 error "User $CL_USER not found in changelog_users"
11849 # check user2 unregistered
11850 $GET_CL_USERS | grep -q $CL_USER2 &&
11851 error "User $CL_USER2 still found in changelog_users"
11853 # check changelogs are present and starting at $USER_REC2 + 1
11854 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11855 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11856 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11857 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11861 run_test 160f "changelog garbage collect (timestamped users)"
11864 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11865 # should be set by default
11867 local CL_USERS="mdd.$MDT0.changelog_users"
11868 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11869 local save_params="$TMP/sanity-$TESTNAME.parameters"
11871 save_lustre_params $SINGLEMDS \
11872 "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
11873 save_lustre_params $SINGLEMDS \
11874 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11875 save_lustre_params $SINGLEMDS \
11876 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11878 trap cleanup_160f EXIT
11880 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
11881 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
11884 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11885 changelog_register -n)
11886 echo "Registered as changelog user $CL_USER"
11887 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11888 changelog_register -n)
11889 echo "Registered as changelog user $CL_USER2"
11890 $GET_CL_USERS | grep -q $CL_USER ||
11891 error "User $CL_USER not found in changelog_users"
11892 $GET_CL_USERS | grep -q $CL_USER2 ||
11893 error "User $CL_USER2 not found in changelog_users"
11895 # generate some changelogs to accumulate
11896 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11897 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11898 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11899 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11901 # check changelogs have been generated
11902 nbcl=$($LFS changelog $MDT0 | wc -l)
11903 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11905 do_facet $SINGLEMDS $LCTL set_param \
11906 mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
11907 do_facet $SINGLEMDS $LCTL set_param \
11908 mdd.$MDT0.changelog_min_gc_interval=2
11909 do_facet $SINGLEMDS $LCTL set_param \
11910 mdd.$MDT0.changelog_min_free_cat_entries=3
11912 # simulate changelog catalog almost full
11913 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11914 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11915 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11917 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11918 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
11919 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11920 echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
11921 [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
11922 error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
11924 # generate one more changelog to trigger fail_loc
11925 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11927 # ensure gc thread is done
11928 wait_update_facet $SINGLEMDS \
11929 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11931 # check user still registered
11932 $GET_CL_USERS | grep -q $CL_USER ||
11933 error "User $CL_USER not found in changelog_users"
11934 # check user2 unregistered
11935 $GET_CL_USERS | grep -q $CL_USER2 &&
11936 error "User $CL_USER2 still found in changelog_users"
11938 # check changelogs are present and starting at $USER_REC2 + 1
11939 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11940 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11941 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11942 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11946 run_test 160g "changelog garbage collect (old users)"
11949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11950 test_mkdir -c1 $DIR/$tdir
11951 cp /etc/hosts $DIR/$tdir/$tfile
11952 test_mkdir -c1 $DIR/$tdir/foo1
11953 test_mkdir -c1 $DIR/$tdir/foo2
11954 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11955 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11956 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11957 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11958 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11959 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11960 $LFS fid2path $DIR $FID
11961 err17935 "bad link ea"
11964 rm $DIR/$tdir/foo2/zachary
11966 rm $DIR/$tdir/foo2/thor
11968 rm $DIR/$tdir/$tfile
11970 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11971 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11973 $LFS fid2path $DIR $FID
11974 err17935 "bad link rename"
11976 rm $DIR/$tdir/foo2/maggie
11979 local longname=filename_avg_len_is_thirty_two_
11980 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11981 error "failed to hardlink many files"
11982 links=$($LFS fid2path $DIR $FID | wc -l)
11983 echo -n "${links}/1000 links in link EA"
11984 [[ $links -gt 60 ]] ||
11985 err17935 "expected at least 60 links in link EA"
11986 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11987 error "failed to unlink many hardlinks"
11989 run_test 161a "link ea sanity"
11992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11993 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11995 local remote_dir=$DIR/$tdir/remote_dir
11997 mkdir -p $DIR/$tdir
11998 $LFS mkdir -i $MDTIDX $remote_dir ||
11999 error "create remote directory failed"
12001 cp /etc/hosts $remote_dir/$tfile
12002 mkdir -p $remote_dir/foo1
12003 mkdir -p $remote_dir/foo2
12004 ln $remote_dir/$tfile $remote_dir/foo1/sofia
12005 ln $remote_dir/$tfile $remote_dir/foo2/zachary
12006 ln $remote_dir/$tfile $remote_dir/foo1/luna
12007 ln $remote_dir/$tfile $remote_dir/foo2/thor
12009 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
12011 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12012 $LFS fid2path $DIR $FID
12013 err17935 "bad link ea"
12016 rm $remote_dir/foo2/zachary
12018 rm $remote_dir/foo2/thor
12020 rm $remote_dir/$tfile
12022 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
12023 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
12024 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
12025 $LFS fid2path $DIR $FID
12026 err17935 "bad link rename"
12028 rm $remote_dir/foo2/maggie
12031 local longname=filename_avg_len_is_thirty_two_
12032 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
12033 error "failed to hardlink many files"
12034 links=$($LFS fid2path $DIR $FID | wc -l)
12035 echo -n "${links}/1000 links in link EA"
12036 [[ ${links} -gt 60 ]] ||
12037 err17935 "expected at least 60 links in link EA"
12038 unlinkmany $remote_dir/foo2/$longname 1000 ||
12039 error "failed to unlink many hardlinks"
12041 run_test 161b "link ea sanity under remote directory"
12044 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12046 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
12047 skip "Need MDS version at least 2.1.5" && return
12049 # define CLF_RENAME_LAST 0x0001
12050 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
12051 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
12052 changelog_register -n)
12054 trap cleanup_changelog EXIT
12056 mkdir -p $DIR/$tdir
12057 touch $DIR/$tdir/foo_161c
12058 touch $DIR/$tdir/bar_161c
12059 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12060 $LFS changelog $MDT0 | grep RENME
12061 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
12063 $LFS changelog_clear $MDT0 $CL_USER 0
12064 if [ x$flags != "x0x1" ]; then
12065 error "flag $flags is not 0x1"
12067 echo "rename overwrite a target having nlink = 1," \
12068 "changelog record has flags of $flags"
12070 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
12071 touch $DIR/$tdir/foo_161c
12072 touch $DIR/$tdir/bar_161c
12073 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12074 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12075 $LFS changelog $MDT0 | grep RENME
12076 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
12077 $LFS changelog_clear $MDT0 $CL_USER 0
12078 if [ x$flags != "x0x0" ]; then
12079 error "flag $flags is not 0x0"
12081 echo "rename overwrite a target having nlink > 1," \
12082 "changelog record has flags of $flags"
12084 # rename doesn't overwrite a target (changelog flag 0x0)
12085 touch $DIR/$tdir/foo_161c
12086 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
12087 $LFS changelog $MDT0 | grep RENME
12088 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
12089 $LFS changelog_clear $MDT0 $CL_USER 0
12090 if [ x$flags != "x0x0" ]; then
12091 error "flag $flags is not 0x0"
12093 echo "rename doesn't overwrite a target," \
12094 "changelog record has flags of $flags"
12096 # define CLF_UNLINK_LAST 0x0001
12097 # unlink a file having nlink = 1 (changelog flag 0x1)
12098 rm -f $DIR/$tdir/foo2_161c
12099 $LFS changelog $MDT0 | grep UNLNK
12100 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
12101 $LFS changelog_clear $MDT0 $CL_USER 0
12102 if [ x$flags != "x0x1" ]; then
12103 error "flag $flags is not 0x1"
12105 echo "unlink a file having nlink = 1," \
12106 "changelog record has flags of $flags"
12108 # unlink a file having nlink > 1 (changelog flag 0x0)
12109 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12110 rm -f $DIR/$tdir/foobar_161c
12111 $LFS changelog $MDT0 | grep UNLNK
12112 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
12113 $LFS changelog_clear $MDT0 $CL_USER 0
12114 if [ x$flags != "x0x0" ]; then
12115 error "flag $flags is not 0x0"
12117 echo "unlink a file having nlink > 1," \
12118 "changelog record has flags of $flags"
12121 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
12128 # cleanup previous run
12129 rm -rf $DIR/$tdir/$tfile
12131 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
12132 changelog_register -n)
12133 [[ $? -eq 0 ]] || error "changelog_register failed"
12135 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
12136 # interfer with $MOUNT/.lustre/fid/ access
12138 [[ $? -eq 0 ]] || error "mkdir failed"
12140 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
12141 $LCTL set_param fail_loc=0x8000140c
12143 $LCTL set_param fail_val=5
12146 echo foofoo > $DIR/$tdir/$tfile &
12149 # wait for create to be delayed
12153 [[ $? -eq 0 ]] || error "create should be blocked"
12155 local tempfile=$(mktemp)
12156 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
12157 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
12158 # some delay may occur during ChangeLog publishing and file read just
12159 # above, that could allow file write to happen finally
12160 [[ -s $tempfile ]] && echo "file should be empty"
12162 $LCTL set_param fail_loc=0
12165 [[ $? -eq 0 ]] || error "create failed"
12167 $LFS changelog_clear $MDT0 $user 0
12168 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
12170 run_test 161d "create with concurrent .lustre/fid access"
12177 local path=$(${LFS} fid2path $*)
12178 # Remove the '//' indicating a remote directory
12179 path=$(echo $path | sed 's#//#/#g')
12182 if [ $RC -ne 0 ]; then
12183 err17935 "path looked up of $expected failed. Error $RC"
12185 elif [ "${path}" != "${expected}" ]; then
12186 err17935 "path looked up \"${path}\" instead of \"${expected}\""
12189 echo "fid $fid resolves to path $path (expected $expected)"
12192 test_162a() { # was test_162
12193 # Make changes to filesystem
12194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12195 test_mkdir -p -c1 $DIR/$tdir/d2
12196 touch $DIR/$tdir/d2/$tfile
12197 touch $DIR/$tdir/d2/x1
12198 touch $DIR/$tdir/d2/x2
12199 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
12200 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
12202 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
12203 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
12204 error "check path $tdir/d2/$tfile failed"
12207 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
12208 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
12209 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
12210 error "check path $tdir/d2/p/q/r/slink failed"
12212 # softlink to wrong file
12213 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
12214 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
12215 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
12216 error "check path $tdir/d2/p/q/r/slink.wrong failed"
12219 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
12220 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
12221 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
12222 # fid2path dir/fsname should both work
12223 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
12224 error "check path $tdir/d2/a/b/c/new_file failed"
12225 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
12226 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
12228 # hardlink count: check that there are 2 links
12229 # Doesnt work with CMD yet: 17935
12230 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
12231 err17935 "expected 2 links"
12233 # hardlink indexing: remove the first link
12234 rm $DIR/$tdir/d2/p/q/r/hlink
12235 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
12236 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
12240 run_test 162a "path lookup sanity"
12243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12244 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12247 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12248 error "create striped dir failed"
12250 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
12251 tail -n 1 | awk '{print $2}')
12252 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
12254 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
12255 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
12258 for ((i=0;i<5;i++)); do
12259 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
12260 error "get fid for f$i failed"
12261 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
12262 error "check path $tdir/striped_dir/f$i failed"
12264 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
12265 error "get fid for d$i failed"
12266 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
12267 error "check path $tdir/striped_dir/d$i failed"
12272 run_test 162b "striped directory path lookup sanity"
12274 # LU-4239: Verify fid2path works with paths 100 or more directories deep
12276 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
12277 skip "Need MDS version at least 2.7.51" && return
12278 test_mkdir $DIR/$tdir.local
12279 test_mkdir $DIR/$tdir.remote
12280 local lpath=$tdir.local
12281 local rpath=$tdir.remote
12283 for ((i = 0; i <= 101; i++)); do
12286 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
12287 error "get fid for local directory $DIR/$lpath failed"
12288 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
12289 error "check path for local directory $DIR/$lpath failed"
12292 test_mkdir $DIR/$rpath
12293 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
12294 error "get fid for remote directory $DIR/$rpath failed"
12295 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
12296 error "check path for remote directory $DIR/$rpath failed"
12301 run_test 162c "fid2path works with paths 100 or more directories deep"
12304 # do directio so as not to populate the page cache
12305 log "creating a 10 Mb file"
12306 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12307 log "starting reads"
12308 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12309 log "truncating the file"
12310 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12312 kill %+ || true # reads might have finished
12313 echo "wait until dd is finished"
12315 log "removing the temporary file"
12316 rm -rf $DIR/$tfile || error "tmp file removal failed"
12318 run_test 169 "parallel read and truncate should not deadlock"
12321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12323 $LCTL clear # bug 18514
12324 $LCTL debug_daemon start $TMP/${tfile}_log_good
12326 $LCTL debug_daemon stop
12327 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
12328 error "sed failed to read log_good"
12330 $LCTL debug_daemon start $TMP/${tfile}_log_good
12332 $LCTL debug_daemon stop
12334 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
12335 error "lctl df log_bad failed"
12337 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12338 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12340 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
12341 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
12343 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
12344 error "bad_line good_line1 good_line2 are empty"
12346 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12347 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
12348 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12350 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
12351 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12352 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12354 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
12355 error "bad_line_new good_line_new are empty"
12357 local expected_good=$((good_line1 + good_line2*2))
12359 rm -f $TMP/${tfile}*
12360 # LU-231, short malformed line may not be counted into bad lines
12361 if [ $bad_line -ne $bad_line_new ] &&
12362 [ $bad_line -ne $((bad_line_new - 1)) ]; then
12363 error "expected $bad_line bad lines, but got $bad_line_new"
12367 if [ $expected_good -ne $good_line_new ]; then
12368 error "expected $expected_good good lines, but got $good_line_new"
12373 run_test 170 "test lctl df to handle corrupted log ====================="
12375 test_171() { # bug20592
12376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12377 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12378 $LCTL set_param fail_loc=0x50e
12379 $LCTL set_param fail_val=3000
12380 multiop_bg_pause $DIR/$tfile O_s || true
12382 kill -USR1 $MULTIPID
12386 if dmesg | grep "recursive fault"; then
12387 error "caught a recursive fault"
12389 $LCTL set_param fail_loc=0
12392 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12394 # it would be good to share it with obdfilter-survey/iokit-libecho code
12395 setup_obdecho_osc () {
12398 local obdfilter_name=$2
12399 echo "Creating new osc for $obdfilter_name on $ost_nid"
12400 # make sure we can find loopback nid
12401 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12403 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12404 ${obdfilter_name}_osc_UUID || rc=2; }
12405 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12406 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12410 cleanup_obdecho_osc () {
12411 local obdfilter_name=$1
12412 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12413 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12420 local pages=${3:-64}
12425 local obd_size=$(get_obd_size $node $OBD)
12426 local page_size=$(get_page_size $node)
12427 if [[ -n "$obd_size" ]]; then
12428 local new_count=$((obd_size / (pages * page_size / 1024)))
12429 [[ $new_count -ge $count ]] || count=$new_count
12432 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12433 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12435 if [ $rc -eq 0 ]; then
12436 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12437 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12439 echo "New object id is $id"
12440 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12442 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12443 "test_brw $count w v $pages $id" || rc=4; }
12444 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12446 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12447 "cleanup" || rc=5; }
12448 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12449 "detach" || rc=6; }
12450 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12456 remote_ost_nodsh && skip "remote OST with nodsh" && return
12458 local rmmod_local=0
12460 if ! module_loaded obdecho; then
12461 load_module obdecho/obdecho
12465 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12466 local host=$(lctl get_param -n osc.$osc.import |
12467 awk '/current_connection:/ {print $2}' )
12468 local target=$(lctl get_param -n osc.$osc.import |
12469 awk '/target:/ {print $2}' )
12470 target=${target%_UUID}
12472 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12473 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12474 [[ -n $target ]] && cleanup_obdecho_osc $target
12475 [ $rmmod_local -eq 1 ] && rmmod obdecho
12478 run_test 180a "test obdecho on osc"
12481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12482 remote_ost_nodsh && skip "remote OST with nodsh" && return
12484 local rmmod_remote=0
12486 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12487 rmmod_remote=true || error "failed to load module obdecho"
12488 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12489 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12490 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12493 run_test 180b "test obdecho directly on obdfilter"
12495 test_180c() { # LU-2598
12496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12497 remote_ost_nodsh && skip "remote OST with nodsh" && return
12498 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12499 skip "Need MDS version at least 2.4.0" && return
12502 local rmmod_remote=false
12503 local pages=16384 # 64MB bulk I/O RPC size
12506 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12507 rmmod_remote=true || error "failed to load module obdecho"
12509 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12511 if [ -n "$target" ]; then
12512 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12514 echo "there is no obdfilter target on ost1"
12517 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12520 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12522 test_181() { # bug 22177
12523 test_mkdir $DIR/$tdir
12524 # create enough files to index the directory
12525 createmany -o $DIR/$tdir/foobar 4000
12526 # print attributes for debug purpose
12529 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12531 # remove the files & current working dir
12532 unlinkmany $DIR/$tdir/foobar 4000
12534 kill -USR1 $MULTIPID
12536 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12539 run_test 181 "Test open-unlinked dir ========================"
12545 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12547 $LCTL set_param mdc.*.rpc_stats=clear
12549 for (( i = 0; i < $tcount; i++ )) ; do
12550 mkdir $DIR/$tdir/$i
12553 for (( i = 0; i < $tcount; i++ )) ; do
12554 createmany -o $DIR/$tdir/$i/f- $fcount &
12558 for (( i = 0; i < $tcount; i++ )) ; do
12559 unlinkmany $DIR/$tdir/$i/f- $fcount &
12563 $LCTL get_param mdc.*.rpc_stats
12567 run_test 182 "Test parallel modify metadata operations ================"
12569 test_183() { # LU-2275
12570 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12571 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12572 skip "Need MDS version at least 2.3.56" && return
12574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12575 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12576 echo aaa > $DIR/$tdir/$tfile
12578 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12579 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12581 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12582 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12584 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12586 # Flush negative dentry cache
12587 touch $DIR/$tdir/$tfile
12589 # We are not checking for any leaked references here, they'll
12590 # become evident next time we do cleanup with module unload.
12593 run_test 183 "No crash or request leak in case of strange dispositions ========"
12595 # test suite 184 is for LU-2016, LU-2017
12597 check_swap_layouts_support && return 0
12599 dir0=$DIR/$tdir/$testnum
12600 test_mkdir -p -c1 $dir0
12605 $SETSTRIPE -c1 $file1
12607 $SETSTRIPE -c2 $file2
12609 gen1=$($GETSTRIPE -g $file1)
12610 gen2=$($GETSTRIPE -g $file2)
12612 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12613 gen=$($GETSTRIPE -g $file1)
12614 [[ $gen1 != $gen ]] ||
12615 "Layout generation on $file1 does not change"
12616 gen=$($GETSTRIPE -g $file2)
12617 [[ $gen2 != $gen ]] ||
12618 "Layout generation on $file2 does not change"
12620 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12621 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12623 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
12625 run_test 184a "Basic layout swap"
12628 check_swap_layouts_support && return 0
12630 dir0=$DIR/$tdir/$testnum
12631 mkdir -p $dir0 || error "creating dir $dir0"
12638 $SETSTRIPE -c1 $file1
12639 $SETSTRIPE -c2 $file2
12640 $SETSTRIPE -c1 $file3
12641 chown $RUNAS_ID $file3
12642 gen1=$($GETSTRIPE -g $file1)
12643 gen2=$($GETSTRIPE -g $file2)
12645 $LFS swap_layouts $dir1 $dir2 &&
12646 error "swap of directories layouts should fail"
12647 $LFS swap_layouts $dir1 $file1 &&
12648 error "swap of directory and file layouts should fail"
12649 $RUNAS $LFS swap_layouts $file1 $file2 &&
12650 error "swap of file we cannot write should fail"
12651 $LFS swap_layouts $file1 $file3 &&
12652 error "swap of file with different owner should fail"
12653 /bin/true # to clear error code
12655 run_test 184b "Forbidden layout swap (will generate errors)"
12658 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12659 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12660 check_swap_layouts_support && return 0
12662 local dir0=$DIR/$tdir/$testnum
12663 mkdir -p $dir0 || error "creating dir $dir0"
12665 local ref1=$dir0/ref1
12666 local ref2=$dir0/ref2
12667 local file1=$dir0/file1
12668 local file2=$dir0/file2
12669 # create a file large enough for the concurrent test
12670 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12671 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12672 echo "ref file size: ref1($(stat -c %s $ref1))," \
12673 "ref2($(stat -c %s $ref2))"
12676 dd if=$ref1 of=$file1 bs=16k &
12679 # Make sure dd starts to copy file
12680 while [ ! -f $file1 ]; do sleep 0.1; done
12682 $LFS swap_layouts $file1 $file2
12685 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12686 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12688 # how many bytes copied before swapping layout
12689 local copied=$(stat -c %s $file2)
12690 local remaining=$(stat -c %s $ref1)
12691 remaining=$((remaining - copied))
12692 echo "Copied $copied bytes before swapping layout..."
12694 cmp -n $copied $file1 $ref2 | grep differ &&
12695 error "Content mismatch [0, $copied) of ref2 and file1"
12696 cmp -n $copied $file2 $ref1 ||
12697 error "Content mismatch [0, $copied) of ref1 and file2"
12698 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12699 error "Content mismatch [$copied, EOF) of ref1 and file1"
12702 rm -f $ref1 $ref2 $file1 $file2
12704 run_test 184c "Concurrent write and layout swap"
12707 check_swap_layouts_support && return 0
12708 [ -z "$(which getfattr 2>/dev/null)" ] &&
12709 skip "no getfattr command" && return 0
12711 local file1=$DIR/$tdir/$tfile-1
12712 local file2=$DIR/$tdir/$tfile-2
12713 local file3=$DIR/$tdir/$tfile-3
12717 mkdir -p $DIR/$tdir
12718 touch $file1 || error "create $file1 failed"
12719 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12720 error "create $file2 failed"
12721 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12722 error "create $file3 failed"
12723 lovea1=$(get_layout_param $file1)
12725 $LFS swap_layouts $file2 $file3 ||
12726 error "swap $file2 $file3 layouts failed"
12727 $LFS swap_layouts $file1 $file2 ||
12728 error "swap $file1 $file2 layouts failed"
12730 lovea2=$(get_layout_param $file2)
12733 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12735 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12736 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12738 run_test 184d "allow stripeless layouts swap"
12741 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12742 { skip "Need MDS version at least 2.6.94"; return 0; }
12743 check_swap_layouts_support && return 0
12744 [ -z "$(which getfattr 2>/dev/null)" ] &&
12745 skip "no getfattr command" && return 0
12747 local file1=$DIR/$tdir/$tfile-1
12748 local file2=$DIR/$tdir/$tfile-2
12749 local file3=$DIR/$tdir/$tfile-3
12752 mkdir -p $DIR/$tdir
12753 touch $file1 || error "create $file1 failed"
12754 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12755 error "create $file2 failed"
12756 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12757 error "create $file3 failed"
12759 $LFS swap_layouts $file1 $file2 ||
12760 error "swap $file1 $file2 layouts failed"
12762 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12763 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12765 echo 123 > $file1 || error "Should be able to write into $file1"
12767 $LFS swap_layouts $file1 $file3 ||
12768 error "swap $file1 $file3 layouts failed"
12770 echo 123 > $file1 || error "Should be able to write into $file1"
12772 rm -rf $file1 $file2 $file3
12774 run_test 184e "Recreate layout after stripeless layout swaps"
12776 test_185() { # LU-2441
12777 # LU-3553 - no volatile file support in old servers
12778 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12779 { skip "Need MDS version at least 2.3.60"; return 0; }
12781 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12782 touch $DIR/$tdir/spoo
12783 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12784 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12785 error "cannot create/write a volatile file"
12786 [ "$FILESET" == "" ] &&
12787 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12788 error "FID is still valid after close"
12790 multiop_bg_pause $DIR/$tdir vVw4096_c
12797 # assume that the next FID for this client is sequential, since stdout
12798 # is unfortunately eaten by multiop_bg_pause
12799 local n=$((${fidv[1]} + 1))
12800 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12801 if [ "$FILESET" == "" ]; then
12802 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12803 error "FID is missing before close"
12805 kill -USR1 $multi_pid
12806 # 1 second delay, so if mtime change we will see it
12808 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12809 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12811 run_test 185 "Volatile file support"
12814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12815 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12816 skip "Need MDS version at least 2.3.0" && return
12818 local dir0=$DIR/$tdir/$testnum
12819 mkdir -p $dir0 || error "creating dir $dir0"
12821 local file=$dir0/file1
12822 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12823 local dv1=$($LFS data_version $file)
12824 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12825 local dv2=$($LFS data_version $file)
12826 [[ $dv1 != $dv2 ]] ||
12827 error "data version did not change on write $dv1 == $dv2"
12832 run_test 187a "Test data version change"
12835 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12836 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12837 skip "Need MDS version at least 2.3.0" && return
12839 local dir0=$DIR/$tdir/$testnum
12840 mkdir -p $dir0 || error "creating dir $dir0"
12842 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12843 [[ ${DV[0]} != ${DV[1]} ]] ||
12844 error "data version did not change on write"\
12845 " ${DV[0]} == ${DV[1]}"
12850 run_test 187b "Test data version change on volatile file"
12853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12854 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12855 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12857 local POOL=${POOL:-cea1}
12858 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12859 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12862 local last_ost=$(($OSTCOUNT - 1))
12864 local ost_list=$(seq $first_ost $ost_step $last_ost)
12865 local ost_range="$first_ost $last_ost $ost_step"
12866 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12867 local file_dir=$POOL_ROOT/file_tst
12868 local subdir=$test_path/subdir
12871 if ! combined_mgs_mds ; then
12876 # former test_200a test_200b
12877 pool_add $POOL || { rc=$? ; break; }
12878 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12879 # former test_200c test_200d
12880 mkdir -p $test_path
12881 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12882 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12884 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12885 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12886 || { rc=$? ; break; }
12887 # former test_200e test_200f
12888 local files=$((OSTCOUNT*3))
12889 pool_alloc_files $POOL $test_path $files "$ost_list" \
12890 || { rc=$? ; break; }
12891 pool_create_files $POOL $file_dir $files "$ost_list" \
12892 || { rc=$? ; break; }
12893 # former test_200g test_200h
12894 pool_lfs_df $POOL || { rc=$? ; break; }
12895 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12897 # former test_201a test_201b test_201c
12898 pool_remove_first_target $POOL || { rc=$? ; break; }
12900 local f=$test_path/$tfile
12901 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12902 pool_remove $POOL $f || { rc=$? ; break; }
12908 if ! combined_mgs_mds ; then
12913 run_test 200 "OST pools"
12915 # usage: default_attr <count | size | offset>
12917 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12920 # usage: check_default_stripe_attr
12921 check_default_stripe_attr() {
12922 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12925 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12927 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12931 error "unknown getstripe attr '$1'"
12934 [ $ACTUAL == $EXPECTED ] ||
12935 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12939 test_mkdir $DIR/$tdir
12940 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12942 check_default_stripe_attr --stripe-count
12943 check_default_stripe_attr --stripe-size
12944 check_default_stripe_attr --stripe-index
12946 run_test 204a "Print default stripe attributes"
12949 test_mkdir $DIR/$tdir
12950 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12952 check_default_stripe_attr --stripe-size
12953 check_default_stripe_attr --stripe-index
12955 run_test 204b "Print default stripe size and offset"
12958 test_mkdir $DIR/$tdir
12959 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12961 check_default_stripe_attr --stripe-count
12962 check_default_stripe_attr --stripe-index
12964 run_test 204c "Print default stripe count and offset"
12967 test_mkdir $DIR/$tdir
12968 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12970 check_default_stripe_attr --stripe-count
12971 check_default_stripe_attr --stripe-size
12973 run_test 204d "Print default stripe count and size"
12976 test_mkdir $DIR/$tdir
12977 $SETSTRIPE -d $DIR/$tdir
12979 check_default_stripe_attr --stripe-count --raw
12980 check_default_stripe_attr --stripe-size --raw
12981 check_default_stripe_attr --stripe-index --raw
12983 run_test 204e "Print raw stripe attributes"
12986 test_mkdir $DIR/$tdir
12987 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12989 check_default_stripe_attr --stripe-size --raw
12990 check_default_stripe_attr --stripe-index --raw
12992 run_test 204f "Print raw stripe size and offset"
12995 test_mkdir $DIR/$tdir
12996 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12998 check_default_stripe_attr --stripe-count --raw
12999 check_default_stripe_attr --stripe-index --raw
13001 run_test 204g "Print raw stripe count and offset"
13004 test_mkdir $DIR/$tdir
13005 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13007 check_default_stripe_attr --stripe-count --raw
13008 check_default_stripe_attr --stripe-size --raw
13010 run_test 204h "Print raw stripe count and size"
13012 # Figure out which job scheduler is being used, if any,
13013 # or use a fake one
13014 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
13015 JOBENV=SLURM_JOB_ID
13016 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
13018 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
13020 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
13021 JOBENV=LOADL_STEP_ID
13022 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
13025 $LCTL list_param jobid_name > /dev/null 2>&1
13026 if [ $? -eq 0 ]; then
13033 verify_jobstats() {
13038 # we don't really need to clear the stats for this test to work, since each
13039 # command has a unique jobid, but it makes debugging easier if needed.
13040 # for facet in $facets; do
13041 # local dev=$(convert_facet2label $facet)
13042 # # clear old jobstats
13043 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
13046 # use a new JobID for each test, or we might see an old one
13047 [ "$JOBENV" = "FAKE_JOBID" ] &&
13048 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13052 [ "$JOBENV" = "nodelocal" ] && {
13053 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13054 $LCTL set_param jobid_name=$FAKE_JOBID
13058 log "Test: ${cmd[*]}"
13059 log "Using JobID environment variable $JOBENV=$JOBVAL"
13061 if [ $JOBENV = "FAKE_JOBID" ]; then
13062 FAKE_JOBID=$JOBVAL ${cmd[*]}
13067 # all files are created on OST0000
13068 for facet in $facets; do
13069 local stats="*.$(convert_facet2label $facet).job_stats"
13070 if [ $(do_facet $facet lctl get_param $stats |
13071 grep -c $JOBVAL) -ne 1 ]; then
13072 do_facet $facet lctl get_param $stats
13073 error "No jobstats for $JOBVAL found on $facet::$stats"
13080 NEW_JOBENV=${1:-$OLD_JOBENV}
13081 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
13082 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
13087 do_facet $SINGLEMDS \
13088 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
13089 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
13093 test_205() { # Job stats
13094 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
13095 { skip "Need MDS version with at least 2.7.1"; return 0; }
13097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13098 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13099 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13100 remote_ost_nodsh && skip "remote OST with nodsh" && return
13102 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
13103 skip "Server doesn't support jobstats" && return 0
13104 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
13106 OLD_JOBENV=$($LCTL get_param -n jobid_var)
13107 if [ $OLD_JOBENV != $JOBENV ]; then
13108 jobstats_set $JOBENV
13109 trap cleanup_205 EXIT
13112 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
13113 echo "Registered as changelog user $CL_USER"
13115 OLD_INTERVAL=$(do_facet $SINGLEMDS \
13116 lctl get_param -n mdt.*.job_cleanup_interval)
13117 local interval_new=5
13118 do_facet $SINGLEMDS \
13119 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
13120 local start=$SECONDS
13124 cmd="mkdir $DIR/$tdir"
13125 verify_jobstats "$cmd" "$SINGLEMDS"
13127 cmd="rmdir $DIR/$tdir"
13128 verify_jobstats "$cmd" "$SINGLEMDS"
13129 # mkdir on secondary MDT
13130 if [ $MDSCOUNT -gt 1 ]; then
13131 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
13132 verify_jobstats "$cmd" "mds2"
13135 cmd="mknod $DIR/$tfile c 1 3"
13136 verify_jobstats "$cmd" "$SINGLEMDS"
13138 cmd="rm -f $DIR/$tfile"
13139 verify_jobstats "$cmd" "$SINGLEMDS"
13140 # create all files on OST0000 so verify_jobstats can find OST stats
13142 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
13143 verify_jobstats "$cmd" "$SINGLEMDS"
13145 cmd="touch $DIR/$tfile"
13146 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13148 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
13149 verify_jobstats "$cmd" "ost1"
13151 cancel_lru_locks osc
13152 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
13153 verify_jobstats "$cmd" "ost1"
13155 cmd="$TRUNCATE $DIR/$tfile 0"
13156 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13158 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
13159 verify_jobstats "$cmd" "$SINGLEMDS"
13160 # jobstats expiry - sleep until old stats should be expired
13161 local left=$((interval_new + 5 - (SECONDS - start)))
13162 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
13163 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
13165 cmd="mkdir $DIR/$tdir.expire"
13166 verify_jobstats "$cmd" "$SINGLEMDS"
13167 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
13168 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
13170 # Ensure that jobid are present in changelog (if supported by MDS)
13171 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
13173 $LFS changelog $MDT0 | tail -9
13174 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
13175 [ $jobids -eq 9 ] ||
13176 error "Wrong changelog jobid count $jobids != 9"
13180 jobstats_set $JOBENV
13182 $LFS changelog $MDT0 | tail -1
13183 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
13184 [ $jobids -eq 0 ] ||
13185 error "Unexpected jobids when jobid_var=$JOBENV"
13190 run_test 205 "Verify job stats"
13192 # LU-1480, LU-1773 and LU-1657
13194 mkdir -p $DIR/$tdir
13195 $SETSTRIPE -c -1 $DIR/$tdir
13196 #define OBD_FAIL_LOV_INIT 0x1403
13197 $LCTL set_param fail_loc=0xa0001403
13198 $LCTL set_param fail_val=1
13199 touch $DIR/$tdir/$tfile || true
13201 run_test 206 "fail lov_init_raid0() doesn't lbug"
13204 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13205 local fsz=`stat -c %s $DIR/$tfile`
13206 cancel_lru_locks mdc
13208 # do not return layout in getattr intent
13209 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
13210 $LCTL set_param fail_loc=0x170
13211 local sz=`stat -c %s $DIR/$tfile`
13213 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
13217 run_test 207a "can refresh layout at glimpse"
13220 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13221 local cksum=`md5sum $DIR/$tfile`
13222 local fsz=`stat -c %s $DIR/$tfile`
13223 cancel_lru_locks mdc
13224 cancel_lru_locks osc
13226 # do not return layout in getattr intent
13227 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
13228 $LCTL set_param fail_loc=0x171
13230 # it will refresh layout after the file is opened but before read issues
13231 echo checksum is "$cksum"
13232 echo "$cksum" |md5sum -c --quiet || error "file differs"
13236 run_test 207b "can refresh layout at open"
13239 # FIXME: in this test suite, only RD lease is used. This is okay
13240 # for now as only exclusive open is supported. After generic lease
13241 # is done, this test suite should be revised. - Jinshan
13243 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13244 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
13245 { skip "Need MDS version at least 2.4.52"; return 0; }
13247 echo "==== test 1: verify get lease work"
13248 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
13250 echo "==== test 2: verify lease can be broken by upcoming open"
13251 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13255 $MULTIOP $DIR/$tfile oO_RDONLY:c
13256 kill -USR1 $PID && wait $PID || error "break lease error"
13258 echo "==== test 3: verify lease can't be granted if an open already exists"
13259 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
13263 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
13264 kill -USR1 $PID && wait $PID || error "open file error"
13266 echo "==== test 4: lease can sustain over recovery"
13267 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
13273 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
13275 echo "==== test 5: lease broken can't be regained by replay"
13276 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13280 # open file to break lease and then recovery
13281 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
13284 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
13288 run_test 208 "Exclusive open"
13291 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
13292 skip_env "must have disp_stripe" && return
13295 sync; sleep 5; sync;
13297 echo 3 > /proc/sys/vm/drop_caches
13298 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13300 # open/close 500 times
13301 for i in $(seq 500); do
13305 echo 3 > /proc/sys/vm/drop_caches
13306 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13308 echo "before: $req_before, after: $req_after"
13309 [ $((req_after - req_before)) -ge 300 ] &&
13310 error "open/close requests are not freed"
13313 run_test 209 "read-only open/close requests should be freed promptly"
13317 size=$((size % 8192 + 1))
13318 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
13319 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
13320 rm -f $DIR/f212 $DIR/f212.xyz
13322 run_test 212 "Sendfile test ============================================"
13325 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
13326 cancel_lru_locks osc
13327 lctl set_param fail_loc=0x8000040f
13328 # generate a read lock
13329 cat $DIR/$tfile > /dev/null
13330 # write to the file, it will try to cancel the above read lock.
13331 cat /etc/hosts >> $DIR/$tfile
13333 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
13335 test_214() { # for bug 20133
13336 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
13337 for (( i=0; i < 340; i++ )) ; do
13338 touch $DIR/$tdir/d214c/a$i
13341 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
13342 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
13343 ls $DIR/d214c || error "ls $DIR/d214c failed"
13344 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
13345 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
13347 run_test 214 "hash-indexed directory test - bug 20133"
13349 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
13350 create_lnet_proc_files() {
13351 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
13354 # counterpart of create_lnet_proc_files
13355 remove_lnet_proc_files() {
13356 rm -f $TMP/lnet_$1.sys
13359 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13360 # 3rd arg as regexp for body
13361 check_lnet_proc_stats() {
13362 local l=$(cat "$TMP/lnet_$1" |wc -l)
13363 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13365 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13368 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13369 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13370 # optional and can be regexp for 2nd line (lnet.routes case)
13371 check_lnet_proc_entry() {
13372 local blp=2 # blp stands for 'position of 1st line of body'
13373 [ -z "$5" ] || blp=3 # lnet.routes case
13375 local l=$(cat "$TMP/lnet_$1" |wc -l)
13376 # subtracting one from $blp because the body can be empty
13377 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13379 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13380 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13382 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13383 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13385 # bail out if any unexpected line happened
13386 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13387 [ "$?" != 0 ] || error "$2 misformatted"
13390 test_215() { # for bugs 18102, 21079, 21517
13391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13392 local N='(0|[1-9][0-9]*)' # non-negative numeric
13393 local P='[1-9][0-9]*' # positive numeric
13394 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13395 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13396 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13397 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13399 local L1 # regexp for 1st line
13400 local L2 # regexp for 2nd line (optional)
13401 local BR # regexp for the rest (body)
13403 # lnet.stats should look as 11 space-separated non-negative numerics
13404 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13405 create_lnet_proc_files "stats"
13406 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13407 remove_lnet_proc_files "stats"
13409 # lnet.routes should look like this:
13410 # Routing disabled/enabled
13411 # net hops priority state router
13412 # where net is a string like tcp0, hops > 0, priority >= 0,
13413 # state is up/down,
13414 # router is a string like 192.168.1.1@tcp2
13415 L1="^Routing (disabled|enabled)$"
13416 L2="^net +hops +priority +state +router$"
13417 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13418 create_lnet_proc_files "routes"
13419 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13420 remove_lnet_proc_files "routes"
13422 # lnet.routers should look like this:
13423 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13424 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13425 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13426 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13427 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13428 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13429 create_lnet_proc_files "routers"
13430 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13431 remove_lnet_proc_files "routers"
13433 # lnet.peers should look like this:
13434 # nid refs state last max rtr min tx min queue
13435 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13436 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13437 # numeric (0 or >0 or <0), queue >= 0.
13438 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13439 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13440 create_lnet_proc_files "peers"
13441 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13442 remove_lnet_proc_files "peers"
13444 # lnet.buffers should look like this:
13445 # pages count credits min
13446 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13447 L1="^pages +count +credits +min$"
13448 BR="^ +$N +$N +$I +$I$"
13449 create_lnet_proc_files "buffers"
13450 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13451 remove_lnet_proc_files "buffers"
13453 # lnet.nis should look like this:
13454 # nid status alive refs peer rtr max tx min
13455 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13456 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13457 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13458 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13459 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13460 create_lnet_proc_files "nis"
13461 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13462 remove_lnet_proc_files "nis"
13464 # can we successfully write to lnet.stats?
13465 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13467 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13469 test_216() { # bug 20317
13470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13471 remote_ost_nodsh && skip "remote OST with nodsh" && return
13474 local facets=$(get_facets OST)
13475 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13477 save_lustre_params client "osc.*.contention_seconds" > $p
13478 save_lustre_params $facets \
13479 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13480 save_lustre_params $facets \
13481 "ldlm.namespaces.filter-*.contended_locks" >> $p
13482 save_lustre_params $facets \
13483 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13484 clear_stats osc.*.osc_stats
13486 # agressive lockless i/o settings
13487 do_nodes $(comma_list $(osts_nodes)) \
13488 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13489 ldlm.namespaces.filter-*.contended_locks=0 \
13490 ldlm.namespaces.filter-*.contention_seconds=60"
13491 lctl set_param -n osc.*.contention_seconds=60
13493 $DIRECTIO write $DIR/$tfile 0 10 4096
13494 $CHECKSTAT -s 40960 $DIR/$tfile
13496 # disable lockless i/o
13497 do_nodes $(comma_list $(osts_nodes)) \
13498 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13499 ldlm.namespaces.filter-*.contended_locks=32 \
13500 ldlm.namespaces.filter-*.contention_seconds=0"
13501 lctl set_param -n osc.*.contention_seconds=0
13502 clear_stats osc.*.osc_stats
13504 dd if=/dev/zero of=$DIR/$tfile count=0
13505 $CHECKSTAT -s 0 $DIR/$tfile
13507 restore_lustre_params <$p
13511 run_test 216 "check lockless direct write updates file size and kms correctly"
13513 test_217() { # bug 22430
13514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13518 for node in $(nodes_list); do
13519 nid=$(host_nids_address $node $NETTYPE)
13520 if [[ $nid = *-* ]] ; then
13521 echo "lctl ping $(h2nettype $nid)"
13522 lctl ping $(h2nettype $nid)
13524 echo "skipping $node (no hyphen detected)"
13528 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13531 # do directio so as not to populate the page cache
13532 log "creating a 10 Mb file"
13533 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13534 log "starting reads"
13535 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13536 log "truncating the file"
13537 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13539 kill %+ || true # reads might have finished
13540 echo "wait until dd is finished"
13542 log "removing the temporary file"
13543 rm -rf $DIR/$tfile || error "tmp file removal failed"
13545 run_test 218 "parallel read and truncate should not deadlock ======================="
13548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13549 # write one partial page
13550 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13551 # set no grant so vvp_io_commit_write will do sync write
13552 $LCTL set_param fail_loc=0x411
13553 # write a full page at the end of file
13554 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13556 $LCTL set_param fail_loc=0
13557 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13558 $LCTL set_param fail_loc=0x411
13559 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13562 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13563 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13565 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13567 test_220() { #LU-325
13568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13569 remote_ost_nodsh && skip "remote OST with nodsh" && return
13570 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13571 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13574 # create on MDT0000 so the last_id and next_id are correct
13576 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13580 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13581 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13582 osc.$mdtosc_proc1.prealloc_last_id)
13583 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13584 osc.$mdtosc_proc1.prealloc_next_id)
13588 if ! combined_mgs_mds ; then
13592 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13593 #define OBD_FAIL_OST_ENOINO 0x229
13594 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13595 create_pool $FSNAME.$TESTNAME || return 1
13596 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13598 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13600 MDSOBJS=$((last_id - next_id))
13601 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13603 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13604 echo "OST still has $count kbytes free"
13606 echo "create $MDSOBJS files @next_id..."
13607 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13609 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13610 osc.$mdtosc_proc1.prealloc_last_id)
13611 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13612 osc.$mdtosc_proc1.prealloc_next_id)
13614 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13619 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13620 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13622 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13623 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13624 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13625 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13626 echo "unlink $MDSOBJS files @$next_id..."
13627 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13629 if ! combined_mgs_mds ; then
13633 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13637 dd if=`which date` of=$MOUNT/date oflag=sync
13638 chmod +x $MOUNT/date
13640 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13641 $LCTL set_param fail_loc=0x80001401
13643 $MOUNT/date > /dev/null
13646 run_test 221 "make sure fault and truncate race to not cause OOM"
13649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13651 test_mkdir $DIR/$tdir
13652 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13653 createmany -o $DIR/$tdir/$tfile 10
13654 cancel_lru_locks mdc
13655 cancel_lru_locks osc
13656 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13657 $LCTL set_param fail_loc=0x31a
13658 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13659 $LCTL set_param fail_loc=0
13662 run_test 222a "AGL for ls should not trigger CLIO lock failure"
13665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13667 test_mkdir $DIR/$tdir
13668 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13669 createmany -o $DIR/$tdir/$tfile 10
13670 cancel_lru_locks mdc
13671 cancel_lru_locks osc
13672 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13673 $LCTL set_param fail_loc=0x31a
13674 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13675 $LCTL set_param fail_loc=0
13677 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
13680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13682 test_mkdir $DIR/$tdir
13683 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13684 createmany -o $DIR/$tdir/$tfile 10
13685 cancel_lru_locks mdc
13686 cancel_lru_locks osc
13687 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13688 $LCTL set_param fail_loc=0x31b
13689 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13690 $LCTL set_param fail_loc=0
13693 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13695 test_224a() { # LU-1039, MRP-303
13696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13697 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13698 $LCTL set_param fail_loc=0x508
13699 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13700 $LCTL set_param fail_loc=0
13703 run_test 224a "Don't panic on bulk IO failure"
13705 test_224b() { # LU-1039, MRP-303
13706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13707 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13708 cancel_lru_locks osc
13709 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13710 $LCTL set_param fail_loc=0x515
13711 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13712 $LCTL set_param fail_loc=0
13715 run_test 224b "Don't panic on bulk IO failure"
13717 test_224c() { # LU-6441
13718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13719 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13721 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13722 save_writethrough $p
13723 set_cache writethrough on
13725 local pages_per_rpc=$($LCTL get_param \
13726 osc.*.max_pages_per_rpc)
13727 local at_max=$($LCTL get_param -n at_max)
13728 local timeout=$($LCTL get_param -n timeout)
13729 local test_at="$LCTL get_param -n at_max"
13730 local param_at="$FSNAME.sys.at_max"
13731 local test_timeout="$LCTL get_param -n timeout"
13732 local param_timeout="$FSNAME.sys.timeout"
13734 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13736 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13737 error "conf_param at_max=0 failed"
13738 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13739 error "conf_param timeout=5 failed"
13741 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13742 do_facet ost1 $LCTL set_param fail_loc=0x520
13743 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13744 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13746 do_facet ost1 $LCTL set_param fail_loc=0
13748 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13749 error "conf_param at_max=$at_max failed"
13750 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13751 $timeout || error "conf_param timeout=$timeout failed"
13753 $LCTL set_param -n $pages_per_rpc
13754 restore_lustre_params < $p
13757 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13759 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13762 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13763 if [ -z ${MDSSURVEY} ]; then
13764 skip_env "mds-survey not found" && return
13767 [ $MDSCOUNT -ge 2 ] &&
13768 skip "skipping now for more than one MDT" && return
13770 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13771 { skip "Need MDS version at least 2.2.51"; return; }
13773 local mds=$(facet_host $SINGLEMDS)
13774 local target=$(do_nodes $mds 'lctl dl' | \
13775 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13777 local cmd1="file_count=1000 thrhi=4"
13778 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13779 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13780 local cmd="$cmd1 $cmd2 $cmd3"
13782 rm -f ${TMP}/mds_survey*
13784 eval $cmd || error "mds-survey with zero-stripe failed"
13785 cat ${TMP}/mds_survey*
13786 rm -f ${TMP}/mds_survey*
13788 run_test 225a "Metadata survey sanity with zero-stripe"
13791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13792 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13793 if [ -z ${MDSSURVEY} ]; then
13794 skip_env "mds-survey not found" && return
13796 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13797 { skip "Need MDS version at least 2.2.51"; return; }
13799 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13800 skip_env "Need to mount OST to test" && return
13803 local mds=$(facet_host $SINGLEMDS)
13804 local target=$(do_nodes $mds 'lctl dl' | \
13805 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13807 local cmd1="file_count=1000 thrhi=4"
13808 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13809 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13810 local cmd="$cmd1 $cmd2 $cmd3"
13812 rm -f ${TMP}/mds_survey*
13814 eval $cmd || error "mds-survey with stripe_count failed"
13815 cat ${TMP}/mds_survey*
13816 rm -f ${TMP}/mds_survey*
13818 run_test 225b "Metadata survey sanity with stripe_count = 1"
13820 mcreate_path2fid () {
13826 local path=$DIR/$tdir/$name
13831 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13832 error "cannot create $desc"
13834 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13836 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13838 fid_path=$($LFS fid2path $MOUNT $fid)
13840 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13842 [ "$path" == "$fid_path" ] ||
13843 error "fid2path returned $fid_path, expected $path"
13845 echo "pass with $path and $fid"
13850 mkdir -p $DIR/$tdir
13852 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13853 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13854 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13855 mcreate_path2fid 0040666 0 0 dir "directory"
13856 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13857 mcreate_path2fid 0100666 0 0 file "regular file"
13858 mcreate_path2fid 0120666 0 0 link "symbolic link"
13859 mcreate_path2fid 0140666 0 0 sock "socket"
13861 run_test 226a "call path2fid and fid2path on files of all type"
13864 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13868 mkdir -p $DIR/$tdir
13869 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13870 error "create remote directory failed"
13871 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13872 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13873 "character special file (null)"
13874 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13875 "character special file (no device)"
13876 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13877 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13878 "block special file (loop)"
13879 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13880 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13881 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13883 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13885 # LU-1299 Executing or running ldd on a truncated executable does not
13886 # cause an out-of-memory condition.
13888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13889 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13890 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13891 chmod +x $MOUNT/date
13893 $MOUNT/date > /dev/null
13894 ldd $MOUNT/date > /dev/null
13897 run_test 227 "running truncated executable does not cause OOM"
13899 # LU-1512 try to reuse idle OI blocks
13901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13902 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13903 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13904 skip "ldiskfs only test" && return
13906 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13907 local myDIR=$DIR/$tdir
13910 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13911 $LCTL set_param fail_loc=0x80001002
13912 createmany -o $myDIR/t- 10000
13913 $LCTL set_param fail_loc=0
13914 # The guard is current the largest FID holder
13916 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13918 local IDX=$(($SEQ % 64))
13920 do_facet $SINGLEMDS sync
13921 # Make sure journal flushed.
13923 local blk1=$(do_facet $SINGLEMDS \
13924 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13925 grep Blockcount | awk '{print $4}')
13927 # Remove old files, some OI blocks will become idle.
13928 unlinkmany $myDIR/t- 10000
13929 # Create new files, idle OI blocks should be reused.
13930 createmany -o $myDIR/t- 2000
13931 do_facet $SINGLEMDS sync
13932 # Make sure journal flushed.
13934 local blk2=$(do_facet $SINGLEMDS \
13935 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13936 grep Blockcount | awk '{print $4}')
13938 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13940 run_test 228a "try to reuse idle OI blocks"
13943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13944 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13945 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13946 skip "ldiskfs only test" && return
13948 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13949 local myDIR=$DIR/$tdir
13952 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13953 $LCTL set_param fail_loc=0x80001002
13954 createmany -o $myDIR/t- 10000
13955 $LCTL set_param fail_loc=0
13956 # The guard is current the largest FID holder
13958 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13960 local IDX=$(($SEQ % 64))
13962 do_facet $SINGLEMDS sync
13963 # Make sure journal flushed.
13965 local blk1=$(do_facet $SINGLEMDS \
13966 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13967 grep Blockcount | awk '{print $4}')
13969 # Remove old files, some OI blocks will become idle.
13970 unlinkmany $myDIR/t- 10000
13973 stop $SINGLEMDS || error "Fail to stop MDT."
13975 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13977 df $MOUNT || error "Fail to df."
13978 # Create new files, idle OI blocks should be reused.
13979 createmany -o $myDIR/t- 2000
13980 do_facet $SINGLEMDS sync
13981 # Make sure journal flushed.
13983 local blk2=$(do_facet $SINGLEMDS \
13984 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13985 grep Blockcount | awk '{print $4}')
13987 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13989 run_test 228b "idle OI blocks can be reused after MDT restart"
13993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13994 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13995 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13996 skip "ldiskfs only test" && return
13998 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13999 local myDIR=$DIR/$tdir
14002 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14003 $LCTL set_param fail_loc=0x80001002
14004 # 20000 files can guarantee there are index nodes in the OI file
14005 createmany -o $myDIR/t- 20000
14006 $LCTL set_param fail_loc=0
14007 # The guard is current the largest FID holder
14009 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14011 local IDX=$(($SEQ % 64))
14013 do_facet $SINGLEMDS sync
14014 # Make sure journal flushed.
14016 local blk1=$(do_facet $SINGLEMDS \
14017 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14018 grep Blockcount | awk '{print $4}')
14020 # Remove old files, some OI blocks will become idle.
14021 unlinkmany $myDIR/t- 20000
14023 # The OI file should become empty now
14025 # Create new files, idle OI blocks should be reused.
14026 createmany -o $myDIR/t- 2000
14027 do_facet $SINGLEMDS sync
14028 # Make sure journal flushed.
14030 local blk2=$(do_facet $SINGLEMDS \
14031 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14032 grep Blockcount | awk '{print $4}')
14034 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14036 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
14038 test_229() { # LU-2482, LU-3448
14039 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
14040 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
14042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14043 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
14047 # Create a file with a released layout and stripe count 2.
14048 $MULTIOP $DIR/$tfile H2c ||
14049 error "failed to create file with released layout"
14051 $GETSTRIPE -v $DIR/$tfile
14053 local pattern=$($GETSTRIPE -L $DIR/$tfile)
14054 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
14056 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
14057 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
14058 stat $DIR/$tfile || error "failed to stat released file"
14060 chown $RUNAS_ID $DIR/$tfile ||
14061 error "chown $RUNAS_ID $DIR/$tfile failed"
14063 chgrp $RUNAS_ID $DIR/$tfile ||
14064 error "chgrp $RUNAS_ID $DIR/$tfile failed"
14066 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
14067 rm $DIR/$tfile || error "failed to remove released file"
14069 run_test 229 "getstripe/stat/rm/attr changes work on released files"
14072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14076 test_mkdir $DIR/$tdir
14077 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
14078 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
14079 [ $mdt_idx -ne 0 ] &&
14080 error "create local directory on wrong MDT $mdt_idx"
14082 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
14083 error "create remote directory failed"
14084 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
14085 [ $mdt_idx -ne $MDTIDX ] &&
14086 error "create remote directory on wrong MDT $mdt_idx"
14088 createmany -o $DIR/$tdir/test_230/t- 10 ||
14089 error "create files on remote directory failed"
14090 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
14091 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
14092 rm -r $DIR/$tdir || error "unlink remote directory failed"
14094 run_test 230a "Create remote directory and files under the remote directory"
14097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14098 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14105 local migrate_dir=$DIR/$tdir/migrate_dir
14106 local other_dir=$DIR/$tdir/other_dir
14108 test_mkdir $DIR/$tdir
14109 test_mkdir -i0 -c1 $migrate_dir
14110 test_mkdir -i0 -c1 $other_dir
14111 for ((i=0; i<10; i++)); do
14112 mkdir -p $migrate_dir/dir_${i}
14113 createmany -o $migrate_dir/dir_${i}/f 10 ||
14114 error "create files under remote dir failed $i"
14117 cp /etc/passwd $migrate_dir/$tfile
14118 cp /etc/passwd $other_dir/$tfile
14119 chattr +SAD $migrate_dir
14120 chattr +SAD $migrate_dir/$tfile
14122 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14123 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14124 local old_dir_mode=$(stat -c%f $migrate_dir)
14125 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
14127 mkdir -p $migrate_dir/dir_default_stripe2
14128 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
14129 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
14131 mkdir -p $other_dir
14132 ln $migrate_dir/$tfile $other_dir/luna
14133 ln $migrate_dir/$tfile $migrate_dir/sofia
14134 ln $other_dir/$tfile $migrate_dir/david
14135 ln -s $migrate_dir/$tfile $other_dir/zachary
14136 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
14137 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
14139 $LFS migrate -m $MDTIDX $migrate_dir ||
14140 error "fails on migrating remote dir to MDT1"
14142 echo "migratate to MDT1, then checking.."
14143 for ((i = 0; i < 10; i++)); do
14144 for file in $(find $migrate_dir/dir_${i}); do
14145 mdt_index=$($LFS getstripe -M $file)
14146 [ $mdt_index == $MDTIDX ] ||
14147 error "$file is not on MDT${MDTIDX}"
14151 # the multiple link file should still in MDT0
14152 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
14153 [ $mdt_index == 0 ] ||
14154 error "$file is not on MDT${MDTIDX}"
14156 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14157 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14158 error " expect $old_dir_flag get $new_dir_flag"
14160 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14161 [ "$old_file_flag" = "$new_file_flag" ] ||
14162 error " expect $old_file_flag get $new_file_flag"
14164 local new_dir_mode=$(stat -c%f $migrate_dir)
14165 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14166 error "expect mode $old_dir_mode get $new_dir_mode"
14168 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14169 [ "$old_file_mode" = "$new_file_mode" ] ||
14170 error "expect mode $old_file_mode get $new_file_mode"
14172 diff /etc/passwd $migrate_dir/$tfile ||
14173 error "$tfile different after migration"
14175 diff /etc/passwd $other_dir/luna ||
14176 error "luna different after migration"
14178 diff /etc/passwd $migrate_dir/sofia ||
14179 error "sofia different after migration"
14181 diff /etc/passwd $migrate_dir/david ||
14182 error "david different after migration"
14184 diff /etc/passwd $other_dir/zachary ||
14185 error "zachary different after migration"
14187 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14188 error "${tfile}_ln different after migration"
14190 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14191 error "${tfile}_ln_other different after migration"
14193 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
14194 [ $stripe_count = 2 ] ||
14195 error "dir strpe_count $d != 2 after migration."
14197 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
14198 [ $stripe_count = 2 ] ||
14199 error "file strpe_count $d != 2 after migration."
14201 #migrate back to MDT0
14204 $LFS migrate -m $MDTIDX $migrate_dir ||
14205 error "fails on migrating remote dir to MDT0"
14207 echo "migrate back to MDT0, checking.."
14208 for file in $(find $migrate_dir); do
14209 mdt_index=$($LFS getstripe -M $file)
14210 [ $mdt_index == $MDTIDX ] ||
14211 error "$file is not on MDT${MDTIDX}"
14214 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14215 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14216 error " expect $old_dir_flag get $new_dir_flag"
14218 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14219 [ "$old_file_flag" = "$new_file_flag" ] ||
14220 error " expect $old_file_flag get $new_file_flag"
14222 local new_dir_mode=$(stat -c%f $migrate_dir)
14223 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14224 error "expect mode $old_dir_mode get $new_dir_mode"
14226 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14227 [ "$old_file_mode" = "$new_file_mode" ] ||
14228 error "expect mode $old_file_mode get $new_file_mode"
14230 diff /etc/passwd ${migrate_dir}/$tfile ||
14231 error "$tfile different after migration"
14233 diff /etc/passwd ${other_dir}/luna ||
14234 error "luna different after migration"
14236 diff /etc/passwd ${migrate_dir}/sofia ||
14237 error "sofia different after migration"
14239 diff /etc/passwd ${other_dir}/zachary ||
14240 error "zachary different after migration"
14242 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14243 error "${tfile}_ln different after migration"
14245 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14246 error "${tfile}_ln_other different after migration"
14248 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
14249 [ $stripe_count = 2 ] ||
14250 error "dir strpe_count $d != 2 after migration."
14252 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
14253 [ $stripe_count = 2 ] ||
14254 error "file strpe_count $d != 2 after migration."
14256 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14258 run_test 230b "migrate directory"
14261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14262 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14263 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14267 local migrate_dir=$DIR/$tdir/migrate_dir
14269 #If migrating directory fails in the middle, all entries of
14270 #the directory is still accessiable.
14271 test_mkdir $DIR/$tdir
14272 test_mkdir -i0 -c1 $migrate_dir
14274 createmany -o $migrate_dir/f 10 ||
14275 error "create files under ${migrate_dir} failed"
14277 #failed after migrating 5 entries
14278 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
14279 do_facet mds1 lctl set_param fail_loc=0x20001801
14280 do_facet mds1 lctl set_param fail_val=5
14281 local t=$(ls $migrate_dir | wc -l)
14282 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
14283 error "migrate should fail after 5 entries"
14285 mkdir $migrate_dir/dir &&
14286 error "mkdir succeeds under migrating directory"
14287 touch $migrate_dir/file &&
14288 error "touch file succeeds under migrating directory"
14290 local u=$(ls $migrate_dir | wc -l)
14291 [ "$u" == "$t" ] || error "$u != $t during migration"
14293 for file in $(find $migrate_dir); do
14294 stat $file || error "stat $file failed"
14297 do_facet mds1 lctl set_param fail_loc=0
14298 do_facet mds1 lctl set_param fail_val=0
14300 $LFS migrate -m $MDTIDX $migrate_dir ||
14301 error "migrate open files should failed with open files"
14303 echo "Finish migration, then checking.."
14304 for file in $(find $migrate_dir); do
14305 mdt_index=$($LFS getstripe -M $file)
14306 [ $mdt_index == $MDTIDX ] ||
14307 error "$file is not on MDT${MDTIDX}"
14310 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14312 run_test 230c "check directory accessiblity if migration is failed"
14315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14316 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14319 local migrate_dir=$DIR/$tdir/migrate_dir
14323 test_mkdir $DIR/$tdir
14324 test_mkdir -i0 -c1 $migrate_dir
14326 for ((i=0; i<100; i++)); do
14327 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
14328 createmany -o $migrate_dir/dir_${i}/f 100 ||
14329 error "create files under remote dir failed $i"
14332 $LFS migrate -m $MDTIDX $migrate_dir ||
14333 error "migrate remote dir error"
14335 echo "Finish migration, then checking.."
14336 for file in $(find $migrate_dir); do
14337 mdt_index=$($LFS getstripe -M $file)
14338 [ $mdt_index == $MDTIDX ] ||
14339 error "$file is not on MDT${MDTIDX}"
14342 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14344 run_test 230d "check migrate big directory"
14347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14348 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14354 mkdir -p $DIR/$tdir
14355 mkdir $DIR/$tdir/migrate_dir
14356 mkdir $DIR/$tdir/other_dir
14357 touch $DIR/$tdir/migrate_dir/a
14358 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14359 ls $DIR/$tdir/other_dir
14361 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14362 error "migrate dir fails"
14364 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14365 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14367 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14368 [ $mdt_index == 0 ] || error "a is not on MDT0"
14370 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14371 error "migrate dir fails"
14373 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14374 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14376 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14377 [ $mdt_index == 1 ] || error "a is not on MDT1"
14379 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14380 [ $mdt_index == 1 ] || error "b is not on MDT1"
14382 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14383 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14385 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14387 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14389 run_test 230e "migrate mulitple local link files"
14392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14393 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14397 mkdir -p $DIR/$tdir
14398 mkdir $DIR/$tdir/migrate_dir
14399 $LFS mkdir -i1 $DIR/$tdir/other_dir
14400 touch $DIR/$tdir/migrate_dir/a
14401 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14402 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14403 ls $DIR/$tdir/other_dir
14405 # a should be migrated to MDT1, since no other links on MDT0
14406 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14407 error "#1 migrate dir fails"
14408 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14409 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14410 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14411 [ $mdt_index == 1 ] || error "a is not on MDT1"
14413 # a should stay on MDT1, because it is a mulitple link file
14414 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14415 error "#2 migrate dir fails"
14416 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14417 [ $mdt_index == 1 ] || error "a is not on MDT1"
14419 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14420 error "#3 migrate dir fails"
14422 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14423 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14424 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14426 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14427 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14429 # a should be migrated to MDT0, since no other links on MDT1
14430 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14431 error "#4 migrate dir fails"
14432 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14433 [ $mdt_index == 0 ] || error "a is not on MDT0"
14435 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14437 run_test 230f "migrate mulitple remote link files"
14440 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14441 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14443 mkdir -p $DIR/$tdir/migrate_dir
14445 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14446 error "migrating dir to non-exist MDT succeeds"
14449 run_test 230g "migrate dir to non-exist MDT"
14452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14453 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14454 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14455 skip "Need MDS version at least 2.7.64" && return
14458 mkdir -p $DIR/$tdir/migrate_dir
14460 $LFS migrate -m1 $DIR &&
14461 error "migrating mountpoint1 should fail"
14463 $LFS migrate -m1 $DIR/$tdir/.. &&
14464 error "migrating mountpoint2 should fail"
14466 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14467 error "migrating $tdir fail"
14469 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14470 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14472 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14473 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14476 run_test 230h "migrate .. and root"
14479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14482 mkdir -p $DIR/$tdir/migrate_dir
14484 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14485 error "migration fails with a tailing slash"
14487 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14488 error "migration fails with two tailing slashes"
14490 run_test 230i "lfs migrate -m tolerates trailing slashes"
14494 # For simplicity this test assumes that max_pages_per_rpc
14495 # is the same across all OSCs
14496 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14497 local bulk_size=$((max_pages * 4096))
14498 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14501 mkdir -p $DIR/$tdir
14502 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14503 error "failed to set stripe with -S ${brw_size}M option"
14505 # clear the OSC stats
14506 $LCTL set_param osc.*.stats=0 &>/dev/null
14509 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14510 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14511 oflag=direct &>/dev/null || error "dd failed"
14513 sync; sleep 1; sync # just to be safe
14514 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14515 if [ x$nrpcs != "x1" ]; then
14516 $LCTL get_param osc.*.stats
14517 error "found $nrpcs ost_write RPCs, not 1 as expected"
14521 # Drop the OSC cache, otherwise we will read from it
14522 cancel_lru_locks osc
14524 # clear the OSC stats
14525 $LCTL set_param osc.*.stats=0 &>/dev/null
14527 # Client reads $bulk_size.
14528 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14529 iflag=direct &>/dev/null || error "dd failed"
14531 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14532 if [ x$nrpcs != "x1" ]; then
14533 $LCTL get_param osc.*.stats
14534 error "found $nrpcs ost_read RPCs, not 1 as expected"
14537 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14540 mkdir -p $DIR/$tdir
14542 for i in {0..1023}; do
14543 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14544 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14545 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14549 run_test 231b "must not assert on fully utilized OST request buffer"
14552 mkdir -p $DIR/$tdir
14553 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14555 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14556 do_facet ost1 $LCTL set_param fail_loc=0x31c
14558 # ignore dd failure
14559 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14561 do_facet ost1 $LCTL set_param fail_loc=0
14562 umount_client $MOUNT || error "umount failed"
14563 mount_client $MOUNT || error "mount failed"
14564 stop ost1 || error "cannot stop ost1"
14565 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14567 run_test 232a "failed lock should not block umount"
14570 mkdir -p $DIR/$tdir
14571 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14572 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
14574 cancel_lru_locks osc
14576 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14577 do_facet ost1 $LCTL set_param fail_loc=0x31c
14580 $LFS data_version $DIR/$tdir/$tfile || true
14582 do_facet ost1 $LCTL set_param fail_loc=0
14583 umount_client $MOUNT || error "umount failed"
14584 mount_client $MOUNT || error "mount failed"
14585 stop ost1 || error "cannot stop ost1"
14586 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14588 run_test 232b "failed data version lock should not block umount"
14591 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14592 { skip "Need MDS version at least 2.3.64"; return; }
14593 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14595 local fid=$($LFS path2fid $MOUNT)
14596 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14597 error "cannot access $MOUNT using its FID '$fid'"
14599 run_test 233a "checking that OBF of the FS root succeeds"
14602 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14603 { skip "Need MDS version at least 2.5.90"; return; }
14604 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14606 local fid=$($LFS path2fid $MOUNT/.lustre)
14607 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14608 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14610 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14611 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14612 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14614 run_test 233b "checking that OBF of the FS .lustre succeeds"
14617 local p="$TMP/sanityN-$TESTNAME.parameters"
14618 save_lustre_params client "llite.*.xattr_cache" > $p
14619 lctl set_param llite.*.xattr_cache 1 ||
14620 { skip "xattr cache is not supported"; return 0; }
14622 mkdir -p $DIR/$tdir || error "mkdir failed"
14623 touch $DIR/$tdir/$tfile || error "touch failed"
14624 # OBD_FAIL_LLITE_XATTR_ENOMEM
14625 $LCTL set_param fail_loc=0x1405
14626 getfattr -n user.attr $DIR/$tdir/$tfile &&
14627 error "getfattr should have failed with ENOMEM"
14628 $LCTL set_param fail_loc=0x0
14631 restore_lustre_params < $p
14634 run_test 234 "xattr cache should not crash on ENOMEM"
14637 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14638 skip "Need MDS version at least 2.4.52" && return
14639 flock_deadlock $DIR/$tfile
14644 124) error "process hangs on a deadlock"
14646 *) error "error executing flock_deadlock $DIR/$tfile"
14650 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14654 check_swap_layouts_support && return 0
14655 test_mkdir -c1 $DIR/$tdir
14657 local ref1=/etc/passwd
14658 local ref2=/etc/group
14659 local file1=$DIR/$tdir/f1
14660 local file2=$DIR/$tdir/f2
14662 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14663 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14664 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14665 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14666 local fd=$(free_fd)
14667 local cmd="exec $fd<>$file2"
14670 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14671 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14674 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14679 run_test 236 "Layout swap on open unlinked file"
14681 # test to verify file handle related system calls
14682 # (name_to_handle_at/open_by_handle_at)
14683 # The new system calls are supported in glibc >= 2.14.
14686 echo "Test file_handle syscalls" > $DIR/$tfile ||
14687 error "write failed"
14688 check_fhandle_syscalls $DIR/$tfile ||
14689 error "check_fhandle_syscalls failed"
14691 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14693 # LU-4659 linkea consistency
14695 local server_version=$(lustre_version_code $SINGLEMDS)
14697 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14698 [[ $server_version -gt $(version_code 2.5.1) &&
14699 $server_version -lt $(version_code 2.5.50) ]] ||
14700 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14703 ln $DIR/$tfile $DIR/$tfile.lnk
14704 touch $DIR/$tfile.new
14705 mv $DIR/$tfile.new $DIR/$tfile
14706 local fid1=$($LFS path2fid $DIR/$tfile)
14707 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14708 local path1=$($LFS fid2path $FSNAME "$fid1")
14709 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14710 local path2=$($LFS fid2path $FSNAME "$fid2")
14711 [ $tfile.lnk == $path2 ] ||
14712 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14715 run_test 238 "Verify linkea consistency"
14718 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14719 skip "Need MDS version at least 2.5.60" && return
14720 local list=$(comma_list $(mdts_nodes))
14722 mkdir -p $DIR/$tdir
14723 createmany -o $DIR/$tdir/f- 5000
14724 unlinkmany $DIR/$tdir/f- 5000
14725 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
14726 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14727 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14728 osp.*MDT*.sync_in_flight" | calc_sum)
14729 [ "$changes" -eq 0 ] || error "$changes not synced"
14731 run_test 239 "osp_sync test"
14733 test_239a() { #LU-5297
14734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14736 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14737 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14738 chgrp $RUNAS_GID $DIR/$tfile
14739 wait_delete_completed
14741 run_test 239a "process invalid osp sync record correctly"
14743 test_239b() { #LU-5297
14744 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14746 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14747 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14748 chgrp $RUNAS_GID $DIR/$tfile1
14749 wait_delete_completed
14750 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14752 chgrp $RUNAS_GID $DIR/$tfile2
14753 wait_delete_completed
14755 run_test 239b "process osp sync record with ENOMEM error correctly"
14758 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14759 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14761 mkdir -p $DIR/$tdir
14763 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14764 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14765 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14766 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14768 umount_client $MOUNT || error "umount failed"
14769 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14770 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14771 mount_client $MOUNT || error "failed to mount client"
14773 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14774 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14776 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14779 for LOOP in $(seq $1); do
14780 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14781 cancel_lru_locks $OSC || true
14786 for LOOP in $(seq $1); do
14787 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14788 iflag=direct 2>/dev/null
14792 test_241a() { # was test_241
14793 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14795 cancel_lru_locks $OSC
14796 test_241_bio 1000 &
14801 run_test 241a "bio vs dio"
14804 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14806 test_241_dio 1000 &
14811 run_test 241b "dio vs dio"
14814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14815 mkdir -p $DIR/$tdir
14816 touch $DIR/$tdir/$tfile
14818 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14819 do_facet mds1 lctl set_param fail_loc=0x105
14820 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14822 do_facet mds1 lctl set_param fail_loc=0
14823 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14825 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14829 test_mkdir $DIR/$tdir
14830 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14832 run_test 243 "various group lock tests"
14836 test_mkdir $DIR/$tdir
14837 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14838 sendfile_grouplock $DIR/$tdir/$tfile || \
14839 error "sendfile+grouplock failed"
14842 run_test 244 "sendfile with group lock tests"
14845 local flagname="multi_mod_rpcs"
14846 local connect_data_name="max_mod_rpcs"
14849 # check if multiple modify RPCs flag is set
14850 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14851 grep "connect_flags:")
14854 echo "$out" | grep -qw $flagname
14855 if [ $? -ne 0 ]; then
14856 echo "connect flag $flagname is not set"
14860 # check if multiple modify RPCs data is set
14861 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14864 echo "$out" | grep -qw $connect_data_name ||
14865 error "import should have connect data $connect_data_name"
14867 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14869 test_246() { # LU-7371
14870 remote_ost_nodsh && skip "remote OST with nodsh" && return
14871 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14872 skip "Need OST version >= 2.7.62" && return 0
14873 do_facet ost1 $LCTL set_param fail_val=4095
14874 #define OBD_FAIL_OST_READ_SIZE 0x234
14875 do_facet ost1 $LCTL set_param fail_loc=0x234
14876 $LFS setstripe $DIR/$tfile -i 0 -c 1
14877 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14878 cancel_lru_locks $FSNAME-OST0000
14879 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14881 run_test 246 "Read file of size 4095 should return right length"
14887 umount_client $submount
14892 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14894 { skip "Fileset feature is not supported"; return; }
14896 local submount=${MOUNT}_$tdir
14899 mkdir -p $submount || error "mkdir $submount failed"
14900 FILESET="$FILESET/$tdir" mount_client $submount ||
14901 error "mount $submount failed"
14902 trap "cleanup_247 $submount" EXIT
14903 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14904 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14905 error "read $MOUNT/$tdir/$tfile failed"
14906 cleanup_247 $submount
14908 run_test 247a "mount subdir as fileset"
14911 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14912 { skip "Fileset feature is not supported"; return; }
14914 local submount=${MOUNT}_$tdir
14916 rm -rf $MOUNT/$tdir
14917 mkdir -p $submount || error "mkdir $submount failed"
14919 FILESET="$FILESET/$tdir" mount_client $submount &&
14920 error "mount $submount should fail"
14923 run_test 247b "mount subdir that dose not exist"
14926 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14927 { skip "Fileset feature is not supported"; return; }
14929 local submount=${MOUNT}_$tdir
14931 mkdir -p $MOUNT/$tdir/dir1
14932 mkdir -p $submount || error "mkdir $submount failed"
14933 trap "cleanup_247 $submount" EXIT
14934 FILESET="$FILESET/$tdir" mount_client $submount ||
14935 error "mount $submount failed"
14936 local fid=$($LFS path2fid $MOUNT/)
14937 $LFS fid2path $submount $fid && error "fid2path should fail"
14938 cleanup_247 $submount
14940 run_test 247c "running fid2path outside root"
14943 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14944 { skip "Fileset feature is not supported"; return; }
14946 local submount=${MOUNT}_$tdir
14948 mkdir -p $MOUNT/$tdir/dir1
14949 mkdir -p $submount || error "mkdir $submount failed"
14950 FILESET="$FILESET/$tdir" mount_client $submount ||
14951 error "mount $submount failed"
14952 trap "cleanup_247 $submount" EXIT
14953 local fid=$($LFS path2fid $submount/dir1)
14954 $LFS fid2path $submount $fid || error "fid2path should succeed"
14955 cleanup_247 $submount
14957 run_test 247d "running fid2path inside root"
14961 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14963 { skip "Fileset feature is not supported"; return; }
14965 local submount=${MOUNT}_$tdir
14968 mkdir -p $submount || error "mkdir $submount failed"
14969 FILESET="$FILESET/.." mount_client $submount &&
14970 error "mount $submount should fail"
14973 run_test 247e "mount .. as fileset"
14976 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14977 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14979 # create a large file for fast read verification
14980 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14982 # make sure the file is created correctly
14983 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14984 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14986 echo "Test 1: verify that fast read is 4 times faster on cache read"
14988 # small read with fast read enabled
14989 $LCTL set_param -n llite.*.fast_read=1
14990 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14991 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14992 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14993 # small read with fast read disabled
14994 $LCTL set_param -n llite.*.fast_read=0
14995 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14996 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14997 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14999 # verify that fast read is 4 times faster for cache read
15000 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
15001 error_not_in_vm "fast read was not 4 times faster: " \
15002 "$t_fast vs $t_slow"
15004 echo "Test 2: verify the performance between big and small read"
15005 $LCTL set_param -n llite.*.fast_read=1
15007 # 1k non-cache read
15008 cancel_lru_locks osc
15009 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15010 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15011 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15013 # 1M non-cache read
15014 cancel_lru_locks osc
15015 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15016 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15017 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15019 # verify that big IO is not 4 times faster than small IO
15020 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
15021 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
15023 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
15026 run_test 248 "fast read verification"
15028 test_249() { # LU-7890
15030 $SETSTRIPE -c 1 $DIR/$tfile
15032 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
15033 skip "Need at least version 2.8.54"
15035 # Offset 2T == 4k * 512M
15036 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
15037 error "dd to 2T offset failed"
15039 run_test 249 "Write above 2T file size"
15042 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
15043 && skip "no 16TB file size limit on ZFS" && return
15045 $SETSTRIPE -c 1 $DIR/$tfile
15046 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
15047 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
15048 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
15049 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
15050 conv=notrunc,fsync && error "append succeeded"
15053 run_test 250 "Write above 16T limit"
15056 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
15058 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
15059 #Skip once - writing the first stripe will succeed
15060 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15061 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
15062 error "short write happened"
15064 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15065 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
15066 error "short read happened"
15070 run_test 251 "Handling short read and write correctly"
15080 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15081 remote_ost_nodsh && skip "remote OST with nodsh" && return
15082 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
15083 "$(facet_fstype mds1)" != "ldiskfs" ]; then
15084 skip "ldiskfs only test"
15088 # check lr_reader on OST0000
15090 dev=$(facet_device $tgt)
15091 out=$(do_facet $tgt $LR_READER $dev)
15092 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15094 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
15095 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
15096 error "Invalid uuid returned by $LR_READER on target $tgt"
15097 echo -e "uuid returned by $LR_READER is '$uuid'\n"
15099 # check lr_reader -c on MDT0000
15101 dev=$(facet_device $tgt)
15102 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
15103 echo "$LR_READER does not support additional options"
15106 out=$(do_facet $tgt $LR_READER -c $dev)
15107 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15109 num=$(echo "$out" | grep -c "mdtlov")
15110 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
15111 error "Invalid number of mdtlov clients returned by $LR_READER"
15112 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
15114 # check lr_reader -cr on MDT0000
15115 out=$(do_facet $tgt $LR_READER -cr $dev)
15116 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15118 echo "$out" | grep -q "^reply_data:$" ||
15119 error "$LR_READER should have returned 'reply_data' section"
15120 num=$(echo "$out" | grep -c "client_generation")
15121 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
15123 run_test 252 "check lr_reader tool"
15125 test_253_fill_ost() {
15126 local size_mb #how many MB should we write to pass watermark
15127 local lwm=$3 #low watermark
15128 local free_10mb #10% of free space
15130 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15131 size_mb=$((free_kb / 1024 - lwm))
15132 free_10mb=$((free_kb / 10240))
15133 #If 10% of free space cross low watermark use it
15134 if (( free_10mb > size_mb )); then
15137 #At least we need to store 1.1 of difference between
15138 #free space and low watermark
15139 size_mb=$((size_mb + size_mb / 10))
15141 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
15142 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
15143 oflag=append conv=notrunc
15148 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15149 echo "OST still has $((free_kb / 1024)) mbytes free"
15156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15157 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15158 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
15160 local ost_name=$($LFS osts |
15161 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
15163 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
15164 do_facet $SINGLEMDS $LCTL get_param -n \
15165 osp.$mdtosc_proc1.reserved_mb_high ||
15166 { skip "remote MDS does not support reserved_mb_high" &&
15171 wait_delete_completed
15174 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
15175 osp.$mdtosc_proc1.reserved_mb_high)
15176 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
15177 osp.$mdtosc_proc1.reserved_mb_low)
15178 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
15180 if ! combined_mgs_mds ; then
15183 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
15184 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
15185 error "Adding $ost_name to pool failed"
15187 # Wait for client to see a OST at pool
15188 wait_update $HOSTNAME "$LCTL get_param -n
15189 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
15190 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
15191 error "Client can not see the pool"
15192 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
15193 error "Setstripe failed"
15195 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
15196 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
15197 echo "OST still has $((blocks/1024)) mbytes free"
15199 local new_lwm=$((blocks/1024-10))
15200 do_facet $SINGLEMDS $LCTL set_param \
15201 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
15202 do_facet $SINGLEMDS $LCTL set_param \
15203 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
15205 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15207 #First enospc could execute orphan deletion so repeat.
15208 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15210 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15211 osp.$mdtosc_proc1.prealloc_status)
15212 echo "prealloc_status $oa_status"
15214 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
15215 error "File creation should fail"
15216 #object allocation was stopped, but we still able to append files
15217 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
15218 error "Append failed"
15219 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
15221 wait_delete_completed
15225 for i in $(seq 10 12); do
15226 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
15227 error "File creation failed after rm";
15230 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15231 osp.$mdtosc_proc1.prealloc_status)
15232 echo "prealloc_status $oa_status"
15234 if (( oa_status != 0 )); then
15235 error "Object allocation still disable after rm"
15237 do_facet $SINGLEMDS $LCTL set_param \
15238 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
15239 do_facet $SINGLEMDS $LCTL set_param \
15240 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
15243 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
15244 error "Remove $ost_name from pool failed"
15245 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15246 error "Pool destroy fialed"
15248 if ! combined_mgs_mds ; then
15252 run_test 253 "Check object allocation limit"
15257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15258 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15259 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
15260 { skip "MDS does not support changelog_size" && return; }
15262 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15263 echo "Registered as changelog user $cl_user"
15265 $LFS changelog_clear $MDT0 $cl_user 0
15267 local size1=$(do_facet mds1 \
15268 $LCTL get_param -n mdd.$MDT0.changelog_size)
15269 echo "Changelog size $size1"
15272 $LFS mkdir -i 0 $DIR/$tdir
15274 mkdir -p $DIR/$tdir/pics/2008/zachy
15275 touch $DIR/$tdir/pics/2008/zachy/timestamp
15276 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
15277 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15278 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15279 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15280 rm $DIR/$tdir/pics/desktop.jpg
15282 local size2=$(do_facet mds1 \
15283 $LCTL get_param -n mdd.$MDT0.changelog_size)
15284 echo "Changelog size after work $size2"
15286 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15288 if (( size2 <= size1 )); then
15289 error "Changelog size after work should be greater than original"
15293 run_test 254 "Check changelog size"
15300 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
15301 awk -F: '{print $2}' | grep $type > /dev/null
15302 if [ $? -ne 0 ]; then
15312 lfs ladvise -a willread $file > /dev/null 2>&1
15313 if [ $? -eq 0 ]; then
15317 lfs ladvise -a willread $file 2>&1 |
15318 grep "Inappropriate ioctl for device" > /dev/null
15319 if [ $? -eq 0 ]; then
15326 bc <<<"scale=2; ($1 - $2) * 100 / $2"
15329 # run a random read IO workload
15330 # usage: random_read_iops <filename> <filesize> <iosize>
15331 random_read_iops() {
15334 local iosize=${3:-4096}
15336 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
15337 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
15340 drop_file_oss_cache() {
15344 $LFS ladvise -a dontneed $file 2>/dev/null ||
15345 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
15348 ladvise_willread_performance()
15351 local average_origin=0
15352 local average_cache=0
15353 local average_ladvise=0
15355 for ((i = 1; i <= $repeat; i++)); do
15356 echo "Iter $i/$repeat: reading without willread hint"
15357 cancel_lru_locks osc
15358 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15359 local speed_origin=$(random_read_iops $DIR/$tfile $size)
15360 echo "Iter $i/$repeat: uncached speed: $speed_origin"
15361 average_origin=$(bc <<<"$average_origin + $speed_origin")
15363 cancel_lru_locks osc
15364 local speed_cache=$(random_read_iops $DIR/$tfile $size)
15365 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
15366 average_cache=$(bc <<<"$average_cache + $speed_cache")
15368 cancel_lru_locks osc
15369 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15370 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
15371 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
15372 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
15373 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
15375 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
15376 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
15377 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
15379 speedup_cache=$(percent $average_cache $average_origin)
15380 speedup_ladvise=$(percent $average_ladvise $average_origin)
15382 echo "Average uncached read: $average_origin"
15383 echo "Average speedup with OSS cached read: " \
15384 "$average_cache = +$speedup_cache%"
15385 echo "Average speedup with ladvise willread: " \
15386 "$average_ladvise = +$speedup_ladvise%"
15388 local lowest_speedup=20
15389 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15390 echo "Speedup with OSS cached read less than $lowest_speedup%," \
15391 "got $average_cache%. Skipping ladvise willread check."
15395 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15396 # it is still good to run until then to exercise 'ladvise willread'
15397 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15398 [ "$(facet_fstype ost1)" = "zfs" ] &&
15399 echo "osd-zfs does not support dontneed or drop_caches" &&
15402 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15403 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15404 error_not_in_vm "Speedup with willread is less than " \
15405 "$lowest_speedup%, got $average_ladvise%"
15409 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15410 skip "lustre < 2.8.54 does not support ladvise " && return
15411 remote_ost_nodsh && skip "remote OST with nodsh" && return
15413 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15415 ladvise_no_type willread $DIR/$tfile &&
15416 skip "willread ladvise is not supported" && return
15418 ladvise_no_ioctl $DIR/$tfile &&
15419 skip "ladvise ioctl is not supported" && return
15422 local size=$((size_mb * 1048576))
15423 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15424 error "dd to $DIR/$tfile failed"
15426 lfs ladvise -a willread $DIR/$tfile ||
15427 error "Ladvise failed with no range argument"
15429 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15430 error "Ladvise failed with no -l or -e argument"
15432 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15433 error "Ladvise failed with only -e argument"
15435 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15436 error "Ladvise failed with only -l argument"
15438 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15439 error "End offset should not be smaller than start offset"
15441 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15442 error "End offset should not be equal to start offset"
15444 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15445 error "Ladvise failed with overflowing -s argument"
15447 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15448 error "Ladvise failed with overflowing -e argument"
15450 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15451 error "Ladvise failed with overflowing -l argument"
15453 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15454 error "Ladvise succeeded with conflicting -l and -e arguments"
15456 echo "Synchronous ladvise should wait"
15458 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15459 do_nodes $(comma_list $(osts_nodes)) \
15460 $LCTL set_param fail_val=$delay fail_loc=0x237
15462 local start_ts=$SECONDS
15463 lfs ladvise -a willread $DIR/$tfile ||
15464 error "Ladvise failed with no range argument"
15465 local end_ts=$SECONDS
15466 local inteval_ts=$((end_ts - start_ts))
15468 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15469 error "Synchronous advice didn't wait reply"
15472 echo "Asynchronous ladvise shouldn't wait"
15473 local start_ts=$SECONDS
15474 lfs ladvise -a willread -b $DIR/$tfile ||
15475 error "Ladvise failed with no range argument"
15476 local end_ts=$SECONDS
15477 local inteval_ts=$((end_ts - start_ts))
15479 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15480 error "Asynchronous advice blocked"
15483 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15484 ladvise_willread_performance
15486 run_test 255a "check 'lfs ladvise -a willread'"
15492 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15496 remote_ost_nodsh && skip "remote OST with nodsh" && return
15498 lfs setstripe -c 1 -i 0 $DIR/$tfile
15500 ladvise_no_type dontneed $DIR/$tfile &&
15501 skip "dontneed ladvise is not supported" && return
15503 ladvise_no_ioctl $DIR/$tfile &&
15504 skip "ladvise ioctl is not supported" && return
15506 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15507 skip "lustre < 2.8.54 does not support ladvise" && return
15509 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15510 [ "$(facet_fstype ost1)" = "zfs" ] &&
15511 skip "zfs-osd does not support 'ladvise dontneed'" && return
15514 local size=$((size_mb * 1048576))
15515 # In order to prevent disturbance of other processes, only check 3/4
15516 # of the memory usage
15517 local kibibytes=$((size_mb * 1024 * 3 / 4))
15519 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15520 error "dd to $DIR/$tfile failed"
15522 local total=$(facet_meminfo ost1 MemTotal)
15523 echo "Total memory: $total KiB"
15525 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15526 local before_read=$(facet_meminfo ost1 Cached)
15527 echo "Cache used before read: $before_read KiB"
15529 lfs ladvise -a willread $DIR/$tfile ||
15530 error "Ladvise willread failed"
15531 local after_read=$(facet_meminfo ost1 Cached)
15532 echo "Cache used after read: $after_read KiB"
15534 lfs ladvise -a dontneed $DIR/$tfile ||
15535 error "Ladvise dontneed again failed"
15536 local no_read=$(facet_meminfo ost1 Cached)
15537 echo "Cache used after dontneed ladvise: $no_read KiB"
15539 if [ $total -lt $((before_read + kibibytes)) ]; then
15540 echo "Memory is too small, abort checking"
15544 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15545 error "Ladvise willread should use more memory" \
15546 "than $kibibytes KiB"
15549 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15550 error "Ladvise dontneed should release more memory" \
15551 "than $kibibytes KiB"
15554 run_test 255b "check 'lfs ladvise -a dontneed'"
15563 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
15564 skip "lustre < 2.10.53 does not support lockahead" && return
15566 test_mkdir -p $DIR/$tdir
15567 $SETSTRIPE -i 0 $DIR/$tdir
15569 #test 10 returns only success/failure
15571 lockahead_test -d $DIR/$tdir -t $i
15573 if [ $rc -eq 255 ]; then
15574 error "Ladvise test${i} failed, ${rc}"
15577 #test 11 counts lock enqueue requests, all others count new locks
15579 count=$(do_facet ost1 \
15580 $LCTL get_param -n ost.OSS.ost.stats)
15581 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
15583 lockahead_test -d $DIR/$tdir -t $i
15585 if [ $rc -eq 255 ]; then
15586 error "Ladvise test${i} failed, ${rc}"
15589 new_count=$(do_facet ost1 \
15590 $LCTL get_param -n ost.OSS.ost.stats)
15591 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
15592 awk '{ print $2 }')
15594 difference="$((new_count - count))"
15595 if [ $difference -ne $rc ]; then
15596 error "Ladvise test${i}, bad enqueue count, returned " \
15597 "${rc}, actual ${difference}"
15600 for i in $(seq 12 21); do
15601 # If we do not do this, we run the risk of having too many
15602 # locks and starting lock cancellation while we are checking
15604 cancel_lru_locks osc
15606 count=$($LCTL get_param -n \
15607 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15609 lockahead_test -d $DIR/$tdir -t $i
15611 if [ $rc -eq 255 ]; then
15612 error "Ladvise test ${i} failed, ${rc}"
15615 new_count=$($LCTL get_param -n \
15616 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15617 difference="$((new_count - count))"
15619 # Test 15 output is divided by 100 to map down to valid return
15620 if [ $i -eq 15 ]; then
15624 if [ $difference -ne $rc ]; then
15625 error "Ladvise test ${i}, bad lock count, returned " \
15626 "${rc}, actual ${difference}"
15630 #test 22 returns only success/failure
15632 lockahead_test -d $DIR/$tdir -t $i
15634 if [ $rc -eq 255 ]; then
15635 error "Ladvise test${i} failed, ${rc}"
15639 run_test 255c "suite of ladvise lockahead tests"
15646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15648 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15649 skip "ldiskfs only test" && return
15651 mdt_dev=$(mdsdevname 1)
15653 cl_user=$(do_facet mds1 \
15654 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15655 if [[ -n $cl_user ]]; then
15656 skip "active changelog user"
15660 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15661 echo "Registered as changelog user $cl_user"
15664 mkdir -p $DIR/$tdir
15666 $LFS changelog_clear $MDT0 $cl_user 0
15669 touch $DIR/$tdir/{1..10}
15672 stop mds1 || error "Fail to stop MDT."
15675 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15677 #after mount new plainllog is used
15678 touch $DIR/$tdir/{11..19}
15680 local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15681 cat_sl=$(do_facet mds1 \
15682 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15683 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15684 do_facet mds1 rm $TEMP256FILE
15686 if (( cat_sl != 2 )); then
15687 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15688 error "Changelog catalog has wrong number of slots $cat_sl"
15691 $LFS changelog_clear $MDT0 $cl_user 0
15694 TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15695 cat_sl=$(do_facet mds1 \
15696 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15697 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15698 do_facet mds1 rm $TEMP256FILE
15700 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15702 if (( cat_sl == 2 )); then
15703 error "Empty plain llog was not deleted from changelog catalog"
15705 if (( cat_sl != 1 )); then
15706 error "Active plain llog shouldn\`t be deleted from catalog"
15709 run_test 256 "Check llog delete for empty and not full state"
15712 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15713 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15714 skip "Need MDS version at least 2.8.55" && return
15716 test_mkdir $DIR/$tdir
15718 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15719 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15722 #define OBD_FAIL_MDS_XATTR_REP 0x161
15723 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15724 local facet=mds$((mdtidx + 1))
15725 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15726 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15728 stop $facet || error "stop MDS failed"
15729 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15730 error "start MDS fail"
15732 run_test 257 "xattr locks are not lost"
15734 # Verify we take the i_mutex when security requires it
15736 #define OBD_FAIL_IMUTEX_SEC 0x141c
15737 $LCTL set_param fail_loc=0x141c
15739 chmod u+s $DIR/$tfile
15740 chmod a+rwx $DIR/$tfile
15741 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15743 if [ $RC -ne 0 ]; then
15744 error "error, failed to take i_mutex, rc=$?"
15750 # Verify we do NOT take the i_mutex in the normal case
15752 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15753 $LCTL set_param fail_loc=0x141d
15756 chmod a+rw $DIR/$tfile
15757 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15759 if [ $RC -ne 0 ]; then
15760 error "error, took i_mutex unnecessarily, rc=$?"
15765 run_test 258b "verify i_mutex security behavior"
15768 #define OBD_FAIL_MDC_CLOSE 0x806
15769 $LCTL set_param fail_loc=0x80000806
15773 run_test 260 "Check mdc_close fail"
15775 ### Data-on-MDT sanity tests ###
15778 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15779 skip "Need MDS version at least 2.10.55" && return
15782 local dom=$DIR/$tdir/dom_file
15783 local tmp=$DIR/$tdir/tmp_file
15785 mkdir -p $DIR/$tdir
15787 # basic checks for DoM component creation
15788 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
15789 error "Can set MDT layout to non-first entry"
15791 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
15792 error "Can define multiple entries as MDT layout"
15794 $LFS setstripe -E 1M -L mdt $dom ||
15795 error "Can't create DoM layout"
15797 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
15798 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
15799 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
15801 local mdtidx=$($GETSTRIPE -M $dom)
15802 local mdtname=MDT$(printf %04x $mdtidx)
15803 local facet=mds$((mdtidx + 1))
15804 local space_check=1
15806 # Skip free space checks with ZFS
15807 if [ "$(facet_fstype $facet)" == "zfs" ]; then
15813 local mdtfree1=$(do_facet $facet \
15814 lctl get_param -n osd*.*$mdtname.kbytesfree)
15815 dd if=/dev/urandom of=$tmp bs=1024 count=100
15816 # check also direct IO along write
15817 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
15819 cmp $tmp $dom || error "file data is different"
15820 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
15821 if [ $space_check == 1 ]; then
15822 local mdtfree2=$(do_facet $facet \
15823 lctl get_param -n osd*.*$mdtname.kbytesfree)
15824 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15825 error "MDT free space is wrong after write"
15829 $TRUNCATE $dom 10000
15830 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
15831 if [ $space_check == 1 ]; then
15832 mdtfree1=$(do_facet $facet \
15833 lctl get_param -n osd*.*$mdtname.kbytesfree)
15834 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
15835 error "MDT free space is wrong after truncate"
15841 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
15842 if [ $space_check == 1 ]; then
15843 mdtfree2=$(do_facet $facet \
15844 lctl get_param -n osd*.*$mdtname.kbytesfree)
15845 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15846 error "MDT free space is wrong after append"
15851 if [ $space_check == 1 ]; then
15852 mdtfree1=$(do_facet $facet \
15853 lctl get_param -n osd*.*$mdtname.kbytesfree)
15854 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
15855 error "MDT free space is wrong after removal"
15858 # combined striping
15859 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
15860 error "Can't create DoM + OST striping"
15862 dd if=/dev/urandom of=$tmp bs=1024 count=2000
15863 # check also direct IO along write
15864 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
15866 cmp $tmp $dom || error "file data is different"
15867 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
15873 run_test 270a "DoM: basic functionality tests"
15876 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15877 skip "Need MDS version at least 2.10.55" && return
15879 local dom=$DIR/$tdir/dom_file
15880 local max_size=1048576
15882 mkdir -p $DIR/$tdir
15883 $LFS setstripe -E $max_size -L mdt $dom
15885 # truncate over the limit
15886 $TRUNCATE $dom $(($max_size + 1)) &&
15887 error "successful truncate over the maximum size"
15888 # write over the limit
15889 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
15890 error "successful write over the maximum size"
15891 # append over the limit
15892 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
15893 echo "12345" >> $dom && error "successful append over the maximum size"
15898 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
15901 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15902 skip "Need MDS version at least 2.10.55" && return
15904 mkdir -p $DIR/$tdir
15905 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15907 # check files inherit DoM EA
15908 touch $DIR/$tdir/first
15909 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
15910 error "bad pattern"
15911 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
15912 error "bad stripe count"
15913 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
15914 error "bad stripe size"
15916 # check directory inherits DoM EA and uses it as default
15917 mkdir $DIR/$tdir/subdir
15918 touch $DIR/$tdir/subdir/second
15919 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
15920 error "bad pattern in sub-directory"
15921 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
15922 error "bad stripe count in sub-directory"
15923 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
15924 error "bad stripe size in sub-directory"
15927 run_test 270c "DoM: DoM EA inheritance tests"
15930 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15931 skip "Need MDS version at least 2.10.55" && return
15933 mkdir -p $DIR/$tdir
15934 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15936 # inherit default DoM striping
15937 mkdir $DIR/$tdir/subdir
15938 touch $DIR/$tdir/subdir/f1
15940 # change default directory striping
15941 $LFS setstripe -c 1 $DIR/$tdir/subdir
15942 touch $DIR/$tdir/subdir/f2
15943 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
15944 error "wrong default striping in file 2"
15945 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
15946 error "bad pattern in file 2"
15949 run_test 270d "DoM: change striping from DoM to RAID0"
15952 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15953 skip "Need MDS version at least 2.10.55" && return
15955 mkdir -p $DIR/$tdir/dom
15956 mkdir -p $DIR/$tdir/norm
15959 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
15960 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
15962 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
15963 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
15965 # find DoM files by layout
15966 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
15967 [ $NUM -eq $DOMFILES ] ||
15968 error "lfs find -L: found $NUM, expected $DOMFILES"
15969 echo "Test 1: lfs find 20 DOM files by layout: OK"
15971 # there should be 1 dir with default DOM striping
15972 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
15974 error "lfs find -L: found $NUM, expected 1 dir"
15975 echo "Test 2: lfs find 1 DOM dir by layout: OK"
15977 # find DoM files by stripe size
15978 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
15979 [ $NUM -eq $DOMFILES ] ||
15980 error "lfs find -S: found $NUM, expected $DOMFILES"
15981 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
15983 # find files by stripe offset except DoM files
15984 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
15985 [ $NUM -eq $NORMFILES ] ||
15986 error "lfs find -i: found $NUM, expected $NORMFILES"
15987 echo "Test 5: lfs find no DOM files by stripe index: OK"
15990 run_test 270e "DoM: lfs find with DoM files test"
15993 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15994 skip "Need MDS version at least 2.10.55" && return
15996 local mdtname=${FSNAME}-MDT0000-mdtlov
15997 local dom=$DIR/$tdir/dom_file
15998 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
15999 lod.$mdtname.dom_stripesize)
16000 local dom_limit=131072
16002 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
16003 local dom_current=$(do_facet mds1 $LCTL get_param -n \
16004 lod.$mdtname.dom_stripesize)
16005 [ ${dom_limit} -eq ${dom_current} ] ||
16006 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
16008 $LFS mkdir -i 0 -c 1 $DIR/$tdir
16009 $LFS setstripe -d $DIR/$tdir
16010 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
16011 error "Can't set directory default striping"
16013 # exceed maximum stripe size
16014 $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
16015 error "Able to create DoM component size more than LOD limit"
16017 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
16018 dom_current=$(do_facet mds1 $LCTL get_param -n \
16019 lod.$mdtname.dom_stripesize)
16020 [ 0 -eq ${dom_current} ] ||
16021 error "Can't set zero DoM stripe limit"
16023 # too low values to be aligned with smallest stripe size 64K
16024 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
16025 dom_current=$(do_facet mds1 $LCTL get_param -n \
16026 lod.$mdtname.dom_stripesize)
16027 [ 30000 -eq ${dom_current} ] &&
16028 error "Can set too small DoM stripe limit"
16030 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
16031 dom_current=$(do_facet mds1 $LCTL get_param -n \
16032 lod.$mdtname.dom_stripesize)
16034 [ 2147483648 -eq ${dom_current} ] &&
16035 error "Can set too large DoM stripe limit"
16037 do_facet mds1 $LCTL set_param -n \
16038 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
16039 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16040 error "Can't create DoM component size after limit change"
16041 do_facet mds1 $LCTL set_param -n \
16042 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
16043 $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
16044 error "Can create big DoM component after limit decrease"
16045 touch ${dom}_def ||
16046 error "Can't create file with old default layout"
16048 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
16051 run_test 270f "DoM: maximum DoM stripe size checks"
16054 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16055 skip "Need MDS version at least 2.10.55" && return
16057 local dom=$DIR/$tdir/dom
16059 mkdir -p $DIR/$tdir
16061 $LFS setstripe -E 1024K -L mdt $dom
16063 lctl set_param -n mdc.*.stats=clear
16064 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16065 cat $dom > /dev/null
16066 local reads=$(lctl get_param -n mdc.*.stats |
16067 awk '/ost_read/ {print $2}')
16068 [ -z $reads ] || error "Unexpected $reads READ RPCs"
16072 run_test 271a "DoM: data is cached for read after write"
16075 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16076 skip "Need MDS version at least 2.10.55" && return
16078 local dom=$DIR/$tdir/dom
16080 mkdir -p $DIR/$tdir
16082 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16084 lctl set_param -n mdc.*.stats=clear
16085 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16086 cancel_lru_locks mdc
16087 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
16088 # second stat to check size is cached on client
16089 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
16090 local gls=$(lctl get_param -n mdc.*.stats |
16091 awk '/ldlm_glimpse/ {print $2}')
16092 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16095 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
16098 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16099 skip "Need MDS version at least 2.10.55" && return
16101 local dom=$DIR/$tdir/dom
16103 mkdir -p $DIR/$tdir
16105 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16107 lctl set_param -n mdc.*.stats=clear
16108 lctl set_param -n osc.*.stats=clear
16109 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
16110 cancel_lru_locks mdc
16111 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16112 # second stat to check size is cached on client
16113 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16114 local gls=$(lctl get_param -n mdc.*.stats |
16115 awk '/ldlm_glimpse/ {print $2}')
16116 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16117 local gls=$(lctl get_param -n osc.*.stats |
16118 awk '/ldlm_glimpse/ {print $2}')
16119 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
16122 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
16125 # test to be enabled with lock_convert
16126 skip "skipped until lock convert will be implemented" && return
16128 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16129 skip "Need MDS version at least 2.10.55" && return
16131 local dom=$DIR/$tdir/dom
16133 mkdir -p $DIR/$tdir
16135 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16137 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
16138 local facet=mds$((mdtidx + 1))
16140 cancel_lru_locks mdc
16141 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
16142 createmany -o $dom 1000
16143 lctl set_param -n mdc.*.stats=clear
16144 smalliomany -w $dom 1000 200
16145 lctl get_param -n mdc.*.stats
16146 local enq=$(lctl get_param -n mdc.*.stats |
16147 awk '/ldlm_ibits_enqueue/ {print $2}')
16148 # Each file has 1 open, 1 IO enqueues, total 2000
16149 # but now we have also +1 getxattr for security.capability, total 3000
16150 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
16151 unlinkmany $dom 1000
16153 cancel_lru_locks mdc
16154 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
16155 createmany -o $dom 1000
16156 lctl set_param -n mdc.*.stats=clear
16157 smalliomany -w $dom 1000 200
16158 lctl get_param -n mdc.*.stats
16159 local enq_2=$(lctl get_param -n mdc.*.stats |
16160 awk '/ldlm_ibits_enqueue/ {print $2}')
16161 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
16162 # for OPEN and IO lock.
16163 [ $((enq - enq_2)) -ge 1000 ] ||
16164 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
16165 unlinkmany $dom 1000
16168 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
16170 cleanup_test_300() {
16174 test_striped_dir() {
16179 mkdir -p $DIR/$tdir
16181 SAVE_UMASK=$(umask)
16182 trap cleanup_test_300 RETURN EXIT
16184 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
16185 $DIR/$tdir/striped_dir ||
16186 error "set striped dir error"
16188 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
16189 [ "$mode" = "755" ] || error "expect 755 got $mode"
16191 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
16192 error "getdirstripe failed"
16193 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
16194 if [ "$stripe_count" != "2" ]; then
16195 error "1:stripe_count is $stripe_count, expect 2"
16197 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
16198 if [ "$stripe_count" != "2" ]; then
16199 error "2:stripe_count is $stripe_count, expect 2"
16202 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
16203 if [ "$stripe_index" != "$mdt_index" ]; then
16204 error "stripe_index is $stripe_index, expect $mdt_index"
16207 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16208 error "nlink error after create striped dir"
16210 mkdir $DIR/$tdir/striped_dir/a
16211 mkdir $DIR/$tdir/striped_dir/b
16213 stat $DIR/$tdir/striped_dir/a ||
16214 error "create dir under striped dir failed"
16215 stat $DIR/$tdir/striped_dir/b ||
16216 error "create dir under striped dir failed"
16218 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
16219 error "nlink error after mkdir"
16221 rmdir $DIR/$tdir/striped_dir/a
16222 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
16223 error "nlink error after rmdir"
16225 rmdir $DIR/$tdir/striped_dir/b
16226 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16227 error "nlink error after rmdir"
16229 chattr +i $DIR/$tdir/striped_dir
16230 createmany -o $DIR/$tdir/striped_dir/f 10 &&
16231 error "immutable flags not working under striped dir!"
16232 chattr -i $DIR/$tdir/striped_dir
16234 rmdir $DIR/$tdir/striped_dir ||
16235 error "rmdir striped dir error"
16243 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16244 skip "skipped for lustre < 2.7.0" && return
16245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16248 test_striped_dir 0 || error "failed on striped dir on MDT0"
16249 test_striped_dir 1 || error "failed on striped dir on MDT0"
16251 run_test 300a "basic striped dir sanity test"
16254 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16255 skip "skipped for lustre < 2.7.0" && return
16256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16257 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16263 test_mkdir $DIR/$tdir
16264 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16265 error "set striped dir error"
16266 for ((i=0; i<10; i++)); do
16267 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
16269 touch $DIR/$tdir/striped_dir/file_$i ||
16270 error "touch error $i"
16271 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
16272 [ $mtime1 -eq $mtime2 ] &&
16273 error "mtime not change after create"
16275 rm -f $DIR/$tdir/striped_dir/file_$i ||
16276 error "unlink error $i"
16277 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
16278 [ $mtime2 -eq $mtime3 ] &&
16279 error "mtime did not change after unlink"
16283 run_test 300b "check ctime/mtime for striped dir"
16286 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16287 skip "skipped for lustre < 2.7.0" && return
16288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16289 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16292 mkdir -p $DIR/$tdir
16293 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
16294 error "set striped dir error"
16296 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
16297 error "chown striped dir failed"
16299 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
16300 error "create 5k files failed"
16302 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
16304 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
16308 run_test 300c "chown && check ls under striped directory"
16311 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16312 skip "skipped for lustre < 2.7.0" && return
16313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16314 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16318 mkdir -p $DIR/$tdir
16319 $SETSTRIPE -c 2 $DIR/$tdir
16321 #local striped directory
16322 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16323 error "set striped dir error"
16324 createmany -o $DIR/$tdir/striped_dir/f 10 ||
16325 error "create 10 files failed"
16327 #remote striped directory
16328 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
16329 error "set striped dir error"
16330 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
16331 error "create 10 files failed"
16333 for file in $(find $DIR/$tdir); do
16334 stripe_count=$($GETSTRIPE -c $file)
16335 [ $stripe_count -eq 2 ] ||
16336 error "wrong stripe $stripe_count for $file"
16341 run_test 300d "check default stripe under striped directory"
16344 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16345 skip "Need MDS version at least 2.7.55" && return
16346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16347 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16351 mkdir -p $DIR/$tdir
16353 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16354 error "set striped dir error"
16356 touch $DIR/$tdir/striped_dir/a
16357 touch $DIR/$tdir/striped_dir/b
16358 touch $DIR/$tdir/striped_dir/c
16360 mkdir $DIR/$tdir/striped_dir/dir_a
16361 mkdir $DIR/$tdir/striped_dir/dir_b
16362 mkdir $DIR/$tdir/striped_dir/dir_c
16364 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
16365 error "set striped adir under striped dir error"
16367 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
16368 error "set striped bdir under striped dir error"
16370 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
16371 error "set striped cdir under striped dir error"
16373 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
16374 error "rename dir under striped dir fails"
16376 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
16377 error "rename dir under different stripes fails"
16379 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
16380 error "rename file under striped dir should succeed"
16382 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
16383 error "rename dir under striped dir should succeed"
16387 run_test 300e "check rename under striped directory"
16390 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16391 skip "Need MDS version at least 2.7.55" && return
16392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16393 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16398 mkdir -p $DIR/$tdir
16400 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16401 error "set striped dir error"
16403 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
16404 error "set striped dir error"
16406 touch $DIR/$tdir/striped_dir/a
16407 mkdir $DIR/$tdir/striped_dir/dir_a
16408 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
16409 error "create striped dir under striped dir fails"
16411 touch $DIR/$tdir/striped_dir1/b
16412 mkdir $DIR/$tdir/striped_dir1/dir_b
16413 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
16414 error "create striped dir under striped dir fails"
16416 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
16417 error "rename dir under different striped dir should fail"
16419 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
16420 error "rename striped dir under diff striped dir should fail"
16422 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
16423 error "rename file under diff striped dirs fails"
16427 run_test 300f "check rename cross striped directory"
16429 test_300_check_default_striped_dir()
16432 local default_count=$2
16433 local default_index=$3
16436 local dir_stripe_index
16439 echo "checking $dirname $default_count $default_index"
16440 $LFS setdirstripe -D -c $default_count -i $default_index \
16441 -t all_char $DIR/$tdir/$dirname ||
16442 error "set default stripe on striped dir error"
16443 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
16444 [ $stripe_count -eq $default_count ] ||
16445 error "expect $default_count get $stripe_count for $dirname"
16447 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
16448 [ $stripe_index -eq $default_index ] ||
16449 error "expect $default_index get $stripe_index for $dirname"
16451 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
16452 error "create dirs failed"
16454 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
16455 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
16456 for dir in $(find $DIR/$tdir/$dirname/*); do
16457 stripe_count=$($LFS getdirstripe -c $dir)
16458 [ $stripe_count -eq $default_count ] ||
16459 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
16460 error "stripe count $default_count != $stripe_count for $dir"
16462 stripe_index=$($LFS getdirstripe -i $dir)
16463 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
16464 error "$stripe_index != $default_index for $dir"
16466 #check default stripe
16467 stripe_count=$($LFS getdirstripe -D -c $dir)
16468 [ $stripe_count -eq $default_count ] ||
16469 error "default count $default_count != $stripe_count for $dir"
16471 stripe_index=$($LFS getdirstripe -D -i $dir)
16472 [ $stripe_index -eq $default_index ] ||
16473 error "default index $default_index != $stripe_index for $dir"
16475 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
16479 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16480 skip "Need MDS version at least 2.7.55" && return
16481 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16487 mkdir $DIR/$tdir/normal_dir
16489 #Checking when client cache stripe index
16490 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
16491 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
16492 error "create striped_dir failed"
16494 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
16495 error "create dir0 fails"
16496 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
16497 [ $stripe_index -eq 0 ] ||
16498 error "dir0 expect index 0 got $stripe_index"
16500 mkdir $DIR/$tdir/striped_dir/dir1 ||
16501 error "create dir1 fails"
16502 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
16503 [ $stripe_index -eq 1 ] ||
16504 error "dir1 expect index 1 got $stripe_index"
16506 #check default stripe count/stripe index
16507 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
16508 test_300_check_default_striped_dir normal_dir 1 0
16509 test_300_check_default_striped_dir normal_dir 2 1
16510 test_300_check_default_striped_dir normal_dir 2 -1
16512 #delete default stripe information
16513 echo "delete default stripeEA"
16514 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
16515 error "set default stripe on striped dir error"
16517 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
16518 for dir in $(find $DIR/$tdir/normal_dir/*); do
16519 stripe_count=$($LFS getdirstripe -c $dir)
16520 [ $stripe_count -eq 0 ] ||
16521 error "expect 1 get $stripe_count for $dir"
16522 stripe_index=$($LFS getdirstripe -i $dir)
16523 [ $stripe_index -eq 0 ] ||
16524 error "expect 0 get $stripe_index for $dir"
16527 run_test 300g "check default striped directory for normal directory"
16530 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16531 skip "Need MDS version at least 2.7.55" && return
16532 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16537 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
16538 $DIR/$tdir/striped_dir ||
16539 error "set striped dir error"
16541 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
16542 test_300_check_default_striped_dir striped_dir 1 0
16543 test_300_check_default_striped_dir striped_dir 2 1
16544 test_300_check_default_striped_dir striped_dir 2 -1
16546 #delete default stripe information
16547 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
16548 error "set default stripe on striped dir error"
16550 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
16551 for dir in $(find $DIR/$tdir/striped_dir/*); do
16552 stripe_count=$($LFS getdirstripe -c $dir)
16553 [ $stripe_count -eq 0 ] ||
16554 error "expect 1 get $stripe_count for $dir"
16557 run_test 300h "check default striped directory for striped directory"
16560 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16561 skip "Need MDS version at least 2.7.55" && return
16562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16563 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16569 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16570 error "set striped dir error"
16572 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16573 error "create files under striped dir failed"
16575 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
16576 error "set striped hashdir error"
16578 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
16579 error "create dir0 under hash dir failed"
16580 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
16581 error "create dir1 under hash dir failed"
16583 # unfortunately, we need to umount to clear dir layout cache for now
16584 # once we fully implement dir layout, we can drop this
16585 umount_client $MOUNT || error "umount failed"
16586 mount_client $MOUNT || error "mount failed"
16588 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
16589 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
16590 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
16592 #set the stripe to be unknown hash type
16593 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
16594 $LCTL set_param fail_loc=0x1901
16595 for ((i = 0; i < 10; i++)); do
16596 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
16597 error "stat f-$i failed"
16598 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
16601 touch $DIR/$tdir/striped_dir/f0 &&
16602 error "create under striped dir with unknown hash should fail"
16604 $LCTL set_param fail_loc=0
16606 umount_client $MOUNT || error "umount failed"
16607 mount_client $MOUNT || error "mount failed"
16611 run_test 300i "client handle unknown hash type striped directory"
16614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16615 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16616 skip "Need MDS version at least 2.7.55" && return
16617 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16623 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
16624 $LCTL set_param fail_loc=0x1702
16625 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16626 error "set striped dir error"
16628 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16629 error "create files under striped dir failed"
16631 $LCTL set_param fail_loc=0
16633 rm -rf $DIR/$tdir || error "unlink striped dir fails"
16637 run_test 300j "test large update record"
16640 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16641 skip "Need MDS version at least 2.7.55" && return
16642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16649 #define OBD_FAIL_LARGE_STRIPE 0x1703
16650 $LCTL set_param fail_loc=0x1703
16651 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
16652 error "set striped dir error"
16653 $LCTL set_param fail_loc=0
16655 $LFS getdirstripe $DIR/$tdir/striped_dir ||
16656 error "getstripeddir fails"
16657 rm -rf $DIR/$tdir/striped_dir ||
16658 error "unlink striped dir fails"
16662 run_test 300k "test large striped directory"
16665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16666 skip "Need MDS version at least 2.7.55" && return
16667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16668 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16671 test_mkdir -p $DIR/$tdir/striped_dir
16672 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
16673 error "chown $RUNAS_ID failed"
16674 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
16675 error "set default striped dir failed"
16677 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
16678 $LCTL set_param fail_loc=0x80000158
16679 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
16681 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
16682 [ $stripe_index -eq 1 ] ||
16683 error "expect 1 get $stripe_index for $dir"
16685 run_test 300l "non-root user to create dir under striped dir with stale layout"
16688 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16689 skip "Need MDS version at least 2.7.55" && return
16690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16691 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
16693 mkdir -p $DIR/$tdir/striped_dir
16694 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
16695 error "set default stripes dir error"
16697 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
16699 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
16700 [ $stripe_count -eq 0 ] ||
16701 error "expect 0 get $stripe_count for a"
16703 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
16704 error "set default stripes dir error"
16706 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
16708 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
16709 [ $stripe_count -eq 0 ] ||
16710 error "expect 0 get $stripe_count for b"
16712 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
16713 error "set default stripes dir error"
16715 mkdir $DIR/$tdir/striped_dir/c &&
16716 error "default stripe_index is invalid, mkdir c should fails"
16718 rm -rf $DIR/$tdir || error "rmdir fails"
16720 run_test 300m "setstriped directory on single MDT FS"
16723 local list=$(comma_list $(mdts_nodes))
16726 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16730 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16731 skip "Need MDS version at least 2.7.55" && return
16732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16733 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16737 local list=$(comma_list $(mdts_nodes))
16739 trap cleanup_300n RETURN EXIT
16740 mkdir -p $DIR/$tdir
16741 chmod 777 $DIR/$tdir
16742 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16743 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16744 error "create striped dir succeeds with gid=0"
16746 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16747 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16748 error "create striped dir fails with gid=-1"
16750 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16751 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16752 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16753 error "set default striped dir succeeds with gid=0"
16756 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16757 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16758 error "set default striped dir fails with gid=-1"
16761 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16762 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16763 error "create test_dir fails"
16764 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16765 error "create test_dir1 fails"
16766 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16767 error "create test_dir2 fails"
16770 run_test 300n "non-root user to create dir under striped dir with default EA"
16773 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16774 skip "Need MDS version at least 2.7.55" && return
16775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16780 mkdir -p $DIR/$tdir
16782 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16783 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16784 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16785 skip "not enough free inodes $numfree1 $numfree2"
16789 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16790 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16791 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16792 skip "not enough free space $numfree1 $numfree2"
16796 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16797 error "setdirstripe fails"
16799 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16800 error "create dirs fails"
16802 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16803 ls $DIR/$tdir/striped_dir > /dev/null ||
16804 error "ls striped dir fails"
16805 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16806 error "unlink big striped dir fails"
16808 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16812 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16813 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16815 mkdir -p $DIR/$tdir
16817 #define OBD_FAIL_OUT_ENOSPC 0x1704
16818 do_facet mds2 lctl set_param fail_loc=0x80001704
16819 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16820 error "create striped directory should fail"
16822 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16824 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16827 run_test 300p "create striped directory without space"
16830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16831 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16833 local fd=$(free_fd)
16834 local cmd="exec $fd<$tdir"
16836 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16839 trap "eval $cmd" EXIT
16840 cd $tdir || error "cd $tdir fails"
16841 rmdir ../$tdir || error "rmdir $tdir fails"
16842 mkdir local_dir && error "create dir succeeds"
16843 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16847 run_test 300q "create remote directory under orphan directory"
16849 prepare_remote_file() {
16850 mkdir $DIR/$tdir/src_dir ||
16851 error "create remote source failed"
16853 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16854 touch $DIR/$tdir/src_dir/a
16856 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16857 error "create remote target dir failed"
16859 touch $DIR/$tdir/tgt_dir/b
16861 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16862 error "rename dir cross MDT failed!"
16864 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16865 error "src_child still exists after rename"
16867 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16868 error "missing file(a) after rename"
16870 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16871 error "diff after rename"
16875 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16877 local remote_file=$DIR/$tdir/tgt_dir/b
16879 mkdir -p $DIR/$tdir
16881 prepare_remote_file || error "prepare remote file failed"
16884 $OPENUNLINK $remote_file $remote_file || error
16885 $CHECKSTAT -a $remote_file || error
16887 run_test 310a "open unlink remote file"
16890 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16892 local remote_file=$DIR/$tdir/tgt_dir/b
16894 mkdir -p $DIR/$tdir
16896 prepare_remote_file || error "prepare remote file failed"
16898 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16899 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16900 $CHECKSTAT -t file $remote_file || error "check file failed"
16902 run_test 310b "unlink remote file with multiple links while open"
16905 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16907 local remote_file=$DIR/$tdir/tgt_dir/b
16909 mkdir -p $DIR/$tdir
16911 prepare_remote_file || error "prepare remote file failed"
16913 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16914 multiop_bg_pause $remote_file O_uc ||
16915 error "mulitop failed for remote file"
16917 $MULTIOP $DIR/$tfile Ouc
16918 kill -USR1 $MULTIPID
16921 run_test 310c "open-unlink remote file with multiple links"
16925 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16926 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16928 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16930 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16932 mkdir -p $DIR/$tdir
16933 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16934 createmany -o $DIR/$tdir/$tfile. 1000
16936 # statfs data is not real time, let's just calculate it
16937 old_iused=$((old_iused + 1000))
16939 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16940 osp.*OST0000*MDT0000.create_count")
16941 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16942 osp.*OST0000*MDT0000.max_create_count")
16943 for idx in $(seq $MDSCOUNT); do
16944 do_facet mds$idx "lctl set_param -n \
16945 osp.*OST0000*MDT000?.max_create_count=0"
16948 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16949 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16950 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16952 unlinkmany $DIR/$tdir/$tfile. 1000
16954 for idx in $(seq $MDSCOUNT); do
16955 do_facet mds$idx "lctl set_param -n \
16956 osp.*OST0000*MDT000?.max_create_count=$max_count"
16957 do_facet mds$idx "lctl set_param -n \
16958 osp.*OST0000*MDT000?.create_count=$count"
16962 for i in $(seq 120); do
16963 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16964 # system may be too busy to destroy all objs in time, use
16965 # a somewhat small value to not fail autotest
16966 [ $((old_iused - new_iused)) -gt 400 ] && break
16970 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16971 [ $((old_iused - new_iused)) -gt 400 ] ||
16972 error "objs not destroyed after unlink"
16974 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16981 local vdevdir=$(dirname $(facet_vdevice $ost))
16982 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16983 local zfs_zapid=$(do_facet $ost $cmd |
16984 grep -w "/O/0/d$((objid%32))" -C 5 |
16985 awk '/Object/{getline; print $1}')
16986 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16987 awk "/$objid = /"'{printf $3}')
16992 zfs_object_blksz() {
16996 local vdevdir=$(dirname $(facet_vdevice $ost))
16997 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16998 local blksz=$(do_facet $ost $cmd $objid |
16999 awk '/dblk/{getline; printf $4}')
17001 case "${blksz: -1}" in
17002 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
17003 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
17010 test_312() { # LU-4856
17011 remote_ost_nodsh && skip "remote OST with nodsh" && return
17013 [ $(facet_fstype ost1) = "zfs" ] ||
17014 { skip "the test only applies to zfs" && return; }
17016 local max_blksz=$(do_facet ost1 \
17017 $ZFS get -p recordsize $(facet_device ost1) |
17018 awk '!/VALUE/{print $3}')
17019 local min_blksz=$(getconf PAGE_SIZE)
17021 # to make life a little bit easier
17022 $LFS mkdir -c 1 -i 0 $DIR/$tdir
17023 $LFS setstripe -c 1 -i 0 $DIR/$tdir
17025 local tf=$DIR/$tdir/$tfile
17027 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17029 # Get ZFS object id
17030 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17032 # block size change by sequential over write
17034 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
17035 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
17037 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17038 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
17042 # block size change by sequential append write
17043 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
17044 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17045 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17047 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
17048 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
17049 oflag=sync conv=notrunc
17051 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17052 [ $blksz -eq $((2 * count * min_blksz)) ] ||
17053 error "blksz error, actual $blksz, " \
17054 "expected: 2 * $count * $min_blksz"
17060 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17061 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17063 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
17064 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17065 [ $blksz -eq $min_blksz ] ||
17066 error "blksz error: $blksz, expected: $min_blksz"
17068 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
17069 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17070 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
17072 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
17073 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17074 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
17076 run_test 312 "make sure ZFS adjusts its block size by write pattern"
17079 remote_ost_nodsh && skip "remote OST with nodsh" && return
17081 local file=$DIR/$tfile
17083 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
17085 # define OBD_FAIL_TGT_RCVD_EIO 0x720
17086 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17087 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
17088 error "write should failed"
17089 do_facet ost1 "$LCTL set_param fail_loc=0"
17092 run_test 313 "io should fail after last_rcvd update fail"
17095 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
17096 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17098 wait_delete_completed
17099 do_facet ost1 "$LCTL set_param fail_loc=0"
17101 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
17103 test_315() { # LU-618
17104 local file=$DIR/$tfile
17107 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
17108 $MULTIOP $file oO_RDONLY:r4096000_c &
17113 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
17116 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
17119 run_test 315 "read should be accounted"
17122 local read_write=$1
17123 if [ "$read_write" = "write" ]; then
17124 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
17125 elif [ "$read_write" = "read" ]; then
17126 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
17128 error "argument error"
17131 # turn off debug for performance testing
17132 local saved_debug=$($LCTL get_param -n debug)
17133 $LCTL set_param debug=0
17135 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
17137 # get ost1 size - lustre-OST0000
17138 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
17139 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
17140 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
17142 if [ "$read_write" = "read" ]; then
17143 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
17146 local start_time=$(date +%s.%N)
17147 $dd_cmd bs=1M count=$blocks oflag=sync ||
17148 error "real dd $read_write error"
17149 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
17151 if [ "$read_write" = "write" ]; then
17155 # define OBD_FAIL_OST_FAKE_RW 0x238
17156 do_facet ost1 $LCTL set_param fail_loc=0x238
17158 local start_time=$(date +%s.%N)
17159 $dd_cmd bs=1M count=$blocks oflag=sync ||
17160 error "fake dd $read_write error"
17161 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
17163 if [ "$read_write" = "write" ]; then
17165 cancel_lru_locks osc
17166 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
17167 error "$tfile size not $blocks MB"
17169 do_facet ost1 $LCTL set_param fail_loc=0
17171 echo "fake $read_write $duration_fake vs. normal $read_write" \
17172 "$duration in seconds"
17173 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
17174 error_not_in_vm "fake write is slower"
17176 $LCTL set_param -n debug="$saved_debug"
17179 test_399a() { # LU-7655 for OST fake write
17180 remote_ost_nodsh && skip "remote OST with nodsh" && return
17184 run_test 399a "fake write should not be slower than normal write"
17186 test_399b() { # LU-8726 for OST fake read
17187 remote_ost_nodsh && skip "remote OST with nodsh" && return
17189 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
17190 skip "ldiskfs only test" && return 0
17194 run_test 399b "fake read should not be slower than normal read"
17196 test_400a() { # LU-1606, was conf-sanity test_74
17197 local extra_flags=''
17198 local out=$TMP/$tfile
17199 local prefix=/usr/include/lustre
17202 if ! which $CC > /dev/null 2>&1; then
17203 skip_env "$CC is not installed"
17207 if ! [[ -d $prefix ]]; then
17208 # Assume we're running in tree and fixup the include path.
17209 extra_flags+=" -I$LUSTRE/include"
17210 extra_flags+=" -L$LUSTRE/utils"
17213 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
17214 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
17215 error "client api broken"
17219 run_test 400a "Lustre client api program can compile and link"
17221 test_400b() { # LU-1606, LU-5011
17223 local out=$TMP/$tfile
17224 local prefix=/usr/include/linux/lustre
17226 # We use a hard coded prefix so that this test will not fail
17227 # when run in tree. There are headers in lustre/include/lustre/
17228 # that are not packaged (like lustre_idl.h) and have more
17229 # complicated include dependencies (like config.h and lnet/types.h).
17230 # Since this test about correct packaging we just skip them when
17231 # they don't exist (see below) rather than try to fixup cppflags.
17233 if ! which $CC > /dev/null 2>&1; then
17234 skip_env "$CC is not installed"
17238 for header in $prefix/*.h; do
17239 if ! [[ -f "$header" ]]; then
17243 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
17244 continue # lustre_ioctl.h is internal header
17247 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
17248 error "cannot compile '$header'"
17252 run_test 400b "packaged headers can be compiled"
17254 test_401a() { #LU-7437
17255 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
17256 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
17258 #count the number of parameters by "list_param -R"
17259 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
17260 #count the number of parameters by listing proc files
17261 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
17262 echo "proc_dirs='$proc_dirs'"
17263 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
17264 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
17267 [ $params -eq $procs ] ||
17268 error "found $params parameters vs. $procs proc files"
17270 # test the list_param -D option only returns directories
17271 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
17272 #count the number of parameters by listing proc directories
17273 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
17276 [ $params -eq $procs ] ||
17277 error "found $params parameters vs. $procs proc files"
17279 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
17282 local save=$($LCTL get_param -n jobid_var)
17285 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
17286 error "no error returned when setting bad parameters"
17288 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
17289 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
17291 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
17292 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
17293 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
17295 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
17298 local jobid_var_old=$($LCTL get_param -n jobid_var)
17299 local jobid_var_new
17301 $LCTL set_param jobid_var= &&
17302 error "no error returned for 'set_param a='"
17304 jobid_var_new=$($LCTL get_param -n jobid_var)
17305 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17306 error "jobid_var was changed by setting without value"
17308 $LCTL set_param jobid_var &&
17309 error "no error returned for 'set_param a'"
17311 jobid_var_new=$($LCTL get_param -n jobid_var)
17312 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17313 error "jobid_var was changed by setting without value"
17315 run_test 401c "Verify 'lctl set_param' without value fails in either format."
17318 local jobid_var_old=$($LCTL get_param -n jobid_var)
17319 local jobid_var_new
17320 local new_value="foo=bar"
17322 $LCTL set_param jobid_var=$new_value ||
17323 error "'set_param a=b' did not accept a value containing '='"
17325 jobid_var_new=$($LCTL get_param -n jobid_var)
17326 [[ "$jobid_var_new" == "$new_value" ]] ||
17327 error "'set_param a=b' failed on a value containing '='"
17329 # Reset the jobid_var to test the other format
17330 $LCTL set_param jobid_var=$jobid_var_old
17331 jobid_var_new=$($LCTL get_param -n jobid_var)
17332 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17333 error "failed to reset jobid_var"
17335 $LCTL set_param jobid_var $new_value ||
17336 error "'set_param a b' did not accept a value containing '='"
17338 jobid_var_new=$($LCTL get_param -n jobid_var)
17339 [[ "$jobid_var_new" == "$new_value" ]] ||
17340 error "'set_param a b' failed on a value containing '='"
17342 $LCTL set_param jobid_var $jobid_var_old
17343 jobid_var_new=$($LCTL get_param -n jobid_var)
17344 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17345 error "failed to reset jobid_var"
17347 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
17350 local server_version=$(lustre_version_code $SINGLEMDS)
17351 [[ $server_version -ge $(version_code 2.7.66) ]] ||
17352 [[ $server_version -ge $(version_code 2.7.18.4) &&
17353 $server_version -lt $(version_code 2.7.50) ]] ||
17354 [[ $server_version -ge $(version_code 2.7.2) &&
17355 $server_version -lt $(version_code 2.7.11) ]] ||
17356 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
17358 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17359 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
17360 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
17361 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
17362 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
17363 echo "Touch failed - OK"
17365 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
17368 local file1=$DIR/$tfile.1
17369 local file2=$DIR/$tfile.2
17370 local tfile=$TMP/$tfile
17372 rm -f $file1 $file2 $tfile
17377 # 30 sec OBD_TIMEOUT in ll_getattr()
17378 # right before populating st_nlink
17379 $LCTL set_param fail_loc=0x80001409
17380 stat -c %h $file1 > $tfile &
17382 # create an alias, drop all locks and reclaim the dentry
17384 cancel_lru_locks mdc
17385 cancel_lru_locks osc
17386 sysctl -w vm.drop_caches=2
17390 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
17392 rm -f $tfile $file1 $file2
17394 run_test 403 "i_nlink should not drop to zero due to aliasing"
17396 test_404() { # LU-6601
17397 local server_version=$(lustre_version_code $SINGLEMDS)
17398 [[ $server_version -ge $(version_code 2.8.53) ]] ||
17399 { skip "Need server version newer than 2.8.52"; return 0; }
17401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17402 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
17403 awk '/osp .*-osc-MDT/ { print $4}')
17406 for osp in $mosps; do
17407 echo "Deactivate: " $osp
17408 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
17409 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17410 awk -vp=$osp '$4 == p { print $2 }')
17411 [ $stat = IN ] || {
17412 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17413 error "deactivate error"
17415 echo "Activate: " $osp
17416 do_facet $SINGLEMDS $LCTL --device %$osp activate
17417 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17418 awk -vp=$osp '$4 == p { print $2 }')
17419 [ $stat = UP ] || {
17420 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17421 error "activate error"
17425 run_test 404 "validate manual {de}activated works properly for OSPs"
17428 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
17429 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
17430 skip "Layout swap lock is not supported" && return
17432 check_swap_layouts_support && return 0
17434 test_mkdir $DIR/$tdir
17435 swap_lock_test -d $DIR/$tdir ||
17436 error "One layout swap locked test failed"
17438 run_test 405 "Various layout swap lock tests"
17441 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17442 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17443 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
17444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17445 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
17446 skip "Need MDS version at least 2.8.50" && return
17448 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
17449 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
17450 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
17451 local def_pool=$($GETSTRIPE -p $MOUNT)
17452 local test_pool=$TESTNAME
17454 if ! combined_mgs_mds ; then
17457 pool_add $test_pool || error "pool_add failed"
17458 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
17459 error "pool_add_targets failed"
17461 # parent set default stripe count only, child will stripe from both
17462 # parent and fs default
17463 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
17464 error "setstripe $MOUNT failed"
17465 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
17466 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
17467 for i in $(seq 10); do
17468 local f=$DIR/$tdir/$tfile.$i
17469 touch $f || error "touch failed"
17470 local count=$($GETSTRIPE -c $f)
17471 [ $count -eq $OSTCOUNT ] ||
17472 error "$f stripe count $count != $OSTCOUNT"
17473 local offset=$($GETSTRIPE -i $f)
17474 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
17475 local size=$($GETSTRIPE -S $f)
17476 [ $size -eq $((def_stripe_size * 2)) ] ||
17477 error "$f stripe size $size != $((def_stripe_size * 2))"
17478 local pool=$($GETSTRIPE -p $f)
17479 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
17482 # change fs default striping, delete parent default striping, now child
17483 # will stripe from new fs default striping only
17484 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
17485 error "change $MOUNT default stripe failed"
17486 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
17487 for i in $(seq 11 20); do
17488 local f=$DIR/$tdir/$tfile.$i
17489 touch $f || error "touch $f failed"
17490 local count=$($GETSTRIPE -c $f)
17491 [ $count -eq 1 ] || error "$f stripe count $count != 1"
17492 local offset=$($GETSTRIPE -i $f)
17493 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
17494 local size=$($GETSTRIPE -S $f)
17495 [ $size -eq $def_stripe_size ] ||
17496 error "$f stripe size $size != $def_stripe_size"
17497 local pool=$($GETSTRIPE -p $f)
17498 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
17502 unlinkmany $DIR/$tdir/$tfile. 1 20
17504 # restore FS default striping
17505 if [ -z $def_pool ]; then
17506 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17507 -i $def_stripe_offset $MOUNT ||
17508 error "restore default striping failed"
17510 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17511 -i $def_stripe_offset -p $def_pool $MOUNT ||
17512 error "restore default striping with $def_pool failed"
17515 local f=$DIR/$tdir/$tfile
17516 pool_remove_all_targets $test_pool $f
17517 pool_remove $test_pool $f
17519 if ! combined_mgs_mds ; then
17523 run_test 406 "DNE support fs default striping"
17526 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17527 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
17528 skip "Need MDS version at least 2.8.55" && return
17529 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17531 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
17532 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
17533 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
17534 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
17535 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
17537 #define OBD_FAIL_DT_TXN_STOP 0x2019
17538 for idx in $(seq $MDSCOUNT); do
17539 do_facet mds$idx "lctl set_param fail_loc=0x2019"
17541 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
17542 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
17543 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
17546 run_test 407 "transaction fail should cause operation fail"
17549 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
17551 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
17552 lctl set_param fail_loc=0x8000040a
17553 # let ll_prepare_partial_page() fail
17554 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
17558 # create at least 100 unused inodes so that
17559 # shrink_icache_memory(0) should not return 0
17560 touch $DIR/$tfile-{0..100}
17561 rm -f $DIR/$tfile-{0..100}
17564 echo 2 > /proc/sys/vm/drop_caches
17566 run_test 408 "drop_caches should not hang due to page leaks"
17570 [ $MDSCOUNT -lt 2 ] &&
17571 skip "We need at least 2 MDTs for this test" && return
17573 check_mount_and_prep
17575 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
17576 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
17577 touch $DIR/$tdir/guard || error "(2) Fail to create"
17579 local PREFIX=$(str_repeat 'A' 128)
17580 echo "Create 1K hard links start at $(date)"
17581 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17582 error "(3) Fail to hard link"
17584 echo "Links count should be right although linkEA overflow"
17585 stat $DIR/$tdir/guard || error "(4) Fail to stat"
17586 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
17587 [ $linkcount -eq 1001 ] ||
17588 error "(5) Unexpected hard links count: $linkcount"
17590 echo "List all links start at $(date)"
17591 ls -l $DIR/$tdir/foo > /dev/null ||
17592 error "(6) Fail to list $DIR/$tdir/foo"
17594 echo "Unlink hard links start at $(date)"
17595 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17596 error "(7) Fail to unlink"
17598 run_test 409 "Large amount of cross-MDTs hard links on the same file"
17602 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
17603 skip "Need client version at least 2.9.59" && return
17605 # Create a file, and stat it from the kernel
17606 local testfile=$DIR/$tfile
17609 local run_id=$RANDOM
17610 local my_ino=$(stat --format "%i" $testfile)
17612 # Try to insert the module. This will always fail as the
17613 # module is designed to not be inserted.
17614 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
17617 # Anything but success is a test failure
17619 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
17620 error "no inode match"
17622 run_test 410 "Test inode number returned from kernel thread"
17624 cleanup_test411_cgroup() {
17630 local cg_basedir=/sys/fs/cgroup/memory
17632 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
17633 { skip "no setup for cgroup"; return; }
17635 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
17636 error "test file creation failed"
17637 cancel_lru_locks osc
17639 # Create a very small memory cgroup to force a slab allocation error
17640 local cgdir=$cg_basedir/osc_slab_alloc
17641 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
17642 trap "cleanup_test411_cgroup $cgdir" EXIT
17643 echo 2M > $cgdir/memory.kmem.limit_in_bytes
17644 echo 1M > $cgdir/memory.limit_in_bytes
17646 # Should not LBUG, just be killed by oom-killer
17647 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
17648 error "fail to trigger a memory allocation error"
17650 cleanup_test411_cgroup $cgdir
17654 run_test 411 "Slab allocation error with cgroup does not LBUG"
17657 [ $MDSCOUNT -lt 2 ] &&
17658 skip "We need at least 2 MDTs for this test" && return
17660 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
17661 skip "Need server version at least 2.10.55" & exit 0
17664 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
17665 error "mkdir failed"
17666 $LFS getdirstripe $DIR/$tdir
17667 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
17668 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
17669 error "expect $((MDSCOUT - 1)) get $stripe_index"
17670 stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
17671 [ $stripe_count -eq 2 ] ||
17672 error "expect 2 get $stripe_count"
17674 run_test 412 "mkdir on specific MDTs"
17677 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17678 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17679 skip "Need server version at least 2.9.55" & exit 0
17680 start_full_debug_logging
17684 stop_full_debug_logging
17688 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17689 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17690 awk '/The barrier for/ { print $7 }')
17693 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
17698 barrier_expired() {
17701 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17702 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17703 awk '/will be expired/ { print $7 }')
17705 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
17714 echo "Start barrier_freeze at: $(date)"
17715 #define OBD_FAIL_BARRIER_DELAY 0x2202
17716 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17717 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
17720 local b_status=$(barrier_stat)
17721 echo "Got barrier status at: $(date)"
17722 [ "$b_status" = "'freezing_p1'" ] ||
17723 error "(1) unexpected barrier status $b_status"
17725 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17727 b_status=$(barrier_stat)
17728 [ "$b_status" = "'frozen'" ] ||
17729 error "(2) unexpected barrier status $b_status"
17731 local expired=$(barrier_expired)
17732 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
17733 sleep $((expired + 3))
17735 b_status=$(barrier_stat)
17736 [ "$b_status" = "'expired'" ] ||
17737 error "(3) unexpected barrier status $b_status"
17739 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
17740 error "(4) fail to freeze barrier"
17742 b_status=$(barrier_stat)
17743 [ "$b_status" = "'frozen'" ] ||
17744 error "(5) unexpected barrier status $b_status"
17746 echo "Start barrier_thaw at: $(date)"
17747 #define OBD_FAIL_BARRIER_DELAY 0x2202
17748 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17749 do_facet mgs $LCTL barrier_thaw $FSNAME &
17752 b_status=$(barrier_stat)
17753 echo "Got barrier status at: $(date)"
17754 [ "$b_status" = "'thawing'" ] ||
17755 error "(6) unexpected barrier status $b_status"
17757 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17759 b_status=$(barrier_stat)
17760 [ "$b_status" = "'thawed'" ] ||
17761 error "(7) unexpected barrier status $b_status"
17763 #define OBD_FAIL_BARRIER_FAILURE 0x2203
17764 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
17765 do_facet mgs $LCTL barrier_freeze $FSNAME
17767 b_status=$(barrier_stat)
17768 [ "$b_status" = "'failed'" ] ||
17769 error "(8) unexpected barrier status $b_status"
17771 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17772 do_facet mgs $LCTL barrier_thaw $FSNAME
17776 run_test 801a "write barrier user interfaces and stat machine"
17781 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17782 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17783 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17784 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17785 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
17787 cancel_lru_locks mdc
17789 # 180 seconds should be long enough
17790 do_facet mgs $LCTL barrier_freeze $FSNAME 180
17792 local b_status=$(barrier_stat)
17793 [ "$b_status" = "'frozen'" ] ||
17794 error "(6) unexpected barrier status $b_status"
17796 mkdir $DIR/$tdir/d0/d10 &
17799 touch $DIR/$tdir/d1/f13 &
17802 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
17805 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
17808 rm -f $DIR/$tdir/d4/f12 &
17811 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
17813 # To guarantee taht the 'stat' is not blocked
17814 b_status=$(barrier_stat)
17815 [ "$b_status" = "'frozen'" ] ||
17816 error "(8) unexpected barrier status $b_status"
17818 # let above commands to run at background
17821 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
17822 ps -p $touch_pid || error "(10) touch should be blocked"
17823 ps -p $ln_pid || error "(11) link should be blocked"
17824 ps -p $mv_pid || error "(12) rename should be blocked"
17825 ps -p $rm_pid || error "(13) unlink should be blocked"
17827 b_status=$(barrier_stat)
17828 [ "$b_status" = "'frozen'" ] ||
17829 error "(14) unexpected barrier status $b_status"
17831 do_facet mgs $LCTL barrier_thaw $FSNAME
17832 b_status=$(barrier_stat)
17833 [ "$b_status" = "'thawed'" ] ||
17834 error "(15) unexpected barrier status $b_status"
17836 wait $mkdir_pid || error "(16) mkdir should succeed"
17837 wait $touch_pid || error "(17) touch should succeed"
17838 wait $ln_pid || error "(18) link should succeed"
17839 wait $mv_pid || error "(19) rename should succeed"
17840 wait $rm_pid || error "(20) unlink should succeed"
17844 run_test 801b "modification will be blocked by write barrier"
17847 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17851 stop mds2 || error "(1) Fail to stop mds2"
17853 do_facet mgs $LCTL barrier_freeze $FSNAME 30
17855 local b_status=$(barrier_stat)
17856 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17857 do_facet mgs $LCTL barrier_thaw $FSNAME
17858 error "(2) unexpected barrier status $b_status"
17861 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17862 error "(3) Fail to rescan barrier bitmap"
17864 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17866 b_status=$(barrier_stat)
17867 [ "$b_status" = "'frozen'" ] ||
17868 error "(4) unexpected barrier status $b_status"
17870 do_facet mgs $LCTL barrier_thaw $FSNAME
17871 b_status=$(barrier_stat)
17872 [ "$b_status" = "'thawed'" ] ||
17873 error "(5) unexpected barrier status $b_status"
17875 local devname=$(mdsdevname 2)
17877 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17879 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17880 error "(7) Fail to rescan barrier bitmap"
17884 run_test 801c "rescan barrier bitmap"
17886 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17887 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17888 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17894 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17895 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17896 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17902 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17903 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17904 skip "Need server version at least 2.9.55" & exit 0
17906 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17908 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17909 error "(2) Fail to copy"
17911 trap cleanup_802 EXIT
17913 # sync by force before remount as readonly
17914 sync; sync_all_data; sleep 3; sync_all_data
17918 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17919 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17920 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17922 echo "Mount the server as read only"
17923 setupall server_only || error "(3) Fail to start servers"
17925 echo "Mount client without ro should fail"
17926 mount_client $MOUNT &&
17927 error "(4) Mount client without 'ro' should fail"
17929 echo "Mount client with ro should succeed"
17930 mount_client $MOUNT ro ||
17931 error "(5) Mount client with 'ro' should succeed"
17933 echo "Modify should be refused"
17934 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17936 echo "Read should be allowed"
17937 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17938 error "(7) Read should succeed under ro mode"
17942 run_test 802 "simulate readonly device"
17945 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17946 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17947 skip "MDS needs to be newer than 2.10.54" && return
17949 mkdir -p $DIR/$tdir
17950 # Create some objects on all MDTs to trigger related logs objects
17951 for idx in $(seq $MDSCOUNT); do
17952 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
17953 $DIR/$tdir/dir${idx} ||
17954 error "Fail to create $DIR/$tdir/dir${idx}"
17958 echo "before create:"
17960 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17962 for ((i=0; i<10; i++)); do
17963 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
17964 error "Fail to create $DIR/$tdir/foo$i"
17968 echo "after create:"
17970 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17972 [ $after_used -ge $((before_used + 10)) ] ||
17973 error "before ($before_used) + 10 > after ($after_used)"
17975 for ((i=0; i<10; i++)); do
17976 rm -rf $DIR/$tdir/foo$i ||
17977 error "Fail to remove $DIR/$tdir/foo$i"
17980 wait_delete_completed
17981 echo "after unlink:"
17983 before_used=$after_used
17984 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17986 [ $after_used -le $((before_used - 8)) ] ||
17987 error "before ($before_used) - 8 < after ($after_used)"
17989 run_test 803 "verify agent object for remote object"
17992 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17993 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17994 skip "MDS needs to be newer than 2.10.54" && return
17996 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
17997 skip "ldiskfs only test" && return 0
17999 mkdir -p $DIR/$tdir
18000 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
18001 error "Fail to create $DIR/$tdir/dir0"
18003 local fid=$($LFS path2fid $DIR/$tdir/dir0)
18004 local dev=$(mdsdevname 2)
18006 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18007 grep ${fid} || error "NOT found agent entry for dir0"
18009 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
18010 error "Fail to create $DIR/$tdir/dir1"
18012 touch $DIR/$tdir/dir1/foo0 ||
18013 error "Fail to create $DIR/$tdir/dir1/foo0"
18014 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
18017 for idx in $(seq $MDSCOUNT); do
18018 dev=$(mdsdevname $idx)
18019 do_facet mds${idx} \
18020 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18021 grep ${fid} && rc=$idx
18024 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
18025 error "Fail to rename foo0 to foo1"
18026 if [ $rc -eq 0 ]; then
18027 for idx in $(seq $MDSCOUNT); do
18028 dev=$(mdsdevname $idx)
18029 do_facet mds${idx} \
18030 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18031 grep ${fid} && rc=$idx
18035 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
18036 error "Fail to rename foo1 to foo2"
18037 if [ $rc -eq 0 ]; then
18038 for idx in $(seq $MDSCOUNT); do
18039 dev=$(mdsdevname $idx)
18040 do_facet mds${idx} \
18041 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18042 grep ${fid} && rc=$idx
18046 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
18048 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
18049 error "Fail to link to $DIR/$tdir/dir1/foo2"
18050 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
18051 error "Fail to rename foo2 to foo0"
18052 unlink $DIR/$tdir/dir1/foo0 ||
18053 error "Fail to unlink $DIR/$tdir/dir1/foo0"
18054 rm -rf $DIR/$tdir/dir0 ||
18055 error "Fail to rm $DIR/$tdir/dir0"
18057 for idx in $(seq $MDSCOUNT); do
18058 dev=$(mdsdevname $idx)
18062 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
18064 start mds${idx} $dev $MDS_MOUNT_OPTS ||
18065 error "mount mds$idx failed"
18066 df $MOUNT > /dev/null 2>&1
18068 # e2fsck should not return error
18070 error "e2fsck detected error on MDT${idx}: rc=$rc"
18073 run_test 804 "verify agent entry for remote entry"
18076 # tests that do cleanup/setup should be run at the end
18080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18082 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
18083 $LCTL set_param fail_loc=0x903
18085 cancel_lru_locks MGC
18087 FAIL_ON_ERROR=true cleanup
18088 FAIL_ON_ERROR=true setup
18090 run_test 900 "umount should not race with any mgc requeue thread"
18093 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
18094 check_and_cleanup_lustre
18095 if [ "$I_MOUNTED" != "yes" ]; then
18096 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true