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)"
10043 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10044 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
10047 local fm_file=$DIR/$tfile
10048 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
10049 error "multiop create with lov_delay_create on $fm_file"
10051 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10052 filefrag_extents=$(filefrag -vek $fm_file |
10053 awk '/extents? found/ { print $2 }')
10054 if [[ "$filefrag_extents" != "0" ]]; then
10055 error "FIEMAP on $fm_file failed; " \
10056 "returned $filefrag_extents expected 0"
10061 run_test 130f "FIEMAP (unstriped file)"
10063 # Test for writev/readv
10065 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10066 error "writev test failed"
10067 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10068 error "readv failed"
10071 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10074 local fsize=$((524288 + 1048576 + 1572864))
10075 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10076 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10077 error "append writev test failed"
10079 ((fsize += 1572864 + 1048576))
10080 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10081 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10082 error "append writev test failed"
10085 run_test 131b "test append writev"
10088 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10091 run_test 131c "test read/write on file w/o objects"
10094 rwv -f $DIR/$tfile -w -n 1 1572864
10095 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10096 if [ "$NOB" != 1572864 ]; then
10097 error "Short read filed: read $NOB bytes instead of 1572864"
10101 run_test 131d "test short read"
10104 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10105 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10106 error "read hitting hole failed"
10109 run_test 131e "test read hitting hole"
10118 mds*) res=$(do_facet $facet \
10119 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10121 ost*) res=$(do_facet $facet \
10122 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10124 *) error "Wrong facet '$facet'" ;;
10127 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10128 # if the argument $3 is zero, it means any stat increment is ok.
10129 if [[ $want -gt 0 ]]; then
10130 local count=$(echo $res | awk '{ print $2 }')
10131 [[ $count -ne $want ]] &&
10132 error "The $op counter on $facet is $count, not $want"
10137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10138 remote_ost_nodsh && skip "remote OST with nodsh" && return
10139 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10141 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10142 { skip "MDS doesn't support rename stats"; return; }
10143 local testdir=$DIR/${tdir}/stats_testdir
10144 mkdir -p $DIR/${tdir}
10147 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10148 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10150 # verify mdt stats first.
10151 mkdir ${testdir} || error "mkdir failed"
10152 check_stats $SINGLEMDS "mkdir" 1
10153 touch ${testdir}/${tfile} || error "touch failed"
10154 check_stats $SINGLEMDS "open" 1
10155 check_stats $SINGLEMDS "close" 1
10156 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10157 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10158 check_stats $SINGLEMDS "mknod" 2
10160 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10161 check_stats $SINGLEMDS "unlink" 1
10162 rm -f ${testdir}/${tfile} || error "file remove failed"
10163 check_stats $SINGLEMDS "unlink" 2
10165 # remove working dir and check mdt stats again.
10166 rmdir ${testdir} || error "rmdir failed"
10167 check_stats $SINGLEMDS "rmdir" 1
10169 local testdir1=$DIR/${tdir}/stats_testdir1
10170 mkdir -p ${testdir}
10171 mkdir -p ${testdir1}
10172 touch ${testdir1}/test1
10173 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10174 check_stats $SINGLEMDS "crossdir_rename" 1
10176 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10177 check_stats $SINGLEMDS "samedir_rename" 1
10179 rm -rf $DIR/${tdir}
10181 run_test 133a "Verifying MDT stats ========================================"
10184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10185 remote_ost_nodsh && skip "remote OST with nodsh" && return
10186 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10187 local testdir=$DIR/${tdir}/stats_testdir
10188 mkdir -p ${testdir} || error "mkdir failed"
10189 touch ${testdir}/${tfile} || error "touch failed"
10190 cancel_lru_locks mdc
10193 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10194 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10196 # extra mdt stats verification.
10197 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10198 check_stats $SINGLEMDS "setattr" 1
10199 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10200 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10202 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10203 check_stats $SINGLEMDS "getattr" 1
10205 $LFS df || error "lfs failed"
10206 check_stats $SINGLEMDS "statfs" 1
10208 rm -rf $DIR/${tdir}
10210 run_test 133b "Verifying extra MDT stats =================================="
10213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10214 remote_ost_nodsh && skip "remote OST with nodsh" && return
10215 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10216 local testdir=$DIR/$tdir/stats_testdir
10217 test_mkdir -p $testdir
10219 # verify obdfilter stats.
10220 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10222 cancel_lru_locks osc
10223 wait_delete_completed
10226 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10227 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10229 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10232 cancel_lru_locks osc
10233 check_stats ost1 "write" 1
10235 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10236 check_stats ost1 "read" 1
10238 > $testdir/$tfile || error "truncate failed"
10239 check_stats ost1 "punch" 1
10241 rm -f $testdir/$tfile || error "file remove failed"
10242 wait_delete_completed
10243 check_stats ost1 "destroy" 1
10247 run_test 133c "Verifying OST stats ========================================"
10254 while [ $value -ge 2 ]; do
10259 if [ $orig -gt $order ]; then
10267 local size=('K' 'M' 'G' 'T');
10269 local size_string=$value
10271 while [ $value -ge 1024 ]; do
10272 if [ $i -gt 3 ]; then
10273 #T is the biggest unit we get here, if that is bigger,
10275 size_string=${value}T
10278 value=$((value >> 10))
10279 if [ $value -lt 1024 ]; then
10280 size_string=${value}${size[$i]}
10289 get_rename_size() {
10291 local context=${2:-.}
10292 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
10293 grep -A1 $context |
10294 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10300 remote_ost_nodsh && skip "remote OST with nodsh" && return
10301 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10302 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10303 { skip "MDS doesn't support rename stats"; return; }
10305 local testdir1=$DIR/${tdir}/stats_testdir1
10306 local testdir2=$DIR/${tdir}/stats_testdir2
10308 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10310 mkdir -p ${testdir1} || error "mkdir failed"
10311 mkdir -p ${testdir2} || error "mkdir failed"
10313 createmany -o $testdir1/test 512 || error "createmany failed"
10315 # check samedir rename size
10316 mv ${testdir1}/test0 ${testdir1}/test_0
10318 local testdir1_size=$(ls -l $DIR/${tdir} |
10319 awk '/stats_testdir1/ {print $5}')
10320 local testdir2_size=$(ls -l $DIR/${tdir} |
10321 awk '/stats_testdir2/ {print $5}')
10323 testdir1_size=$(order_2 $testdir1_size)
10324 testdir2_size=$(order_2 $testdir2_size)
10326 testdir1_size=$(size_in_KMGT $testdir1_size)
10327 testdir2_size=$(size_in_KMGT $testdir2_size)
10329 echo "source rename dir size: ${testdir1_size}"
10330 echo "target rename dir size: ${testdir2_size}"
10332 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
10333 eval $cmd || error "$cmd failed"
10334 local samedir=$($cmd | grep 'same_dir')
10335 local same_sample=$(get_rename_size $testdir1_size)
10336 [ -z "$samedir" ] && error "samedir_rename_size count error"
10337 [[ $same_sample -eq 1 ]] ||
10338 error "samedir_rename_size error $same_sample"
10339 echo "Check same dir rename stats success"
10341 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10343 # check crossdir rename size
10344 mv ${testdir1}/test_0 ${testdir2}/test_0
10346 testdir1_size=$(ls -l $DIR/${tdir} |
10347 awk '/stats_testdir1/ {print $5}')
10348 testdir2_size=$(ls -l $DIR/${tdir} |
10349 awk '/stats_testdir2/ {print $5}')
10351 testdir1_size=$(order_2 $testdir1_size)
10352 testdir2_size=$(order_2 $testdir2_size)
10354 testdir1_size=$(size_in_KMGT $testdir1_size)
10355 testdir2_size=$(size_in_KMGT $testdir2_size)
10357 echo "source rename dir size: ${testdir1_size}"
10358 echo "target rename dir size: ${testdir2_size}"
10360 eval $cmd || error "$cmd failed"
10361 local crossdir=$($cmd | grep 'crossdir')
10362 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10363 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10364 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10365 [[ $src_sample -eq 1 ]] ||
10366 error "crossdir_rename_size error $src_sample"
10367 [[ $tgt_sample -eq 1 ]] ||
10368 error "crossdir_rename_size error $tgt_sample"
10369 echo "Check cross dir rename stats success"
10370 rm -rf $DIR/${tdir}
10372 run_test 133d "Verifying rename_stats ========================================"
10375 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10376 remote_ost_nodsh && skip "remote OST with nodsh" && return
10377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10378 local testdir=$DIR/${tdir}/stats_testdir
10379 local ctr f0 f1 bs=32768 count=42 sum
10381 mkdir -p ${testdir} || error "mkdir failed"
10383 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10385 for ctr in {write,read}_bytes; do
10387 cancel_lru_locks osc
10389 do_facet ost1 $LCTL set_param -n \
10390 "obdfilter.*.exports.clear=clear"
10392 if [ $ctr = write_bytes ]; then
10394 f1=${testdir}/${tfile}
10396 f0=${testdir}/${tfile}
10400 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10403 cancel_lru_locks osc
10405 sum=$(do_facet ost1 $LCTL get_param \
10406 "obdfilter.*.exports.*.stats" |
10407 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10408 $1 == ctr { sum += $7 }
10409 END { printf("%0.0f", sum) }')
10411 if ((sum != bs * count)); then
10412 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10416 rm -rf $DIR/${tdir}
10418 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10420 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10423 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10424 remote_ost_nodsh && skip "remote OST with nodsh" && return
10425 # First without trusting modes.
10426 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10427 echo "proc_dirs='$proc_dirs'"
10428 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10429 find $proc_dirs -exec cat '{}' \; &> /dev/null
10431 # Second verifying readability.
10432 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10434 # eventually, this can also be replaced with "lctl get_param -R",
10435 # but not until that option is always available on the server
10437 for facet in mds1 ost1; do
10438 local facet_proc_dirs=$(do_facet $facet \
10439 \\\ls -d $proc_regexp 2>/dev/null)
10440 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10441 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10442 do_facet $facet find $facet_proc_dirs \
10443 ! -name req_history \
10444 -exec cat '{}' \\\; &> /dev/null
10446 do_facet $facet find $facet_proc_dirs \
10447 ! -name req_history \
10449 -exec cat '{}' \\\; &> /dev/null ||
10450 error "proc file read failed"
10453 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10457 remote_ost_nodsh && skip "remote OST with nodsh" && return
10458 # Second verifying writability.
10459 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10460 echo "proc_dirs='$proc_dirs'"
10461 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10463 -ignore_readdir_race \
10465 -not -name force_lbug \
10466 -not -name changelog_mask \
10467 -exec badarea_io '{}' \; ||
10468 error "find $proc_dirs failed"
10471 for facet in mds1 ost1; do
10472 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10473 skip "Too old lustre on $facet" && continue
10474 local facet_proc_dirs=$(do_facet $facet \
10475 \\\ls -d $proc_regexp 2> /dev/null)
10476 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10477 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10478 do_facet $facet find $facet_proc_dirs \
10479 -ignore_readdir_race \
10481 -not -name force_lbug \
10482 -not -name changelog_mask \
10483 -exec badarea_io '{}' \\\; ||
10484 error "$facet find $facet_proc_dirs failed"
10487 # remount the FS in case writes/reads /proc break the FS
10488 cleanup || error "failed to unmount"
10489 setup || error "failed to setup"
10492 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10495 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10496 remote_ost_nodsh && skip "remote OST with nodsh" && return
10497 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10498 skip "Need MDS version at least 2.9.54" && return
10501 for facet in client mds1 ost1; do
10502 local facet_proc_dirs=$(do_facet $facet \
10503 \\\ls -d $proc_regexp 2> /dev/null)
10504 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10505 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10506 # Get the list of files that are missing the terminating newline
10507 local missing=($(do_facet $facet \
10508 find ${facet_proc_dirs} -type f \| \
10509 while read F\; do \
10510 awk -v FS='\v' -v RS='\v\v' \
10511 "'END { if(NR>0 && \
10512 \\\$NF !~ /.*\\\n\$/) \
10513 print FILENAME}'" \
10516 [ ${#missing[*]} -eq 0 ] ||
10517 error "files do not end with newline: ${missing[*]}"
10520 run_test 133h "Proc files should end with newlines"
10523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10524 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10525 skip "Need MDS version at least 2.7.54" && return
10527 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10528 cancel_lru_locks mdc
10530 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10531 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10532 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10535 createmany -o $DIR/$tdir/f $nr ||
10536 error "failed to create $nr files in $DIR/$tdir"
10537 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10539 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10540 do_facet mds1 $LCTL set_param fail_loc=0x327
10541 do_facet mds1 $LCTL set_param fail_val=500
10544 echo "sleep 10 seconds ..."
10546 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10548 do_facet mds1 $LCTL set_param fail_loc=0
10549 do_facet mds1 $LCTL set_param fail_val=0
10550 [ $lck_cnt -lt $unused ] ||
10551 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10554 unlinkmany $DIR/$tdir/f $nr
10556 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10559 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10560 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10561 skip "Need MDS version at least 2.7.54" && return
10563 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10564 cancel_lru_locks mdc
10566 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10567 ldlm.lock_reclaim_threshold_mb)
10568 # disable reclaim temporarily
10569 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10571 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10572 do_facet mds1 $LCTL set_param fail_loc=0x328
10573 do_facet mds1 $LCTL set_param fail_val=500
10575 $LCTL set_param debug=+trace
10578 createmany -o $DIR/$tdir/f $nr &
10579 local create_pid=$!
10581 echo "Sleep $TIMEOUT seconds ..."
10583 if ! ps -p $create_pid > /dev/null 2>&1; then
10584 do_facet mds1 $LCTL set_param fail_loc=0
10585 do_facet mds1 $LCTL set_param fail_val=0
10586 do_facet mds1 $LCTL set_param \
10587 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10588 error "createmany finished incorrectly!"
10590 do_facet mds1 $LCTL set_param fail_loc=0
10591 do_facet mds1 $LCTL set_param fail_val=0
10592 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10593 wait $create_pid || return 1
10595 unlinkmany $DIR/$tdir/f $nr
10597 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10599 test_140() { #bug-17379
10600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10601 test_mkdir $DIR/$tdir
10602 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10603 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10605 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10606 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10608 while i=$((i + 1)); do
10610 cd $i || error "Changing to $i"
10611 ln -s ../stat stat || error "Creating stat symlink"
10612 # Read the symlink until ELOOP present,
10613 # not LBUGing the system is considered success,
10614 # we didn't overrun the stack.
10615 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10616 if [ $ret -ne 0 ]; then
10617 if [ $ret -eq 40 ]; then
10620 error "Open stat symlink"
10626 echo "The symlink depth = $i"
10627 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10628 error "Invalid symlink depth"
10630 # Test recursive symlink
10631 ln -s symlink_self symlink_self
10632 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10633 echo "open symlink_self returns $ret"
10634 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10636 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10640 local TF="$TMP/$tfile"
10642 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10644 cancel_lru_locks $OSC
10645 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10646 remount_client $MOUNT
10648 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10651 $TRUNCATE $DIR/$tfile 6000
10652 cancel_lru_locks $OSC
10653 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10656 echo "12345" >>$DIR/$tfile
10657 cancel_lru_locks $OSC
10658 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10661 echo "12345" >>$DIR/$tfile
10662 cancel_lru_locks $OSC
10663 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10668 run_test 150 "truncate/append tests"
10670 #LU-2902 roc_hit was not able to read all values from lproc
10671 function roc_hit_init() {
10672 local list=$(comma_list $(osts_nodes))
10673 local dir=$DIR/$tdir-check
10674 local file=$dir/$tfile
10680 #use setstripe to do a write to every ost
10681 for i in $(seq 0 $((OSTCOUNT-1))); do
10682 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10683 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10684 idx=$(printf %04x $i)
10685 BEFORE=$(get_osd_param $list *OST*$idx stats |
10686 awk '$1 == "cache_access" {sum += $7}
10687 END { printf("%0.0f", sum) }')
10689 cancel_lru_locks osc
10690 cat $file >/dev/null
10692 AFTER=$(get_osd_param $list *OST*$idx stats |
10693 awk '$1 == "cache_access" {sum += $7}
10694 END { printf("%0.0f", sum) }')
10696 echo BEFORE:$BEFORE AFTER:$AFTER
10697 if ! let "AFTER - BEFORE == 4"; then
10699 error "roc_hit is not safe to use"
10707 function roc_hit() {
10708 local list=$(comma_list $(osts_nodes))
10709 echo $(get_osd_param $list '' stats |
10710 awk '$1 == "cache_hit" {sum += $7}
10711 END { printf("%0.0f", sum) }')
10714 function set_cache() {
10717 if [ "$2" == "off" ]; then
10720 local list=$(comma_list $(osts_nodes))
10721 set_osd_param $list '' $1_cache_enable $on
10723 cancel_lru_locks osc
10727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10728 remote_ost_nodsh && skip "remote OST with nodsh" && return
10731 local list=$(comma_list $(osts_nodes))
10733 # check whether obdfilter is cache capable at all
10734 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10735 echo "not cache-capable obdfilter"
10739 # check cache is enabled on all obdfilters
10740 if get_osd_param $list '' read_cache_enable | grep 0; then
10741 echo "oss cache is disabled"
10745 set_osd_param $list '' writethrough_cache_enable 1
10747 # check write cache is enabled on all obdfilters
10748 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10749 echo "oss write cache is NOT enabled"
10755 #define OBD_FAIL_OBD_NO_LRU 0x609
10756 do_nodes $list $LCTL set_param fail_loc=0x609
10758 # pages should be in the case right after write
10759 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10762 local BEFORE=$(roc_hit)
10763 cancel_lru_locks osc
10764 cat $DIR/$tfile >/dev/null
10765 local AFTER=$(roc_hit)
10767 do_nodes $list $LCTL set_param fail_loc=0
10769 if ! let "AFTER - BEFORE == CPAGES"; then
10770 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10773 # the following read invalidates the cache
10774 cancel_lru_locks osc
10775 set_osd_param $list '' read_cache_enable 0
10776 cat $DIR/$tfile >/dev/null
10778 # now data shouldn't be found in the cache
10780 cancel_lru_locks osc
10781 cat $DIR/$tfile >/dev/null
10783 if let "AFTER - BEFORE != 0"; then
10784 error "IN CACHE: before: $BEFORE, after: $AFTER"
10787 set_osd_param $list '' read_cache_enable 1
10790 run_test 151 "test cache on oss and controls ==============================="
10793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10794 local TF="$TMP/$tfile"
10796 # simulate ENOMEM during write
10797 #define OBD_FAIL_OST_NOMEM 0x226
10798 lctl set_param fail_loc=0x80000226
10799 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10801 sync || error "sync failed"
10802 lctl set_param fail_loc=0
10804 # discard client's cache
10805 cancel_lru_locks osc
10807 # simulate ENOMEM during read
10808 lctl set_param fail_loc=0x80000226
10809 cmp $TF $DIR/$tfile || error "cmp failed"
10810 lctl set_param fail_loc=0
10814 run_test 152 "test read/write with enomem ============================"
10817 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10819 run_test 153 "test if fdatasync does not crash ======================="
10821 dot_lustre_fid_permission_check() {
10823 local ffid=$MOUNT/.lustre/fid/$fid
10826 echo "stat fid $fid"
10827 stat $ffid > /dev/null || error "stat $ffid failed."
10828 echo "touch fid $fid"
10829 touch $ffid || error "touch $ffid failed."
10830 echo "write to fid $fid"
10831 cat /etc/hosts > $ffid || error "write $ffid failed."
10832 echo "read fid $fid"
10833 diff /etc/hosts $ffid || error "read $ffid failed."
10834 echo "append write to fid $fid"
10835 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10836 echo "rename fid $fid"
10837 mv $ffid $test_dir/$tfile.1 &&
10838 error "rename $ffid to $tfile.1 should fail."
10839 touch $test_dir/$tfile.1
10840 mv $test_dir/$tfile.1 $ffid &&
10841 error "rename $tfile.1 to $ffid should fail."
10842 rm -f $test_dir/$tfile.1
10843 echo "truncate fid $fid"
10844 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10845 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10846 echo "link fid $fid"
10847 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10849 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10850 echo "setfacl fid $fid"
10851 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10852 echo "getfacl fid $fid"
10853 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10855 echo "unlink fid $fid"
10856 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10857 echo "mknod fid $fid"
10858 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10860 fid=[0xf00000400:0x1:0x0]
10861 ffid=$MOUNT/.lustre/fid/$fid
10863 echo "stat non-exist fid $fid"
10864 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10865 echo "write to non-exist fid $fid"
10866 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10867 echo "link new fid $fid"
10868 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10870 mkdir -p $test_dir/$tdir
10871 touch $test_dir/$tdir/$tfile
10872 fid=$($LFS path2fid $test_dir/$tdir)
10875 error "error: could not get fid for $test_dir/$dir/$tfile."
10877 ffid=$MOUNT/.lustre/fid/$fid
10880 ls $ffid > /dev/null || error "ls $ffid failed."
10881 echo "touch $fid/$tfile.1"
10882 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10884 echo "touch $MOUNT/.lustre/fid/$tfile"
10885 touch $MOUNT/.lustre/fid/$tfile && \
10886 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10888 echo "setxattr to $MOUNT/.lustre/fid"
10889 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10891 echo "listxattr for $MOUNT/.lustre/fid"
10892 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10894 echo "delxattr from $MOUNT/.lustre/fid"
10895 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10897 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10898 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10899 error "touch invalid fid should fail."
10901 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10902 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10903 error "touch non-normal fid should fail."
10905 echo "rename $tdir to $MOUNT/.lustre/fid"
10906 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10907 error "rename to $MOUNT/.lustre/fid should fail."
10909 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10911 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10912 local new_obf_mode=777
10914 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10915 chmod $new_obf_mode $DIR/.lustre/fid ||
10916 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10918 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10919 [ $obf_mode -eq $new_obf_mode ] ||
10920 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10922 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10923 chmod $old_obf_mode $DIR/.lustre/fid ||
10924 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10927 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10928 fid=$($LFS path2fid $test_dir/$tfile-2)
10930 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10932 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10933 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10934 error "create lov data thru .lustre failed"
10936 echo "cp /etc/passwd $test_dir/$tfile-2"
10937 cp /etc/passwd $test_dir/$tfile-2 ||
10938 error "copy to $test_dir/$tfile-2 failed."
10939 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10940 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10941 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10943 rm -rf $test_dir/tfile.lnk
10944 rm -rf $test_dir/$tfile-2
10948 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10949 skip "Need MDS version at least 2.4.1" && return
10951 local tf=$DIR/$tfile
10954 local fid=$($LFS path2fid $tf)
10955 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10957 # check that we get the same pathname back
10958 local found=$($LFS fid2path $MOUNT "$fid")
10959 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10960 [ "$found" == "$tf" ] ||
10961 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10963 run_test 154A "lfs path2fid and fid2path basic checks"
10966 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10967 skip "Need MDS version at least 2.4.1" && return
10969 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10970 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10971 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10972 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10974 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10975 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10977 # check that we get the same pathname
10978 echo "PFID: $PFID, name: $name"
10979 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10980 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10981 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10982 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10984 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10986 run_test 154B "verify the ll_decode_linkea tool"
10989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10990 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10991 { skip "Need MDS version at least 2.2.51"; return 0; }
10992 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10993 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10995 cp /etc/hosts $DIR/$tfile
10997 fid=$($LFS path2fid $DIR/$tfile)
10999 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
11001 dot_lustre_fid_permission_check "$fid" $DIR ||
11002 error "dot lustre permission check $fid failed"
11004 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
11006 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
11008 touch $MOUNT/.lustre/file &&
11009 error "creation is not allowed under .lustre"
11011 mkdir $MOUNT/.lustre/dir &&
11012 error "mkdir is not allowed under .lustre"
11016 run_test 154a "Open-by-FID"
11019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11020 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11021 { skip "Need MDS version at least 2.2.51"; return 0; }
11022 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11024 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11026 local remote_dir=$DIR/$tdir/remote_dir
11030 mkdir -p $DIR/$tdir
11031 $LFS mkdir -i $MDTIDX $remote_dir ||
11032 error "create remote directory failed"
11034 cp /etc/hosts $remote_dir/$tfile
11036 fid=$($LFS path2fid $remote_dir/$tfile)
11038 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11040 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11041 error "dot lustre permission check $fid failed"
11044 run_test 154b "Open-by-FID for remote directory"
11047 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11048 skip "Need MDS version at least 2.4.1" && return
11050 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11051 local FID1=$($LFS path2fid $DIR/$tfile.1)
11052 local FID2=$($LFS path2fid $DIR/$tfile.2)
11053 local FID3=$($LFS path2fid $DIR/$tfile.3)
11056 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11057 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11058 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11060 [ "$FID" = "${!want}" ] ||
11061 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11065 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11067 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11068 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11072 run_test 154c "lfs path2fid and fid2path multiple arguments"
11075 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11076 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
11077 skip "Need MDS version at least 2.5.53" && return
11079 if remote_mds; then
11080 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11084 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11091 local fid=$($LFS path2fid $DIR/$tfile)
11094 cmd="exec $fd<$DIR/$tfile"
11096 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11097 echo "$fid_list" | grep "$fid"
11100 cmd="exec $fd>/dev/null"
11102 if [ $rc -ne 0 ]; then
11103 error "FID $fid not found in open files list $fid_list"
11106 run_test 154d "Verify open file fid"
11110 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
11111 skip "Need MDS version at least 2.6.50" && return
11113 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11114 error ".lustre returned by readdir"
11117 run_test 154e ".lustre is not returned by readdir"
11120 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11121 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11122 test_mkdir -p -c1 $DIR/$tdir/d
11123 # test dirs inherit from its stripe
11124 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11125 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11126 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11127 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11130 # get fid of parents
11131 local FID0=$($LFS path2fid $DIR/$tdir/d)
11132 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11133 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11134 local FID3=$($LFS path2fid $DIR)
11136 # check that path2fid --parents returns expected <parent_fid>/name
11137 # 1) test for a directory (single parent)
11138 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11139 [ "$parent" == "$FID0/foo1" ] ||
11140 error "expected parent: $FID0/foo1, got: $parent"
11142 # 2) test for a file with nlink > 1 (multiple parents)
11143 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11144 echo "$parent" | grep -F "$FID1/$tfile" ||
11145 error "$FID1/$tfile not returned in parent list"
11146 echo "$parent" | grep -F "$FID2/link" ||
11147 error "$FID2/link not returned in parent list"
11149 # 3) get parent by fid
11150 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11151 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11152 echo "$parent" | grep -F "$FID1/$tfile" ||
11153 error "$FID1/$tfile not returned in parent list (by fid)"
11154 echo "$parent" | grep -F "$FID2/link" ||
11155 error "$FID2/link not returned in parent list (by fid)"
11157 # 4) test for entry in root directory
11158 parent=$($LFS path2fid --parents $DIR/f)
11159 echo "$parent" | grep -F "$FID3/f" ||
11160 error "$FID3/f not returned in parent list"
11162 # 5) test it on root directory
11163 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11164 error "$MOUNT should not have parents"
11166 # enable xattr caching and check that linkea is correctly updated
11167 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11168 save_lustre_params client "llite.*.xattr_cache" > $save
11169 lctl set_param llite.*.xattr_cache 1
11171 # 6.1) linkea update on rename
11172 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11174 # get parents by fid
11175 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11176 # foo1 should no longer be returned in parent list
11177 echo "$parent" | grep -F "$FID1" &&
11178 error "$FID1 should no longer be in parent list"
11179 # the new path should appear
11180 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11181 error "$FID2/$tfile.moved is not in parent list"
11183 # 6.2) linkea update on unlink
11184 rm -f $DIR/$tdir/d/foo2/link
11185 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11186 # foo2/link should no longer be returned in parent list
11187 echo "$parent" | grep -F "$FID2/link" &&
11188 error "$FID2/link should no longer be in parent list"
11192 restore_lustre_params < $save
11195 run_test 154f "get parent fids by reading link ea"
11199 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11200 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11201 { skip "Need MDS version at least 2.6.92"; return 0; }
11202 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11204 mkdir -p $DIR/$tdir
11205 llapi_fid_test -d $DIR/$tdir
11207 run_test 154g "various llapi FID tests"
11209 test_155_small_load() {
11210 local temp=$TMP/$tfile
11211 local file=$DIR/$tfile
11213 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11214 error "dd of=$temp bs=6096 count=1 failed"
11216 cancel_lru_locks $OSC
11217 cmp $temp $file || error "$temp $file differ"
11219 $TRUNCATE $temp 6000
11220 $TRUNCATE $file 6000
11221 cmp $temp $file || error "$temp $file differ (truncate1)"
11223 echo "12345" >>$temp
11224 echo "12345" >>$file
11225 cmp $temp $file || error "$temp $file differ (append1)"
11227 echo "12345" >>$temp
11228 echo "12345" >>$file
11229 cmp $temp $file || error "$temp $file differ (append2)"
11235 test_155_big_load() {
11236 remote_ost_nodsh && skip "remote OST with nodsh" && return
11237 local temp=$TMP/$tfile
11238 local file=$DIR/$tfile
11241 local cache_size=$(do_facet ost$((MAXI+1)) \
11242 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11243 local large_file_size=$((cache_size * 2))
11245 echo "OSS cache size: $cache_size KB"
11246 echo "Large file size: $large_file_size KB"
11248 [ $MAXV -le $large_file_size ] && \
11249 skip_env "max available OST size needs > $large_file_size KB" && \
11252 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11254 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
11255 error "dd of=$temp bs=$large_file_size count=1k failed"
11258 cancel_lru_locks osc
11259 cmp $temp $file || error "$temp $file differ"
11265 save_writethrough() {
11266 local facets=$(get_facets OST)
11268 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11269 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11274 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11275 save_writethrough $p
11278 set_cache writethrough on
11279 test_155_small_load
11280 restore_lustre_params < $p
11283 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11287 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11288 save_writethrough $p
11291 set_cache writethrough off
11292 test_155_small_load
11293 restore_lustre_params < $p
11296 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11300 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11301 save_writethrough $p
11304 set_cache writethrough on
11305 test_155_small_load
11306 restore_lustre_params < $p
11309 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11313 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11314 save_writethrough $p
11317 set_cache writethrough off
11318 test_155_small_load
11319 restore_lustre_params < $p
11322 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11326 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11327 save_writethrough $p
11330 set_cache writethrough on
11332 restore_lustre_params < $p
11335 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11339 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11340 save_writethrough $p
11343 set_cache writethrough off
11345 restore_lustre_params < $p
11348 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11352 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11353 save_writethrough $p
11356 set_cache writethrough on
11358 restore_lustre_params < $p
11361 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11365 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11366 save_writethrough $p
11369 set_cache writethrough off
11371 restore_lustre_params < $p
11374 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11377 remote_ost_nodsh && skip "remote OST with nodsh" && return
11378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11382 local file="$DIR/$tfile"
11383 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11385 [ "$(facet_fstype ost1)" = "zfs" -a \
11386 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11387 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11390 save_writethrough $p
11393 log "Turn on read and write cache"
11395 set_cache writethrough on
11397 log "Write data and read it back."
11398 log "Read should be satisfied from the cache."
11399 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11401 cancel_lru_locks osc
11402 cat $file >/dev/null
11404 if ! let "AFTER - BEFORE == CPAGES"; then
11405 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11407 log "cache hits:: before: $BEFORE, after: $AFTER"
11410 log "Read again; it should be satisfied from the cache."
11412 cancel_lru_locks osc
11413 cat $file >/dev/null
11415 if ! let "AFTER - BEFORE == CPAGES"; then
11416 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11418 log "cache hits:: before: $BEFORE, after: $AFTER"
11421 log "Turn off the read cache and turn on the write cache"
11423 set_cache writethrough on
11425 log "Read again; it should be satisfied from the cache."
11427 cancel_lru_locks osc
11428 cat $file >/dev/null
11430 if ! let "AFTER - BEFORE == CPAGES"; then
11431 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11433 log "cache hits:: before: $BEFORE, after: $AFTER"
11436 log "Read again; it should not be satisfied from the cache."
11438 cancel_lru_locks osc
11439 cat $file >/dev/null
11441 if ! let "AFTER - BEFORE == 0"; then
11442 error "IN CACHE: before: $BEFORE, after: $AFTER"
11444 log "cache hits:: before: $BEFORE, after: $AFTER"
11447 log "Write data and read it back."
11448 log "Read should be satisfied from the cache."
11449 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11451 cancel_lru_locks osc
11452 cat $file >/dev/null
11454 if ! let "AFTER - BEFORE == CPAGES"; then
11455 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11457 log "cache hits:: before: $BEFORE, after: $AFTER"
11460 log "Read again; it should not be satisfied from the cache."
11462 cancel_lru_locks osc
11463 cat $file >/dev/null
11465 if ! let "AFTER - BEFORE == 0"; then
11466 error "IN CACHE: before: $BEFORE, after: $AFTER"
11468 log "cache hits:: before: $BEFORE, after: $AFTER"
11471 log "Turn off read and write cache"
11473 set_cache writethrough off
11475 log "Write data and read it back"
11476 log "It should not be satisfied from the cache."
11478 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11479 cancel_lru_locks osc
11481 cat $file >/dev/null
11483 if ! let "AFTER - BEFORE == 0"; then
11484 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11486 log "cache hits:: before: $BEFORE, after: $AFTER"
11489 log "Turn on the read cache and turn off the write cache"
11491 set_cache writethrough off
11493 log "Write data and read it back"
11494 log "It should not be satisfied from the cache."
11496 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11498 cancel_lru_locks osc
11499 cat $file >/dev/null
11501 if ! let "AFTER - BEFORE == 0"; then
11502 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11504 log "cache hits:: before: $BEFORE, after: $AFTER"
11507 log "Read again; it should be satisfied from the cache."
11509 cancel_lru_locks osc
11510 cat $file >/dev/null
11512 if ! let "AFTER - BEFORE == CPAGES"; then
11513 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11515 log "cache hits:: before: $BEFORE, after: $AFTER"
11518 restore_lustre_params < $p
11521 run_test 156 "Verification of tunables"
11524 cleanup_changelog () {
11526 echo "Deregistering changelog client $CL_USER"
11527 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11531 if [[ $MDSCOUNT -gt 1 ]]; then
11532 error_ignore bz17935 $*
11540 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11542 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11544 if [ $MASK -eq 1 ]; then
11545 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11547 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11551 changelog_extract_field() {
11555 local identifier=$4
11557 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11558 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11564 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11565 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11566 { skip "Need MDS version at least 2.2.0"; return; }
11568 local CL_USERS="mdd.$MDT0.changelog_users"
11569 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11570 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11571 changelog_register -n)
11572 echo "Registered as changelog user $CL_USER"
11573 trap cleanup_changelog EXIT
11574 $GET_CL_USERS | grep -q $CL_USER ||
11575 error "User $CL_USER not found in changelog_users"
11578 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11579 touch $DIR/$tdir/pics/2008/zachy/timestamp
11580 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11581 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11582 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11583 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11584 rm $DIR/$tdir/pics/desktop.jpg
11586 $LFS changelog $MDT0 | tail -5
11588 echo "verifying changelog mask"
11589 changelog_chmask "MKDIR"
11590 changelog_chmask "CLOSE"
11592 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11593 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11595 changelog_chmask "MKDIR"
11596 changelog_chmask "CLOSE"
11598 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11599 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11601 $LFS changelog $MDT0
11602 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11603 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11604 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11605 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11608 echo "verifying target fid"
11609 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11610 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11611 [ "$fidc" == "$fidf" ] ||
11612 err17935 "fid in changelog $fidc != file fid $fidf"
11613 echo "verifying parent fid"
11614 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11615 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11616 [ "$fidc" == "$fidf" ] ||
11617 err17935 "pfid in changelog $fidc != dir fid $fidf"
11619 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11620 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11621 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11622 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11623 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11624 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11626 MIN_REC=$($GET_CL_USERS |
11627 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11628 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11629 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11630 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11631 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11633 # LU-3446 changelog index reset on MDT restart
11634 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11635 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11636 $LFS changelog_clear $MDT0 $CL_USER 0
11637 stop $SINGLEMDS || error "Fail to stop MDT."
11638 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11639 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11640 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11641 [ $CUR_REC1 == $CUR_REC2 ] ||
11642 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11644 echo "verifying user deregister"
11646 $GET_CL_USERS | grep -q $CL_USER &&
11647 error "User $CL_USER still in changelog_users"
11649 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11650 if [ $CL_USER -eq 0 ]; then
11651 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11652 touch $DIR/$tdir/chloe
11653 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11654 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11655 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11657 echo "$CL_USER other changelog users; can't verify off"
11660 run_test 160a "changelog sanity"
11662 test_160b() { # LU-3587
11663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11664 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11665 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11666 { skip "Need MDS version at least 2.2.0"; return; }
11668 local CL_USERS="mdd.$MDT0.changelog_users"
11669 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11670 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11671 changelog_register -n)
11672 echo "Registered as changelog user $CL_USER"
11673 trap cleanup_changelog EXIT
11674 $GET_CL_USERS | grep -q $CL_USER ||
11675 error "User $CL_USER not found in changelog_users"
11677 local LONGNAME1=$(str_repeat a 255)
11678 local LONGNAME2=$(str_repeat b 255)
11681 echo "creating very long named file"
11682 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11683 echo "moving very long named file"
11684 mv $LONGNAME1 $LONGNAME2
11686 $LFS changelog $MDT0 | grep RENME
11690 run_test 160b "Verify that very long rename doesn't crash in changelog"
11693 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11696 local server_version=$(lustre_version_code $SINGLEMDS)
11698 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11699 [[ $server_version -gt $(version_code 2.5.1) &&
11700 $server_version -lt $(version_code 2.5.50) ]] ||
11701 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11704 # Registration step
11705 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11706 changelog_register -n)
11707 trap cleanup_changelog EXIT
11710 mkdir -p $DIR/$tdir
11711 $MCREATE $DIR/$tdir/foo_160c
11712 changelog_chmask "TRUNC"
11713 $TRUNCATE $DIR/$tdir/foo_160c 200
11714 changelog_chmask "TRUNC"
11715 $TRUNCATE $DIR/$tdir/foo_160c 199
11716 $LFS changelog $MDT0
11717 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11718 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11719 $LFS changelog_clear $MDT0 $CL_USER 0
11721 # Deregistration step
11724 run_test 160c "verify that changelog log catch the truncate event"
11727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11728 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11730 local server_version=$(lustre_version_code mds1)
11731 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11733 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11734 { skip "Need MDS version at least 2.7.60+"; return; }
11735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11737 # Registration step
11738 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11739 changelog_register -n)
11741 trap cleanup_changelog EXIT
11742 mkdir -p $DIR/$tdir/migrate_dir
11743 $LFS changelog_clear $MDT0 $CL_USER 0
11745 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11746 $LFS changelog $MDT0
11747 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11748 $LFS changelog_clear $MDT0 $CL_USER 0
11749 [ $MIGRATES -eq 1 ] ||
11750 error "MIGRATE changelog mask count $MIGRATES != 1"
11752 # Deregistration step
11755 run_test 160d "verify that changelog log catch the migrate event"
11758 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11761 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11762 changelog_register -n)
11763 echo "Registered as changelog user $CL_USER"
11764 trap cleanup_changelog EXIT
11766 # Delete a future user (expect fail)
11767 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11770 if [ $rc -eq 0 ]; then
11771 error "Deleted non-existant user cl77"
11772 elif [ $rc -ne 2 ]; then
11773 error "changelog_deregister failed with $rc, " \
11774 "expected 2 (ENOENT)"
11777 # Clear to a bad index (1 billion should be safe)
11778 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11781 if [ $rc -eq 0 ]; then
11782 error "Successfully cleared to invalid CL index"
11783 elif [ $rc -ne 22 ]; then
11784 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11787 run_test 160e "changelog negative testing"
11791 do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
11792 echo "Deregistering changelog client $CL_USER"
11793 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11794 echo "Deregistering changelog client $CL_USER2"
11795 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
11796 restore_lustre_params < $save_params
11801 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11802 # should be set by default
11804 local CL_USERS="mdd.$MDT0.changelog_users"
11805 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11806 local save_params="$TMP/sanity-$TESTNAME.parameters"
11808 save_lustre_params $SINGLEMDS \
11809 "mdd.$MDT0.changelog_max_idle_time" > $save_params
11810 save_lustre_params $SINGLEMDS \
11811 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11812 save_lustre_params $SINGLEMDS \
11813 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11815 trap cleanup_160f EXIT
11818 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11819 changelog_register -n)
11820 echo "Registered as changelog user $CL_USER"
11821 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11822 changelog_register -n)
11823 echo "Registered as changelog user $CL_USER2"
11824 $GET_CL_USERS | grep -q $CL_USER ||
11825 error "User $CL_USER not found in changelog_users"
11826 $GET_CL_USERS | grep -q $CL_USER2 ||
11827 error "User $CL_USER2 not found in changelog_users"
11829 # generate some changelogs to accumulate
11830 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11831 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11832 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11833 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11835 # check changelogs have been generated
11836 nbcl=$($LFS changelog $MDT0 | wc -l)
11837 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11839 do_facet $SINGLEMDS $LCTL set_param \
11840 mdd.$MDT0.changelog_max_idle_time=10
11841 do_facet $SINGLEMDS $LCTL set_param \
11842 mdd.$MDT0.changelog_min_gc_interval=2
11843 do_facet $SINGLEMDS $LCTL set_param \
11844 mdd.$MDT0.changelog_min_free_cat_entries=3
11846 # simulate changelog catalog almost full
11847 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11848 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11849 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11852 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11853 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
11854 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11855 echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
11856 [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
11857 error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
11860 # generate one more changelog to trigger fail_loc
11861 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11863 # ensure gc thread is done
11864 wait_update_facet $SINGLEMDS \
11865 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11867 # check user still registered
11868 $GET_CL_USERS | grep -q $CL_USER ||
11869 error "User $CL_USER not found in changelog_users"
11870 # check user2 unregistered
11871 $GET_CL_USERS | grep -q $CL_USER2 &&
11872 error "User $CL_USER2 still found in changelog_users"
11874 # check changelogs are present and starting at $USER_REC2 + 1
11875 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11876 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11877 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11878 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11882 run_test 160f "changelog garbage collect (timestamped users)"
11885 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11886 # should be set by default
11888 local CL_USERS="mdd.$MDT0.changelog_users"
11889 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11890 local save_params="$TMP/sanity-$TESTNAME.parameters"
11892 save_lustre_params $SINGLEMDS \
11893 "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
11894 save_lustre_params $SINGLEMDS \
11895 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11896 save_lustre_params $SINGLEMDS \
11897 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11899 trap cleanup_160f EXIT
11901 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
11902 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
11905 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11906 changelog_register -n)
11907 echo "Registered as changelog user $CL_USER"
11908 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11909 changelog_register -n)
11910 echo "Registered as changelog user $CL_USER2"
11911 $GET_CL_USERS | grep -q $CL_USER ||
11912 error "User $CL_USER not found in changelog_users"
11913 $GET_CL_USERS | grep -q $CL_USER2 ||
11914 error "User $CL_USER2 not found in changelog_users"
11916 # generate some changelogs to accumulate
11917 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11918 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11919 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11920 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11922 # check changelogs have been generated
11923 nbcl=$($LFS changelog $MDT0 | wc -l)
11924 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11926 do_facet $SINGLEMDS $LCTL set_param \
11927 mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
11928 do_facet $SINGLEMDS $LCTL set_param \
11929 mdd.$MDT0.changelog_min_gc_interval=2
11930 do_facet $SINGLEMDS $LCTL set_param \
11931 mdd.$MDT0.changelog_min_free_cat_entries=3
11933 # simulate changelog catalog almost full
11934 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11935 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11936 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11938 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11939 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
11940 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11941 echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
11942 [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
11943 error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
11945 # generate one more changelog to trigger fail_loc
11946 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11948 # ensure gc thread is done
11949 wait_update_facet $SINGLEMDS \
11950 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11952 # check user still registered
11953 $GET_CL_USERS | grep -q $CL_USER ||
11954 error "User $CL_USER not found in changelog_users"
11955 # check user2 unregistered
11956 $GET_CL_USERS | grep -q $CL_USER2 &&
11957 error "User $CL_USER2 still found in changelog_users"
11959 # check changelogs are present and starting at $USER_REC2 + 1
11960 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11961 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11962 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11963 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11967 run_test 160g "changelog garbage collect (old users)"
11970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11971 test_mkdir -c1 $DIR/$tdir
11972 cp /etc/hosts $DIR/$tdir/$tfile
11973 test_mkdir -c1 $DIR/$tdir/foo1
11974 test_mkdir -c1 $DIR/$tdir/foo2
11975 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11976 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11977 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11978 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11979 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11980 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11981 $LFS fid2path $DIR $FID
11982 err17935 "bad link ea"
11985 rm $DIR/$tdir/foo2/zachary
11987 rm $DIR/$tdir/foo2/thor
11989 rm $DIR/$tdir/$tfile
11991 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11992 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11994 $LFS fid2path $DIR $FID
11995 err17935 "bad link rename"
11997 rm $DIR/$tdir/foo2/maggie
12000 local longname=filename_avg_len_is_thirty_two_
12001 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
12002 error "failed to hardlink many files"
12003 links=$($LFS fid2path $DIR $FID | wc -l)
12004 echo -n "${links}/1000 links in link EA"
12005 [[ $links -gt 60 ]] ||
12006 err17935 "expected at least 60 links in link EA"
12007 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
12008 error "failed to unlink many hardlinks"
12010 run_test 161a "link ea sanity"
12013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12014 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
12016 local remote_dir=$DIR/$tdir/remote_dir
12018 mkdir -p $DIR/$tdir
12019 $LFS mkdir -i $MDTIDX $remote_dir ||
12020 error "create remote directory failed"
12022 cp /etc/hosts $remote_dir/$tfile
12023 mkdir -p $remote_dir/foo1
12024 mkdir -p $remote_dir/foo2
12025 ln $remote_dir/$tfile $remote_dir/foo1/sofia
12026 ln $remote_dir/$tfile $remote_dir/foo2/zachary
12027 ln $remote_dir/$tfile $remote_dir/foo1/luna
12028 ln $remote_dir/$tfile $remote_dir/foo2/thor
12030 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
12032 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12033 $LFS fid2path $DIR $FID
12034 err17935 "bad link ea"
12037 rm $remote_dir/foo2/zachary
12039 rm $remote_dir/foo2/thor
12041 rm $remote_dir/$tfile
12043 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
12044 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
12045 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
12046 $LFS fid2path $DIR $FID
12047 err17935 "bad link rename"
12049 rm $remote_dir/foo2/maggie
12052 local longname=filename_avg_len_is_thirty_two_
12053 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
12054 error "failed to hardlink many files"
12055 links=$($LFS fid2path $DIR $FID | wc -l)
12056 echo -n "${links}/1000 links in link EA"
12057 [[ ${links} -gt 60 ]] ||
12058 err17935 "expected at least 60 links in link EA"
12059 unlinkmany $remote_dir/foo2/$longname 1000 ||
12060 error "failed to unlink many hardlinks"
12062 run_test 161b "link ea sanity under remote directory"
12065 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12067 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
12068 skip "Need MDS version at least 2.1.5" && return
12070 # define CLF_RENAME_LAST 0x0001
12071 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
12072 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
12073 changelog_register -n)
12075 trap cleanup_changelog EXIT
12077 mkdir -p $DIR/$tdir
12078 touch $DIR/$tdir/foo_161c
12079 touch $DIR/$tdir/bar_161c
12080 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12081 $LFS changelog $MDT0 | grep RENME
12082 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
12084 $LFS changelog_clear $MDT0 $CL_USER 0
12085 if [ x$flags != "x0x1" ]; then
12086 error "flag $flags is not 0x1"
12088 echo "rename overwrite a target having nlink = 1," \
12089 "changelog record has flags of $flags"
12091 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
12092 touch $DIR/$tdir/foo_161c
12093 touch $DIR/$tdir/bar_161c
12094 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12095 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12096 $LFS changelog $MDT0 | grep RENME
12097 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
12098 $LFS changelog_clear $MDT0 $CL_USER 0
12099 if [ x$flags != "x0x0" ]; then
12100 error "flag $flags is not 0x0"
12102 echo "rename overwrite a target having nlink > 1," \
12103 "changelog record has flags of $flags"
12105 # rename doesn't overwrite a target (changelog flag 0x0)
12106 touch $DIR/$tdir/foo_161c
12107 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
12108 $LFS changelog $MDT0 | grep RENME
12109 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
12110 $LFS changelog_clear $MDT0 $CL_USER 0
12111 if [ x$flags != "x0x0" ]; then
12112 error "flag $flags is not 0x0"
12114 echo "rename doesn't overwrite a target," \
12115 "changelog record has flags of $flags"
12117 # define CLF_UNLINK_LAST 0x0001
12118 # unlink a file having nlink = 1 (changelog flag 0x1)
12119 rm -f $DIR/$tdir/foo2_161c
12120 $LFS changelog $MDT0 | grep UNLNK
12121 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
12122 $LFS changelog_clear $MDT0 $CL_USER 0
12123 if [ x$flags != "x0x1" ]; then
12124 error "flag $flags is not 0x1"
12126 echo "unlink a file having nlink = 1," \
12127 "changelog record has flags of $flags"
12129 # unlink a file having nlink > 1 (changelog flag 0x0)
12130 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12131 rm -f $DIR/$tdir/foobar_161c
12132 $LFS changelog $MDT0 | grep UNLNK
12133 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
12134 $LFS changelog_clear $MDT0 $CL_USER 0
12135 if [ x$flags != "x0x0" ]; then
12136 error "flag $flags is not 0x0"
12138 echo "unlink a file having nlink > 1," \
12139 "changelog record has flags of $flags"
12142 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
12149 # cleanup previous run
12150 rm -rf $DIR/$tdir/$tfile
12152 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
12153 changelog_register -n)
12154 [[ $? -eq 0 ]] || error "changelog_register failed"
12156 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
12157 # interfer with $MOUNT/.lustre/fid/ access
12159 [[ $? -eq 0 ]] || error "mkdir failed"
12161 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
12162 $LCTL set_param fail_loc=0x8000140c
12164 $LCTL set_param fail_val=5
12167 echo foofoo > $DIR/$tdir/$tfile &
12170 # wait for create to be delayed
12174 [[ $? -eq 0 ]] || error "create should be blocked"
12176 local tempfile=$(mktemp)
12177 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
12178 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
12179 # some delay may occur during ChangeLog publishing and file read just
12180 # above, that could allow file write to happen finally
12181 [[ -s $tempfile ]] && echo "file should be empty"
12183 $LCTL set_param fail_loc=0
12186 [[ $? -eq 0 ]] || error "create failed"
12188 $LFS changelog_clear $MDT0 $user 0
12189 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
12191 run_test 161d "create with concurrent .lustre/fid access"
12198 local path=$(${LFS} fid2path $*)
12199 # Remove the '//' indicating a remote directory
12200 path=$(echo $path | sed 's#//#/#g')
12203 if [ $RC -ne 0 ]; then
12204 err17935 "path looked up of $expected failed. Error $RC"
12206 elif [ "${path}" != "${expected}" ]; then
12207 err17935 "path looked up \"${path}\" instead of \"${expected}\""
12210 echo "fid $fid resolves to path $path (expected $expected)"
12213 test_162a() { # was test_162
12214 # Make changes to filesystem
12215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12216 test_mkdir -p -c1 $DIR/$tdir/d2
12217 touch $DIR/$tdir/d2/$tfile
12218 touch $DIR/$tdir/d2/x1
12219 touch $DIR/$tdir/d2/x2
12220 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
12221 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
12223 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
12224 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
12225 error "check path $tdir/d2/$tfile failed"
12228 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
12229 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
12230 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
12231 error "check path $tdir/d2/p/q/r/slink failed"
12233 # softlink to wrong file
12234 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
12235 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
12236 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
12237 error "check path $tdir/d2/p/q/r/slink.wrong failed"
12240 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
12241 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
12242 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
12243 # fid2path dir/fsname should both work
12244 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
12245 error "check path $tdir/d2/a/b/c/new_file failed"
12246 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
12247 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
12249 # hardlink count: check that there are 2 links
12250 # Doesnt work with CMD yet: 17935
12251 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
12252 err17935 "expected 2 links"
12254 # hardlink indexing: remove the first link
12255 rm $DIR/$tdir/d2/p/q/r/hlink
12256 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
12257 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
12261 run_test 162a "path lookup sanity"
12264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12265 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12268 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12269 error "create striped dir failed"
12271 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
12272 tail -n 1 | awk '{print $2}')
12273 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
12275 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
12276 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
12279 for ((i=0;i<5;i++)); do
12280 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
12281 error "get fid for f$i failed"
12282 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
12283 error "check path $tdir/striped_dir/f$i failed"
12285 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
12286 error "get fid for d$i failed"
12287 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
12288 error "check path $tdir/striped_dir/d$i failed"
12293 run_test 162b "striped directory path lookup sanity"
12295 # LU-4239: Verify fid2path works with paths 100 or more directories deep
12297 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
12298 skip "Need MDS version at least 2.7.51" && return
12299 test_mkdir $DIR/$tdir.local
12300 test_mkdir $DIR/$tdir.remote
12301 local lpath=$tdir.local
12302 local rpath=$tdir.remote
12304 for ((i = 0; i <= 101; i++)); do
12307 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
12308 error "get fid for local directory $DIR/$lpath failed"
12309 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
12310 error "check path for local directory $DIR/$lpath failed"
12313 test_mkdir $DIR/$rpath
12314 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
12315 error "get fid for remote directory $DIR/$rpath failed"
12316 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
12317 error "check path for remote directory $DIR/$rpath failed"
12322 run_test 162c "fid2path works with paths 100 or more directories deep"
12325 # do directio so as not to populate the page cache
12326 log "creating a 10 Mb file"
12327 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12328 log "starting reads"
12329 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12330 log "truncating the file"
12331 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12333 kill %+ || true # reads might have finished
12334 echo "wait until dd is finished"
12336 log "removing the temporary file"
12337 rm -rf $DIR/$tfile || error "tmp file removal failed"
12339 run_test 169 "parallel read and truncate should not deadlock"
12342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12344 $LCTL clear # bug 18514
12345 $LCTL debug_daemon start $TMP/${tfile}_log_good
12347 $LCTL debug_daemon stop
12348 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
12349 error "sed failed to read log_good"
12351 $LCTL debug_daemon start $TMP/${tfile}_log_good
12353 $LCTL debug_daemon stop
12355 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
12356 error "lctl df log_bad failed"
12358 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12359 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12361 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
12362 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
12364 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
12365 error "bad_line good_line1 good_line2 are empty"
12367 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12368 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
12369 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12371 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
12372 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12373 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12375 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
12376 error "bad_line_new good_line_new are empty"
12378 local expected_good=$((good_line1 + good_line2*2))
12380 rm -f $TMP/${tfile}*
12381 # LU-231, short malformed line may not be counted into bad lines
12382 if [ $bad_line -ne $bad_line_new ] &&
12383 [ $bad_line -ne $((bad_line_new - 1)) ]; then
12384 error "expected $bad_line bad lines, but got $bad_line_new"
12388 if [ $expected_good -ne $good_line_new ]; then
12389 error "expected $expected_good good lines, but got $good_line_new"
12394 run_test 170 "test lctl df to handle corrupted log ====================="
12396 test_171() { # bug20592
12397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12398 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12399 $LCTL set_param fail_loc=0x50e
12400 $LCTL set_param fail_val=3000
12401 multiop_bg_pause $DIR/$tfile O_s || true
12403 kill -USR1 $MULTIPID
12407 if dmesg | grep "recursive fault"; then
12408 error "caught a recursive fault"
12410 $LCTL set_param fail_loc=0
12413 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12415 # it would be good to share it with obdfilter-survey/iokit-libecho code
12416 setup_obdecho_osc () {
12419 local obdfilter_name=$2
12420 echo "Creating new osc for $obdfilter_name on $ost_nid"
12421 # make sure we can find loopback nid
12422 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12424 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12425 ${obdfilter_name}_osc_UUID || rc=2; }
12426 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12427 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12431 cleanup_obdecho_osc () {
12432 local obdfilter_name=$1
12433 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12434 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12441 local pages=${3:-64}
12446 local obd_size=$(get_obd_size $node $OBD)
12447 local page_size=$(get_page_size $node)
12448 if [[ -n "$obd_size" ]]; then
12449 local new_count=$((obd_size / (pages * page_size / 1024)))
12450 [[ $new_count -ge $count ]] || count=$new_count
12453 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12454 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12456 if [ $rc -eq 0 ]; then
12457 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12458 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12460 echo "New object id is $id"
12461 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12463 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12464 "test_brw $count w v $pages $id" || rc=4; }
12465 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12467 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12468 "cleanup" || rc=5; }
12469 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12470 "detach" || rc=6; }
12471 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12477 remote_ost_nodsh && skip "remote OST with nodsh" && return
12479 local rmmod_local=0
12481 if ! module_loaded obdecho; then
12482 load_module obdecho/obdecho
12486 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12487 local host=$(lctl get_param -n osc.$osc.import |
12488 awk '/current_connection:/ {print $2}' )
12489 local target=$(lctl get_param -n osc.$osc.import |
12490 awk '/target:/ {print $2}' )
12491 target=${target%_UUID}
12493 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12494 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12495 [[ -n $target ]] && cleanup_obdecho_osc $target
12496 [ $rmmod_local -eq 1 ] && rmmod obdecho
12499 run_test 180a "test obdecho on osc"
12502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12503 remote_ost_nodsh && skip "remote OST with nodsh" && return
12505 local rmmod_remote=0
12507 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12508 rmmod_remote=true || error "failed to load module obdecho"
12509 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12510 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12511 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12514 run_test 180b "test obdecho directly on obdfilter"
12516 test_180c() { # LU-2598
12517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12518 remote_ost_nodsh && skip "remote OST with nodsh" && return
12519 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12520 skip "Need MDS version at least 2.4.0" && return
12523 local rmmod_remote=false
12524 local pages=16384 # 64MB bulk I/O RPC size
12527 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12528 rmmod_remote=true || error "failed to load module obdecho"
12530 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12532 if [ -n "$target" ]; then
12533 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12535 echo "there is no obdfilter target on ost1"
12538 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12541 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12543 test_181() { # bug 22177
12544 test_mkdir $DIR/$tdir
12545 # create enough files to index the directory
12546 createmany -o $DIR/$tdir/foobar 4000
12547 # print attributes for debug purpose
12550 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12552 # remove the files & current working dir
12553 unlinkmany $DIR/$tdir/foobar 4000
12555 kill -USR1 $MULTIPID
12557 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12560 run_test 181 "Test open-unlinked dir ========================"
12566 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12568 $LCTL set_param mdc.*.rpc_stats=clear
12570 for (( i = 0; i < $tcount; i++ )) ; do
12571 mkdir $DIR/$tdir/$i
12574 for (( i = 0; i < $tcount; i++ )) ; do
12575 createmany -o $DIR/$tdir/$i/f- $fcount &
12579 for (( i = 0; i < $tcount; i++ )) ; do
12580 unlinkmany $DIR/$tdir/$i/f- $fcount &
12584 $LCTL get_param mdc.*.rpc_stats
12588 run_test 182 "Test parallel modify metadata operations ================"
12590 test_183() { # LU-2275
12591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12592 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12593 skip "Need MDS version at least 2.3.56" && return
12595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12596 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12597 echo aaa > $DIR/$tdir/$tfile
12599 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12600 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12602 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12603 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12605 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12607 # Flush negative dentry cache
12608 touch $DIR/$tdir/$tfile
12610 # We are not checking for any leaked references here, they'll
12611 # become evident next time we do cleanup with module unload.
12614 run_test 183 "No crash or request leak in case of strange dispositions ========"
12616 # test suite 184 is for LU-2016, LU-2017
12618 check_swap_layouts_support && return 0
12620 dir0=$DIR/$tdir/$testnum
12621 test_mkdir -p -c1 $dir0
12626 $SETSTRIPE -c1 $file1
12628 $SETSTRIPE -c2 $file2
12630 gen1=$($GETSTRIPE -g $file1)
12631 gen2=$($GETSTRIPE -g $file2)
12633 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12634 gen=$($GETSTRIPE -g $file1)
12635 [[ $gen1 != $gen ]] ||
12636 "Layout generation on $file1 does not change"
12637 gen=$($GETSTRIPE -g $file2)
12638 [[ $gen2 != $gen ]] ||
12639 "Layout generation on $file2 does not change"
12641 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12642 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12644 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
12646 run_test 184a "Basic layout swap"
12649 check_swap_layouts_support && return 0
12651 dir0=$DIR/$tdir/$testnum
12652 mkdir -p $dir0 || error "creating dir $dir0"
12659 $SETSTRIPE -c1 $file1
12660 $SETSTRIPE -c2 $file2
12661 $SETSTRIPE -c1 $file3
12662 chown $RUNAS_ID $file3
12663 gen1=$($GETSTRIPE -g $file1)
12664 gen2=$($GETSTRIPE -g $file2)
12666 $LFS swap_layouts $dir1 $dir2 &&
12667 error "swap of directories layouts should fail"
12668 $LFS swap_layouts $dir1 $file1 &&
12669 error "swap of directory and file layouts should fail"
12670 $RUNAS $LFS swap_layouts $file1 $file2 &&
12671 error "swap of file we cannot write should fail"
12672 $LFS swap_layouts $file1 $file3 &&
12673 error "swap of file with different owner should fail"
12674 /bin/true # to clear error code
12676 run_test 184b "Forbidden layout swap (will generate errors)"
12679 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12680 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12681 check_swap_layouts_support && return 0
12683 local dir0=$DIR/$tdir/$testnum
12684 mkdir -p $dir0 || error "creating dir $dir0"
12686 local ref1=$dir0/ref1
12687 local ref2=$dir0/ref2
12688 local file1=$dir0/file1
12689 local file2=$dir0/file2
12690 # create a file large enough for the concurrent test
12691 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12692 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12693 echo "ref file size: ref1($(stat -c %s $ref1))," \
12694 "ref2($(stat -c %s $ref2))"
12697 dd if=$ref1 of=$file1 bs=16k &
12700 # Make sure dd starts to copy file
12701 while [ ! -f $file1 ]; do sleep 0.1; done
12703 $LFS swap_layouts $file1 $file2
12706 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12707 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12709 # how many bytes copied before swapping layout
12710 local copied=$(stat -c %s $file2)
12711 local remaining=$(stat -c %s $ref1)
12712 remaining=$((remaining - copied))
12713 echo "Copied $copied bytes before swapping layout..."
12715 cmp -n $copied $file1 $ref2 | grep differ &&
12716 error "Content mismatch [0, $copied) of ref2 and file1"
12717 cmp -n $copied $file2 $ref1 ||
12718 error "Content mismatch [0, $copied) of ref1 and file2"
12719 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12720 error "Content mismatch [$copied, EOF) of ref1 and file1"
12723 rm -f $ref1 $ref2 $file1 $file2
12725 run_test 184c "Concurrent write and layout swap"
12728 check_swap_layouts_support && return 0
12729 [ -z "$(which getfattr 2>/dev/null)" ] &&
12730 skip "no getfattr command" && return 0
12732 local file1=$DIR/$tdir/$tfile-1
12733 local file2=$DIR/$tdir/$tfile-2
12734 local file3=$DIR/$tdir/$tfile-3
12738 mkdir -p $DIR/$tdir
12739 touch $file1 || error "create $file1 failed"
12740 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12741 error "create $file2 failed"
12742 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12743 error "create $file3 failed"
12744 lovea1=$(get_layout_param $file1)
12746 $LFS swap_layouts $file2 $file3 ||
12747 error "swap $file2 $file3 layouts failed"
12748 $LFS swap_layouts $file1 $file2 ||
12749 error "swap $file1 $file2 layouts failed"
12751 lovea2=$(get_layout_param $file2)
12754 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12756 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12757 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12759 run_test 184d "allow stripeless layouts swap"
12762 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12763 { skip "Need MDS version at least 2.6.94"; return 0; }
12764 check_swap_layouts_support && return 0
12765 [ -z "$(which getfattr 2>/dev/null)" ] &&
12766 skip "no getfattr command" && return 0
12768 local file1=$DIR/$tdir/$tfile-1
12769 local file2=$DIR/$tdir/$tfile-2
12770 local file3=$DIR/$tdir/$tfile-3
12773 mkdir -p $DIR/$tdir
12774 touch $file1 || error "create $file1 failed"
12775 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12776 error "create $file2 failed"
12777 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12778 error "create $file3 failed"
12780 $LFS swap_layouts $file1 $file2 ||
12781 error "swap $file1 $file2 layouts failed"
12783 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12784 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12786 echo 123 > $file1 || error "Should be able to write into $file1"
12788 $LFS swap_layouts $file1 $file3 ||
12789 error "swap $file1 $file3 layouts failed"
12791 echo 123 > $file1 || error "Should be able to write into $file1"
12793 rm -rf $file1 $file2 $file3
12795 run_test 184e "Recreate layout after stripeless layout swaps"
12797 test_185() { # LU-2441
12798 # LU-3553 - no volatile file support in old servers
12799 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12800 { skip "Need MDS version at least 2.3.60"; return 0; }
12802 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12803 touch $DIR/$tdir/spoo
12804 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12805 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12806 error "cannot create/write a volatile file"
12807 [ "$FILESET" == "" ] &&
12808 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12809 error "FID is still valid after close"
12811 multiop_bg_pause $DIR/$tdir vVw4096_c
12818 # assume that the next FID for this client is sequential, since stdout
12819 # is unfortunately eaten by multiop_bg_pause
12820 local n=$((${fidv[1]} + 1))
12821 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12822 if [ "$FILESET" == "" ]; then
12823 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12824 error "FID is missing before close"
12826 kill -USR1 $multi_pid
12827 # 1 second delay, so if mtime change we will see it
12829 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12830 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12832 run_test 185 "Volatile file support"
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 local file=$dir0/file1
12843 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12844 local dv1=$($LFS data_version $file)
12845 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12846 local dv2=$($LFS data_version $file)
12847 [[ $dv1 != $dv2 ]] ||
12848 error "data version did not change on write $dv1 == $dv2"
12853 run_test 187a "Test data version change"
12856 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12857 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12858 skip "Need MDS version at least 2.3.0" && return
12860 local dir0=$DIR/$tdir/$testnum
12861 mkdir -p $dir0 || error "creating dir $dir0"
12863 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12864 [[ ${DV[0]} != ${DV[1]} ]] ||
12865 error "data version did not change on write"\
12866 " ${DV[0]} == ${DV[1]}"
12871 run_test 187b "Test data version change on volatile file"
12874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12875 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12876 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12878 local POOL=${POOL:-cea1}
12879 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12880 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12883 local last_ost=$(($OSTCOUNT - 1))
12885 local ost_list=$(seq $first_ost $ost_step $last_ost)
12886 local ost_range="$first_ost $last_ost $ost_step"
12887 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12888 local file_dir=$POOL_ROOT/file_tst
12889 local subdir=$test_path/subdir
12892 if ! combined_mgs_mds ; then
12897 # former test_200a test_200b
12898 pool_add $POOL || { rc=$? ; break; }
12899 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12900 # former test_200c test_200d
12901 mkdir -p $test_path
12902 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12903 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12905 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12906 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12907 || { rc=$? ; break; }
12908 # former test_200e test_200f
12909 local files=$((OSTCOUNT*3))
12910 pool_alloc_files $POOL $test_path $files "$ost_list" \
12911 || { rc=$? ; break; }
12912 pool_create_files $POOL $file_dir $files "$ost_list" \
12913 || { rc=$? ; break; }
12914 # former test_200g test_200h
12915 pool_lfs_df $POOL || { rc=$? ; break; }
12916 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12918 # former test_201a test_201b test_201c
12919 pool_remove_first_target $POOL || { rc=$? ; break; }
12921 local f=$test_path/$tfile
12922 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12923 pool_remove $POOL $f || { rc=$? ; break; }
12929 if ! combined_mgs_mds ; then
12934 run_test 200 "OST pools"
12936 # usage: default_attr <count | size | offset>
12938 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12941 # usage: check_default_stripe_attr
12942 check_default_stripe_attr() {
12943 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12946 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12948 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12952 error "unknown getstripe attr '$1'"
12955 [ $ACTUAL == $EXPECTED ] ||
12956 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12960 test_mkdir $DIR/$tdir
12961 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12963 check_default_stripe_attr --stripe-count
12964 check_default_stripe_attr --stripe-size
12965 check_default_stripe_attr --stripe-index
12967 run_test 204a "Print default stripe attributes"
12970 test_mkdir $DIR/$tdir
12971 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12973 check_default_stripe_attr --stripe-size
12974 check_default_stripe_attr --stripe-index
12976 run_test 204b "Print default stripe size and offset"
12979 test_mkdir $DIR/$tdir
12980 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12982 check_default_stripe_attr --stripe-count
12983 check_default_stripe_attr --stripe-index
12985 run_test 204c "Print default stripe count and offset"
12988 test_mkdir $DIR/$tdir
12989 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12991 check_default_stripe_attr --stripe-count
12992 check_default_stripe_attr --stripe-size
12994 run_test 204d "Print default stripe count and size"
12997 test_mkdir $DIR/$tdir
12998 $SETSTRIPE -d $DIR/$tdir
13000 check_default_stripe_attr --stripe-count --raw
13001 check_default_stripe_attr --stripe-size --raw
13002 check_default_stripe_attr --stripe-index --raw
13004 run_test 204e "Print raw stripe attributes"
13007 test_mkdir $DIR/$tdir
13008 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13010 check_default_stripe_attr --stripe-size --raw
13011 check_default_stripe_attr --stripe-index --raw
13013 run_test 204f "Print raw stripe size and offset"
13016 test_mkdir $DIR/$tdir
13017 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13019 check_default_stripe_attr --stripe-count --raw
13020 check_default_stripe_attr --stripe-index --raw
13022 run_test 204g "Print raw stripe count and offset"
13025 test_mkdir $DIR/$tdir
13026 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13028 check_default_stripe_attr --stripe-count --raw
13029 check_default_stripe_attr --stripe-size --raw
13031 run_test 204h "Print raw stripe count and size"
13033 # Figure out which job scheduler is being used, if any,
13034 # or use a fake one
13035 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
13036 JOBENV=SLURM_JOB_ID
13037 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
13039 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
13041 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
13042 JOBENV=LOADL_STEP_ID
13043 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
13046 $LCTL list_param jobid_name > /dev/null 2>&1
13047 if [ $? -eq 0 ]; then
13054 verify_jobstats() {
13059 # we don't really need to clear the stats for this test to work, since each
13060 # command has a unique jobid, but it makes debugging easier if needed.
13061 # for facet in $facets; do
13062 # local dev=$(convert_facet2label $facet)
13063 # # clear old jobstats
13064 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
13067 # use a new JobID for each test, or we might see an old one
13068 [ "$JOBENV" = "FAKE_JOBID" ] &&
13069 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13073 [ "$JOBENV" = "nodelocal" ] && {
13074 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13075 $LCTL set_param jobid_name=$FAKE_JOBID
13079 log "Test: ${cmd[*]}"
13080 log "Using JobID environment variable $JOBENV=$JOBVAL"
13082 if [ $JOBENV = "FAKE_JOBID" ]; then
13083 FAKE_JOBID=$JOBVAL ${cmd[*]}
13088 # all files are created on OST0000
13089 for facet in $facets; do
13090 local stats="*.$(convert_facet2label $facet).job_stats"
13091 if [ $(do_facet $facet lctl get_param $stats |
13092 grep -c $JOBVAL) -ne 1 ]; then
13093 do_facet $facet lctl get_param $stats
13094 error "No jobstats for $JOBVAL found on $facet::$stats"
13101 NEW_JOBENV=${1:-$OLD_JOBENV}
13102 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
13103 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
13108 do_facet $SINGLEMDS \
13109 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
13110 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
13114 test_205() { # Job stats
13115 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
13116 { skip "Need MDS version with at least 2.7.1"; return 0; }
13118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13119 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13120 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13121 remote_ost_nodsh && skip "remote OST with nodsh" && return
13123 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
13124 skip "Server doesn't support jobstats" && return 0
13125 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
13127 OLD_JOBENV=$($LCTL get_param -n jobid_var)
13128 if [ $OLD_JOBENV != $JOBENV ]; then
13129 jobstats_set $JOBENV
13130 trap cleanup_205 EXIT
13133 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
13134 echo "Registered as changelog user $CL_USER"
13136 OLD_INTERVAL=$(do_facet $SINGLEMDS \
13137 lctl get_param -n mdt.*.job_cleanup_interval)
13138 local interval_new=5
13139 do_facet $SINGLEMDS \
13140 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
13141 local start=$SECONDS
13145 cmd="mkdir $DIR/$tdir"
13146 verify_jobstats "$cmd" "$SINGLEMDS"
13148 cmd="rmdir $DIR/$tdir"
13149 verify_jobstats "$cmd" "$SINGLEMDS"
13150 # mkdir on secondary MDT
13151 if [ $MDSCOUNT -gt 1 ]; then
13152 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
13153 verify_jobstats "$cmd" "mds2"
13156 cmd="mknod $DIR/$tfile c 1 3"
13157 verify_jobstats "$cmd" "$SINGLEMDS"
13159 cmd="rm -f $DIR/$tfile"
13160 verify_jobstats "$cmd" "$SINGLEMDS"
13161 # create all files on OST0000 so verify_jobstats can find OST stats
13163 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
13164 verify_jobstats "$cmd" "$SINGLEMDS"
13166 cmd="touch $DIR/$tfile"
13167 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13169 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
13170 verify_jobstats "$cmd" "ost1"
13172 cancel_lru_locks osc
13173 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
13174 verify_jobstats "$cmd" "ost1"
13176 cmd="$TRUNCATE $DIR/$tfile 0"
13177 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13179 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
13180 verify_jobstats "$cmd" "$SINGLEMDS"
13181 # jobstats expiry - sleep until old stats should be expired
13182 local left=$((interval_new + 5 - (SECONDS - start)))
13183 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
13184 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
13186 cmd="mkdir $DIR/$tdir.expire"
13187 verify_jobstats "$cmd" "$SINGLEMDS"
13188 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
13189 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
13191 # Ensure that jobid are present in changelog (if supported by MDS)
13192 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
13194 $LFS changelog $MDT0 | tail -9
13195 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
13196 [ $jobids -eq 9 ] ||
13197 error "Wrong changelog jobid count $jobids != 9"
13201 jobstats_set $JOBENV
13203 $LFS changelog $MDT0 | tail -1
13204 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
13205 [ $jobids -eq 0 ] ||
13206 error "Unexpected jobids when jobid_var=$JOBENV"
13211 run_test 205 "Verify job stats"
13213 # LU-1480, LU-1773 and LU-1657
13215 mkdir -p $DIR/$tdir
13216 $SETSTRIPE -c -1 $DIR/$tdir
13217 #define OBD_FAIL_LOV_INIT 0x1403
13218 $LCTL set_param fail_loc=0xa0001403
13219 $LCTL set_param fail_val=1
13220 touch $DIR/$tdir/$tfile || true
13222 run_test 206 "fail lov_init_raid0() doesn't lbug"
13225 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13226 local fsz=`stat -c %s $DIR/$tfile`
13227 cancel_lru_locks mdc
13229 # do not return layout in getattr intent
13230 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
13231 $LCTL set_param fail_loc=0x170
13232 local sz=`stat -c %s $DIR/$tfile`
13234 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
13238 run_test 207a "can refresh layout at glimpse"
13241 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13242 local cksum=`md5sum $DIR/$tfile`
13243 local fsz=`stat -c %s $DIR/$tfile`
13244 cancel_lru_locks mdc
13245 cancel_lru_locks osc
13247 # do not return layout in getattr intent
13248 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
13249 $LCTL set_param fail_loc=0x171
13251 # it will refresh layout after the file is opened but before read issues
13252 echo checksum is "$cksum"
13253 echo "$cksum" |md5sum -c --quiet || error "file differs"
13257 run_test 207b "can refresh layout at open"
13260 # FIXME: in this test suite, only RD lease is used. This is okay
13261 # for now as only exclusive open is supported. After generic lease
13262 # is done, this test suite should be revised. - Jinshan
13264 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13265 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
13266 { skip "Need MDS version at least 2.4.52"; return 0; }
13268 echo "==== test 1: verify get lease work"
13269 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
13271 echo "==== test 2: verify lease can be broken by upcoming open"
13272 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13276 $MULTIOP $DIR/$tfile oO_RDONLY:c
13277 kill -USR1 $PID && wait $PID || error "break lease error"
13279 echo "==== test 3: verify lease can't be granted if an open already exists"
13280 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
13284 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
13285 kill -USR1 $PID && wait $PID || error "open file error"
13287 echo "==== test 4: lease can sustain over recovery"
13288 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
13294 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
13296 echo "==== test 5: lease broken can't be regained by replay"
13297 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13301 # open file to break lease and then recovery
13302 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
13305 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
13309 run_test 208 "Exclusive open"
13312 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
13313 skip_env "must have disp_stripe" && return
13316 sync; sleep 5; sync;
13318 echo 3 > /proc/sys/vm/drop_caches
13319 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13321 # open/close 500 times
13322 for i in $(seq 500); do
13326 echo 3 > /proc/sys/vm/drop_caches
13327 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13329 echo "before: $req_before, after: $req_after"
13330 [ $((req_after - req_before)) -ge 300 ] &&
13331 error "open/close requests are not freed"
13334 run_test 209 "read-only open/close requests should be freed promptly"
13338 size=$((size % 8192 + 1))
13339 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
13340 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
13341 rm -f $DIR/f212 $DIR/f212.xyz
13343 run_test 212 "Sendfile test ============================================"
13346 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
13347 cancel_lru_locks osc
13348 lctl set_param fail_loc=0x8000040f
13349 # generate a read lock
13350 cat $DIR/$tfile > /dev/null
13351 # write to the file, it will try to cancel the above read lock.
13352 cat /etc/hosts >> $DIR/$tfile
13354 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
13356 test_214() { # for bug 20133
13357 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
13358 for (( i=0; i < 340; i++ )) ; do
13359 touch $DIR/$tdir/d214c/a$i
13362 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
13363 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
13364 ls $DIR/d214c || error "ls $DIR/d214c failed"
13365 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
13366 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
13368 run_test 214 "hash-indexed directory test - bug 20133"
13370 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
13371 create_lnet_proc_files() {
13372 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
13375 # counterpart of create_lnet_proc_files
13376 remove_lnet_proc_files() {
13377 rm -f $TMP/lnet_$1.sys
13380 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13381 # 3rd arg as regexp for body
13382 check_lnet_proc_stats() {
13383 local l=$(cat "$TMP/lnet_$1" |wc -l)
13384 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13386 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13389 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13390 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13391 # optional and can be regexp for 2nd line (lnet.routes case)
13392 check_lnet_proc_entry() {
13393 local blp=2 # blp stands for 'position of 1st line of body'
13394 [ -z "$5" ] || blp=3 # lnet.routes case
13396 local l=$(cat "$TMP/lnet_$1" |wc -l)
13397 # subtracting one from $blp because the body can be empty
13398 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13400 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13401 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13403 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13404 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13406 # bail out if any unexpected line happened
13407 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13408 [ "$?" != 0 ] || error "$2 misformatted"
13411 test_215() { # for bugs 18102, 21079, 21517
13412 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13413 local N='(0|[1-9][0-9]*)' # non-negative numeric
13414 local P='[1-9][0-9]*' # positive numeric
13415 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13416 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13417 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13418 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13420 local L1 # regexp for 1st line
13421 local L2 # regexp for 2nd line (optional)
13422 local BR # regexp for the rest (body)
13424 # lnet.stats should look as 11 space-separated non-negative numerics
13425 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13426 create_lnet_proc_files "stats"
13427 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13428 remove_lnet_proc_files "stats"
13430 # lnet.routes should look like this:
13431 # Routing disabled/enabled
13432 # net hops priority state router
13433 # where net is a string like tcp0, hops > 0, priority >= 0,
13434 # state is up/down,
13435 # router is a string like 192.168.1.1@tcp2
13436 L1="^Routing (disabled|enabled)$"
13437 L2="^net +hops +priority +state +router$"
13438 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13439 create_lnet_proc_files "routes"
13440 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13441 remove_lnet_proc_files "routes"
13443 # lnet.routers should look like this:
13444 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13445 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13446 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13447 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13448 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13449 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13450 create_lnet_proc_files "routers"
13451 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13452 remove_lnet_proc_files "routers"
13454 # lnet.peers should look like this:
13455 # nid refs state last max rtr min tx min queue
13456 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13457 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13458 # numeric (0 or >0 or <0), queue >= 0.
13459 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13460 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13461 create_lnet_proc_files "peers"
13462 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13463 remove_lnet_proc_files "peers"
13465 # lnet.buffers should look like this:
13466 # pages count credits min
13467 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13468 L1="^pages +count +credits +min$"
13469 BR="^ +$N +$N +$I +$I$"
13470 create_lnet_proc_files "buffers"
13471 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13472 remove_lnet_proc_files "buffers"
13474 # lnet.nis should look like this:
13475 # nid status alive refs peer rtr max tx min
13476 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13477 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13478 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13479 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13480 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13481 create_lnet_proc_files "nis"
13482 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13483 remove_lnet_proc_files "nis"
13485 # can we successfully write to lnet.stats?
13486 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13488 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13490 test_216() { # bug 20317
13491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13492 remote_ost_nodsh && skip "remote OST with nodsh" && return
13495 local facets=$(get_facets OST)
13496 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13498 save_lustre_params client "osc.*.contention_seconds" > $p
13499 save_lustre_params $facets \
13500 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13501 save_lustre_params $facets \
13502 "ldlm.namespaces.filter-*.contended_locks" >> $p
13503 save_lustre_params $facets \
13504 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13505 clear_stats osc.*.osc_stats
13507 # agressive lockless i/o settings
13508 do_nodes $(comma_list $(osts_nodes)) \
13509 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13510 ldlm.namespaces.filter-*.contended_locks=0 \
13511 ldlm.namespaces.filter-*.contention_seconds=60"
13512 lctl set_param -n osc.*.contention_seconds=60
13514 $DIRECTIO write $DIR/$tfile 0 10 4096
13515 $CHECKSTAT -s 40960 $DIR/$tfile
13517 # disable lockless i/o
13518 do_nodes $(comma_list $(osts_nodes)) \
13519 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13520 ldlm.namespaces.filter-*.contended_locks=32 \
13521 ldlm.namespaces.filter-*.contention_seconds=0"
13522 lctl set_param -n osc.*.contention_seconds=0
13523 clear_stats osc.*.osc_stats
13525 dd if=/dev/zero of=$DIR/$tfile count=0
13526 $CHECKSTAT -s 0 $DIR/$tfile
13528 restore_lustre_params <$p
13532 run_test 216 "check lockless direct write updates file size and kms correctly"
13534 test_217() { # bug 22430
13535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13539 for node in $(nodes_list); do
13540 nid=$(host_nids_address $node $NETTYPE)
13541 if [[ $nid = *-* ]] ; then
13542 echo "lctl ping $(h2nettype $nid)"
13543 lctl ping $(h2nettype $nid)
13545 echo "skipping $node (no hyphen detected)"
13549 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13552 # do directio so as not to populate the page cache
13553 log "creating a 10 Mb file"
13554 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13555 log "starting reads"
13556 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13557 log "truncating the file"
13558 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13560 kill %+ || true # reads might have finished
13561 echo "wait until dd is finished"
13563 log "removing the temporary file"
13564 rm -rf $DIR/$tfile || error "tmp file removal failed"
13566 run_test 218 "parallel read and truncate should not deadlock ======================="
13569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13570 # write one partial page
13571 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13572 # set no grant so vvp_io_commit_write will do sync write
13573 $LCTL set_param fail_loc=0x411
13574 # write a full page at the end of file
13575 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13577 $LCTL set_param fail_loc=0
13578 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13579 $LCTL set_param fail_loc=0x411
13580 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13583 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13584 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13586 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13588 test_220() { #LU-325
13589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13590 remote_ost_nodsh && skip "remote OST with nodsh" && return
13591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13592 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13595 # create on MDT0000 so the last_id and next_id are correct
13597 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13601 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13602 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13603 osc.$mdtosc_proc1.prealloc_last_id)
13604 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13605 osc.$mdtosc_proc1.prealloc_next_id)
13609 if ! combined_mgs_mds ; then
13613 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13614 #define OBD_FAIL_OST_ENOINO 0x229
13615 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13616 create_pool $FSNAME.$TESTNAME || return 1
13617 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13619 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13621 MDSOBJS=$((last_id - next_id))
13622 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13624 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13625 echo "OST still has $count kbytes free"
13627 echo "create $MDSOBJS files @next_id..."
13628 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13630 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13631 osc.$mdtosc_proc1.prealloc_last_id)
13632 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13633 osc.$mdtosc_proc1.prealloc_next_id)
13635 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13640 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13641 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13643 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13644 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13645 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13646 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13647 echo "unlink $MDSOBJS files @$next_id..."
13648 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13650 if ! combined_mgs_mds ; then
13654 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13658 dd if=`which date` of=$MOUNT/date oflag=sync
13659 chmod +x $MOUNT/date
13661 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13662 $LCTL set_param fail_loc=0x80001401
13664 $MOUNT/date > /dev/null
13667 run_test 221 "make sure fault and truncate race to not cause OOM"
13670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13672 test_mkdir $DIR/$tdir
13673 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13674 createmany -o $DIR/$tdir/$tfile 10
13675 cancel_lru_locks mdc
13676 cancel_lru_locks osc
13677 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13678 $LCTL set_param fail_loc=0x31a
13679 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13680 $LCTL set_param fail_loc=0
13683 run_test 222a "AGL for ls should not trigger CLIO lock failure"
13686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13688 test_mkdir $DIR/$tdir
13689 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13690 createmany -o $DIR/$tdir/$tfile 10
13691 cancel_lru_locks mdc
13692 cancel_lru_locks osc
13693 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13694 $LCTL set_param fail_loc=0x31a
13695 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13696 $LCTL set_param fail_loc=0
13698 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
13701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13703 test_mkdir $DIR/$tdir
13704 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13705 createmany -o $DIR/$tdir/$tfile 10
13706 cancel_lru_locks mdc
13707 cancel_lru_locks osc
13708 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13709 $LCTL set_param fail_loc=0x31b
13710 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13711 $LCTL set_param fail_loc=0
13714 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13716 test_224a() { # LU-1039, MRP-303
13717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13718 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13719 $LCTL set_param fail_loc=0x508
13720 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13721 $LCTL set_param fail_loc=0
13724 run_test 224a "Don't panic on bulk IO failure"
13726 test_224b() { # LU-1039, MRP-303
13727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13728 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13729 cancel_lru_locks osc
13730 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13731 $LCTL set_param fail_loc=0x515
13732 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13733 $LCTL set_param fail_loc=0
13736 run_test 224b "Don't panic on bulk IO failure"
13738 test_224c() { # LU-6441
13739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13740 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13742 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13743 save_writethrough $p
13744 set_cache writethrough on
13746 local pages_per_rpc=$($LCTL get_param \
13747 osc.*.max_pages_per_rpc)
13748 local at_max=$($LCTL get_param -n at_max)
13749 local timeout=$($LCTL get_param -n timeout)
13750 local test_at="$LCTL get_param -n at_max"
13751 local param_at="$FSNAME.sys.at_max"
13752 local test_timeout="$LCTL get_param -n timeout"
13753 local param_timeout="$FSNAME.sys.timeout"
13755 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13757 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13758 error "conf_param at_max=0 failed"
13759 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13760 error "conf_param timeout=5 failed"
13762 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13763 do_facet ost1 $LCTL set_param fail_loc=0x520
13764 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13765 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13767 do_facet ost1 $LCTL set_param fail_loc=0
13769 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13770 error "conf_param at_max=$at_max failed"
13771 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13772 $timeout || error "conf_param timeout=$timeout failed"
13774 $LCTL set_param -n $pages_per_rpc
13775 restore_lustre_params < $p
13778 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13780 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13783 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13784 if [ -z ${MDSSURVEY} ]; then
13785 skip_env "mds-survey not found" && return
13788 [ $MDSCOUNT -ge 2 ] &&
13789 skip "skipping now for more than one MDT" && return
13791 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13792 { skip "Need MDS version at least 2.2.51"; return; }
13794 local mds=$(facet_host $SINGLEMDS)
13795 local target=$(do_nodes $mds 'lctl dl' | \
13796 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13798 local cmd1="file_count=1000 thrhi=4"
13799 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13800 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13801 local cmd="$cmd1 $cmd2 $cmd3"
13803 rm -f ${TMP}/mds_survey*
13805 eval $cmd || error "mds-survey with zero-stripe failed"
13806 cat ${TMP}/mds_survey*
13807 rm -f ${TMP}/mds_survey*
13809 run_test 225a "Metadata survey sanity with zero-stripe"
13812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13813 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13814 if [ -z ${MDSSURVEY} ]; then
13815 skip_env "mds-survey not found" && return
13817 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13818 { skip "Need MDS version at least 2.2.51"; return; }
13820 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13821 skip_env "Need to mount OST to test" && return
13824 local mds=$(facet_host $SINGLEMDS)
13825 local target=$(do_nodes $mds 'lctl dl' | \
13826 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13828 local cmd1="file_count=1000 thrhi=4"
13829 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13830 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13831 local cmd="$cmd1 $cmd2 $cmd3"
13833 rm -f ${TMP}/mds_survey*
13835 eval $cmd || error "mds-survey with stripe_count failed"
13836 cat ${TMP}/mds_survey*
13837 rm -f ${TMP}/mds_survey*
13839 run_test 225b "Metadata survey sanity with stripe_count = 1"
13841 mcreate_path2fid () {
13847 local path=$DIR/$tdir/$name
13852 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13853 error "cannot create $desc"
13855 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13857 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13859 fid_path=$($LFS fid2path $MOUNT $fid)
13861 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13863 [ "$path" == "$fid_path" ] ||
13864 error "fid2path returned $fid_path, expected $path"
13866 echo "pass with $path and $fid"
13871 mkdir -p $DIR/$tdir
13873 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13874 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13875 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13876 mcreate_path2fid 0040666 0 0 dir "directory"
13877 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13878 mcreate_path2fid 0100666 0 0 file "regular file"
13879 mcreate_path2fid 0120666 0 0 link "symbolic link"
13880 mcreate_path2fid 0140666 0 0 sock "socket"
13882 run_test 226a "call path2fid and fid2path on files of all type"
13885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13889 mkdir -p $DIR/$tdir
13890 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13891 error "create remote directory failed"
13892 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13893 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13894 "character special file (null)"
13895 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13896 "character special file (no device)"
13897 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13898 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13899 "block special file (loop)"
13900 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13901 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13902 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13904 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13906 # LU-1299 Executing or running ldd on a truncated executable does not
13907 # cause an out-of-memory condition.
13909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13910 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13911 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13912 chmod +x $MOUNT/date
13914 $MOUNT/date > /dev/null
13915 ldd $MOUNT/date > /dev/null
13918 run_test 227 "running truncated executable does not cause OOM"
13920 # LU-1512 try to reuse idle OI blocks
13922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13923 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13924 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13925 skip "ldiskfs only test" && return
13927 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13928 local myDIR=$DIR/$tdir
13931 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13932 $LCTL set_param fail_loc=0x80001002
13933 createmany -o $myDIR/t- 10000
13934 $LCTL set_param fail_loc=0
13935 # The guard is current the largest FID holder
13937 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13939 local IDX=$(($SEQ % 64))
13941 do_facet $SINGLEMDS sync
13942 # Make sure journal flushed.
13944 local blk1=$(do_facet $SINGLEMDS \
13945 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13946 grep Blockcount | awk '{print $4}')
13948 # Remove old files, some OI blocks will become idle.
13949 unlinkmany $myDIR/t- 10000
13950 # Create new files, idle OI blocks should be reused.
13951 createmany -o $myDIR/t- 2000
13952 do_facet $SINGLEMDS sync
13953 # Make sure journal flushed.
13955 local blk2=$(do_facet $SINGLEMDS \
13956 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13957 grep Blockcount | awk '{print $4}')
13959 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13961 run_test 228a "try to reuse idle OI blocks"
13964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13965 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13966 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13967 skip "ldiskfs only test" && return
13969 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13970 local myDIR=$DIR/$tdir
13973 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13974 $LCTL set_param fail_loc=0x80001002
13975 createmany -o $myDIR/t- 10000
13976 $LCTL set_param fail_loc=0
13977 # The guard is current the largest FID holder
13979 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13981 local IDX=$(($SEQ % 64))
13983 do_facet $SINGLEMDS sync
13984 # Make sure journal flushed.
13986 local blk1=$(do_facet $SINGLEMDS \
13987 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13988 grep Blockcount | awk '{print $4}')
13990 # Remove old files, some OI blocks will become idle.
13991 unlinkmany $myDIR/t- 10000
13994 stop $SINGLEMDS || error "Fail to stop MDT."
13996 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13998 df $MOUNT || error "Fail to df."
13999 # Create new files, idle OI blocks should be reused.
14000 createmany -o $myDIR/t- 2000
14001 do_facet $SINGLEMDS sync
14002 # Make sure journal flushed.
14004 local blk2=$(do_facet $SINGLEMDS \
14005 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14006 grep Blockcount | awk '{print $4}')
14008 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14010 run_test 228b "idle OI blocks can be reused after MDT restart"
14014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14015 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14016 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14017 skip "ldiskfs only test" && return
14019 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14020 local myDIR=$DIR/$tdir
14023 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14024 $LCTL set_param fail_loc=0x80001002
14025 # 20000 files can guarantee there are index nodes in the OI file
14026 createmany -o $myDIR/t- 20000
14027 $LCTL set_param fail_loc=0
14028 # The guard is current the largest FID holder
14030 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14032 local IDX=$(($SEQ % 64))
14034 do_facet $SINGLEMDS sync
14035 # Make sure journal flushed.
14037 local blk1=$(do_facet $SINGLEMDS \
14038 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14039 grep Blockcount | awk '{print $4}')
14041 # Remove old files, some OI blocks will become idle.
14042 unlinkmany $myDIR/t- 20000
14044 # The OI file should become empty now
14046 # Create new files, idle OI blocks should be reused.
14047 createmany -o $myDIR/t- 2000
14048 do_facet $SINGLEMDS sync
14049 # Make sure journal flushed.
14051 local blk2=$(do_facet $SINGLEMDS \
14052 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14053 grep Blockcount | awk '{print $4}')
14055 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14057 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
14059 test_229() { # LU-2482, LU-3448
14060 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
14061 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
14063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14064 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
14068 # Create a file with a released layout and stripe count 2.
14069 $MULTIOP $DIR/$tfile H2c ||
14070 error "failed to create file with released layout"
14072 $GETSTRIPE -v $DIR/$tfile
14074 local pattern=$($GETSTRIPE -L $DIR/$tfile)
14075 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
14077 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
14078 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
14079 stat $DIR/$tfile || error "failed to stat released file"
14081 chown $RUNAS_ID $DIR/$tfile ||
14082 error "chown $RUNAS_ID $DIR/$tfile failed"
14084 chgrp $RUNAS_ID $DIR/$tfile ||
14085 error "chgrp $RUNAS_ID $DIR/$tfile failed"
14087 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
14088 rm $DIR/$tfile || error "failed to remove released file"
14090 run_test 229 "getstripe/stat/rm/attr changes work on released files"
14093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14094 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14097 test_mkdir $DIR/$tdir
14098 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
14099 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
14100 [ $mdt_idx -ne 0 ] &&
14101 error "create local directory on wrong MDT $mdt_idx"
14103 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
14104 error "create remote directory failed"
14105 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
14106 [ $mdt_idx -ne $MDTIDX ] &&
14107 error "create remote directory on wrong MDT $mdt_idx"
14109 createmany -o $DIR/$tdir/test_230/t- 10 ||
14110 error "create files on remote directory failed"
14111 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
14112 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
14113 rm -r $DIR/$tdir || error "unlink remote directory failed"
14115 run_test 230a "Create remote directory and files under the remote directory"
14118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14119 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14126 local migrate_dir=$DIR/$tdir/migrate_dir
14127 local other_dir=$DIR/$tdir/other_dir
14129 test_mkdir $DIR/$tdir
14130 test_mkdir -i0 -c1 $migrate_dir
14131 test_mkdir -i0 -c1 $other_dir
14132 for ((i=0; i<10; i++)); do
14133 mkdir -p $migrate_dir/dir_${i}
14134 createmany -o $migrate_dir/dir_${i}/f 10 ||
14135 error "create files under remote dir failed $i"
14138 cp /etc/passwd $migrate_dir/$tfile
14139 cp /etc/passwd $other_dir/$tfile
14140 chattr +SAD $migrate_dir
14141 chattr +SAD $migrate_dir/$tfile
14143 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14144 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14145 local old_dir_mode=$(stat -c%f $migrate_dir)
14146 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
14148 mkdir -p $migrate_dir/dir_default_stripe2
14149 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
14150 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
14152 mkdir -p $other_dir
14153 ln $migrate_dir/$tfile $other_dir/luna
14154 ln $migrate_dir/$tfile $migrate_dir/sofia
14155 ln $other_dir/$tfile $migrate_dir/david
14156 ln -s $migrate_dir/$tfile $other_dir/zachary
14157 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
14158 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
14160 $LFS migrate -m $MDTIDX $migrate_dir ||
14161 error "fails on migrating remote dir to MDT1"
14163 echo "migratate to MDT1, then checking.."
14164 for ((i = 0; i < 10; i++)); do
14165 for file in $(find $migrate_dir/dir_${i}); do
14166 mdt_index=$($LFS getstripe -M $file)
14167 [ $mdt_index == $MDTIDX ] ||
14168 error "$file is not on MDT${MDTIDX}"
14172 # the multiple link file should still in MDT0
14173 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
14174 [ $mdt_index == 0 ] ||
14175 error "$file is not on MDT${MDTIDX}"
14177 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14178 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14179 error " expect $old_dir_flag get $new_dir_flag"
14181 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14182 [ "$old_file_flag" = "$new_file_flag" ] ||
14183 error " expect $old_file_flag get $new_file_flag"
14185 local new_dir_mode=$(stat -c%f $migrate_dir)
14186 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14187 error "expect mode $old_dir_mode get $new_dir_mode"
14189 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14190 [ "$old_file_mode" = "$new_file_mode" ] ||
14191 error "expect mode $old_file_mode get $new_file_mode"
14193 diff /etc/passwd $migrate_dir/$tfile ||
14194 error "$tfile different after migration"
14196 diff /etc/passwd $other_dir/luna ||
14197 error "luna different after migration"
14199 diff /etc/passwd $migrate_dir/sofia ||
14200 error "sofia different after migration"
14202 diff /etc/passwd $migrate_dir/david ||
14203 error "david different after migration"
14205 diff /etc/passwd $other_dir/zachary ||
14206 error "zachary different after migration"
14208 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14209 error "${tfile}_ln different after migration"
14211 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14212 error "${tfile}_ln_other different after migration"
14214 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
14215 [ $stripe_count = 2 ] ||
14216 error "dir strpe_count $d != 2 after migration."
14218 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
14219 [ $stripe_count = 2 ] ||
14220 error "file strpe_count $d != 2 after migration."
14222 #migrate back to MDT0
14225 $LFS migrate -m $MDTIDX $migrate_dir ||
14226 error "fails on migrating remote dir to MDT0"
14228 echo "migrate back to MDT0, checking.."
14229 for file in $(find $migrate_dir); do
14230 mdt_index=$($LFS getstripe -M $file)
14231 [ $mdt_index == $MDTIDX ] ||
14232 error "$file is not on MDT${MDTIDX}"
14235 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14236 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14237 error " expect $old_dir_flag get $new_dir_flag"
14239 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14240 [ "$old_file_flag" = "$new_file_flag" ] ||
14241 error " expect $old_file_flag get $new_file_flag"
14243 local new_dir_mode=$(stat -c%f $migrate_dir)
14244 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14245 error "expect mode $old_dir_mode get $new_dir_mode"
14247 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14248 [ "$old_file_mode" = "$new_file_mode" ] ||
14249 error "expect mode $old_file_mode get $new_file_mode"
14251 diff /etc/passwd ${migrate_dir}/$tfile ||
14252 error "$tfile different after migration"
14254 diff /etc/passwd ${other_dir}/luna ||
14255 error "luna different after migration"
14257 diff /etc/passwd ${migrate_dir}/sofia ||
14258 error "sofia different after migration"
14260 diff /etc/passwd ${other_dir}/zachary ||
14261 error "zachary different after migration"
14263 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14264 error "${tfile}_ln different after migration"
14266 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14267 error "${tfile}_ln_other different after migration"
14269 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
14270 [ $stripe_count = 2 ] ||
14271 error "dir strpe_count $d != 2 after migration."
14273 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
14274 [ $stripe_count = 2 ] ||
14275 error "file strpe_count $d != 2 after migration."
14277 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14279 run_test 230b "migrate directory"
14282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14283 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14284 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14288 local migrate_dir=$DIR/$tdir/migrate_dir
14290 #If migrating directory fails in the middle, all entries of
14291 #the directory is still accessiable.
14292 test_mkdir $DIR/$tdir
14293 test_mkdir -i0 -c1 $migrate_dir
14295 createmany -o $migrate_dir/f 10 ||
14296 error "create files under ${migrate_dir} failed"
14298 #failed after migrating 5 entries
14299 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
14300 do_facet mds1 lctl set_param fail_loc=0x20001801
14301 do_facet mds1 lctl set_param fail_val=5
14302 local t=$(ls $migrate_dir | wc -l)
14303 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
14304 error "migrate should fail after 5 entries"
14306 mkdir $migrate_dir/dir &&
14307 error "mkdir succeeds under migrating directory"
14308 touch $migrate_dir/file &&
14309 error "touch file succeeds under migrating directory"
14311 local u=$(ls $migrate_dir | wc -l)
14312 [ "$u" == "$t" ] || error "$u != $t during migration"
14314 for file in $(find $migrate_dir); do
14315 stat $file || error "stat $file failed"
14318 do_facet mds1 lctl set_param fail_loc=0
14319 do_facet mds1 lctl set_param fail_val=0
14321 $LFS migrate -m $MDTIDX $migrate_dir ||
14322 error "migrate open files should failed with open files"
14324 echo "Finish migration, then checking.."
14325 for file in $(find $migrate_dir); do
14326 mdt_index=$($LFS getstripe -M $file)
14327 [ $mdt_index == $MDTIDX ] ||
14328 error "$file is not on MDT${MDTIDX}"
14331 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14333 run_test 230c "check directory accessiblity if migration is failed"
14336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14337 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14340 local migrate_dir=$DIR/$tdir/migrate_dir
14344 test_mkdir $DIR/$tdir
14345 test_mkdir -i0 -c1 $migrate_dir
14347 for ((i=0; i<100; i++)); do
14348 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
14349 createmany -o $migrate_dir/dir_${i}/f 100 ||
14350 error "create files under remote dir failed $i"
14353 $LFS migrate -m $MDTIDX $migrate_dir ||
14354 error "migrate remote dir error"
14356 echo "Finish migration, then checking.."
14357 for file in $(find $migrate_dir); do
14358 mdt_index=$($LFS getstripe -M $file)
14359 [ $mdt_index == $MDTIDX ] ||
14360 error "$file is not on MDT${MDTIDX}"
14363 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14365 run_test 230d "check migrate big directory"
14368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14369 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14375 mkdir -p $DIR/$tdir
14376 mkdir $DIR/$tdir/migrate_dir
14377 mkdir $DIR/$tdir/other_dir
14378 touch $DIR/$tdir/migrate_dir/a
14379 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14380 ls $DIR/$tdir/other_dir
14382 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14383 error "migrate dir fails"
14385 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14386 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14388 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14389 [ $mdt_index == 0 ] || error "a is not on MDT0"
14391 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14392 error "migrate dir fails"
14394 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14395 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14397 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14398 [ $mdt_index == 1 ] || error "a is not on MDT1"
14400 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14401 [ $mdt_index == 1 ] || error "b is not on MDT1"
14403 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14404 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14406 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14408 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14410 run_test 230e "migrate mulitple local link files"
14413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14414 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14418 mkdir -p $DIR/$tdir
14419 mkdir $DIR/$tdir/migrate_dir
14420 $LFS mkdir -i1 $DIR/$tdir/other_dir
14421 touch $DIR/$tdir/migrate_dir/a
14422 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14423 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14424 ls $DIR/$tdir/other_dir
14426 # a should be migrated to MDT1, since no other links on MDT0
14427 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14428 error "#1 migrate dir fails"
14429 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14430 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14431 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14432 [ $mdt_index == 1 ] || error "a is not on MDT1"
14434 # a should stay on MDT1, because it is a mulitple link file
14435 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14436 error "#2 migrate dir fails"
14437 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14438 [ $mdt_index == 1 ] || error "a is not on MDT1"
14440 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14441 error "#3 migrate dir fails"
14443 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14444 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14445 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14447 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14448 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14450 # a should be migrated to MDT0, since no other links on MDT1
14451 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14452 error "#4 migrate dir fails"
14453 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14454 [ $mdt_index == 0 ] || error "a is not on MDT0"
14456 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14458 run_test 230f "migrate mulitple remote link files"
14461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14464 mkdir -p $DIR/$tdir/migrate_dir
14466 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14467 error "migrating dir to non-exist MDT succeeds"
14470 run_test 230g "migrate dir to non-exist MDT"
14473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14474 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14475 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14476 skip "Need MDS version at least 2.7.64" && return
14479 mkdir -p $DIR/$tdir/migrate_dir
14481 $LFS migrate -m1 $DIR &&
14482 error "migrating mountpoint1 should fail"
14484 $LFS migrate -m1 $DIR/$tdir/.. &&
14485 error "migrating mountpoint2 should fail"
14487 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14488 error "migrating $tdir fail"
14490 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14491 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14493 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14494 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14497 run_test 230h "migrate .. and root"
14500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14501 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14503 mkdir -p $DIR/$tdir/migrate_dir
14505 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14506 error "migration fails with a tailing slash"
14508 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14509 error "migration fails with two tailing slashes"
14511 run_test 230i "lfs migrate -m tolerates trailing slashes"
14515 # For simplicity this test assumes that max_pages_per_rpc
14516 # is the same across all OSCs
14517 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14518 local bulk_size=$((max_pages * 4096))
14519 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14522 mkdir -p $DIR/$tdir
14523 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14524 error "failed to set stripe with -S ${brw_size}M option"
14526 # clear the OSC stats
14527 $LCTL set_param osc.*.stats=0 &>/dev/null
14530 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14531 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14532 oflag=direct &>/dev/null || error "dd failed"
14534 sync; sleep 1; sync # just to be safe
14535 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14536 if [ x$nrpcs != "x1" ]; then
14537 $LCTL get_param osc.*.stats
14538 error "found $nrpcs ost_write RPCs, not 1 as expected"
14542 # Drop the OSC cache, otherwise we will read from it
14543 cancel_lru_locks osc
14545 # clear the OSC stats
14546 $LCTL set_param osc.*.stats=0 &>/dev/null
14548 # Client reads $bulk_size.
14549 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14550 iflag=direct &>/dev/null || error "dd failed"
14552 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14553 if [ x$nrpcs != "x1" ]; then
14554 $LCTL get_param osc.*.stats
14555 error "found $nrpcs ost_read RPCs, not 1 as expected"
14558 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14561 mkdir -p $DIR/$tdir
14563 for i in {0..1023}; do
14564 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14565 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14566 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14570 run_test 231b "must not assert on fully utilized OST request buffer"
14573 mkdir -p $DIR/$tdir
14574 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14576 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14577 do_facet ost1 $LCTL set_param fail_loc=0x31c
14579 # ignore dd failure
14580 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || 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 232a "failed lock should not block umount"
14591 mkdir -p $DIR/$tdir
14592 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14593 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
14595 cancel_lru_locks osc
14597 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14598 do_facet ost1 $LCTL set_param fail_loc=0x31c
14601 $LFS data_version $DIR/$tdir/$tfile || true
14603 do_facet ost1 $LCTL set_param fail_loc=0
14604 umount_client $MOUNT || error "umount failed"
14605 mount_client $MOUNT || error "mount failed"
14606 stop ost1 || error "cannot stop ost1"
14607 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14609 run_test 232b "failed data version lock should not block umount"
14612 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14613 { skip "Need MDS version at least 2.3.64"; return; }
14614 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14616 local fid=$($LFS path2fid $MOUNT)
14617 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14618 error "cannot access $MOUNT using its FID '$fid'"
14620 run_test 233a "checking that OBF of the FS root succeeds"
14623 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14624 { skip "Need MDS version at least 2.5.90"; return; }
14625 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14627 local fid=$($LFS path2fid $MOUNT/.lustre)
14628 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14629 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14631 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14632 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14633 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14635 run_test 233b "checking that OBF of the FS .lustre succeeds"
14638 local p="$TMP/sanityN-$TESTNAME.parameters"
14639 save_lustre_params client "llite.*.xattr_cache" > $p
14640 lctl set_param llite.*.xattr_cache 1 ||
14641 { skip "xattr cache is not supported"; return 0; }
14643 mkdir -p $DIR/$tdir || error "mkdir failed"
14644 touch $DIR/$tdir/$tfile || error "touch failed"
14645 # OBD_FAIL_LLITE_XATTR_ENOMEM
14646 $LCTL set_param fail_loc=0x1405
14647 getfattr -n user.attr $DIR/$tdir/$tfile &&
14648 error "getfattr should have failed with ENOMEM"
14649 $LCTL set_param fail_loc=0x0
14652 restore_lustre_params < $p
14655 run_test 234 "xattr cache should not crash on ENOMEM"
14658 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14659 skip "Need MDS version at least 2.4.52" && return
14660 flock_deadlock $DIR/$tfile
14665 124) error "process hangs on a deadlock"
14667 *) error "error executing flock_deadlock $DIR/$tfile"
14671 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14675 check_swap_layouts_support && return 0
14676 test_mkdir -c1 $DIR/$tdir
14678 local ref1=/etc/passwd
14679 local ref2=/etc/group
14680 local file1=$DIR/$tdir/f1
14681 local file2=$DIR/$tdir/f2
14683 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14684 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14685 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14686 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14687 local fd=$(free_fd)
14688 local cmd="exec $fd<>$file2"
14691 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14692 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14695 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14700 run_test 236 "Layout swap on open unlinked file"
14702 # test to verify file handle related system calls
14703 # (name_to_handle_at/open_by_handle_at)
14704 # The new system calls are supported in glibc >= 2.14.
14707 echo "Test file_handle syscalls" > $DIR/$tfile ||
14708 error "write failed"
14709 check_fhandle_syscalls $DIR/$tfile ||
14710 error "check_fhandle_syscalls failed"
14712 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14714 # LU-4659 linkea consistency
14716 local server_version=$(lustre_version_code $SINGLEMDS)
14718 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14719 [[ $server_version -gt $(version_code 2.5.1) &&
14720 $server_version -lt $(version_code 2.5.50) ]] ||
14721 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14724 ln $DIR/$tfile $DIR/$tfile.lnk
14725 touch $DIR/$tfile.new
14726 mv $DIR/$tfile.new $DIR/$tfile
14727 local fid1=$($LFS path2fid $DIR/$tfile)
14728 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14729 local path1=$($LFS fid2path $FSNAME "$fid1")
14730 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14731 local path2=$($LFS fid2path $FSNAME "$fid2")
14732 [ $tfile.lnk == $path2 ] ||
14733 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14736 run_test 238 "Verify linkea consistency"
14739 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14740 skip "Need MDS version at least 2.5.60" && return
14741 local list=$(comma_list $(mdts_nodes))
14743 mkdir -p $DIR/$tdir
14744 createmany -o $DIR/$tdir/f- 5000
14745 unlinkmany $DIR/$tdir/f- 5000
14746 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
14747 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14748 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14749 osp.*MDT*.sync_in_flight" | calc_sum)
14750 [ "$changes" -eq 0 ] || error "$changes not synced"
14752 run_test 239 "osp_sync test"
14754 test_239a() { #LU-5297
14755 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14757 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14758 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14759 chgrp $RUNAS_GID $DIR/$tfile
14760 wait_delete_completed
14762 run_test 239a "process invalid osp sync record correctly"
14764 test_239b() { #LU-5297
14765 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14767 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14768 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14769 chgrp $RUNAS_GID $DIR/$tfile1
14770 wait_delete_completed
14771 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14773 chgrp $RUNAS_GID $DIR/$tfile2
14774 wait_delete_completed
14776 run_test 239b "process osp sync record with ENOMEM error correctly"
14779 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14780 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14782 mkdir -p $DIR/$tdir
14784 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14785 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14786 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14787 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14789 umount_client $MOUNT || error "umount failed"
14790 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14791 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14792 mount_client $MOUNT || error "failed to mount client"
14794 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14795 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14797 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14800 for LOOP in $(seq $1); do
14801 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14802 cancel_lru_locks $OSC || true
14807 for LOOP in $(seq $1); do
14808 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14809 iflag=direct 2>/dev/null
14813 test_241a() { # was test_241
14814 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14816 cancel_lru_locks $OSC
14817 test_241_bio 1000 &
14822 run_test 241a "bio vs dio"
14825 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14827 test_241_dio 1000 &
14832 run_test 241b "dio vs dio"
14835 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14836 mkdir -p $DIR/$tdir
14837 touch $DIR/$tdir/$tfile
14839 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14840 do_facet mds1 lctl set_param fail_loc=0x105
14841 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14843 do_facet mds1 lctl set_param fail_loc=0
14844 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14846 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14850 test_mkdir $DIR/$tdir
14851 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14853 run_test 243 "various group lock tests"
14857 test_mkdir $DIR/$tdir
14858 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14859 sendfile_grouplock $DIR/$tdir/$tfile || \
14860 error "sendfile+grouplock failed"
14863 run_test 244 "sendfile with group lock tests"
14866 local flagname="multi_mod_rpcs"
14867 local connect_data_name="max_mod_rpcs"
14870 # check if multiple modify RPCs flag is set
14871 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14872 grep "connect_flags:")
14875 echo "$out" | grep -qw $flagname
14876 if [ $? -ne 0 ]; then
14877 echo "connect flag $flagname is not set"
14881 # check if multiple modify RPCs data is set
14882 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14885 echo "$out" | grep -qw $connect_data_name ||
14886 error "import should have connect data $connect_data_name"
14888 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14890 test_246() { # LU-7371
14891 remote_ost_nodsh && skip "remote OST with nodsh" && return
14892 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14893 skip "Need OST version >= 2.7.62" && return 0
14894 do_facet ost1 $LCTL set_param fail_val=4095
14895 #define OBD_FAIL_OST_READ_SIZE 0x234
14896 do_facet ost1 $LCTL set_param fail_loc=0x234
14897 $LFS setstripe $DIR/$tfile -i 0 -c 1
14898 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14899 cancel_lru_locks $FSNAME-OST0000
14900 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14902 run_test 246 "Read file of size 4095 should return right length"
14908 umount_client $submount
14913 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14915 { skip "Fileset feature is not supported"; return; }
14917 local submount=${MOUNT}_$tdir
14920 mkdir -p $submount || error "mkdir $submount failed"
14921 FILESET="$FILESET/$tdir" mount_client $submount ||
14922 error "mount $submount failed"
14923 trap "cleanup_247 $submount" EXIT
14924 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14925 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14926 error "read $MOUNT/$tdir/$tfile failed"
14927 cleanup_247 $submount
14929 run_test 247a "mount subdir as fileset"
14932 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14933 { skip "Fileset feature is not supported"; return; }
14935 local submount=${MOUNT}_$tdir
14937 rm -rf $MOUNT/$tdir
14938 mkdir -p $submount || error "mkdir $submount failed"
14940 FILESET="$FILESET/$tdir" mount_client $submount &&
14941 error "mount $submount should fail"
14944 run_test 247b "mount subdir that dose not exist"
14947 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14948 { skip "Fileset feature is not supported"; return; }
14950 local submount=${MOUNT}_$tdir
14952 mkdir -p $MOUNT/$tdir/dir1
14953 mkdir -p $submount || error "mkdir $submount failed"
14954 trap "cleanup_247 $submount" EXIT
14955 FILESET="$FILESET/$tdir" mount_client $submount ||
14956 error "mount $submount failed"
14957 local fid=$($LFS path2fid $MOUNT/)
14958 $LFS fid2path $submount $fid && error "fid2path should fail"
14959 cleanup_247 $submount
14961 run_test 247c "running fid2path outside root"
14964 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14965 { skip "Fileset feature is not supported"; return; }
14967 local submount=${MOUNT}_$tdir
14969 mkdir -p $MOUNT/$tdir/dir1
14970 mkdir -p $submount || error "mkdir $submount failed"
14971 FILESET="$FILESET/$tdir" mount_client $submount ||
14972 error "mount $submount failed"
14973 trap "cleanup_247 $submount" EXIT
14974 local fid=$($LFS path2fid $submount/dir1)
14975 $LFS fid2path $submount $fid || error "fid2path should succeed"
14976 cleanup_247 $submount
14978 run_test 247d "running fid2path inside root"
14982 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14984 { skip "Fileset feature is not supported"; return; }
14986 local submount=${MOUNT}_$tdir
14989 mkdir -p $submount || error "mkdir $submount failed"
14990 FILESET="$FILESET/.." mount_client $submount &&
14991 error "mount $submount should fail"
14994 run_test 247e "mount .. as fileset"
14997 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14998 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
15000 # create a large file for fast read verification
15001 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
15003 # make sure the file is created correctly
15004 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
15005 { rm -f $DIR/$tfile; skip "file creation error" && return; }
15007 echo "Test 1: verify that fast read is 4 times faster on cache read"
15009 # small read with fast read enabled
15010 $LCTL set_param -n llite.*.fast_read=1
15011 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15012 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15013 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15014 # small read with fast read disabled
15015 $LCTL set_param -n llite.*.fast_read=0
15016 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15017 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15018 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15020 # verify that fast read is 4 times faster for cache read
15021 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
15022 error_not_in_vm "fast read was not 4 times faster: " \
15023 "$t_fast vs $t_slow"
15025 echo "Test 2: verify the performance between big and small read"
15026 $LCTL set_param -n llite.*.fast_read=1
15028 # 1k non-cache read
15029 cancel_lru_locks osc
15030 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15031 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15032 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15034 # 1M non-cache read
15035 cancel_lru_locks osc
15036 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15037 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15038 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15040 # verify that big IO is not 4 times faster than small IO
15041 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
15042 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
15044 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
15047 run_test 248 "fast read verification"
15049 test_249() { # LU-7890
15051 $SETSTRIPE -c 1 $DIR/$tfile
15053 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
15054 skip "Need at least version 2.8.54"
15056 # Offset 2T == 4k * 512M
15057 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
15058 error "dd to 2T offset failed"
15060 run_test 249 "Write above 2T file size"
15063 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
15064 && skip "no 16TB file size limit on ZFS" && return
15066 $SETSTRIPE -c 1 $DIR/$tfile
15067 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
15068 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
15069 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
15070 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
15071 conv=notrunc,fsync && error "append succeeded"
15074 run_test 250 "Write above 16T limit"
15077 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
15079 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
15080 #Skip once - writing the first stripe will succeed
15081 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15082 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
15083 error "short write happened"
15085 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15086 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
15087 error "short read happened"
15091 run_test 251 "Handling short read and write correctly"
15101 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15102 remote_ost_nodsh && skip "remote OST with nodsh" && return
15103 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
15104 "$(facet_fstype mds1)" != "ldiskfs" ]; then
15105 skip "ldiskfs only test"
15109 # check lr_reader on OST0000
15111 dev=$(facet_device $tgt)
15112 out=$(do_facet $tgt $LR_READER $dev)
15113 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15115 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
15116 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
15117 error "Invalid uuid returned by $LR_READER on target $tgt"
15118 echo -e "uuid returned by $LR_READER is '$uuid'\n"
15120 # check lr_reader -c on MDT0000
15122 dev=$(facet_device $tgt)
15123 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
15124 echo "$LR_READER does not support additional options"
15127 out=$(do_facet $tgt $LR_READER -c $dev)
15128 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15130 num=$(echo "$out" | grep -c "mdtlov")
15131 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
15132 error "Invalid number of mdtlov clients returned by $LR_READER"
15133 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
15135 # check lr_reader -cr on MDT0000
15136 out=$(do_facet $tgt $LR_READER -cr $dev)
15137 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15139 echo "$out" | grep -q "^reply_data:$" ||
15140 error "$LR_READER should have returned 'reply_data' section"
15141 num=$(echo "$out" | grep -c "client_generation")
15142 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
15144 run_test 252 "check lr_reader tool"
15146 test_253_fill_ost() {
15147 local size_mb #how many MB should we write to pass watermark
15148 local lwm=$3 #low watermark
15149 local free_10mb #10% of free space
15151 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15152 size_mb=$((free_kb / 1024 - lwm))
15153 free_10mb=$((free_kb / 10240))
15154 #If 10% of free space cross low watermark use it
15155 if (( free_10mb > size_mb )); then
15158 #At least we need to store 1.1 of difference between
15159 #free space and low watermark
15160 size_mb=$((size_mb + size_mb / 10))
15162 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
15163 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
15164 oflag=append conv=notrunc
15169 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15170 echo "OST still has $((free_kb / 1024)) mbytes free"
15177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15178 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15179 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
15181 local ost_name=$($LFS osts |
15182 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
15184 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
15185 do_facet $SINGLEMDS $LCTL get_param -n \
15186 osp.$mdtosc_proc1.reserved_mb_high ||
15187 { skip "remote MDS does not support reserved_mb_high" &&
15192 wait_delete_completed
15195 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
15196 osp.$mdtosc_proc1.reserved_mb_high)
15197 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
15198 osp.$mdtosc_proc1.reserved_mb_low)
15199 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
15201 if ! combined_mgs_mds ; then
15204 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
15205 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
15206 error "Adding $ost_name to pool failed"
15208 # Wait for client to see a OST at pool
15209 wait_update $HOSTNAME "$LCTL get_param -n
15210 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
15211 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
15212 error "Client can not see the pool"
15213 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
15214 error "Setstripe failed"
15216 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
15217 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
15218 echo "OST still has $((blocks/1024)) mbytes free"
15220 local new_lwm=$((blocks/1024-10))
15221 do_facet $SINGLEMDS $LCTL set_param \
15222 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
15223 do_facet $SINGLEMDS $LCTL set_param \
15224 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
15226 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15228 #First enospc could execute orphan deletion so repeat.
15229 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15231 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15232 osp.$mdtosc_proc1.prealloc_status)
15233 echo "prealloc_status $oa_status"
15235 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
15236 error "File creation should fail"
15237 #object allocation was stopped, but we still able to append files
15238 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
15239 error "Append failed"
15240 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
15242 wait_delete_completed
15246 for i in $(seq 10 12); do
15247 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
15248 error "File creation failed after rm";
15251 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15252 osp.$mdtosc_proc1.prealloc_status)
15253 echo "prealloc_status $oa_status"
15255 if (( oa_status != 0 )); then
15256 error "Object allocation still disable after rm"
15258 do_facet $SINGLEMDS $LCTL set_param \
15259 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
15260 do_facet $SINGLEMDS $LCTL set_param \
15261 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
15264 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
15265 error "Remove $ost_name from pool failed"
15266 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15267 error "Pool destroy fialed"
15269 if ! combined_mgs_mds ; then
15273 run_test 253 "Check object allocation limit"
15278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15279 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15280 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
15281 { skip "MDS does not support changelog_size" && return; }
15283 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15284 echo "Registered as changelog user $cl_user"
15286 $LFS changelog_clear $MDT0 $cl_user 0
15288 local size1=$(do_facet mds1 \
15289 $LCTL get_param -n mdd.$MDT0.changelog_size)
15290 echo "Changelog size $size1"
15293 $LFS mkdir -i 0 $DIR/$tdir
15295 mkdir -p $DIR/$tdir/pics/2008/zachy
15296 touch $DIR/$tdir/pics/2008/zachy/timestamp
15297 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
15298 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15299 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15300 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15301 rm $DIR/$tdir/pics/desktop.jpg
15303 local size2=$(do_facet mds1 \
15304 $LCTL get_param -n mdd.$MDT0.changelog_size)
15305 echo "Changelog size after work $size2"
15307 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15309 if (( size2 <= size1 )); then
15310 error "Changelog size after work should be greater than original"
15314 run_test 254 "Check changelog size"
15321 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
15322 awk -F: '{print $2}' | grep $type > /dev/null
15323 if [ $? -ne 0 ]; then
15333 lfs ladvise -a willread $file > /dev/null 2>&1
15334 if [ $? -eq 0 ]; then
15338 lfs ladvise -a willread $file 2>&1 |
15339 grep "Inappropriate ioctl for device" > /dev/null
15340 if [ $? -eq 0 ]; then
15347 bc <<<"scale=2; ($1 - $2) * 100 / $2"
15350 # run a random read IO workload
15351 # usage: random_read_iops <filename> <filesize> <iosize>
15352 random_read_iops() {
15355 local iosize=${3:-4096}
15357 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
15358 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
15361 drop_file_oss_cache() {
15365 $LFS ladvise -a dontneed $file 2>/dev/null ||
15366 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
15369 ladvise_willread_performance()
15372 local average_origin=0
15373 local average_cache=0
15374 local average_ladvise=0
15376 for ((i = 1; i <= $repeat; i++)); do
15377 echo "Iter $i/$repeat: reading without willread hint"
15378 cancel_lru_locks osc
15379 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15380 local speed_origin=$(random_read_iops $DIR/$tfile $size)
15381 echo "Iter $i/$repeat: uncached speed: $speed_origin"
15382 average_origin=$(bc <<<"$average_origin + $speed_origin")
15384 cancel_lru_locks osc
15385 local speed_cache=$(random_read_iops $DIR/$tfile $size)
15386 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
15387 average_cache=$(bc <<<"$average_cache + $speed_cache")
15389 cancel_lru_locks osc
15390 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15391 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
15392 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
15393 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
15394 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
15396 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
15397 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
15398 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
15400 speedup_cache=$(percent $average_cache $average_origin)
15401 speedup_ladvise=$(percent $average_ladvise $average_origin)
15403 echo "Average uncached read: $average_origin"
15404 echo "Average speedup with OSS cached read: " \
15405 "$average_cache = +$speedup_cache%"
15406 echo "Average speedup with ladvise willread: " \
15407 "$average_ladvise = +$speedup_ladvise%"
15409 local lowest_speedup=20
15410 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15411 echo "Speedup with OSS cached read less than $lowest_speedup%," \
15412 "got $average_cache%. Skipping ladvise willread check."
15416 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15417 # it is still good to run until then to exercise 'ladvise willread'
15418 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15419 [ "$(facet_fstype ost1)" = "zfs" ] &&
15420 echo "osd-zfs does not support dontneed or drop_caches" &&
15423 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15424 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15425 error_not_in_vm "Speedup with willread is less than " \
15426 "$lowest_speedup%, got $average_ladvise%"
15430 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15431 skip "lustre < 2.8.54 does not support ladvise " && return
15432 remote_ost_nodsh && skip "remote OST with nodsh" && return
15434 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15436 ladvise_no_type willread $DIR/$tfile &&
15437 skip "willread ladvise is not supported" && return
15439 ladvise_no_ioctl $DIR/$tfile &&
15440 skip "ladvise ioctl is not supported" && return
15443 local size=$((size_mb * 1048576))
15444 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15445 error "dd to $DIR/$tfile failed"
15447 lfs ladvise -a willread $DIR/$tfile ||
15448 error "Ladvise failed with no range argument"
15450 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15451 error "Ladvise failed with no -l or -e argument"
15453 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15454 error "Ladvise failed with only -e argument"
15456 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15457 error "Ladvise failed with only -l argument"
15459 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15460 error "End offset should not be smaller than start offset"
15462 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15463 error "End offset should not be equal to start offset"
15465 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15466 error "Ladvise failed with overflowing -s argument"
15468 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15469 error "Ladvise failed with overflowing -e argument"
15471 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15472 error "Ladvise failed with overflowing -l argument"
15474 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15475 error "Ladvise succeeded with conflicting -l and -e arguments"
15477 echo "Synchronous ladvise should wait"
15479 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15480 do_nodes $(comma_list $(osts_nodes)) \
15481 $LCTL set_param fail_val=$delay fail_loc=0x237
15483 local start_ts=$SECONDS
15484 lfs ladvise -a willread $DIR/$tfile ||
15485 error "Ladvise failed with no range argument"
15486 local end_ts=$SECONDS
15487 local inteval_ts=$((end_ts - start_ts))
15489 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15490 error "Synchronous advice didn't wait reply"
15493 echo "Asynchronous ladvise shouldn't wait"
15494 local start_ts=$SECONDS
15495 lfs ladvise -a willread -b $DIR/$tfile ||
15496 error "Ladvise failed with no range argument"
15497 local end_ts=$SECONDS
15498 local inteval_ts=$((end_ts - start_ts))
15500 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15501 error "Asynchronous advice blocked"
15504 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15505 ladvise_willread_performance
15507 run_test 255a "check 'lfs ladvise -a willread'"
15513 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15517 remote_ost_nodsh && skip "remote OST with nodsh" && return
15519 lfs setstripe -c 1 -i 0 $DIR/$tfile
15521 ladvise_no_type dontneed $DIR/$tfile &&
15522 skip "dontneed ladvise is not supported" && return
15524 ladvise_no_ioctl $DIR/$tfile &&
15525 skip "ladvise ioctl is not supported" && return
15527 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15528 skip "lustre < 2.8.54 does not support ladvise" && return
15530 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15531 [ "$(facet_fstype ost1)" = "zfs" ] &&
15532 skip "zfs-osd does not support 'ladvise dontneed'" && return
15535 local size=$((size_mb * 1048576))
15536 # In order to prevent disturbance of other processes, only check 3/4
15537 # of the memory usage
15538 local kibibytes=$((size_mb * 1024 * 3 / 4))
15540 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15541 error "dd to $DIR/$tfile failed"
15543 local total=$(facet_meminfo ost1 MemTotal)
15544 echo "Total memory: $total KiB"
15546 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15547 local before_read=$(facet_meminfo ost1 Cached)
15548 echo "Cache used before read: $before_read KiB"
15550 lfs ladvise -a willread $DIR/$tfile ||
15551 error "Ladvise willread failed"
15552 local after_read=$(facet_meminfo ost1 Cached)
15553 echo "Cache used after read: $after_read KiB"
15555 lfs ladvise -a dontneed $DIR/$tfile ||
15556 error "Ladvise dontneed again failed"
15557 local no_read=$(facet_meminfo ost1 Cached)
15558 echo "Cache used after dontneed ladvise: $no_read KiB"
15560 if [ $total -lt $((before_read + kibibytes)) ]; then
15561 echo "Memory is too small, abort checking"
15565 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15566 error "Ladvise willread should use more memory" \
15567 "than $kibibytes KiB"
15570 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15571 error "Ladvise dontneed should release more memory" \
15572 "than $kibibytes KiB"
15575 run_test 255b "check 'lfs ladvise -a dontneed'"
15584 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
15585 skip "lustre < 2.10.53 does not support lockahead" && return
15587 test_mkdir -p $DIR/$tdir
15588 $SETSTRIPE -i 0 $DIR/$tdir
15590 #test 10 returns only success/failure
15592 lockahead_test -d $DIR/$tdir -t $i
15594 if [ $rc -eq 255 ]; then
15595 error "Ladvise test${i} failed, ${rc}"
15598 #test 11 counts lock enqueue requests, all others count new locks
15600 count=$(do_facet ost1 \
15601 $LCTL get_param -n ost.OSS.ost.stats)
15602 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
15604 lockahead_test -d $DIR/$tdir -t $i
15606 if [ $rc -eq 255 ]; then
15607 error "Ladvise test${i} failed, ${rc}"
15610 new_count=$(do_facet ost1 \
15611 $LCTL get_param -n ost.OSS.ost.stats)
15612 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
15613 awk '{ print $2 }')
15615 difference="$((new_count - count))"
15616 if [ $difference -ne $rc ]; then
15617 error "Ladvise test${i}, bad enqueue count, returned " \
15618 "${rc}, actual ${difference}"
15621 for i in $(seq 12 21); do
15622 # If we do not do this, we run the risk of having too many
15623 # locks and starting lock cancellation while we are checking
15625 cancel_lru_locks osc
15627 count=$($LCTL get_param -n \
15628 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15630 lockahead_test -d $DIR/$tdir -t $i
15632 if [ $rc -eq 255 ]; then
15633 error "Ladvise test ${i} failed, ${rc}"
15636 new_count=$($LCTL get_param -n \
15637 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15638 difference="$((new_count - count))"
15640 # Test 15 output is divided by 100 to map down to valid return
15641 if [ $i -eq 15 ]; then
15645 if [ $difference -ne $rc ]; then
15646 error "Ladvise test ${i}, bad lock count, returned " \
15647 "${rc}, actual ${difference}"
15651 #test 22 returns only success/failure
15653 lockahead_test -d $DIR/$tdir -t $i
15655 if [ $rc -eq 255 ]; then
15656 error "Ladvise test${i} failed, ${rc}"
15660 run_test 255c "suite of ladvise lockahead tests"
15667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15668 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15669 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15670 skip "ldiskfs only test" && return
15672 mdt_dev=$(mdsdevname 1)
15674 cl_user=$(do_facet mds1 \
15675 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15676 if [[ -n $cl_user ]]; then
15677 skip "active changelog user"
15681 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15682 echo "Registered as changelog user $cl_user"
15685 mkdir -p $DIR/$tdir
15687 $LFS changelog_clear $MDT0 $cl_user 0
15690 touch $DIR/$tdir/{1..10}
15693 stop mds1 || error "Fail to stop MDT."
15696 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15698 #after mount new plainllog is used
15699 touch $DIR/$tdir/{11..19}
15701 local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15702 cat_sl=$(do_facet mds1 \
15703 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15704 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15705 do_facet mds1 rm $TEMP256FILE
15707 if (( cat_sl != 2 )); then
15708 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15709 error "Changelog catalog has wrong number of slots $cat_sl"
15712 $LFS changelog_clear $MDT0 $cl_user 0
15715 TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15716 cat_sl=$(do_facet mds1 \
15717 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15718 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15719 do_facet mds1 rm $TEMP256FILE
15721 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15723 if (( cat_sl == 2 )); then
15724 error "Empty plain llog was not deleted from changelog catalog"
15726 if (( cat_sl != 1 )); then
15727 error "Active plain llog shouldn\`t be deleted from catalog"
15730 run_test 256 "Check llog delete for empty and not full state"
15733 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15734 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15735 skip "Need MDS version at least 2.8.55" && return
15737 test_mkdir $DIR/$tdir
15739 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15740 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15743 #define OBD_FAIL_MDS_XATTR_REP 0x161
15744 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15745 local facet=mds$((mdtidx + 1))
15746 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15747 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15749 stop $facet || error "stop MDS failed"
15750 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15751 error "start MDS fail"
15753 run_test 257 "xattr locks are not lost"
15755 # Verify we take the i_mutex when security requires it
15757 #define OBD_FAIL_IMUTEX_SEC 0x141c
15758 $LCTL set_param fail_loc=0x141c
15760 chmod u+s $DIR/$tfile
15761 chmod a+rwx $DIR/$tfile
15762 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15764 if [ $RC -ne 0 ]; then
15765 error "error, failed to take i_mutex, rc=$?"
15771 # Verify we do NOT take the i_mutex in the normal case
15773 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15774 $LCTL set_param fail_loc=0x141d
15777 chmod a+rw $DIR/$tfile
15778 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15780 if [ $RC -ne 0 ]; then
15781 error "error, took i_mutex unnecessarily, rc=$?"
15786 run_test 258b "verify i_mutex security behavior"
15789 #define OBD_FAIL_MDC_CLOSE 0x806
15790 $LCTL set_param fail_loc=0x80000806
15794 run_test 260 "Check mdc_close fail"
15796 ### Data-on-MDT sanity tests ###
15799 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15800 skip "Need MDS version at least 2.10.55" && return
15803 local dom=$DIR/$tdir/dom_file
15804 local tmp=$DIR/$tdir/tmp_file
15806 mkdir -p $DIR/$tdir
15808 # basic checks for DoM component creation
15809 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
15810 error "Can set MDT layout to non-first entry"
15812 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
15813 error "Can define multiple entries as MDT layout"
15815 $LFS setstripe -E 1M -L mdt $dom ||
15816 error "Can't create DoM layout"
15818 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
15819 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
15820 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
15822 local mdtidx=$($GETSTRIPE -M $dom)
15823 local mdtname=MDT$(printf %04x $mdtidx)
15824 local facet=mds$((mdtidx + 1))
15825 local space_check=1
15827 # Skip free space checks with ZFS
15828 if [ "$(facet_fstype $facet)" == "zfs" ]; then
15834 local mdtfree1=$(do_facet $facet \
15835 lctl get_param -n osd*.*$mdtname.kbytesfree)
15836 dd if=/dev/urandom of=$tmp bs=1024 count=100
15837 # check also direct IO along write
15838 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
15840 cmp $tmp $dom || error "file data is different"
15841 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
15842 if [ $space_check == 1 ]; then
15843 local 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 write"
15850 $TRUNCATE $dom 10000
15851 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
15852 if [ $space_check == 1 ]; then
15853 mdtfree1=$(do_facet $facet \
15854 lctl get_param -n osd*.*$mdtname.kbytesfree)
15855 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
15856 error "MDT free space is wrong after truncate"
15862 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
15863 if [ $space_check == 1 ]; then
15864 mdtfree2=$(do_facet $facet \
15865 lctl get_param -n osd*.*$mdtname.kbytesfree)
15866 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15867 error "MDT free space is wrong after append"
15872 if [ $space_check == 1 ]; then
15873 mdtfree1=$(do_facet $facet \
15874 lctl get_param -n osd*.*$mdtname.kbytesfree)
15875 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
15876 error "MDT free space is wrong after removal"
15879 # combined striping
15880 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
15881 error "Can't create DoM + OST striping"
15883 dd if=/dev/urandom of=$tmp bs=1024 count=2000
15884 # check also direct IO along write
15885 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
15887 cmp $tmp $dom || error "file data is different"
15888 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
15894 run_test 270a "DoM: basic functionality tests"
15897 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15898 skip "Need MDS version at least 2.10.55" && return
15900 local dom=$DIR/$tdir/dom_file
15901 local max_size=1048576
15903 mkdir -p $DIR/$tdir
15904 $LFS setstripe -E $max_size -L mdt $dom
15906 # truncate over the limit
15907 $TRUNCATE $dom $(($max_size + 1)) &&
15908 error "successful truncate over the maximum size"
15909 # write over the limit
15910 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
15911 error "successful write over the maximum size"
15912 # append over the limit
15913 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
15914 echo "12345" >> $dom && error "successful append over the maximum size"
15919 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
15922 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15923 skip "Need MDS version at least 2.10.55" && return
15925 mkdir -p $DIR/$tdir
15926 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15928 # check files inherit DoM EA
15929 touch $DIR/$tdir/first
15930 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
15931 error "bad pattern"
15932 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
15933 error "bad stripe count"
15934 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
15935 error "bad stripe size"
15937 # check directory inherits DoM EA and uses it as default
15938 mkdir $DIR/$tdir/subdir
15939 touch $DIR/$tdir/subdir/second
15940 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
15941 error "bad pattern in sub-directory"
15942 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
15943 error "bad stripe count in sub-directory"
15944 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
15945 error "bad stripe size in sub-directory"
15948 run_test 270c "DoM: DoM EA inheritance tests"
15951 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15952 skip "Need MDS version at least 2.10.55" && return
15954 mkdir -p $DIR/$tdir
15955 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15957 # inherit default DoM striping
15958 mkdir $DIR/$tdir/subdir
15959 touch $DIR/$tdir/subdir/f1
15961 # change default directory striping
15962 $LFS setstripe -c 1 $DIR/$tdir/subdir
15963 touch $DIR/$tdir/subdir/f2
15964 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
15965 error "wrong default striping in file 2"
15966 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
15967 error "bad pattern in file 2"
15970 run_test 270d "DoM: change striping from DoM to RAID0"
15973 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15974 skip "Need MDS version at least 2.10.55" && return
15976 mkdir -p $DIR/$tdir/dom
15977 mkdir -p $DIR/$tdir/norm
15980 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
15981 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
15983 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
15984 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
15986 # find DoM files by layout
15987 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
15988 [ $NUM -eq $DOMFILES ] ||
15989 error "lfs find -L: found $NUM, expected $DOMFILES"
15990 echo "Test 1: lfs find 20 DOM files by layout: OK"
15992 # there should be 1 dir with default DOM striping
15993 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
15995 error "lfs find -L: found $NUM, expected 1 dir"
15996 echo "Test 2: lfs find 1 DOM dir by layout: OK"
15998 # find DoM files by stripe size
15999 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
16000 [ $NUM -eq $DOMFILES ] ||
16001 error "lfs find -S: found $NUM, expected $DOMFILES"
16002 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
16004 # find files by stripe offset except DoM files
16005 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
16006 [ $NUM -eq $NORMFILES ] ||
16007 error "lfs find -i: found $NUM, expected $NORMFILES"
16008 echo "Test 5: lfs find no DOM files by stripe index: OK"
16011 run_test 270e "DoM: lfs find with DoM files test"
16014 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16015 skip "Need MDS version at least 2.10.55" && return
16017 local mdtname=${FSNAME}-MDT0000-mdtlov
16018 local dom=$DIR/$tdir/dom_file
16019 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
16020 lod.$mdtname.dom_stripesize)
16021 local dom_limit=131072
16023 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
16024 local dom_current=$(do_facet mds1 $LCTL get_param -n \
16025 lod.$mdtname.dom_stripesize)
16026 [ ${dom_limit} -eq ${dom_current} ] ||
16027 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
16029 $LFS mkdir -i 0 -c 1 $DIR/$tdir
16030 $LFS setstripe -d $DIR/$tdir
16031 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
16032 error "Can't set directory default striping"
16034 # exceed maximum stripe size
16035 $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
16036 error "Able to create DoM component size more than LOD limit"
16038 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
16039 dom_current=$(do_facet mds1 $LCTL get_param -n \
16040 lod.$mdtname.dom_stripesize)
16041 [ 0 -eq ${dom_current} ] ||
16042 error "Can't set zero DoM stripe limit"
16044 # too low values to be aligned with smallest stripe size 64K
16045 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
16046 dom_current=$(do_facet mds1 $LCTL get_param -n \
16047 lod.$mdtname.dom_stripesize)
16048 [ 30000 -eq ${dom_current} ] &&
16049 error "Can set too small DoM stripe limit"
16051 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
16052 dom_current=$(do_facet mds1 $LCTL get_param -n \
16053 lod.$mdtname.dom_stripesize)
16055 [ 2147483648 -eq ${dom_current} ] &&
16056 error "Can set too large DoM stripe limit"
16058 do_facet mds1 $LCTL set_param -n \
16059 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
16060 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16061 error "Can't create DoM component size after limit change"
16062 do_facet mds1 $LCTL set_param -n \
16063 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
16064 $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
16065 error "Can create big DoM component after limit decrease"
16066 touch ${dom}_def ||
16067 error "Can't create file with old default layout"
16069 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
16072 run_test 270f "DoM: maximum DoM stripe size checks"
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 $dom
16084 lctl set_param -n mdc.*.stats=clear
16085 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16086 cat $dom > /dev/null
16087 local reads=$(lctl get_param -n mdc.*.stats |
16088 awk '/ost_read/ {print $2}')
16089 [ -z $reads ] || error "Unexpected $reads READ RPCs"
16093 run_test 271a "DoM: data is cached for read after write"
16096 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16097 skip "Need MDS version at least 2.10.55" && return
16099 local dom=$DIR/$tdir/dom
16101 mkdir -p $DIR/$tdir
16103 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16105 lctl set_param -n mdc.*.stats=clear
16106 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16107 cancel_lru_locks mdc
16108 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
16109 # second stat to check size is cached on client
16110 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
16111 local gls=$(lctl get_param -n mdc.*.stats |
16112 awk '/ldlm_glimpse/ {print $2}')
16113 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16116 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
16119 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16120 skip "Need MDS version at least 2.10.55" && return
16122 local dom=$DIR/$tdir/dom
16124 mkdir -p $DIR/$tdir
16126 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16128 lctl set_param -n mdc.*.stats=clear
16129 lctl set_param -n osc.*.stats=clear
16130 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
16131 cancel_lru_locks mdc
16132 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16133 # second stat to check size is cached on client
16134 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16135 local gls=$(lctl get_param -n mdc.*.stats |
16136 awk '/ldlm_glimpse/ {print $2}')
16137 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16138 local gls=$(lctl get_param -n osc.*.stats |
16139 awk '/ldlm_glimpse/ {print $2}')
16140 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
16143 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
16146 # test to be enabled with lock_convert
16147 skip "skipped until lock convert will be implemented" && return
16149 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16150 skip "Need MDS version at least 2.10.55" && return
16152 local dom=$DIR/$tdir/dom
16154 mkdir -p $DIR/$tdir
16156 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16158 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
16159 local facet=mds$((mdtidx + 1))
16161 cancel_lru_locks mdc
16162 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
16163 createmany -o $dom 1000
16164 lctl set_param -n mdc.*.stats=clear
16165 smalliomany -w $dom 1000 200
16166 lctl get_param -n mdc.*.stats
16167 local enq=$(lctl get_param -n mdc.*.stats |
16168 awk '/ldlm_ibits_enqueue/ {print $2}')
16169 # Each file has 1 open, 1 IO enqueues, total 2000
16170 # but now we have also +1 getxattr for security.capability, total 3000
16171 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
16172 unlinkmany $dom 1000
16174 cancel_lru_locks mdc
16175 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
16176 createmany -o $dom 1000
16177 lctl set_param -n mdc.*.stats=clear
16178 smalliomany -w $dom 1000 200
16179 lctl get_param -n mdc.*.stats
16180 local enq_2=$(lctl get_param -n mdc.*.stats |
16181 awk '/ldlm_ibits_enqueue/ {print $2}')
16182 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
16183 # for OPEN and IO lock.
16184 [ $((enq - enq_2)) -ge 1000 ] ||
16185 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
16186 unlinkmany $dom 1000
16189 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
16191 cleanup_test_300() {
16195 test_striped_dir() {
16200 mkdir -p $DIR/$tdir
16202 SAVE_UMASK=$(umask)
16203 trap cleanup_test_300 RETURN EXIT
16205 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
16206 $DIR/$tdir/striped_dir ||
16207 error "set striped dir error"
16209 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
16210 [ "$mode" = "755" ] || error "expect 755 got $mode"
16212 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
16213 error "getdirstripe failed"
16214 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
16215 if [ "$stripe_count" != "2" ]; then
16216 error "1:stripe_count is $stripe_count, expect 2"
16218 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
16219 if [ "$stripe_count" != "2" ]; then
16220 error "2:stripe_count is $stripe_count, expect 2"
16223 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
16224 if [ "$stripe_index" != "$mdt_index" ]; then
16225 error "stripe_index is $stripe_index, expect $mdt_index"
16228 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16229 error "nlink error after create striped dir"
16231 mkdir $DIR/$tdir/striped_dir/a
16232 mkdir $DIR/$tdir/striped_dir/b
16234 stat $DIR/$tdir/striped_dir/a ||
16235 error "create dir under striped dir failed"
16236 stat $DIR/$tdir/striped_dir/b ||
16237 error "create dir under striped dir failed"
16239 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
16240 error "nlink error after mkdir"
16242 rmdir $DIR/$tdir/striped_dir/a
16243 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
16244 error "nlink error after rmdir"
16246 rmdir $DIR/$tdir/striped_dir/b
16247 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16248 error "nlink error after rmdir"
16250 chattr +i $DIR/$tdir/striped_dir
16251 createmany -o $DIR/$tdir/striped_dir/f 10 &&
16252 error "immutable flags not working under striped dir!"
16253 chattr -i $DIR/$tdir/striped_dir
16255 rmdir $DIR/$tdir/striped_dir ||
16256 error "rmdir striped dir error"
16264 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16265 skip "skipped for lustre < 2.7.0" && return
16266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16267 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16269 test_striped_dir 0 || error "failed on striped dir on MDT0"
16270 test_striped_dir 1 || error "failed on striped dir on MDT0"
16272 run_test 300a "basic striped dir sanity test"
16275 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16276 skip "skipped for lustre < 2.7.0" && return
16277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16278 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16284 test_mkdir $DIR/$tdir
16285 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16286 error "set striped dir error"
16287 for ((i=0; i<10; i++)); do
16288 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
16290 touch $DIR/$tdir/striped_dir/file_$i ||
16291 error "touch error $i"
16292 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
16293 [ $mtime1 -eq $mtime2 ] &&
16294 error "mtime not change after create"
16296 rm -f $DIR/$tdir/striped_dir/file_$i ||
16297 error "unlink error $i"
16298 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
16299 [ $mtime2 -eq $mtime3 ] &&
16300 error "mtime did not change after unlink"
16304 run_test 300b "check ctime/mtime for striped dir"
16307 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16308 skip "skipped for lustre < 2.7.0" && return
16309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16313 mkdir -p $DIR/$tdir
16314 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
16315 error "set striped dir error"
16317 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
16318 error "chown striped dir failed"
16320 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
16321 error "create 5k files failed"
16323 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
16325 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
16329 run_test 300c "chown && check ls under striped directory"
16332 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16333 skip "skipped for lustre < 2.7.0" && return
16334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16339 mkdir -p $DIR/$tdir
16340 $SETSTRIPE -c 2 $DIR/$tdir
16342 #local striped directory
16343 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16344 error "set striped dir error"
16345 createmany -o $DIR/$tdir/striped_dir/f 10 ||
16346 error "create 10 files failed"
16348 #remote striped directory
16349 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
16350 error "set striped dir error"
16351 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
16352 error "create 10 files failed"
16354 for file in $(find $DIR/$tdir); do
16355 stripe_count=$($GETSTRIPE -c $file)
16356 [ $stripe_count -eq 2 ] ||
16357 error "wrong stripe $stripe_count for $file"
16362 run_test 300d "check default stripe under striped directory"
16365 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16366 skip "Need MDS version at least 2.7.55" && return
16367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16368 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16372 mkdir -p $DIR/$tdir
16374 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16375 error "set striped dir error"
16377 touch $DIR/$tdir/striped_dir/a
16378 touch $DIR/$tdir/striped_dir/b
16379 touch $DIR/$tdir/striped_dir/c
16381 mkdir $DIR/$tdir/striped_dir/dir_a
16382 mkdir $DIR/$tdir/striped_dir/dir_b
16383 mkdir $DIR/$tdir/striped_dir/dir_c
16385 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
16386 error "set striped adir under striped dir error"
16388 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
16389 error "set striped bdir under striped dir error"
16391 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
16392 error "set striped cdir under striped dir error"
16394 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
16395 error "rename dir under striped dir fails"
16397 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
16398 error "rename dir under different stripes fails"
16400 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
16401 error "rename file under striped dir should succeed"
16403 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
16404 error "rename dir under striped dir should succeed"
16408 run_test 300e "check rename under striped directory"
16411 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16412 skip "Need MDS version at least 2.7.55" && return
16413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16414 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16419 mkdir -p $DIR/$tdir
16421 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16422 error "set striped dir error"
16424 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
16425 error "set striped dir error"
16427 touch $DIR/$tdir/striped_dir/a
16428 mkdir $DIR/$tdir/striped_dir/dir_a
16429 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
16430 error "create striped dir under striped dir fails"
16432 touch $DIR/$tdir/striped_dir1/b
16433 mkdir $DIR/$tdir/striped_dir1/dir_b
16434 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
16435 error "create striped dir under striped dir fails"
16437 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
16438 error "rename dir under different striped dir should fail"
16440 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
16441 error "rename striped dir under diff striped dir should fail"
16443 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
16444 error "rename file under diff striped dirs fails"
16448 run_test 300f "check rename cross striped directory"
16450 test_300_check_default_striped_dir()
16453 local default_count=$2
16454 local default_index=$3
16457 local dir_stripe_index
16460 echo "checking $dirname $default_count $default_index"
16461 $LFS setdirstripe -D -c $default_count -i $default_index \
16462 -t all_char $DIR/$tdir/$dirname ||
16463 error "set default stripe on striped dir error"
16464 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
16465 [ $stripe_count -eq $default_count ] ||
16466 error "expect $default_count get $stripe_count for $dirname"
16468 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
16469 [ $stripe_index -eq $default_index ] ||
16470 error "expect $default_index get $stripe_index for $dirname"
16472 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
16473 error "create dirs failed"
16475 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
16476 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
16477 for dir in $(find $DIR/$tdir/$dirname/*); do
16478 stripe_count=$($LFS getdirstripe -c $dir)
16479 [ $stripe_count -eq $default_count ] ||
16480 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
16481 error "stripe count $default_count != $stripe_count for $dir"
16483 stripe_index=$($LFS getdirstripe -i $dir)
16484 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
16485 error "$stripe_index != $default_index for $dir"
16487 #check default stripe
16488 stripe_count=$($LFS getdirstripe -D -c $dir)
16489 [ $stripe_count -eq $default_count ] ||
16490 error "default count $default_count != $stripe_count for $dir"
16492 stripe_index=$($LFS getdirstripe -D -i $dir)
16493 [ $stripe_index -eq $default_index ] ||
16494 error "default index $default_index != $stripe_index for $dir"
16496 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
16500 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16501 skip "Need MDS version at least 2.7.55" && return
16502 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16508 mkdir $DIR/$tdir/normal_dir
16510 #Checking when client cache stripe index
16511 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
16512 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
16513 error "create striped_dir failed"
16515 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
16516 error "create dir0 fails"
16517 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
16518 [ $stripe_index -eq 0 ] ||
16519 error "dir0 expect index 0 got $stripe_index"
16521 mkdir $DIR/$tdir/striped_dir/dir1 ||
16522 error "create dir1 fails"
16523 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
16524 [ $stripe_index -eq 1 ] ||
16525 error "dir1 expect index 1 got $stripe_index"
16527 #check default stripe count/stripe index
16528 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
16529 test_300_check_default_striped_dir normal_dir 1 0
16530 test_300_check_default_striped_dir normal_dir 2 1
16531 test_300_check_default_striped_dir normal_dir 2 -1
16533 #delete default stripe information
16534 echo "delete default stripeEA"
16535 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
16536 error "set default stripe on striped dir error"
16538 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
16539 for dir in $(find $DIR/$tdir/normal_dir/*); do
16540 stripe_count=$($LFS getdirstripe -c $dir)
16541 [ $stripe_count -eq 0 ] ||
16542 error "expect 1 get $stripe_count for $dir"
16543 stripe_index=$($LFS getdirstripe -i $dir)
16544 [ $stripe_index -eq 0 ] ||
16545 error "expect 0 get $stripe_index for $dir"
16548 run_test 300g "check default striped directory for normal directory"
16551 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16552 skip "Need MDS version at least 2.7.55" && return
16553 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16558 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
16559 $DIR/$tdir/striped_dir ||
16560 error "set striped dir error"
16562 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
16563 test_300_check_default_striped_dir striped_dir 1 0
16564 test_300_check_default_striped_dir striped_dir 2 1
16565 test_300_check_default_striped_dir striped_dir 2 -1
16567 #delete default stripe information
16568 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
16569 error "set default stripe on striped dir error"
16571 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
16572 for dir in $(find $DIR/$tdir/striped_dir/*); do
16573 stripe_count=$($LFS getdirstripe -c $dir)
16574 [ $stripe_count -eq 0 ] ||
16575 error "expect 1 get $stripe_count for $dir"
16578 run_test 300h "check default striped directory for striped directory"
16581 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16582 skip "Need MDS version at least 2.7.55" && return
16583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16584 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16590 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16591 error "set striped dir error"
16593 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16594 error "create files under striped dir failed"
16596 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
16597 error "set striped hashdir error"
16599 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
16600 error "create dir0 under hash dir failed"
16601 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
16602 error "create dir1 under hash dir failed"
16604 # unfortunately, we need to umount to clear dir layout cache for now
16605 # once we fully implement dir layout, we can drop this
16606 umount_client $MOUNT || error "umount failed"
16607 mount_client $MOUNT || error "mount failed"
16609 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
16610 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
16611 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
16613 #set the stripe to be unknown hash type
16614 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
16615 $LCTL set_param fail_loc=0x1901
16616 for ((i = 0; i < 10; i++)); do
16617 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
16618 error "stat f-$i failed"
16619 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
16622 touch $DIR/$tdir/striped_dir/f0 &&
16623 error "create under striped dir with unknown hash should fail"
16625 $LCTL set_param fail_loc=0
16627 umount_client $MOUNT || error "umount failed"
16628 mount_client $MOUNT || error "mount failed"
16632 run_test 300i "client handle unknown hash type striped directory"
16635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16636 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16637 skip "Need MDS version at least 2.7.55" && return
16638 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16644 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
16645 $LCTL set_param fail_loc=0x1702
16646 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16647 error "set striped dir error"
16649 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16650 error "create files under striped dir failed"
16652 $LCTL set_param fail_loc=0
16654 rm -rf $DIR/$tdir || error "unlink striped dir fails"
16658 run_test 300j "test large update record"
16661 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16662 skip "Need MDS version at least 2.7.55" && return
16663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16664 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16670 #define OBD_FAIL_LARGE_STRIPE 0x1703
16671 $LCTL set_param fail_loc=0x1703
16672 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
16673 error "set striped dir error"
16674 $LCTL set_param fail_loc=0
16676 $LFS getdirstripe $DIR/$tdir/striped_dir ||
16677 error "getstripeddir fails"
16678 rm -rf $DIR/$tdir/striped_dir ||
16679 error "unlink striped dir fails"
16683 run_test 300k "test large striped directory"
16686 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16687 skip "Need MDS version at least 2.7.55" && return
16688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16689 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16692 test_mkdir -p $DIR/$tdir/striped_dir
16693 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
16694 error "chown $RUNAS_ID failed"
16695 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
16696 error "set default striped dir failed"
16698 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
16699 $LCTL set_param fail_loc=0x80000158
16700 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
16702 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
16703 [ $stripe_index -eq 1 ] ||
16704 error "expect 1 get $stripe_index for $dir"
16706 run_test 300l "non-root user to create dir under striped dir with stale layout"
16709 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16710 skip "Need MDS version at least 2.7.55" && return
16711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16712 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
16714 mkdir -p $DIR/$tdir/striped_dir
16715 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
16716 error "set default stripes dir error"
16718 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
16720 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
16721 [ $stripe_count -eq 0 ] ||
16722 error "expect 0 get $stripe_count for a"
16724 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
16725 error "set default stripes dir error"
16727 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
16729 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
16730 [ $stripe_count -eq 0 ] ||
16731 error "expect 0 get $stripe_count for b"
16733 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
16734 error "set default stripes dir error"
16736 mkdir $DIR/$tdir/striped_dir/c &&
16737 error "default stripe_index is invalid, mkdir c should fails"
16739 rm -rf $DIR/$tdir || error "rmdir fails"
16741 run_test 300m "setstriped directory on single MDT FS"
16744 local list=$(comma_list $(mdts_nodes))
16747 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16751 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16752 skip "Need MDS version at least 2.7.55" && return
16753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16754 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16755 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16758 local list=$(comma_list $(mdts_nodes))
16760 trap cleanup_300n RETURN EXIT
16761 mkdir -p $DIR/$tdir
16762 chmod 777 $DIR/$tdir
16763 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16764 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16765 error "create striped dir succeeds with gid=0"
16767 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16768 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16769 error "create striped dir fails with gid=-1"
16771 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16772 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16773 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16774 error "set default striped dir succeeds with gid=0"
16777 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16778 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16779 error "set default striped dir fails with gid=-1"
16782 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16783 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16784 error "create test_dir fails"
16785 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16786 error "create test_dir1 fails"
16787 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16788 error "create test_dir2 fails"
16791 run_test 300n "non-root user to create dir under striped dir with default EA"
16794 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16795 skip "Need MDS version at least 2.7.55" && return
16796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16801 mkdir -p $DIR/$tdir
16803 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16804 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16805 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16806 skip "not enough free inodes $numfree1 $numfree2"
16810 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16811 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16812 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16813 skip "not enough free space $numfree1 $numfree2"
16817 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16818 error "setdirstripe fails"
16820 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16821 error "create dirs fails"
16823 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16824 ls $DIR/$tdir/striped_dir > /dev/null ||
16825 error "ls striped dir fails"
16826 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16827 error "unlink big striped dir fails"
16829 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16833 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16834 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16836 mkdir -p $DIR/$tdir
16838 #define OBD_FAIL_OUT_ENOSPC 0x1704
16839 do_facet mds2 lctl set_param fail_loc=0x80001704
16840 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16841 error "create striped directory should fail"
16843 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16845 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16848 run_test 300p "create striped directory without space"
16851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16854 local fd=$(free_fd)
16855 local cmd="exec $fd<$tdir"
16857 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16860 trap "eval $cmd" EXIT
16861 cd $tdir || error "cd $tdir fails"
16862 rmdir ../$tdir || error "rmdir $tdir fails"
16863 mkdir local_dir && error "create dir succeeds"
16864 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16868 run_test 300q "create remote directory under orphan directory"
16870 prepare_remote_file() {
16871 mkdir $DIR/$tdir/src_dir ||
16872 error "create remote source failed"
16874 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16875 touch $DIR/$tdir/src_dir/a
16877 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16878 error "create remote target dir failed"
16880 touch $DIR/$tdir/tgt_dir/b
16882 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16883 error "rename dir cross MDT failed!"
16885 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16886 error "src_child still exists after rename"
16888 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16889 error "missing file(a) after rename"
16891 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16892 error "diff after rename"
16896 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16898 local remote_file=$DIR/$tdir/tgt_dir/b
16900 mkdir -p $DIR/$tdir
16902 prepare_remote_file || error "prepare remote file failed"
16905 $OPENUNLINK $remote_file $remote_file || error
16906 $CHECKSTAT -a $remote_file || error
16908 run_test 310a "open unlink remote file"
16911 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16913 local remote_file=$DIR/$tdir/tgt_dir/b
16915 mkdir -p $DIR/$tdir
16917 prepare_remote_file || error "prepare remote file failed"
16919 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16920 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16921 $CHECKSTAT -t file $remote_file || error "check file failed"
16923 run_test 310b "unlink remote file with multiple links while open"
16926 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16928 local remote_file=$DIR/$tdir/tgt_dir/b
16930 mkdir -p $DIR/$tdir
16932 prepare_remote_file || error "prepare remote file failed"
16934 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16935 multiop_bg_pause $remote_file O_uc ||
16936 error "mulitop failed for remote file"
16938 $MULTIOP $DIR/$tfile Ouc
16939 kill -USR1 $MULTIPID
16942 run_test 310c "open-unlink remote file with multiple links"
16946 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16947 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16949 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16951 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16953 mkdir -p $DIR/$tdir
16954 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16955 createmany -o $DIR/$tdir/$tfile. 1000
16957 # statfs data is not real time, let's just calculate it
16958 old_iused=$((old_iused + 1000))
16960 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16961 osp.*OST0000*MDT0000.create_count")
16962 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16963 osp.*OST0000*MDT0000.max_create_count")
16964 for idx in $(seq $MDSCOUNT); do
16965 do_facet mds$idx "lctl set_param -n \
16966 osp.*OST0000*MDT000?.max_create_count=0"
16969 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16970 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16971 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16973 unlinkmany $DIR/$tdir/$tfile. 1000
16975 for idx in $(seq $MDSCOUNT); do
16976 do_facet mds$idx "lctl set_param -n \
16977 osp.*OST0000*MDT000?.max_create_count=$max_count"
16978 do_facet mds$idx "lctl set_param -n \
16979 osp.*OST0000*MDT000?.create_count=$count"
16983 for i in $(seq 120); do
16984 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16985 # system may be too busy to destroy all objs in time, use
16986 # a somewhat small value to not fail autotest
16987 [ $((old_iused - new_iused)) -gt 400 ] && break
16991 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16992 [ $((old_iused - new_iused)) -gt 400 ] ||
16993 error "objs not destroyed after unlink"
16995 run_test 311 "disable OSP precreate, and unlink should destroy objs"
17002 local vdevdir=$(dirname $(facet_vdevice $ost))
17003 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
17004 local zfs_zapid=$(do_facet $ost $cmd |
17005 grep -w "/O/0/d$((objid%32))" -C 5 |
17006 awk '/Object/{getline; print $1}')
17007 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
17008 awk "/$objid = /"'{printf $3}')
17013 zfs_object_blksz() {
17017 local vdevdir=$(dirname $(facet_vdevice $ost))
17018 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
17019 local blksz=$(do_facet $ost $cmd $objid |
17020 awk '/dblk/{getline; printf $4}')
17022 case "${blksz: -1}" in
17023 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
17024 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
17031 test_312() { # LU-4856
17032 remote_ost_nodsh && skip "remote OST with nodsh" && return
17034 [ $(facet_fstype ost1) = "zfs" ] ||
17035 { skip "the test only applies to zfs" && return; }
17037 local max_blksz=$(do_facet ost1 \
17038 $ZFS get -p recordsize $(facet_device ost1) |
17039 awk '!/VALUE/{print $3}')
17040 local min_blksz=$(getconf PAGE_SIZE)
17042 # to make life a little bit easier
17043 $LFS mkdir -c 1 -i 0 $DIR/$tdir
17044 $LFS setstripe -c 1 -i 0 $DIR/$tdir
17046 local tf=$DIR/$tdir/$tfile
17048 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17050 # Get ZFS object id
17051 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17053 # block size change by sequential over write
17055 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
17056 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
17058 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17059 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
17063 # block size change by sequential append write
17064 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
17065 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17066 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17068 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
17069 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
17070 oflag=sync conv=notrunc
17072 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17073 [ $blksz -eq $((2 * count * min_blksz)) ] ||
17074 error "blksz error, actual $blksz, " \
17075 "expected: 2 * $count * $min_blksz"
17081 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17082 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17084 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
17085 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17086 [ $blksz -eq $min_blksz ] ||
17087 error "blksz error: $blksz, expected: $min_blksz"
17089 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
17090 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17091 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
17093 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
17094 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17095 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
17097 run_test 312 "make sure ZFS adjusts its block size by write pattern"
17100 remote_ost_nodsh && skip "remote OST with nodsh" && return
17102 local file=$DIR/$tfile
17104 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
17106 # define OBD_FAIL_TGT_RCVD_EIO 0x720
17107 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17108 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
17109 error "write should failed"
17110 do_facet ost1 "$LCTL set_param fail_loc=0"
17113 run_test 313 "io should fail after last_rcvd update fail"
17116 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
17117 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17119 wait_delete_completed
17120 do_facet ost1 "$LCTL set_param fail_loc=0"
17122 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
17124 test_315() { # LU-618
17125 local file=$DIR/$tfile
17128 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
17129 $MULTIOP $file oO_RDONLY:r4096000_c &
17134 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
17137 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
17140 run_test 315 "read should be accounted"
17143 local read_write=$1
17144 if [ "$read_write" = "write" ]; then
17145 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
17146 elif [ "$read_write" = "read" ]; then
17147 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
17149 error "argument error"
17152 # turn off debug for performance testing
17153 local saved_debug=$($LCTL get_param -n debug)
17154 $LCTL set_param debug=0
17156 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
17158 # get ost1 size - lustre-OST0000
17159 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
17160 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
17161 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
17163 if [ "$read_write" = "read" ]; then
17164 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
17167 local start_time=$(date +%s.%N)
17168 $dd_cmd bs=1M count=$blocks oflag=sync ||
17169 error "real dd $read_write error"
17170 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
17172 if [ "$read_write" = "write" ]; then
17176 # define OBD_FAIL_OST_FAKE_RW 0x238
17177 do_facet ost1 $LCTL set_param fail_loc=0x238
17179 local start_time=$(date +%s.%N)
17180 $dd_cmd bs=1M count=$blocks oflag=sync ||
17181 error "fake dd $read_write error"
17182 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
17184 if [ "$read_write" = "write" ]; then
17186 cancel_lru_locks osc
17187 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
17188 error "$tfile size not $blocks MB"
17190 do_facet ost1 $LCTL set_param fail_loc=0
17192 echo "fake $read_write $duration_fake vs. normal $read_write" \
17193 "$duration in seconds"
17194 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
17195 error_not_in_vm "fake write is slower"
17197 $LCTL set_param -n debug="$saved_debug"
17200 test_399a() { # LU-7655 for OST fake write
17201 remote_ost_nodsh && skip "remote OST with nodsh" && return
17205 run_test 399a "fake write should not be slower than normal write"
17207 test_399b() { # LU-8726 for OST fake read
17208 remote_ost_nodsh && skip "remote OST with nodsh" && return
17210 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
17211 skip "ldiskfs only test" && return 0
17215 run_test 399b "fake read should not be slower than normal read"
17217 test_400a() { # LU-1606, was conf-sanity test_74
17218 local extra_flags=''
17219 local out=$TMP/$tfile
17220 local prefix=/usr/include/lustre
17223 if ! which $CC > /dev/null 2>&1; then
17224 skip_env "$CC is not installed"
17228 if ! [[ -d $prefix ]]; then
17229 # Assume we're running in tree and fixup the include path.
17230 extra_flags+=" -I$LUSTRE/include"
17231 extra_flags+=" -L$LUSTRE/utils"
17234 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
17235 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
17236 error "client api broken"
17240 run_test 400a "Lustre client api program can compile and link"
17242 test_400b() { # LU-1606, LU-5011
17244 local out=$TMP/$tfile
17245 local prefix=/usr/include/linux/lustre
17247 # We use a hard coded prefix so that this test will not fail
17248 # when run in tree. There are headers in lustre/include/lustre/
17249 # that are not packaged (like lustre_idl.h) and have more
17250 # complicated include dependencies (like config.h and lnet/types.h).
17251 # Since this test about correct packaging we just skip them when
17252 # they don't exist (see below) rather than try to fixup cppflags.
17254 if ! which $CC > /dev/null 2>&1; then
17255 skip_env "$CC is not installed"
17259 for header in $prefix/*.h; do
17260 if ! [[ -f "$header" ]]; then
17264 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
17265 continue # lustre_ioctl.h is internal header
17268 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
17269 error "cannot compile '$header'"
17273 run_test 400b "packaged headers can be compiled"
17275 test_401a() { #LU-7437
17276 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
17277 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
17279 #count the number of parameters by "list_param -R"
17280 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
17281 #count the number of parameters by listing proc files
17282 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
17283 echo "proc_dirs='$proc_dirs'"
17284 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
17285 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
17288 [ $params -eq $procs ] ||
17289 error "found $params parameters vs. $procs proc files"
17291 # test the list_param -D option only returns directories
17292 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
17293 #count the number of parameters by listing proc directories
17294 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
17297 [ $params -eq $procs ] ||
17298 error "found $params parameters vs. $procs proc files"
17300 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
17303 local save=$($LCTL get_param -n jobid_var)
17306 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
17307 error "no error returned when setting bad parameters"
17309 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
17310 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
17312 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
17313 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
17314 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
17316 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
17319 local jobid_var_old=$($LCTL get_param -n jobid_var)
17320 local jobid_var_new
17322 $LCTL set_param jobid_var= &&
17323 error "no error returned for 'set_param a='"
17325 jobid_var_new=$($LCTL get_param -n jobid_var)
17326 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17327 error "jobid_var was changed by setting without value"
17329 $LCTL set_param jobid_var &&
17330 error "no error returned for 'set_param a'"
17332 jobid_var_new=$($LCTL get_param -n jobid_var)
17333 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17334 error "jobid_var was changed by setting without value"
17336 run_test 401c "Verify 'lctl set_param' without value fails in either format."
17339 local jobid_var_old=$($LCTL get_param -n jobid_var)
17340 local jobid_var_new
17341 local new_value="foo=bar"
17343 $LCTL set_param jobid_var=$new_value ||
17344 error "'set_param a=b' did not accept a value containing '='"
17346 jobid_var_new=$($LCTL get_param -n jobid_var)
17347 [[ "$jobid_var_new" == "$new_value" ]] ||
17348 error "'set_param a=b' failed on a value containing '='"
17350 # Reset the jobid_var to test the other format
17351 $LCTL set_param jobid_var=$jobid_var_old
17352 jobid_var_new=$($LCTL get_param -n jobid_var)
17353 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17354 error "failed to reset jobid_var"
17356 $LCTL set_param jobid_var $new_value ||
17357 error "'set_param a b' did not accept a value containing '='"
17359 jobid_var_new=$($LCTL get_param -n jobid_var)
17360 [[ "$jobid_var_new" == "$new_value" ]] ||
17361 error "'set_param a b' failed on a value containing '='"
17363 $LCTL set_param jobid_var $jobid_var_old
17364 jobid_var_new=$($LCTL get_param -n jobid_var)
17365 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17366 error "failed to reset jobid_var"
17368 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
17371 local server_version=$(lustre_version_code $SINGLEMDS)
17372 [[ $server_version -ge $(version_code 2.7.66) ]] ||
17373 [[ $server_version -ge $(version_code 2.7.18.4) &&
17374 $server_version -lt $(version_code 2.7.50) ]] ||
17375 [[ $server_version -ge $(version_code 2.7.2) &&
17376 $server_version -lt $(version_code 2.7.11) ]] ||
17377 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
17379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17380 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
17381 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
17382 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
17383 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
17384 echo "Touch failed - OK"
17386 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
17389 local file1=$DIR/$tfile.1
17390 local file2=$DIR/$tfile.2
17391 local tfile=$TMP/$tfile
17393 rm -f $file1 $file2 $tfile
17398 # 30 sec OBD_TIMEOUT in ll_getattr()
17399 # right before populating st_nlink
17400 $LCTL set_param fail_loc=0x80001409
17401 stat -c %h $file1 > $tfile &
17403 # create an alias, drop all locks and reclaim the dentry
17405 cancel_lru_locks mdc
17406 cancel_lru_locks osc
17407 sysctl -w vm.drop_caches=2
17411 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
17413 rm -f $tfile $file1 $file2
17415 run_test 403 "i_nlink should not drop to zero due to aliasing"
17417 test_404() { # LU-6601
17418 local server_version=$(lustre_version_code $SINGLEMDS)
17419 [[ $server_version -ge $(version_code 2.8.53) ]] ||
17420 { skip "Need server version newer than 2.8.52"; return 0; }
17422 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17423 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
17424 awk '/osp .*-osc-MDT/ { print $4}')
17427 for osp in $mosps; do
17428 echo "Deactivate: " $osp
17429 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
17430 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17431 awk -vp=$osp '$4 == p { print $2 }')
17432 [ $stat = IN ] || {
17433 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17434 error "deactivate error"
17436 echo "Activate: " $osp
17437 do_facet $SINGLEMDS $LCTL --device %$osp activate
17438 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17439 awk -vp=$osp '$4 == p { print $2 }')
17440 [ $stat = UP ] || {
17441 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17442 error "activate error"
17446 run_test 404 "validate manual {de}activated works properly for OSPs"
17449 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
17450 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
17451 skip "Layout swap lock is not supported" && return
17453 check_swap_layouts_support && return 0
17455 test_mkdir $DIR/$tdir
17456 swap_lock_test -d $DIR/$tdir ||
17457 error "One layout swap locked test failed"
17459 run_test 405 "Various layout swap lock tests"
17462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17463 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17464 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
17465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17466 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
17467 skip "Need MDS version at least 2.8.50" && return
17469 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
17470 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
17471 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
17472 local def_pool=$($GETSTRIPE -p $MOUNT)
17473 local test_pool=$TESTNAME
17475 if ! combined_mgs_mds ; then
17478 pool_add $test_pool || error "pool_add failed"
17479 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
17480 error "pool_add_targets failed"
17482 # parent set default stripe count only, child will stripe from both
17483 # parent and fs default
17484 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
17485 error "setstripe $MOUNT failed"
17486 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
17487 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
17488 for i in $(seq 10); do
17489 local f=$DIR/$tdir/$tfile.$i
17490 touch $f || error "touch failed"
17491 local count=$($GETSTRIPE -c $f)
17492 [ $count -eq $OSTCOUNT ] ||
17493 error "$f stripe count $count != $OSTCOUNT"
17494 local offset=$($GETSTRIPE -i $f)
17495 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
17496 local size=$($GETSTRIPE -S $f)
17497 [ $size -eq $((def_stripe_size * 2)) ] ||
17498 error "$f stripe size $size != $((def_stripe_size * 2))"
17499 local pool=$($GETSTRIPE -p $f)
17500 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
17503 # change fs default striping, delete parent default striping, now child
17504 # will stripe from new fs default striping only
17505 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
17506 error "change $MOUNT default stripe failed"
17507 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
17508 for i in $(seq 11 20); do
17509 local f=$DIR/$tdir/$tfile.$i
17510 touch $f || error "touch $f failed"
17511 local count=$($GETSTRIPE -c $f)
17512 [ $count -eq 1 ] || error "$f stripe count $count != 1"
17513 local offset=$($GETSTRIPE -i $f)
17514 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
17515 local size=$($GETSTRIPE -S $f)
17516 [ $size -eq $def_stripe_size ] ||
17517 error "$f stripe size $size != $def_stripe_size"
17518 local pool=$($GETSTRIPE -p $f)
17519 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
17523 unlinkmany $DIR/$tdir/$tfile. 1 20
17525 # restore FS default striping
17526 if [ -z $def_pool ]; then
17527 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17528 -i $def_stripe_offset $MOUNT ||
17529 error "restore default striping failed"
17531 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17532 -i $def_stripe_offset -p $def_pool $MOUNT ||
17533 error "restore default striping with $def_pool failed"
17536 local f=$DIR/$tdir/$tfile
17537 pool_remove_all_targets $test_pool $f
17538 pool_remove $test_pool $f
17540 if ! combined_mgs_mds ; then
17544 run_test 406 "DNE support fs default striping"
17547 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17548 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
17549 skip "Need MDS version at least 2.8.55" && return
17550 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17552 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
17553 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
17554 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
17555 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
17556 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
17558 #define OBD_FAIL_DT_TXN_STOP 0x2019
17559 for idx in $(seq $MDSCOUNT); do
17560 do_facet mds$idx "lctl set_param fail_loc=0x2019"
17562 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
17563 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
17564 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
17567 run_test 407 "transaction fail should cause operation fail"
17570 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
17572 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
17573 lctl set_param fail_loc=0x8000040a
17574 # let ll_prepare_partial_page() fail
17575 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
17579 # create at least 100 unused inodes so that
17580 # shrink_icache_memory(0) should not return 0
17581 touch $DIR/$tfile-{0..100}
17582 rm -f $DIR/$tfile-{0..100}
17585 echo 2 > /proc/sys/vm/drop_caches
17587 run_test 408 "drop_caches should not hang due to page leaks"
17591 [ $MDSCOUNT -lt 2 ] &&
17592 skip "We need at least 2 MDTs for this test" && return
17594 check_mount_and_prep
17596 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
17597 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
17598 touch $DIR/$tdir/guard || error "(2) Fail to create"
17600 local PREFIX=$(str_repeat 'A' 128)
17601 echo "Create 1K hard links start at $(date)"
17602 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17603 error "(3) Fail to hard link"
17605 echo "Links count should be right although linkEA overflow"
17606 stat $DIR/$tdir/guard || error "(4) Fail to stat"
17607 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
17608 [ $linkcount -eq 1001 ] ||
17609 error "(5) Unexpected hard links count: $linkcount"
17611 echo "List all links start at $(date)"
17612 ls -l $DIR/$tdir/foo > /dev/null ||
17613 error "(6) Fail to list $DIR/$tdir/foo"
17615 echo "Unlink hard links start at $(date)"
17616 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17617 error "(7) Fail to unlink"
17619 run_test 409 "Large amount of cross-MDTs hard links on the same file"
17623 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
17624 skip "Need client version at least 2.9.59" && return
17626 # Create a file, and stat it from the kernel
17627 local testfile=$DIR/$tfile
17630 local run_id=$RANDOM
17631 local my_ino=$(stat --format "%i" $testfile)
17633 # Try to insert the module. This will always fail as the
17634 # module is designed to not be inserted.
17635 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
17638 # Anything but success is a test failure
17640 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
17641 error "no inode match"
17643 run_test 410 "Test inode number returned from kernel thread"
17645 cleanup_test411_cgroup() {
17651 local cg_basedir=/sys/fs/cgroup/memory
17653 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
17654 { skip "no setup for cgroup"; return; }
17656 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
17657 error "test file creation failed"
17658 cancel_lru_locks osc
17660 # Create a very small memory cgroup to force a slab allocation error
17661 local cgdir=$cg_basedir/osc_slab_alloc
17662 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
17663 trap "cleanup_test411_cgroup $cgdir" EXIT
17664 echo 2M > $cgdir/memory.kmem.limit_in_bytes
17665 echo 1M > $cgdir/memory.limit_in_bytes
17667 # Should not LBUG, just be killed by oom-killer
17668 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
17669 error "fail to trigger a memory allocation error"
17671 cleanup_test411_cgroup $cgdir
17675 run_test 411 "Slab allocation error with cgroup does not LBUG"
17678 [ $MDSCOUNT -lt 2 ] &&
17679 skip "We need at least 2 MDTs for this test" && return
17681 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
17682 skip "Need server version at least 2.10.55" & exit 0
17685 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
17686 error "mkdir failed"
17687 $LFS getdirstripe $DIR/$tdir
17688 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
17689 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
17690 error "expect $((MDSCOUT - 1)) get $stripe_index"
17691 stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
17692 [ $stripe_count -eq 2 ] ||
17693 error "expect 2 get $stripe_count"
17695 run_test 412 "mkdir on specific MDTs"
17698 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17699 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17700 skip "Need server version at least 2.9.55" & exit 0
17701 start_full_debug_logging
17705 stop_full_debug_logging
17709 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17710 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17711 awk '/The barrier for/ { print $7 }')
17714 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
17719 barrier_expired() {
17722 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17723 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17724 awk '/will be expired/ { print $7 }')
17726 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
17735 echo "Start barrier_freeze at: $(date)"
17736 #define OBD_FAIL_BARRIER_DELAY 0x2202
17737 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17738 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
17741 local b_status=$(barrier_stat)
17742 echo "Got barrier status at: $(date)"
17743 [ "$b_status" = "'freezing_p1'" ] ||
17744 error "(1) unexpected barrier status $b_status"
17746 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17748 b_status=$(barrier_stat)
17749 [ "$b_status" = "'frozen'" ] ||
17750 error "(2) unexpected barrier status $b_status"
17752 local expired=$(barrier_expired)
17753 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
17754 sleep $((expired + 3))
17756 b_status=$(barrier_stat)
17757 [ "$b_status" = "'expired'" ] ||
17758 error "(3) unexpected barrier status $b_status"
17760 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
17761 error "(4) fail to freeze barrier"
17763 b_status=$(barrier_stat)
17764 [ "$b_status" = "'frozen'" ] ||
17765 error "(5) unexpected barrier status $b_status"
17767 echo "Start barrier_thaw at: $(date)"
17768 #define OBD_FAIL_BARRIER_DELAY 0x2202
17769 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17770 do_facet mgs $LCTL barrier_thaw $FSNAME &
17773 b_status=$(barrier_stat)
17774 echo "Got barrier status at: $(date)"
17775 [ "$b_status" = "'thawing'" ] ||
17776 error "(6) unexpected barrier status $b_status"
17778 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17780 b_status=$(barrier_stat)
17781 [ "$b_status" = "'thawed'" ] ||
17782 error "(7) unexpected barrier status $b_status"
17784 #define OBD_FAIL_BARRIER_FAILURE 0x2203
17785 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
17786 do_facet mgs $LCTL barrier_freeze $FSNAME
17788 b_status=$(barrier_stat)
17789 [ "$b_status" = "'failed'" ] ||
17790 error "(8) unexpected barrier status $b_status"
17792 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17793 do_facet mgs $LCTL barrier_thaw $FSNAME
17797 run_test 801a "write barrier user interfaces and stat machine"
17802 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17803 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17804 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17805 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17806 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
17808 cancel_lru_locks mdc
17810 # 180 seconds should be long enough
17811 do_facet mgs $LCTL barrier_freeze $FSNAME 180
17813 local b_status=$(barrier_stat)
17814 [ "$b_status" = "'frozen'" ] ||
17815 error "(6) unexpected barrier status $b_status"
17817 mkdir $DIR/$tdir/d0/d10 &
17820 touch $DIR/$tdir/d1/f13 &
17823 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
17826 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
17829 rm -f $DIR/$tdir/d4/f12 &
17832 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
17834 # To guarantee taht the 'stat' is not blocked
17835 b_status=$(barrier_stat)
17836 [ "$b_status" = "'frozen'" ] ||
17837 error "(8) unexpected barrier status $b_status"
17839 # let above commands to run at background
17842 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
17843 ps -p $touch_pid || error "(10) touch should be blocked"
17844 ps -p $ln_pid || error "(11) link should be blocked"
17845 ps -p $mv_pid || error "(12) rename should be blocked"
17846 ps -p $rm_pid || error "(13) unlink should be blocked"
17848 b_status=$(barrier_stat)
17849 [ "$b_status" = "'frozen'" ] ||
17850 error "(14) unexpected barrier status $b_status"
17852 do_facet mgs $LCTL barrier_thaw $FSNAME
17853 b_status=$(barrier_stat)
17854 [ "$b_status" = "'thawed'" ] ||
17855 error "(15) unexpected barrier status $b_status"
17857 wait $mkdir_pid || error "(16) mkdir should succeed"
17858 wait $touch_pid || error "(17) touch should succeed"
17859 wait $ln_pid || error "(18) link should succeed"
17860 wait $mv_pid || error "(19) rename should succeed"
17861 wait $rm_pid || error "(20) unlink should succeed"
17865 run_test 801b "modification will be blocked by write barrier"
17868 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17872 stop mds2 || error "(1) Fail to stop mds2"
17874 do_facet mgs $LCTL barrier_freeze $FSNAME 30
17876 local b_status=$(barrier_stat)
17877 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17878 do_facet mgs $LCTL barrier_thaw $FSNAME
17879 error "(2) unexpected barrier status $b_status"
17882 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17883 error "(3) Fail to rescan barrier bitmap"
17885 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17887 b_status=$(barrier_stat)
17888 [ "$b_status" = "'frozen'" ] ||
17889 error "(4) unexpected barrier status $b_status"
17891 do_facet mgs $LCTL barrier_thaw $FSNAME
17892 b_status=$(barrier_stat)
17893 [ "$b_status" = "'thawed'" ] ||
17894 error "(5) unexpected barrier status $b_status"
17896 local devname=$(mdsdevname 2)
17898 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17900 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17901 error "(7) Fail to rescan barrier bitmap"
17905 run_test 801c "rescan barrier bitmap"
17907 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17908 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17909 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17915 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17916 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17917 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17923 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17924 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17925 skip "Need server version at least 2.9.55" & exit 0
17927 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17929 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17930 error "(2) Fail to copy"
17932 trap cleanup_802 EXIT
17934 # sync by force before remount as readonly
17935 sync; sync_all_data; sleep 3; sync_all_data
17939 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17940 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17941 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17943 echo "Mount the server as read only"
17944 setupall server_only || error "(3) Fail to start servers"
17946 echo "Mount client without ro should fail"
17947 mount_client $MOUNT &&
17948 error "(4) Mount client without 'ro' should fail"
17950 echo "Mount client with ro should succeed"
17951 mount_client $MOUNT ro ||
17952 error "(5) Mount client with 'ro' should succeed"
17954 echo "Modify should be refused"
17955 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17957 echo "Read should be allowed"
17958 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17959 error "(7) Read should succeed under ro mode"
17963 run_test 802 "simulate readonly device"
17966 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17967 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17968 skip "MDS needs to be newer than 2.10.54" && return
17970 mkdir -p $DIR/$tdir
17971 # Create some objects on all MDTs to trigger related logs objects
17972 for idx in $(seq $MDSCOUNT); do
17973 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
17974 $DIR/$tdir/dir${idx} ||
17975 error "Fail to create $DIR/$tdir/dir${idx}"
17979 echo "before create:"
17981 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17983 for ((i=0; i<10; i++)); do
17984 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
17985 error "Fail to create $DIR/$tdir/foo$i"
17989 echo "after create:"
17991 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17993 [ $after_used -ge $((before_used + 10)) ] ||
17994 error "before ($before_used) + 10 > after ($after_used)"
17996 for ((i=0; i<10; i++)); do
17997 rm -rf $DIR/$tdir/foo$i ||
17998 error "Fail to remove $DIR/$tdir/foo$i"
18001 wait_delete_completed
18002 echo "after unlink:"
18004 before_used=$after_used
18005 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18007 [ $after_used -le $((before_used - 8)) ] ||
18008 error "before ($before_used) - 8 < after ($after_used)"
18010 run_test 803 "verify agent object for remote object"
18013 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
18014 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18015 skip "MDS needs to be newer than 2.10.54" && return
18017 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
18018 skip "ldiskfs only test" && return 0
18020 mkdir -p $DIR/$tdir
18021 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
18022 error "Fail to create $DIR/$tdir/dir0"
18024 local fid=$($LFS path2fid $DIR/$tdir/dir0)
18025 local dev=$(mdsdevname 2)
18027 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18028 grep ${fid} || error "NOT found agent entry for dir0"
18030 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
18031 error "Fail to create $DIR/$tdir/dir1"
18033 touch $DIR/$tdir/dir1/foo0 ||
18034 error "Fail to create $DIR/$tdir/dir1/foo0"
18035 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
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
18045 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
18046 error "Fail to rename foo0 to foo1"
18047 if [ $rc -eq 0 ]; then
18048 for idx in $(seq $MDSCOUNT); do
18049 dev=$(mdsdevname $idx)
18050 do_facet mds${idx} \
18051 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18052 grep ${fid} && rc=$idx
18056 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
18057 error "Fail to rename foo1 to foo2"
18058 if [ $rc -eq 0 ]; then
18059 for idx in $(seq $MDSCOUNT); do
18060 dev=$(mdsdevname $idx)
18061 do_facet mds${idx} \
18062 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18063 grep ${fid} && rc=$idx
18067 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
18069 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
18070 error "Fail to link to $DIR/$tdir/dir1/foo2"
18071 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
18072 error "Fail to rename foo2 to foo0"
18073 unlink $DIR/$tdir/dir1/foo0 ||
18074 error "Fail to unlink $DIR/$tdir/dir1/foo0"
18075 rm -rf $DIR/$tdir/dir0 ||
18076 error "Fail to rm $DIR/$tdir/dir0"
18078 for idx in $(seq $MDSCOUNT); do
18079 dev=$(mdsdevname $idx)
18083 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
18085 start mds${idx} $dev $MDS_MOUNT_OPTS ||
18086 error "mount mds$idx failed"
18087 df $MOUNT > /dev/null 2>&1
18089 # e2fsck should not return error
18091 error "e2fsck detected error on MDT${idx}: rc=$rc"
18094 run_test 804 "verify agent entry for remote entry"
18097 # tests that do cleanup/setup should be run at the end
18101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18103 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
18104 $LCTL set_param fail_loc=0x903
18106 cancel_lru_locks MGC
18108 FAIL_ON_ERROR=true cleanup
18109 FAIL_ON_ERROR=true setup
18111 run_test 900 "umount should not race with any mgc requeue thread"
18114 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
18115 check_and_cleanup_lustre
18116 if [ "$I_MOUNTED" != "yes" ]; then
18117 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true