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 LU-11058
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c 77k"
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 distro version
74 # Returns a version string that should only be used in comparing
75 # strings returned by version_code()
78 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
80 # All SuSE Linux versions have one decimal. version_code expects two
81 local sles_version=$version.0
82 version_code $sles_version
85 # Check if we are running on Ubuntu or SLES so we can make decisions on
87 if [ -r /etc/SuSE-release ]; then
88 sles_version=$(sles_version_code)
89 [ $sles_version -lt $(version_code 11.4.0) ] &&
90 # bug number for skipped test: LU-4341
91 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
92 [ $sles_version -lt $(version_code 12.0.0) ] &&
93 # bug number for skipped test: LU-3703
94 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
95 elif [ -r /etc/os-release ]; then
96 if grep -qi ubuntu /etc/os-release; then
97 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
102 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
103 # bug number for skipped test:
104 # LU-10334 LU-10335 LU-10335 LU-10335
105 ALWAYS_EXCEPT+=" 103a 130a 130b 130c"
106 # LU-10335 LU-10335 LU-10365 LU-10366
107 ALWAYS_EXCEPT+=" 130d 130e 400a 410"
116 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
117 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
126 check_swap_layouts_support()
128 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
129 skip "Does not support layout lock."
132 check_and_setup_lustre
136 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
138 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
139 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
140 rm -rf $DIR/[Rdfs][0-9]*
142 # $RUNAS_ID may get set incorrectly somewhere else
143 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
145 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
149 if [ "${ONLY}" = "MOUNT" ] ; then
150 echo "Lustre is up, please go on"
154 echo "preparing for tests involving mounts"
155 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
157 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
158 echo # add a newline after mke2fs.
162 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
163 lctl set_param debug=-1 2> /dev/null || true
166 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
168 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
170 run_test 0a "touch; rm ====================="
173 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
174 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
176 run_test 0b "chmod 0755 $DIR ============================="
179 $LCTL get_param mdc.*.import | grep "state: FULL" ||
180 error "import not FULL"
181 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
184 run_test 0c "check import proc"
186 test_0d() { # LU-3397
187 [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
188 skip "proc exports not supported before 2.10.57"
190 local mgs_exp="mgs.MGS.exports"
191 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
193 local exp_client_version
196 local temp_imp=$DIR/$tfile.import
197 local temp_exp=$DIR/$tfile.export
199 # save mgc import file to $temp_imp
200 $LCTL get_param mgc.*.import | tee $temp_imp
201 # Check if client uuid is found in MGS export
202 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
203 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
207 # save mgs export file to $temp_exp
208 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
210 # Compare the value of field "connect_flags"
211 imp_val=$(grep "connect_flags" $temp_imp)
212 exp_val=$(grep "connect_flags" $temp_exp)
213 [ "$exp_val" == "$imp_val" ] ||
214 error "export flags '$exp_val' != import flags '$imp_val'"
216 # Compare the value of client version
217 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
218 exp_val=$(version_code $exp_client_version)
219 imp_val=$(lustre_version_code client)
220 [ "$exp_val" == "$imp_val" ] ||
221 error "export client version '$exp_val' != '$imp_val'"
223 run_test 0d "check export proc ============================="
226 test_mkdir $DIR/$tdir
227 test_mkdir $DIR/$tdir/d2
228 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
229 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
232 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
234 run_test 1 "mkdir; remkdir; rmdir"
237 test_mkdir $DIR/$tdir
238 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
239 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
241 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
243 run_test 2 "mkdir; touch; rmdir; check file"
246 test_mkdir $DIR/$tdir
247 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
248 touch $DIR/$tdir/$tfile
249 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
251 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
253 run_test 3 "mkdir; touch; rmdir; check dir"
255 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
257 test_mkdir -i 1 $DIR/$tdir
259 touch $DIR/$tdir/$tfile ||
260 error "Create file under remote directory failed"
263 error "Expect error removing in-use dir $DIR/$tdir"
265 test -d $DIR/$tdir || error "Remote directory disappeared"
267 rm -rf $DIR/$tdir || error "remove remote dir error"
269 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
272 test_mkdir $DIR/$tdir
273 test_mkdir $DIR/$tdir/d2
274 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
275 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
276 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
278 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
281 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
282 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
283 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
284 error "$tfile does not have perm 0666 or UID $UID"
285 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
286 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
287 error "$tfile should be 0666 and owned by UID $UID"
289 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
292 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
295 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
296 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
297 error "$tfile should be owned by UID $RUNAS_ID"
298 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
299 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
300 error "$tfile should be owned by UID $RUNAS_ID"
302 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
305 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
308 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
309 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
310 error "$tfile should be owned by GID $UID"
311 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
312 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
313 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
315 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
318 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
320 test_mkdir $DIR/$tdir
321 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
322 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
323 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
324 test_mkdir $DIR/$tdir/d/subdir
325 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
326 error "$tdir/d/subdir should be GID $RUNAS_GID"
327 if [[ $MDSCOUNT -gt 1 ]]; then
328 # check remote dir sgid inherite
329 $LFS mkdir -i 0 $DIR/$tdir.local ||
330 error "mkdir $tdir.local failed"
331 chmod g+s $DIR/$tdir.local ||
332 error "chmod $tdir.local failed"
333 chgrp $RUNAS_GID $DIR/$tdir.local ||
334 error "chgrp $tdir.local failed"
335 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
336 error "mkdir $tdir.remote failed"
337 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
338 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
339 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
340 error "$tdir.remote should be mode 02755"
343 run_test 6g "verify new dir in sgid dir inherits group"
345 test_6h() { # bug 7331
346 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
348 touch $DIR/$tfile || error "touch failed"
349 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
350 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
351 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
352 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
353 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
355 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
358 test_mkdir $DIR/$tdir
359 $MCREATE $DIR/$tdir/$tfile
360 chmod 0666 $DIR/$tdir/$tfile
361 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
362 error "$tdir/$tfile should be mode 0666"
364 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
367 if [ ! -d $DIR/$tdir ]; then
368 test_mkdir $DIR/$tdir
370 $MCREATE $DIR/$tdir/$tfile
371 echo -n foo > $DIR/$tdir/$tfile
372 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
373 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
375 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
378 test_mkdir $DIR/$tdir
379 touch $DIR/$tdir/$tfile
380 chmod 0666 $DIR/$tdir/$tfile
381 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
382 error "$tfile mode not 0666"
384 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
387 test_mkdir $DIR/$tdir
388 test_mkdir $DIR/$tdir/d2
389 test_mkdir $DIR/$tdir/d2/d3
390 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
392 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
395 test_mkdir $DIR/$tdir
396 test_mkdir $DIR/$tdir/d2
397 touch $DIR/$tdir/d2/$tfile
398 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
399 error "$tdir/d2/$tfile not a file"
401 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
404 test_mkdir $DIR/$tdir
405 test_mkdir $DIR/$tdir/d2
406 chmod 0666 $DIR/$tdir/d2
407 chmod 0705 $DIR/$tdir/d2
408 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
409 error "$tdir/d2 mode not 0705"
411 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
414 test_mkdir $DIR/$tdir
415 touch $DIR/$tdir/$tfile
416 chmod 0666 $DIR/$tdir/$tfile
417 chmod 0654 $DIR/$tdir/$tfile
418 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
419 error "$tdir/d2 mode not 0654"
421 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
424 test_mkdir $DIR/$tdir
425 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
427 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
428 error "$tdir/$tfile size not 0 after truncate"
430 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
433 test_mkdir $DIR/$tdir
434 touch $DIR/$tdir/$tfile
436 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
438 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
441 test_mkdir $DIR/$tdir
442 touch $DIR/$tdir/$tfile
443 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
444 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
445 error "$tdir/${tfile_2} not a file after rename"
446 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
448 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
451 test_mkdir $DIR/$tdir
452 touch $DIR/$tdir/$tfile
453 rm -rf $DIR/$tdir/$tfile
454 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
456 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
459 test_mkdir $DIR/$tdir
460 touch $DIR/$tdir/$tfile
461 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
463 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
464 error "$tdir/l-exist not a symlink"
465 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
466 error "$tdir/l-exist not referencing a file"
467 rm -f $DIR/$tdir/l-exist
468 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
470 run_test 17a "symlinks: create, remove (real)"
473 test_mkdir $DIR/$tdir
474 ln -s no-such-file $DIR/$tdir/l-dangle
476 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
477 error "$tdir/l-dangle not referencing no-such-file"
478 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
479 error "$tdir/l-dangle not referencing non-existent file"
480 rm -f $DIR/$tdir/l-dangle
481 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
483 run_test 17b "symlinks: create, remove (dangling)"
485 test_17c() { # bug 3440 - don't save failed open RPC for replay
486 test_mkdir $DIR/$tdir
487 ln -s foo $DIR/$tdir/$tfile
488 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
490 run_test 17c "symlinks: open dangling (should return error)"
493 test_mkdir $DIR/$tdir
494 ln -s foo $DIR/$tdir/$tfile
495 touch $DIR/$tdir/$tfile || error "creating to new symlink"
497 run_test 17d "symlinks: create dangling"
500 test_mkdir $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
502 ln -s $foo $foo || error "create symlink failed"
503 ls -l $foo || error "ls -l failed"
504 ls $foo && error "ls not failed" || true
506 run_test 17e "symlinks: create recursive symlink (should return error)"
509 test_mkdir $DIR/$tdir
510 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
511 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
512 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
513 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
514 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
515 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
518 run_test 17f "symlinks: long and very long symlink name"
520 # str_repeat(S, N) generate a string that is string S repeated N times
525 while [ $((n -= 1)) -ge 0 ]; do
531 # Long symlinks and LU-2241
533 test_mkdir $DIR/$tdir
534 local TESTS="59 60 61 4094 4095"
536 # Fix for inode size boundary in 2.1.4
537 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
540 # Patch not applied to 2.2 or 2.3 branches
541 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
542 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
545 # skip long symlink name for rhel6.5.
546 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
547 grep -q '6.5' /etc/redhat-release &>/dev/null &&
548 TESTS="59 60 61 4062 4063"
551 local SYMNAME=$(str_repeat 'x' $i)
552 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
553 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
556 run_test 17g "symlinks: really long symlink name and inode boundaries"
558 test_17h() { #bug 17378
559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
560 remote_mds_nodsh && skip "remote MDS with nodsh"
564 test_mkdir $DIR/$tdir
565 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
566 $LFS setstripe -c -1 $DIR/$tdir
567 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
568 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
569 touch $DIR/$tdir/$tfile || true
571 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
573 test_17i() { #bug 20018
574 [ $PARALLEL == "yes" ] && skip "skip parallel run"
575 remote_mds_nodsh && skip "remote MDS with nodsh"
577 local foo=$DIR/$tdir/$tfile
580 test_mkdir -c1 $DIR/$tdir
581 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
582 ln -s $foo $foo || error "create symlink failed"
583 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
584 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
585 ls -l $foo && error "error not detected"
588 run_test 17i "don't panic on short symlink (should return error)"
590 test_17k() { #bug 22301
591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
592 [[ -z "$(which rsync 2>/dev/null)" ]] &&
593 skip "no rsync command"
594 rsync --help | grep -q xattr ||
595 skip_env "$(rsync --version | head -n1) does not support xattrs"
596 test_mkdir $DIR/$tdir
597 test_mkdir $DIR/$tdir.new
598 touch $DIR/$tdir/$tfile
599 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
600 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
601 error "rsync failed with xattrs enabled"
603 run_test 17k "symlinks: rsync with xattrs enabled"
605 test_17l() { # LU-279
606 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
607 skip "no getfattr command"
609 test_mkdir $DIR/$tdir
610 touch $DIR/$tdir/$tfile
611 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
612 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
613 # -h to not follow symlinks. -m '' to list all the xattrs.
614 # grep to remove first line: '# file: $path'.
615 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
617 lgetxattr_size_check $path $xattr ||
618 error "lgetxattr_size_check $path $xattr failed"
622 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
627 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
628 skip_env "ldiskfs only test"
629 remote_mds_nodsh && skip "remote MDS with nodsh"
630 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
631 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
632 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
634 local short_sym="0123456789"
635 local wdir=$DIR/$tdir
640 # create a long symlink file
641 for ((i = 0; i < 4; ++i)); do
642 long_sym=${long_sym}${long_sym}
645 echo "create 512 short and long symlink files under $wdir"
646 for ((i = 0; i < 256; ++i)); do
647 ln -sf ${long_sym}"a5a5" $wdir/long-$i
648 ln -sf ${short_sym}"a5a5" $wdir/short-$i
654 wait_delete_completed
656 echo "recreate the 512 symlink files with a shorter string"
657 for ((i = 0; i < 512; ++i)); do
658 # rewrite the symlink file with a shorter string
659 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
660 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
663 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
664 local devname=$(mdsdevname $mds_index)
666 echo "stop and checking mds${mds_index}:"
667 # e2fsck should not return error
669 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
672 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
673 error "start mds${mds_index} failed"
674 df $MOUNT > /dev/null 2>&1
676 error "e2fsck detected error for short/long symlink: rc=$rc"
679 run_test 17m "run e2fsck against MDT which contains short/long symlink"
681 check_fs_consistency_17n() {
685 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
686 # so it only check MDT1/MDT2 instead of all of MDTs.
687 for mdt_index in 1 2; do
688 local devname=$(mdsdevname $mdt_index)
689 # e2fsck should not return error
691 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
694 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
695 error "mount mds$mdt_index failed"
696 df $MOUNT > /dev/null 2>&1
702 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
704 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
705 skip_env "ldiskfs only test"
706 remote_mds_nodsh && skip "remote MDS with nodsh"
707 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
708 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
709 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
713 test_mkdir $DIR/$tdir
714 for ((i=0; i<10; i++)); do
715 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
716 error "create remote dir error $i"
717 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
718 error "create files under remote dir failed $i"
721 check_fs_consistency_17n ||
722 error "e2fsck report error after create files under remote dir"
724 for ((i = 0; i < 10; i++)); do
725 rm -rf $DIR/$tdir/remote_dir_${i} ||
726 error "destroy remote dir error $i"
729 check_fs_consistency_17n ||
730 error "e2fsck report error after unlink files under remote dir"
732 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
733 skip "lustre < 2.4.50 does not support migrate mv"
735 for ((i = 0; i < 10; i++)); do
736 mkdir -p $DIR/$tdir/remote_dir_${i}
737 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
738 error "create files under remote dir failed $i"
739 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
740 error "migrate remote dir error $i"
742 check_fs_consistency_17n || error "e2fsck report error after migration"
744 for ((i = 0; i < 10; i++)); do
745 rm -rf $DIR/$tdir/remote_dir_${i} ||
746 error "destroy remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after unlink"
751 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
754 remote_mds_nodsh && skip "remote MDS with nodsh"
755 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
756 skip "Need MDS version at least 2.3.64"
758 local wdir=$DIR/${tdir}o
764 mdt_index=$($LFS getstripe -m $wdir/$tfile)
765 mdt_index=$((mdt_index + 1))
768 #fail mds will wait the failover finish then set
769 #following fail_loc to avoid interfer the recovery process.
772 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
773 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
774 ls -l $wdir/$tfile && rc=1
775 do_facet mds${mdt_index} lctl set_param fail_loc=0
776 [[ $rc -eq 0 ]] || error "stat file should fail"
778 run_test 17o "stat file with incompat LMA feature"
781 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
782 ls $DIR || error "Failed to ls $DIR: $?"
784 run_test 18 "touch .../f ; ls ... =============================="
790 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
792 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
795 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
797 run_test 19b "ls -l .../f19 (should return error) =============="
800 [ $RUNAS_ID -eq $UID ] &&
801 skip_env "RUNAS_ID = UID = $UID -- skipping"
803 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
805 run_test 19c "$RUNAS touch .../f19 (should return error) =="
808 cat $DIR/f19 && error || true
810 run_test 19d "cat .../f19 (should return error) =============="
819 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
821 run_test 20 "touch .../f ; ls -l ..."
824 test_mkdir $DIR/$tdir
825 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
826 ln -s dangle $DIR/$tdir/link
827 echo foo >> $DIR/$tdir/link
828 cat $DIR/$tdir/dangle
829 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
830 $CHECKSTAT -f -t file $DIR/$tdir/link ||
831 error "$tdir/link not linked to a file"
833 run_test 21 "write to dangling link"
836 local wdir=$DIR/$tdir
838 chown $RUNAS_ID:$RUNAS_GID $wdir
839 (cd $wdir || error "cd $wdir failed";
840 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
842 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
843 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
844 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
845 error "checkstat -u failed"
847 run_test 22 "unpack tar archive as non-root user"
851 test_mkdir $DIR/$tdir
852 local file=$DIR/$tdir/$tfile
854 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
855 openfile -f O_CREAT:O_EXCL $file &&
856 error "$file recreate succeeded" || true
858 run_test 23a "O_CREAT|O_EXCL in subdir"
860 test_23b() { # bug 18988
861 test_mkdir $DIR/$tdir
862 local file=$DIR/$tdir/$tfile
865 echo foo > $file || error "write filed"
866 echo bar >> $file || error "append filed"
867 $CHECKSTAT -s 8 $file || error "wrong size"
870 run_test 23b "O_APPEND check"
872 # LU-9409, size with O_APPEND and tiny writes
874 local file=$DIR/$tfile
877 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
878 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
882 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
883 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
885 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
888 #racing tiny & normal writes
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
892 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
895 #racing tiny & normal writes 2, ugly numbers
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
899 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
902 run_test 23c "O_APPEND size checks for tiny writes"
904 # LU-11069 file offset is correct after appending writes
906 local file=$DIR/$tfile
909 echo CentaurHauls > $file
910 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
911 if ((offset != 26)); then
912 error "wrong offset, expected 26, got '$offset'"
915 run_test 23d "file offset is correct after appending writes"
919 echo '-- same directory rename'
920 test_mkdir $DIR/$tdir
921 touch $DIR/$tdir/$tfile.1
922 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
923 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
925 run_test 24a "rename file to non-existent target"
928 test_mkdir $DIR/$tdir
929 touch $DIR/$tdir/$tfile.{1,2}
930 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
931 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
932 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
934 run_test 24b "rename file to existing target"
937 test_mkdir $DIR/$tdir
938 test_mkdir $DIR/$tdir/d$testnum.1
939 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
940 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
941 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
943 run_test 24c "rename directory to non-existent target"
946 test_mkdir -c1 $DIR/$tdir
947 test_mkdir -c1 $DIR/$tdir/d$testnum.1
948 test_mkdir -c1 $DIR/$tdir/d$testnum.2
949 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
950 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
951 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
953 run_test 24d "rename directory to existing target"
956 echo '-- cross directory renames --'
960 mv $DIR/R5a/f $DIR/R5b/g
961 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
962 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
964 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
969 touch $DIR/R6a/f $DIR/R6b/g
970 mv $DIR/R6a/f $DIR/R6b/g
971 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
972 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
974 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
979 test_mkdir $DIR/R7a/d
980 mv $DIR/R7a/d $DIR/R7b/e
981 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
982 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
984 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
987 test_mkdir -c1 $DIR/R8a
988 test_mkdir -c1 $DIR/R8b
989 test_mkdir -c1 $DIR/R8a/d
990 test_mkdir -c1 $DIR/R8b/e
991 mrename $DIR/R8a/d $DIR/R8b/e
992 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
993 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
995 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
998 echo "-- rename error cases"
1000 test_mkdir $DIR/R9/a
1002 mrename $DIR/R9/f $DIR/R9/a
1003 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1004 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1005 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1007 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1011 mrename $DIR/R10/f $DIR/R10/g
1012 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1013 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1014 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1016 run_test 24j "source does not exist ============================"
1019 test_mkdir $DIR/R11a
1020 test_mkdir $DIR/R11a/d
1022 mv $DIR/R11a/f $DIR/R11a/d
1023 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1024 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1026 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1028 # bug 2429 - rename foo foo foo creates invalid file
1031 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1033 run_test 24l "Renaming a file to itself ========================"
1037 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1038 # on ext3 this does not remove either the source or target files
1039 # though the "expected" operation would be to remove the source
1040 $CHECKSTAT -t file ${f} || error "${f} missing"
1041 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1043 run_test 24m "Renaming a file to a hard link to itself ========="
1047 # this stats the old file after it was renamed, so it should fail
1049 $CHECKSTAT ${f} || error "${f} missing"
1051 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1052 $CHECKSTAT -a ${f} || error "${f} exists"
1054 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1057 test_mkdir $DIR/$tdir
1058 rename_many -s random -v -n 10 $DIR/$tdir
1060 run_test 24o "rename of files during htree split"
1063 test_mkdir $DIR/R12a
1064 test_mkdir $DIR/R12b
1065 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1066 mrename $DIR/R12a $DIR/R12b
1067 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1068 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1069 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1070 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1072 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1074 cleanup_multiop_pause() {
1076 kill -USR1 $MULTIPID
1080 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1082 test_mkdir $DIR/R13a
1083 test_mkdir $DIR/R13b
1084 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1085 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1088 trap cleanup_multiop_pause EXIT
1089 mrename $DIR/R13a $DIR/R13b
1090 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1091 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1092 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1093 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1094 cleanup_multiop_pause
1095 wait $MULTIPID || error "multiop close failed"
1097 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1099 test_24r() { #bug 3789
1100 test_mkdir $DIR/R14a
1101 test_mkdir $DIR/R14a/b
1102 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1103 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1104 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1106 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1109 test_mkdir $DIR/R15a
1110 test_mkdir $DIR/R15a/b
1111 test_mkdir $DIR/R15a/b/c
1112 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1113 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1114 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1116 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1118 test_mkdir $DIR/R16a
1119 test_mkdir $DIR/R16a/b
1120 test_mkdir $DIR/R16a/b/c
1121 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1122 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1123 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1125 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1127 test_24u() { # bug12192
1128 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1129 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1131 run_test 24u "create stripe file"
1135 size=$(getconf PAGE_SIZE 2>/dev/null)
1136 echo -n ${size:-4096}
1139 simple_cleanup_common() {
1142 [ -z "$DIR" -o -z "$tdir" ] && return 0
1144 local start=$SECONDS
1147 wait_delete_completed
1148 echo "cleanup time $((SECONDS - start))"
1152 max_pages_per_rpc() {
1153 local mdtname="$(printf "MDT%04x" ${1:-0})"
1154 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1158 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1160 local nrfiles=${COUNT:-100000}
1161 local fname="$DIR/$tdir/$tfile"
1163 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1164 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1166 test_mkdir "$(dirname $fname)"
1167 # assume MDT0000 has the fewest inodes
1168 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1169 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1170 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1172 trap simple_cleanup_common EXIT
1174 createmany -m "$fname" $nrfiles
1176 cancel_lru_locks mdc
1177 lctl set_param mdc.*.stats clear
1179 # was previously test_24D: LU-6101
1180 # readdir() returns correct number of entries after cursor reload
1181 local num_ls=$(ls $DIR/$tdir | wc -l)
1182 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1183 local num_all=$(ls -a $DIR/$tdir | wc -l)
1184 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1185 $num_all -ne $((nrfiles + 2)) ]; then
1186 error "Expected $nrfiles files, got $num_ls " \
1187 "($num_uniq unique $num_all .&..)"
1189 # LU-5 large readdir
1190 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1191 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1192 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1193 # take into account of overhead in lu_dirpage header and end mark in
1194 # each page, plus one in rpc_num calculation.
1195 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1196 local page_entries=$((($(page_size) - 24) / dirent_size))
1197 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1198 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1199 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1200 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1201 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1202 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1203 error "large readdir doesn't take effect: " \
1204 "$mds_readpage should be about $rpc_max"
1206 simple_cleanup_common
1208 run_test 24v "list large directory (test hash collision, b=17560)"
1210 test_24w() { # bug21506
1212 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1213 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1214 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1215 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1216 [[ "$SZ1" -eq "$SZ2" ]] ||
1217 error "Error reading at the end of the file $tfile"
1219 run_test 24w "Reading a file larger than 4Gb"
1222 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1223 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1224 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1225 skip "Need MDS version at least 2.7.56"
1228 local remote_dir=$DIR/$tdir/remote_dir
1230 test_mkdir $DIR/$tdir
1231 $LFS mkdir -i $MDTIDX $remote_dir ||
1232 error "create remote directory failed"
1234 test_mkdir $DIR/$tdir/src_dir
1235 touch $DIR/$tdir/src_file
1236 test_mkdir $remote_dir/tgt_dir
1237 touch $remote_dir/tgt_file
1239 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1240 error "rename dir cross MDT failed!"
1242 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1243 error "rename file cross MDT failed!"
1245 touch $DIR/$tdir/ln_file
1246 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1247 error "ln file cross MDT failed"
1249 rm -rf $DIR/$tdir || error "Can not delete directories"
1251 run_test 24x "cross MDT rename/link"
1254 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1257 local remote_dir=$DIR/$tdir/remote_dir
1260 test_mkdir $DIR/$tdir
1261 $LFS mkdir -i $mdtidx $remote_dir ||
1262 error "create remote directory failed"
1264 test_mkdir $remote_dir/src_dir
1265 touch $remote_dir/src_file
1266 test_mkdir $remote_dir/tgt_dir
1267 touch $remote_dir/tgt_file
1269 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1270 error "rename subdir in the same remote dir failed!"
1272 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1273 error "rename files in the same remote dir failed!"
1275 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1276 error "link files in the same remote dir failed!"
1278 rm -rf $DIR/$tdir || error "Can not delete directories"
1280 run_test 24y "rename/link on the same dir should succeed"
1282 test_24A() { # LU-3182
1286 test_mkdir $DIR/$tdir
1287 trap simple_cleanup_common EXIT
1288 createmany -m $DIR/$tdir/$tfile $NFILES
1289 local t=$(ls $DIR/$tdir | wc -l)
1290 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1291 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1292 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1293 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1296 simple_cleanup_common || error "Can not delete directories"
1298 run_test 24A "readdir() returns correct number of entries."
1300 test_24B() { # LU-4805
1301 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1305 test_mkdir $DIR/$tdir
1306 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1307 error "create striped dir failed"
1309 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1310 [ $count -eq 2 ] || error "Expected 2, got $count"
1312 touch $DIR/$tdir/striped_dir/a
1314 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1315 [ $count -eq 3 ] || error "Expected 3, got $count"
1317 touch $DIR/$tdir/striped_dir/.f
1319 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1320 [ $count -eq 4 ] || error "Expected 4, got $count"
1322 rm -rf $DIR/$tdir || error "Can not delete directories"
1324 run_test 24B "readdir for striped dir return correct number of entries"
1327 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1333 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1334 error "create striped dir failed"
1336 cd $DIR/$tdir/d0/striped_dir
1338 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1339 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1340 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1342 [ "$d0_ino" = "$parent_ino" ] ||
1343 error ".. wrong, expect $d0_ino, get $parent_ino"
1345 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1346 error "mv striped dir failed"
1348 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1350 [ "$d1_ino" = "$parent_ino" ] ||
1351 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1353 run_test 24C "check .. in striped dir"
1356 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1360 mkdir $DIR/$tdir/src_dir
1361 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1362 error "create remote source failed"
1364 touch $DIR/$tdir/src_dir/src_child/a
1366 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1367 error "create remote target dir failed"
1369 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1370 error "create remote target child failed"
1372 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1373 error "rename dir cross MDT failed!"
1377 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1378 error "src_child still exists after rename"
1380 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1381 error "missing file(a) after rename"
1383 rm -rf $DIR/$tdir || error "Can not delete directories"
1385 run_test 24E "cross MDT rename/link"
1388 echo '== symlink sanity ============================================='
1392 touch $DIR/s25/foo ||
1393 error "File creation in symlinked directory failed"
1395 run_test 25a "create file in symlinked directory ==============="
1398 [ ! -d $DIR/d25 ] && test_25a
1399 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1401 run_test 25b "lookup file in symlinked directory ==============="
1405 test_mkdir $DIR/d26/d26-2
1406 ln -s d26/d26-2 $DIR/s26
1407 touch $DIR/s26/foo || error "File creation failed"
1409 run_test 26a "multiple component symlink ======================="
1412 test_mkdir -p $DIR/$tdir/d26-2
1413 ln -s $tdir/d26-2/foo $DIR/s26-2
1414 touch $DIR/s26-2 || error "File creation failed"
1416 run_test 26b "multiple component symlink at end of lookup ======"
1419 test_mkdir $DIR/d26.2
1420 touch $DIR/d26.2/foo
1421 ln -s d26.2 $DIR/s26.2-1
1422 ln -s s26.2-1 $DIR/s26.2-2
1423 ln -s s26.2-2 $DIR/s26.2-3
1424 chmod 0666 $DIR/s26.2-3/foo
1426 run_test 26c "chain of symlinks"
1428 # recursive symlinks (bug 439)
1430 ln -s d26-3/foo $DIR/d26-3
1432 run_test 26d "create multiple component recursive symlink"
1435 [ ! -h $DIR/d26-3 ] && test_26d
1438 run_test 26e "unlink multiple component recursive symlink"
1440 # recursive symlinks (bug 7022)
1442 test_mkdir $DIR/$tdir
1443 test_mkdir $DIR/$tdir/$tfile
1444 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1445 test_mkdir -p lndir/bar1
1446 test_mkdir $DIR/$tdir/$tfile/$tfile
1447 cd $tfile || error "cd $tfile failed"
1448 ln -s .. dotdot || error "ln dotdot failed"
1449 ln -s dotdot/lndir lndir || error "ln lndir failed"
1450 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1451 output=`ls $tfile/$tfile/lndir/bar1`
1452 [ "$output" = bar1 ] && error "unexpected output"
1453 rm -r $tfile || error "rm $tfile failed"
1454 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1456 run_test 26f "rm -r of a directory which has recursive symlink"
1459 test_mkdir $DIR/$tdir
1460 $LFS getstripe $DIR/$tdir
1461 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1462 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1463 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1465 run_test 27a "one stripe file"
1468 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1470 test_mkdir $DIR/$tdir
1471 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1472 $LFS getstripe -c $DIR/$tdir/$tfile
1473 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1474 error "two-stripe file doesn't have two stripes"
1476 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1478 run_test 27b "create and write to two stripe file"
1481 test_mkdir $DIR/$tdir
1482 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1483 error "setstripe failed"
1484 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1485 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1487 run_test 27d "create file with default settings"
1490 # LU-5839 adds check for existed layout before setting it
1491 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1492 skip "Need MDS version at least 2.7.56"
1494 test_mkdir $DIR/$tdir
1495 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1496 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1497 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1499 run_test 27e "setstripe existing file (should return error)"
1502 test_mkdir $DIR/$tdir
1503 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1504 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1505 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1506 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1507 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1508 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1510 run_test 27f "setstripe with bad stripe size (should return error)"
1513 test_mkdir $DIR/$tdir
1514 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1515 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1516 error "$DIR/$tdir/$tfile has object"
1518 run_test 27g "$LFS getstripe with no objects"
1521 test_mkdir $DIR/$tdir
1522 touch $DIR/$tdir/$tfile || error "touch failed"
1523 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1524 error "missing objects"
1526 run_test 27i "$LFS getstripe with some objects"
1529 test_mkdir $DIR/$tdir
1530 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1531 error "setstripe failed" || true
1533 run_test 27j "setstripe with bad stripe offset (should return error)"
1535 test_27k() { # bug 2844
1536 test_mkdir $DIR/$tdir
1537 local file=$DIR/$tdir/$tfile
1538 local ll_max_blksize=$((4 * 1024 * 1024))
1539 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1540 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1541 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1542 dd if=/dev/zero of=$file bs=4k count=1
1543 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1544 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1546 run_test 27k "limit i_blksize for broken user apps"
1549 mcreate $DIR/$tfile || error "creating file"
1550 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1551 error "setstripe should have failed" || true
1553 run_test 27l "check setstripe permissions (should return error)"
1556 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1558 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1560 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1561 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1563 trap simple_cleanup_common EXIT
1564 test_mkdir $DIR/$tdir
1565 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1566 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1567 error "dd should fill OST0"
1569 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1571 [ $i -gt 256 ] && break
1574 touch $DIR/$tdir/$tfile.$i
1575 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1576 awk '{print $1}'| grep -w "0") ] &&
1577 error "OST0 was full but new created file still use it"
1579 touch $DIR/$tdir/$tfile.$i
1580 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1581 awk '{print $1}'| grep -w "0") ] &&
1582 error "OST0 was full but new created file still use it"
1583 simple_cleanup_common
1585 run_test 27m "create file while OST0 was full"
1588 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1589 awk '{ print $1 * 2; exit; }')
1593 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1594 # if the OST isn't full anymore.
1596 local OSTIDX=${1:-""}
1598 local list=$(comma_list $(osts_nodes))
1599 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1601 do_nodes $list lctl set_param fail_loc=0
1602 sync # initiate all OST_DESTROYs from MDS to OST
1606 exhaust_precreations() {
1609 local FAILIDX=${3:-$OSTIDX}
1610 local ofacet=ost$((OSTIDX + 1))
1612 test_mkdir -p -c1 $DIR/$tdir
1613 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1614 local mfacet=mds$((mdtidx + 1))
1615 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1617 local OST=$(ostname_from_index $OSTIDX)
1620 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1621 local last_id=$(do_facet $mfacet lctl get_param -n \
1622 osc.$mdtosc_proc1.prealloc_last_id)
1623 local next_id=$(do_facet $mfacet lctl get_param -n \
1624 osc.$mdtosc_proc1.prealloc_next_id)
1626 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1627 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1629 test_mkdir -p $DIR/$tdir/${OST}
1630 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1631 #define OBD_FAIL_OST_ENOSPC 0x215
1632 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1633 echo "Creating to objid $last_id on ost $OST..."
1634 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1635 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1636 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1640 exhaust_all_precreations() {
1642 for (( i=0; i < OSTCOUNT; i++ )) ; do
1643 exhaust_precreations $i $1 -1
1648 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1650 remote_mds_nodsh && skip "remote MDS with nodsh"
1651 remote_ost_nodsh && skip "remote OST with nodsh"
1654 rm -f $DIR/$tdir/$tfile
1655 exhaust_precreations 0 0x80000215
1656 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1657 touch $DIR/$tdir/$tfile || error "touch failed"
1658 $LFS getstripe $DIR/$tdir/$tfile
1661 run_test 27n "create file with some full OSTs"
1664 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1665 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1666 remote_mds_nodsh && skip "remote MDS with nodsh"
1667 remote_ost_nodsh && skip "remote OST with nodsh"
1670 rm -f $DIR/$tdir/$tfile
1671 exhaust_all_precreations 0x215
1673 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1678 run_test 27o "create file with all full OSTs (should error)"
1681 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1683 remote_mds_nodsh && skip "remote MDS with nodsh"
1684 remote_ost_nodsh && skip "remote OST with nodsh"
1687 rm -f $DIR/$tdir/$tfile
1688 test_mkdir $DIR/$tdir
1690 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1691 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1692 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1694 exhaust_precreations 0 0x80000215
1695 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1696 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1697 $LFS getstripe $DIR/$tdir/$tfile
1701 run_test 27p "append to a truncated file with some full OSTs"
1704 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1706 remote_mds_nodsh && skip "remote MDS with nodsh"
1707 remote_ost_nodsh && skip "remote OST with nodsh"
1710 rm -f $DIR/$tdir/$tfile
1712 test_mkdir $DIR/$tdir
1713 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1714 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1715 error "truncate $DIR/$tdir/$tfile failed"
1716 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1718 exhaust_all_precreations 0x215
1720 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1721 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1725 run_test 27q "append to truncated file with all OSTs full (should error)"
1728 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1730 remote_mds_nodsh && skip "remote MDS with nodsh"
1731 remote_ost_nodsh && skip "remote OST with nodsh"
1734 rm -f $DIR/$tdir/$tfile
1735 exhaust_precreations 0 0x80000215
1737 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1741 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1743 test_27s() { # bug 10725
1744 test_mkdir $DIR/$tdir
1745 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1746 local stripe_count=0
1747 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1748 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1749 error "stripe width >= 2^32 succeeded" || true
1752 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1754 test_27t() { # bug 10864
1759 $WLFS getstripe $tfile
1762 run_test 27t "check that utils parse path correctly"
1764 test_27u() { # bug 4900
1765 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1766 remote_mds_nodsh && skip "remote MDS with nodsh"
1769 local list=$(comma_list $(mdts_nodes))
1771 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1772 do_nodes $list $LCTL set_param fail_loc=0x139
1773 test_mkdir -p $DIR/$tdir
1774 trap simple_cleanup_common EXIT
1775 createmany -o $DIR/$tdir/t- 1000
1776 do_nodes $list $LCTL set_param fail_loc=0
1778 TLOG=$TMP/$tfile.getstripe
1779 $LFS getstripe $DIR/$tdir > $TLOG
1780 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1781 unlinkmany $DIR/$tdir/t- 1000
1783 [[ $OBJS -gt 0 ]] &&
1784 error "$OBJS objects created on OST-0. See $TLOG" ||
1787 run_test 27u "skip object creation on OSC w/o objects"
1789 test_27v() { # bug 4900
1790 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1792 remote_mds_nodsh && skip "remote MDS with nodsh"
1793 remote_ost_nodsh && skip "remote OST with nodsh"
1795 exhaust_all_precreations 0x215
1798 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1800 touch $DIR/$tdir/$tfile
1801 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1803 for (( i=1; i < OSTCOUNT; i++ )); do
1804 do_facet ost$i lctl set_param fail_loc=0x705
1806 local START=`date +%s`
1807 createmany -o $DIR/$tdir/$tfile 32
1809 local FINISH=`date +%s`
1810 local TIMEOUT=`lctl get_param -n timeout`
1811 local PROCESS=$((FINISH - START))
1812 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1813 error "$FINISH - $START >= $TIMEOUT / 2"
1814 sleep $((TIMEOUT / 2 - PROCESS))
1817 run_test 27v "skip object creation on slow OST"
1819 test_27w() { # bug 10997
1820 test_mkdir $DIR/$tdir
1821 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1822 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1823 error "stripe size $size != 65536" || true
1824 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1825 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1827 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1830 [[ $OSTCOUNT -lt 2 ]] &&
1831 skip_env "skipping multiple stripe count/offset test"
1833 test_mkdir $DIR/$tdir
1834 for i in $(seq 1 $OSTCOUNT); do
1836 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1837 error "setstripe -c $i -i $offset failed"
1838 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1839 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1840 [ $count -ne $i ] && error "stripe count $count != $i" || true
1841 [ $index -ne $offset ] &&
1842 error "stripe offset $index != $offset" || true
1845 run_test 27wa "check $LFS setstripe -c -i options"
1848 remote_ost_nodsh && skip "remote OST with nodsh"
1849 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1850 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1852 OFFSET=$(($OSTCOUNT - 1))
1854 local OST=$(ostname_from_index $OSTIDX)
1856 test_mkdir $DIR/$tdir
1857 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1858 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1860 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1861 for i in $(seq 0 $OFFSET); do
1862 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1863 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1864 error "OST0 was degraded but new created file still use it"
1866 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1868 run_test 27x "create files while OST0 is degraded"
1871 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1872 remote_mds_nodsh && skip "remote MDS with nodsh"
1873 remote_ost_nodsh && skip "remote OST with nodsh"
1874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1876 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1877 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1878 osc.$mdtosc.prealloc_last_id)
1879 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1880 osc.$mdtosc.prealloc_next_id)
1881 local fcount=$((last_id - next_id))
1882 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1883 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1885 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1886 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1887 local OST_DEACTIVE_IDX=-1
1892 for OSC in $MDS_OSCS; do
1893 OST=$(osc_to_ost $OSC)
1894 OSTIDX=$(index_from_ostuuid $OST)
1895 if [ $OST_DEACTIVE_IDX == -1 ]; then
1896 OST_DEACTIVE_IDX=$OSTIDX
1898 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1899 echo $OSC "is Deactivated:"
1900 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1904 OSTIDX=$(index_from_ostuuid $OST)
1905 test_mkdir $DIR/$tdir
1906 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1908 for OSC in $MDS_OSCS; do
1909 OST=$(osc_to_ost $OSC)
1910 OSTIDX=$(index_from_ostuuid $OST)
1911 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1912 echo $OST "is degraded:"
1913 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1914 obdfilter.$OST.degraded=1
1919 createmany -o $DIR/$tdir/$tfile $fcount
1921 for OSC in $MDS_OSCS; do
1922 OST=$(osc_to_ost $OSC)
1923 OSTIDX=$(index_from_ostuuid $OST)
1924 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1925 echo $OST "is recovered from degraded:"
1926 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1927 obdfilter.$OST.degraded=0
1929 do_facet $SINGLEMDS lctl --device %$OSC activate
1933 # all osp devices get activated, hence -1 stripe count restored
1934 local stripe_count=0
1936 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1937 # devices get activated.
1939 $LFS setstripe -c -1 $DIR/$tfile
1940 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1942 [ $stripe_count -ne $OSTCOUNT ] &&
1943 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1946 run_test 27y "create files while OST0 is degraded and the rest inactive"
1952 lmm_count=$($GETSTRIPE -c $1)
1953 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1954 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1956 local old_ifs="$IFS"
1958 fid=($($LFS path2fid $1))
1961 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1962 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1964 # compare lmm_seq and lu_fid->f_seq
1965 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1966 # compare lmm_object_id and lu_fid->oid
1967 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1969 # check the trusted.fid attribute of the OST objects of the file
1970 local have_obdidx=false
1972 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1973 # skip lines up to and including "obdidx"
1974 [ -z "$obdidx" ] && break
1975 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1976 $have_obdidx || continue
1978 local ost=$((obdidx + 1))
1979 local dev=$(ostdevname $ost)
1982 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1984 seq=$(echo $seq | sed -e "s/^0x//g")
1985 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1986 oid_hex=$(echo $oid)
1988 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1990 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1994 # Don't unmount/remount the OSTs if we don't need to do that.
1995 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1996 # update too, until that use mount/ll_decode_filter_fid/mount.
1997 # Re-enable when debugfs will understand new filter_fid.
1999 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2000 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2001 $dev 2>/dev/null" | grep "parent=")
2003 if [ -z "$ff" ]; then
2005 mount_fstype ost$ost
2006 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2007 $(facet_mntpt ost$ost)/$obj_file)
2008 unmount_fstype ost$ost
2009 start ost$ost $dev $OST_MOUNT_OPTS
2013 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2015 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2017 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2018 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2020 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2021 # stripe_size=1048576 component_id=1 component_start=0 \
2022 # component_end=33554432
2023 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2024 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2025 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2027 if grep -q 'stripe=' <<<$ff; then
2028 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2030 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2031 # into f_ver in this case. See comment on ff_parent.
2032 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2035 # compare lmm_seq and filter_fid->ff_parent.f_seq
2036 [ $ff_pseq = $lmm_seq ] ||
2037 error "FF parent SEQ $ff_pseq != $lmm_seq"
2038 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2039 [ $ff_poid = $lmm_oid ] ||
2040 error "FF parent OID $ff_poid != $lmm_oid"
2041 (($ff_pstripe == $stripe_nr)) ||
2042 error "FF stripe $ff_pstripe != $stripe_nr"
2044 stripe_nr=$((stripe_nr + 1))
2045 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2047 if grep -q 'stripe_count=' <<<$ff; then
2048 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2049 -e 's/ .*//' <<<$ff)
2050 [ $lmm_count = $ff_scnt ] ||
2051 error "FF stripe count $lmm_count != $ff_scnt"
2057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2058 remote_ost_nodsh && skip "remote OST with nodsh"
2060 test_mkdir $DIR/$tdir
2061 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2062 { error "setstripe -c -1 failed"; return 1; }
2063 # We need to send a write to every object to get parent FID info set.
2064 # This _should_ also work for setattr, but does not currently.
2065 # touch $DIR/$tdir/$tfile-1 ||
2066 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2067 { error "dd $tfile-1 failed"; return 2; }
2068 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2069 { error "setstripe -c -1 failed"; return 3; }
2070 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2071 { error "dd $tfile-2 failed"; return 4; }
2073 # make sure write RPCs have been sent to OSTs
2076 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2077 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2079 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2081 test_27A() { # b=19102
2082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2084 save_layout_restore_at_exit $MOUNT
2085 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2086 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2087 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2088 local default_size=$($GETSTRIPE -S $MOUNT)
2089 local default_offset=$($GETSTRIPE -i $MOUNT)
2090 local dsize=$(do_facet $SINGLEMDS \
2091 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2092 [ $default_size -eq $dsize ] ||
2093 error "stripe size $default_size != $dsize"
2094 [ $default_offset -eq -1 ] ||
2095 error "stripe offset $default_offset != -1"
2097 run_test 27A "check filesystem-wide default LOV EA values"
2099 test_27B() { # LU-2523
2100 test_mkdir $DIR/$tdir
2101 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2103 # open f1 with O_LOV_DELAY_CREATE
2105 # call setstripe ioctl on open file descriptor for f1
2107 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2111 # open f1 with O_LOV_DELAY_CREATE
2113 # call setstripe ioctl on open file descriptor for f1
2115 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2117 # Allow multiop to fail in imitation of NFS's busted semantics.
2120 run_test 27B "call setstripe on open unlinked file/rename victim"
2122 test_27C() { #LU-2871
2123 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2131 test_mkdir $DIR/$tdir
2133 for i in $(seq 0 $((OSTCOUNT - 1))); do
2134 # set stripe across all OSTs starting from OST$i
2135 $SETSTRIPE -i $i -c -1 $tfile$i
2136 # get striping information
2137 ost_idx=($($GETSTRIPE $tfile$i |
2138 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2142 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2143 error "${#ost_idx[@]} != $OSTCOUNT"
2145 for index in $(seq 0 $((OSTCOUNT - 1))); do
2147 for j in $(echo ${ost_idx[@]}); do
2148 if [ $index -eq $j ]; then
2154 error "Can not find $index in ${ost_idx[@]}"
2158 run_test 27C "check full striping across all OSTs"
2161 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2162 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2163 remote_mds_nodsh && skip "remote MDS with nodsh"
2165 local POOL=${POOL:-testpool}
2167 local last_ost=$(($OSTCOUNT - 1))
2169 local ost_list=$(seq $first_ost $ost_step $last_ost)
2170 local ost_range="$first_ost $last_ost $ost_step"
2172 if ! combined_mgs_mds ; then
2176 test_mkdir $DIR/$tdir
2177 pool_add $POOL || error "pool_add failed"
2178 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2181 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2183 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2184 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2185 skip27D+=" -s 30,31"
2186 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2187 error "llapi_layout_test failed"
2189 destroy_test_pools || error "destroy test pools failed"
2191 if ! combined_mgs_mds ; then
2195 run_test 27D "validate llapi_layout API"
2197 # Verify that default_easize is increased from its initial value after
2198 # accessing a widely striped file.
2200 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2201 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2202 skip "client does not have LU-3338 fix"
2204 # 72 bytes is the minimum space required to store striping
2205 # information for a file striped across one OST:
2206 # (sizeof(struct lov_user_md_v3) +
2207 # sizeof(struct lov_user_ost_data_v1))
2209 $LCTL set_param -n llite.*.default_easize $min_easize ||
2210 error "lctl set_param failed"
2211 local easize=$($LCTL get_param -n llite.*.default_easize)
2213 [ $easize -eq $min_easize ] ||
2214 error "failed to set default_easize"
2216 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2217 error "setstripe failed"
2221 easize=$($LCTL get_param -n llite.*.default_easize)
2223 [ $easize -gt $min_easize ] ||
2224 error "default_easize not updated"
2226 run_test 27E "check that default extended attribute size properly increases"
2228 test_27F() { # LU-5346/LU-7975
2229 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2230 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2231 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2232 skip "Need MDS version at least 2.8.51"
2233 remote_ost_nodsh && skip "remote OST with nodsh"
2235 test_mkdir $DIR/$tdir
2237 $SETSTRIPE -c 2 $DIR/$tdir
2239 # stop all OSTs to reproduce situation for LU-7975 ticket
2240 for num in $(seq $OSTCOUNT); do
2244 # open/create f0 with O_LOV_DELAY_CREATE
2245 # truncate f0 to a non-0 size
2247 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2249 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2250 # open/write it again to force delayed layout creation
2251 cat /etc/hosts > $DIR/$tdir/f0 &
2255 for num in $(seq $OSTCOUNT); do
2256 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2257 error "ost$num failed to start"
2260 wait $catpid || error "cat failed"
2262 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2263 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2266 run_test 27F "Client resend delayed layout creation with non-zero size"
2268 test_27G() { #LU-10629
2269 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2270 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2271 local POOL=${POOL:-testpool}
2272 local ostrange="0 0 1"
2274 test_mkdir $DIR/$tdir
2275 pool_add $POOL || error "pool_add failed"
2276 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2277 $LFS setstripe -p $POOL $DIR/$tdir
2279 local pool=$($LFS getstripe -p $DIR/$tdir)
2281 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2283 $LFS setstripe -d $DIR/$tdir
2285 pool=$($LFS getstripe -p $DIR/$tdir)
2289 [ -z "$pool" ] || error "'$pool' is not empty"
2291 run_test 27G "Clear OST pool from stripe"
2293 # createtest also checks that device nodes are created and
2294 # then visible correctly (#2091)
2295 test_28() { # bug 2091
2297 $CREATETEST $DIR/d28/ct || error "createtest failed"
2299 run_test 28 "create/mknod/mkdir with bad file types ============"
2302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2304 sync; sleep 1; sync # flush out any dirty pages from previous tests
2311 declare -i LOCKCOUNTORIG=0
2312 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2313 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2315 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2317 declare -i LOCKUNUSEDCOUNTORIG=0
2318 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2319 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2326 declare -i LOCKCOUNTCURRENT=0
2327 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2328 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2331 declare -i LOCKUNUSEDCOUNTCURRENT=0
2332 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2333 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2336 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2337 $LCTL set_param -n ldlm.dump_namespaces ""
2338 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2339 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2340 log "dumped log to $TMP/test_29.dk (bug 5793)"
2343 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2344 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2345 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2346 log "dumped log to $TMP/test_29.dk (bug 5793)"
2350 run_test 29 "IT_GETATTR regression ============================"
2352 test_30a() { # was test_30
2353 cp $(which ls) $DIR || cp /bin/ls $DIR
2354 $DIR/ls / || error "Can't execute binary from lustre"
2357 run_test 30a "execute binary from Lustre (execve) =============="
2360 cp `which ls` $DIR || cp /bin/ls $DIR
2362 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2365 run_test 30b "execute binary from Lustre as non-root ==========="
2367 test_30c() { # b=22376
2368 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2370 cp `which ls` $DIR || cp /bin/ls $DIR
2372 cancel_lru_locks mdc
2373 cancel_lru_locks osc
2374 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2377 run_test 30c "execute binary from Lustre without read perms ===="
2380 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2381 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2383 run_test 31a "open-unlink file =================================="
2386 touch $DIR/f31 || error "touch $DIR/f31 failed"
2387 ln $DIR/f31 $DIR/f31b || error "ln failed"
2388 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2389 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2391 run_test 31b "unlink file with multiple links while open ======="
2394 touch $DIR/f31 || error "touch $DIR/f31 failed"
2395 ln $DIR/f31 $DIR/f31c || error "ln failed"
2396 multiop_bg_pause $DIR/f31 O_uc ||
2397 error "multiop_bg_pause for $DIR/f31 failed"
2399 $MULTIOP $DIR/f31c Ouc
2400 kill -USR1 $MULTIPID
2403 run_test 31c "open-unlink file with multiple links ============="
2406 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2407 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2409 run_test 31d "remove of open directory ========================="
2411 test_31e() { # bug 2904
2412 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2414 run_test 31e "remove of open non-empty directory ==============="
2416 test_31f() { # bug 4554
2417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2420 test_mkdir $DIR/d31f
2421 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2422 cp /etc/hosts $DIR/d31f
2424 $GETSTRIPE $DIR/d31f/hosts
2425 multiop_bg_pause $DIR/d31f D_c || return 1
2428 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2429 test_mkdir $DIR/d31f
2430 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2431 cp /etc/hosts $DIR/d31f
2433 $GETSTRIPE $DIR/d31f/hosts
2434 multiop_bg_pause $DIR/d31f D_c || return 1
2437 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2438 wait $MULTIPID || error "first opendir $MULTIPID failed"
2442 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2443 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2446 run_test 31f "remove of open directory with open-unlink file ==="
2449 echo "-- cross directory link --"
2450 test_mkdir -c1 $DIR/${tdir}ga
2451 test_mkdir -c1 $DIR/${tdir}gb
2452 touch $DIR/${tdir}ga/f
2453 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2454 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2455 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2456 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2457 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2459 run_test 31g "cross directory link==============="
2462 echo "-- cross directory link --"
2463 test_mkdir -c1 $DIR/${tdir}
2464 test_mkdir -c1 $DIR/${tdir}/dir
2465 touch $DIR/${tdir}/f
2466 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2467 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2468 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2469 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2470 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2472 run_test 31h "cross directory link under child==============="
2475 echo "-- cross directory link --"
2476 test_mkdir -c1 $DIR/$tdir
2477 test_mkdir -c1 $DIR/$tdir/dir
2478 touch $DIR/$tdir/dir/f
2479 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2480 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2481 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2482 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2483 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2485 run_test 31i "cross directory link under parent==============="
2488 test_mkdir -c1 -p $DIR/$tdir
2489 test_mkdir -c1 -p $DIR/$tdir/dir1
2490 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2491 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2492 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2493 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2496 run_test 31j "link for directory==============="
2499 test_mkdir -c1 -p $DIR/$tdir
2501 touch $DIR/$tdir/exist
2502 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2503 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2504 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2505 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2506 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2507 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2508 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2511 run_test 31k "link to file: the same, non-existing, dir==============="
2517 touch $DIR/d31m2/exist
2518 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2519 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2520 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2521 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2522 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2523 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2526 run_test 31m "link to file: the same, non-existing, dir==============="
2529 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2530 nlink=$(stat --format=%h $DIR/$tfile)
2531 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2533 local cmd="exec $fd<$DIR/$tfile"
2536 trap "eval $cmd" EXIT
2537 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2538 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2539 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2540 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2541 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2544 run_test 31n "check link count of unlinked file"
2547 local TEMPNAME=$(mktemp $1_XXXXXX)
2548 mlink $TEMPNAME $1 2> /dev/null &&
2549 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2553 test_31o() { # LU-2901
2554 test_mkdir $DIR/$tdir
2555 for LOOP in $(seq 100); do
2556 rm -f $DIR/$tdir/$tfile*
2557 for THREAD in $(seq 8); do
2558 link_one $DIR/$tdir/$tfile.$LOOP &
2561 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2562 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2563 error "$LINKS duplicate links to $tfile.$LOOP" &&
2567 run_test 31o "duplicate hard links with same filename"
2570 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2572 test_mkdir $DIR/$tdir
2573 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2574 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2576 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2577 error "open unlink test1 failed"
2578 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2579 error "open unlink test2 failed"
2581 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2582 error "test1 still exists"
2583 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2584 error "test2 still exists"
2586 run_test 31p "remove of open striped directory"
2588 cleanup_test32_mount() {
2591 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2592 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2593 losetup -d $loopdev || true
2599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2601 echo "== more mountpoints and symlinks ================="
2602 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2603 trap cleanup_test32_mount EXIT
2604 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2605 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2606 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2607 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2608 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2609 cleanup_test32_mount
2611 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2616 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2617 trap cleanup_test32_mount EXIT
2618 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2619 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2620 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2621 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2622 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2623 cleanup_test32_mount
2625 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2630 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2631 trap cleanup_test32_mount EXIT
2632 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2633 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2634 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2635 test_mkdir -p $DIR/$tdir/d2/test_dir
2636 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2637 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2638 cleanup_test32_mount
2640 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2645 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2646 trap cleanup_test32_mount EXIT
2647 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2648 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2649 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2650 test_mkdir -p $DIR/$tdir/d2/test_dir
2651 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2652 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2653 cleanup_test32_mount
2655 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2659 test_mkdir -p $DIR/$tdir/tmp
2660 local tmp_dir=$DIR/$tdir/tmp
2661 ln -s $DIR/$tdir $tmp_dir/symlink11
2662 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2663 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2664 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2666 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2670 test_mkdir -p $DIR/$tdir/tmp
2671 local tmp_dir=$DIR/$tdir/tmp
2672 ln -s $DIR/$tdir $tmp_dir/symlink11
2673 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2674 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2675 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2677 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2680 local tmp_dir=$DIR/$tdir/tmp
2681 test_mkdir -p $tmp_dir
2682 test_mkdir $DIR/${tdir}2
2683 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2684 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2685 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2686 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2687 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2688 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2690 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2693 rm -fr $DIR/$tdir $DIR/${tdir}2
2694 tmp_dir=$DIR/$tdir/tmp
2695 test_mkdir -p $tmp_dir
2696 test_mkdir $DIR/${tdir}2
2697 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2698 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2699 ls $tmp_dir/symlink12 || error "listing symlink12"
2700 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2702 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2707 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2708 trap cleanup_test32_mount EXIT
2709 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2710 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2711 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2712 touch $DIR/$tdir/test_file
2713 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2714 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2715 cleanup_test32_mount
2717 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2722 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2723 trap cleanup_test32_mount EXIT
2724 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2725 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2726 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2727 touch $DIR/$tdir/test_file
2728 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2729 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2730 cleanup_test32_mount
2732 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2738 trap cleanup_test32_mount EXIT
2739 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2740 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2741 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2742 test_mkdir -p $DIR/$tdir/d2
2743 touch $DIR/$tdir/d2/test_file || error "touch failed"
2744 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2745 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2746 cleanup_test32_mount
2748 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2751 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2754 trap cleanup_test32_mount EXIT
2755 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2756 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2757 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2758 test_mkdir -p $DIR/$tdir/d2
2759 touch $DIR/$tdir/d2/test_file || error "touch failed"
2760 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2761 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2762 cleanup_test32_mount
2764 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2768 test_mkdir -p $DIR/d32m/tmp
2769 TMP_DIR=$DIR/d32m/tmp
2770 ln -s $DIR $TMP_DIR/symlink11
2771 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2772 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2773 error "symlink11 not a link"
2774 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2775 error "symlink01 not a link"
2777 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2781 test_mkdir -p $DIR/d32n/tmp
2782 TMP_DIR=$DIR/d32n/tmp
2783 ln -s $DIR $TMP_DIR/symlink11
2784 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2785 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2786 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2788 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2792 test_mkdir -p $DIR/d32o/tmp
2793 TMP_DIR=$DIR/d32o/tmp
2794 ln -s $DIR/$tfile $TMP_DIR/symlink12
2795 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2796 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2797 error "symlink12 not a link"
2798 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2799 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2800 error "$DIR/d32o/tmp/symlink12 not file type"
2801 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2802 error "$DIR/d32o/symlink02 not file type"
2804 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2814 test_mkdir -p $DIR/d32p/tmp
2816 TMP_DIR=$DIR/d32p/tmp
2818 ln -s $DIR/$tfile $TMP_DIR/symlink12
2820 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2822 cat $DIR/d32p/tmp/symlink12 ||
2823 error "Can't open $DIR/d32p/tmp/symlink12"
2825 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2828 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2833 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2834 trap cleanup_test32_mount EXIT
2835 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2836 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2837 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2838 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2839 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2840 cleanup_test32_mount
2842 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2847 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2848 trap cleanup_test32_mount EXIT
2849 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2850 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2851 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2852 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2853 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2854 cleanup_test32_mount
2856 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2861 chmod 444 $DIR/$tfile
2862 chown $RUNAS_ID $DIR/$tfile
2864 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2867 run_test 33aa "write file with mode 444 (should return error)"
2871 test_mkdir $DIR/$tdir
2872 chown $RUNAS_ID $DIR/$tdir
2873 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2874 error "$RUNAS create $tdir/$tfile failed"
2875 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2876 error "open RDWR" || true
2878 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2882 test_mkdir $DIR/$tdir
2883 chown $RUNAS_ID $DIR/$tdir
2884 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2886 run_test 33b "test open file with malformed flags (No panic)"
2889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2890 remote_ost_nodsh && skip "remote OST with nodsh"
2899 test_mkdir $DIR/$tdir
2900 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2903 for ostnum in $(seq $OSTCOUNT); do
2904 # test-framework's OST numbering is one-based, while Lustre's
2906 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2907 # Parsing llobdstat's output sucks; we could grep the /proc
2908 # path, but that's likely to not be as portable as using the
2909 # llobdstat utility. So we parse lctl output instead.
2910 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2911 obdfilter/$ostname/stats |
2912 awk '/^write_bytes/ {print $7}' )
2913 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2914 if (( ${write_bytes:-0} > 0 ))
2921 $all_zeros || return 0
2924 echo foo > $DIR/$tdir/bar
2928 # Total up write_bytes after writing. We'd better find non-zeros.
2929 for ostnum in $(seq $OSTCOUNT); do
2930 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2931 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2932 obdfilter/$ostname/stats |
2933 awk '/^write_bytes/ {print $7}' )
2934 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2935 if (( ${write_bytes:-0} > 0 ))
2944 for ostnum in $(seq $OSTCOUNT); do
2945 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2946 echo "Check that write_bytes is present in obdfilter/*/stats:"
2947 do_facet ost$ostnum lctl get_param -n \
2948 obdfilter/$ostname/stats
2950 error "OST not keeping write_bytes stats (b22312)"
2953 run_test 33c "test llobdstat and write_bytes"
2956 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
2957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2960 local remote_dir=$DIR/$tdir/remote_dir
2962 test_mkdir $DIR/$tdir
2963 $LFS mkdir -i $MDTIDX $remote_dir ||
2964 error "create remote directory failed"
2966 touch $remote_dir/$tfile
2967 chmod 444 $remote_dir/$tfile
2968 chown $RUNAS_ID $remote_dir/$tfile
2970 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2972 chown $RUNAS_ID $remote_dir
2973 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2974 error "create" || true
2975 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2976 error "open RDWR" || true
2977 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2979 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2982 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2986 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2987 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2988 mkdir $DIR/$tdir/local_dir
2990 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2991 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2992 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2994 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2995 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2997 rmdir $DIR/$tdir/* || error "rmdir failed"
3000 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3001 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3002 mkdir $DIR/$tdir/local_dir
3004 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3005 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3006 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3008 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3009 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3011 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3014 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3015 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3016 mkdir $DIR/$tdir/local_dir
3018 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3019 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3020 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3022 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3023 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3025 run_test 33e "mkdir and striped directory should have same mode"
3029 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3033 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3034 remote_mds_nodsh && skip "remote MDS with nodsh"
3037 chmod go+rwx $DIR/$tdir
3038 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3039 trap cleanup_33f EXIT
3041 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3042 error "cannot create striped directory"
3044 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3045 error "cannot create files in striped directory"
3047 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3048 error "cannot remove files in striped directory"
3050 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3051 error "cannot remove striped directory"
3055 run_test 33f "nonroot user can create, access, and remove a striped directory"
3058 mkdir -p $DIR/$tdir/dir2
3060 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3062 [[ $err =~ "exists" ]] || error "Not exists error"
3064 run_test 33g "nonroot user create already existing root created file"
3066 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3069 $MCREATE $DIR/f34 || error "mcreate failed"
3070 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3071 error "getstripe failed"
3072 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3073 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3074 error "getstripe failed"
3075 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3076 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3078 run_test 34a "truncate file that has not been opened ==========="
3081 [ ! -f $DIR/f34 ] && test_34a
3082 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3083 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3084 $OPENFILE -f O_RDONLY $DIR/f34
3085 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3086 error "getstripe failed"
3087 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3088 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3090 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3093 [ ! -f $DIR/f34 ] && test_34a
3094 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3095 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3096 $OPENFILE -f O_RDWR $DIR/f34
3097 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3098 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3099 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3101 run_test 34c "O_RDWR opening file-with-size works =============="
3104 [ ! -f $DIR/f34 ] && test_34a
3105 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3107 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3108 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3111 run_test 34d "write to sparse file ============================="
3115 $MCREATE $DIR/f34e || error "mcreate failed"
3116 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3117 $CHECKSTAT -s 1000 $DIR/f34e ||
3118 error "Size of $DIR/f34e not equal to 1000 bytes"
3119 $OPENFILE -f O_RDWR $DIR/f34e
3120 $CHECKSTAT -s 1000 $DIR/f34e ||
3121 error "Size of $DIR/f34e not equal to 1000 bytes"
3123 run_test 34e "create objects, some with size and some without =="
3125 test_34f() { # bug 6242, 6243
3126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3130 $MCREATE $DIR/f34f || error "mcreate failed"
3131 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3132 dd if=$DIR/f34f of=$TMP/f34f
3133 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3134 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3135 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3136 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3137 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3139 run_test 34f "read from a file with no objects until EOF ======="
3142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3144 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3146 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3147 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3148 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3149 cancel_lru_locks osc
3150 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3151 error "wrong size after lock cancel"
3153 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3154 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3155 error "expanding truncate failed"
3156 cancel_lru_locks osc
3157 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3158 error "wrong expanded size after lock cancel"
3160 run_test 34g "truncate long file ==============================="
3163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3168 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3169 sync # Flush the cache so that multiop below does not block on cache
3170 # flush when getting the group lock
3171 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3174 # Since just timed wait is not good enough, let's do a sync write
3175 # that way we are sure enough time for a roundtrip + processing
3176 # passed + 2 seconds of extra margin.
3177 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3181 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3182 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3186 local nsz=`stat -c %s $DIR/$tfile`
3187 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3189 run_test 34h "ftruncate file under grouplock should not block"
3192 cp /bin/sh $DIR/f35a
3194 chown $RUNAS_ID $DIR/f35a
3195 $RUNAS $DIR/f35a && error || true
3198 run_test 35a "exec file with mode 444 (should return and not leak)"
3202 utime $DIR/f36 || error "utime failed for MDS"
3204 run_test 36a "MDS utime check (mknod, utime)"
3208 utime $DIR/f36 || error "utime failed for OST"
3210 run_test 36b "OST utime check (open, utime)"
3215 chown $RUNAS_ID $DIR/d36
3216 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3218 run_test 36c "non-root MDS utime check (mknod, utime)"
3221 [ ! -d $DIR/d36 ] && test_36c
3222 echo "" > $DIR/d36/f36
3223 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3225 run_test 36d "non-root OST utime check (open, utime)"
3228 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3230 test_mkdir $DIR/$tdir
3231 touch $DIR/$tdir/$tfile
3232 $RUNAS utime $DIR/$tdir/$tfile &&
3233 error "utime worked, expected failure" || true
3235 run_test 36e "utime on non-owned file (should return error)"
3239 local LANG_SAVE=$LANG
3240 local LC_LANG_SAVE=$LC_LANG
3241 export LANG=C LC_LANG=C # for date language
3243 DATESTR="Dec 20 2000"
3244 test_mkdir $DIR/$tdir
3245 lctl set_param fail_loc=$fl
3247 cp /etc/hosts $DIR/$tdir/$tfile
3248 sync & # write RPC generated with "current" inode timestamp, but delayed
3250 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3251 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3252 cancel_lru_locks osc
3253 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3255 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3256 echo "BEFORE: $LS_BEFORE" && \
3257 echo "AFTER : $LS_AFTER" && \
3258 echo "WANT : $DATESTR" && \
3259 error "$DIR/$tdir/$tfile timestamps changed" || true
3261 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3267 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3268 subr_36fh "0x80000214"
3270 run_test 36f "utime on file racing with OST BRW write =========="
3273 remote_ost_nodsh && skip "remote OST with nodsh"
3274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3280 test_mkdir $DIR/$tdir
3281 fmd_max_age=$(do_facet ost1 \
3282 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3285 fmd_before=$(do_facet ost1 \
3286 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3287 touch $DIR/$tdir/$tfile
3288 sleep $((fmd_max_age + 12))
3289 fmd_after=$(do_facet ost1 \
3290 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3292 echo "fmd_before: $fmd_before"
3293 echo "fmd_after: $fmd_after"
3294 [[ $fmd_after -gt $fmd_before ]] &&
3295 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3296 error "fmd didn't expire after ping" || true
3298 run_test 36g "filter mod data cache expiry ====================="
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3303 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3304 subr_36fh "0x80000227"
3306 run_test 36h "utime on file racing with OST BRW write =========="
3309 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3311 test_mkdir $DIR/$tdir
3312 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3314 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3315 local new_mtime=$((mtime + 200))
3317 #change Modify time of striped dir
3318 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3319 error "change mtime failed"
3321 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3323 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3325 run_test 36i "change mtime on striped directory"
3327 # test_37 - duplicate with tests 32q 32r
3330 local file=$DIR/$tfile
3332 openfile -f O_DIRECTORY $file
3335 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3336 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3338 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3340 test_39a() { # was test_39
3342 touch $DIR/${tfile}2
3343 # ls -l $DIR/$tfile $DIR/${tfile}2
3344 # ls -lu $DIR/$tfile $DIR/${tfile}2
3345 # ls -lc $DIR/$tfile $DIR/${tfile}2
3347 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3348 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3350 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3352 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3354 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3355 error "O_TRUNC didn't change timestamps"
3358 run_test 39a "mtime changed on create"
3361 test_mkdir -c1 $DIR/$tdir
3362 cp -p /etc/passwd $DIR/$tdir/fopen
3363 cp -p /etc/passwd $DIR/$tdir/flink
3364 cp -p /etc/passwd $DIR/$tdir/funlink
3365 cp -p /etc/passwd $DIR/$tdir/frename
3366 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3369 echo "aaaaaa" >> $DIR/$tdir/fopen
3370 echo "aaaaaa" >> $DIR/$tdir/flink
3371 echo "aaaaaa" >> $DIR/$tdir/funlink
3372 echo "aaaaaa" >> $DIR/$tdir/frename
3374 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3375 local link_new=`stat -c %Y $DIR/$tdir/flink`
3376 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3377 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3379 cat $DIR/$tdir/fopen > /dev/null
3380 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3381 rm -f $DIR/$tdir/funlink2
3382 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3384 for (( i=0; i < 2; i++ )) ; do
3385 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3386 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3387 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3388 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3390 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3391 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3392 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3393 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3395 cancel_lru_locks osc
3396 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3399 run_test 39b "mtime change on open, link, unlink, rename ======"
3401 # this should be set to past
3402 TEST_39_MTIME=`date -d "1 year ago" +%s`
3408 local mtime0=`stat -c %Y $DIR1/$tfile`
3410 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3411 local mtime1=`stat -c %Y $DIR1/$tfile`
3412 [ "$mtime1" = $TEST_39_MTIME ] || \
3413 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3416 echo hello >> $DIR1/$tfile
3418 local mtime2=`stat -c %Y $DIR1/$tfile`
3419 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3420 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3422 mv $DIR1/$tfile $DIR1/$tfile-1
3424 for (( i=0; i < 2; i++ )) ; do
3425 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3426 [ "$mtime2" = "$mtime3" ] || \
3427 error "mtime ($mtime2) changed (to $mtime3) on rename"
3429 cancel_lru_locks osc
3430 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3433 run_test 39c "mtime change on rename ==========================="
3437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3440 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3442 for (( i=0; i < 2; i++ )) ; do
3443 local mtime=`stat -c %Y $DIR1/$tfile`
3444 [ $mtime = $TEST_39_MTIME ] || \
3445 error "mtime($mtime) is not set to $TEST_39_MTIME"
3447 cancel_lru_locks osc
3448 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3451 run_test 39d "create, utime, stat =============================="
3455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3458 local mtime1=`stat -c %Y $DIR1/$tfile`
3460 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3462 for (( i=0; i < 2; i++ )) ; do
3463 local mtime2=`stat -c %Y $DIR1/$tfile`
3464 [ $mtime2 = $TEST_39_MTIME ] || \
3465 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3467 cancel_lru_locks osc
3468 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3471 run_test 39e "create, stat, utime, stat ========================"
3475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3478 mtime1=`stat -c %Y $DIR1/$tfile`
3481 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3483 for (( i=0; i < 2; i++ )) ; do
3484 local mtime2=`stat -c %Y $DIR1/$tfile`
3485 [ $mtime2 = $TEST_39_MTIME ] || \
3486 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3488 cancel_lru_locks osc
3489 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3492 run_test 39f "create, stat, sleep, utime, stat ================="
3496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3498 echo hello >> $DIR1/$tfile
3499 local mtime1=`stat -c %Y $DIR1/$tfile`
3502 chmod o+r $DIR1/$tfile
3504 for (( i=0; i < 2; i++ )) ; do
3505 local mtime2=`stat -c %Y $DIR1/$tfile`
3506 [ "$mtime1" = "$mtime2" ] || \
3507 error "lost mtime: $mtime2, should be $mtime1"
3509 cancel_lru_locks osc
3510 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3513 run_test 39g "write, chmod, stat ==============================="
3517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3523 echo hello >> $DIR1/$tfile
3524 local mtime1=`stat -c %Y $DIR1/$tfile`
3526 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3528 if [ "$d1" != "$d2" ]; then
3529 echo "write and touch not within one second"
3531 for (( i=0; i < 2; i++ )) ; do
3532 local mtime2=`stat -c %Y $DIR1/$tfile`
3533 [ "$mtime2" = $TEST_39_MTIME ] || \
3534 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3536 cancel_lru_locks osc
3537 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3541 run_test 39h "write, utime within one second, stat ============="
3544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3549 echo hello >> $DIR1/$tfile
3550 local mtime1=`stat -c %Y $DIR1/$tfile`
3552 mv $DIR1/$tfile $DIR1/$tfile-1
3554 for (( i=0; i < 2; i++ )) ; do
3555 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3557 [ "$mtime1" = "$mtime2" ] || \
3558 error "lost mtime: $mtime2, should be $mtime1"
3560 cancel_lru_locks osc
3561 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3564 run_test 39i "write, rename, stat =============================="
3567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3569 start_full_debug_logging
3573 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3574 lctl set_param fail_loc=0x80000412
3575 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3576 error "multiop failed"
3578 local mtime1=`stat -c %Y $DIR1/$tfile`
3580 mv $DIR1/$tfile $DIR1/$tfile-1
3582 kill -USR1 $multipid
3583 wait $multipid || error "multiop close failed"
3585 for (( i=0; i < 2; i++ )) ; do
3586 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3587 [ "$mtime1" = "$mtime2" ] ||
3588 error "mtime is lost on close: $mtime2, " \
3591 cancel_lru_locks osc
3592 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3594 lctl set_param fail_loc=0
3595 stop_full_debug_logging
3597 run_test 39j "write, rename, close, stat ======================="
3600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3605 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3607 local mtime1=`stat -c %Y $DIR1/$tfile`
3609 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3611 kill -USR1 $multipid
3612 wait $multipid || error "multiop close failed"
3614 for (( i=0; i < 2; i++ )) ; do
3615 local mtime2=`stat -c %Y $DIR1/$tfile`
3617 [ "$mtime2" = $TEST_39_MTIME ] || \
3618 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3620 cancel_lru_locks osc
3621 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3624 run_test 39k "write, utime, close, stat ========================"
3626 # this should be set to future
3627 TEST_39_ATIME=`date -d "1 year" +%s`
3630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3631 remote_mds_nodsh && skip "remote MDS with nodsh"
3633 local atime_diff=$(do_facet $SINGLEMDS \
3634 lctl get_param -n mdd.*MDT0000*.atime_diff)
3638 # test setting directory atime to future
3639 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3640 local atime=$(stat -c %X $DIR/$tdir)
3641 [ "$atime" = $TEST_39_ATIME ] ||
3642 error "atime is not set to future: $atime, $TEST_39_ATIME"
3644 # test setting directory atime from future to now
3645 local now=$(date +%s)
3646 touch -a -d @$now $DIR/$tdir
3648 atime=$(stat -c %X $DIR/$tdir)
3649 [ "$atime" -eq "$now" ] ||
3650 error "atime is not updated from future: $atime, $now"
3652 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3655 # test setting directory atime when now > dir atime + atime_diff
3656 local d1=$(date +%s)
3658 local d2=$(date +%s)
3659 cancel_lru_locks mdc
3660 atime=$(stat -c %X $DIR/$tdir)
3661 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3662 error "atime is not updated : $atime, should be $d2"
3664 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3667 # test not setting directory atime when now < dir atime + atime_diff
3669 cancel_lru_locks mdc
3670 atime=$(stat -c %X $DIR/$tdir)
3671 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3672 error "atime is updated to $atime, should remain $d1<atime<$d2"
3674 do_facet $SINGLEMDS \
3675 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3677 run_test 39l "directory atime update ==========================="
3680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3684 local far_past_mtime=$(date -d "May 29 1953" +%s)
3685 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3687 touch -m -d @$far_past_mtime $DIR1/$tfile
3688 touch -a -d @$far_past_atime $DIR1/$tfile
3690 for (( i=0; i < 2; i++ )) ; do
3691 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3692 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3693 error "atime or mtime set incorrectly"
3695 cancel_lru_locks osc
3696 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3699 run_test 39m "test atime and mtime before 1970"
3701 test_39n() { # LU-3832
3702 remote_mds_nodsh && skip "remote MDS with nodsh"
3704 local atime_diff=$(do_facet $SINGLEMDS \
3705 lctl get_param -n mdd.*MDT0000*.atime_diff)
3710 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3713 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3714 atime0=$(stat -c %X $DIR/$tfile)
3717 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3718 atime1=$(stat -c %X $DIR/$tfile)
3721 cancel_lru_locks mdc
3722 cancel_lru_locks osc
3723 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3724 atime2=$(stat -c %X $DIR/$tfile)
3726 do_facet $SINGLEMDS \
3727 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3729 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3730 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3732 run_test 39n "check that O_NOATIME is honored"
3735 TESTDIR=$DIR/$tdir/$tfile
3736 [ -e $TESTDIR ] && rm -rf $TESTDIR
3743 links2=$(stat -c %h .)
3744 [ $(($links1 + 2)) != $links2 ] &&
3745 error "wrong links count $(($links1 + 2)) != $links2"
3747 links3=$(stat -c %h .)
3748 [ $(($links1 + 1)) != $links3 ] &&
3749 error "wrong links count $links1 != $links3"
3752 run_test 39o "directory cached attributes updated after create"
3755 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3758 TESTDIR=$DIR/$tdir/$tdir
3759 [ -e $TESTDIR ] && rm -rf $TESTDIR
3760 test_mkdir -p $TESTDIR
3764 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3765 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3767 links2=$(stat -c %h .)
3768 [ $(($links1 + 2)) != $links2 ] &&
3769 error "wrong links count $(($links1 + 2)) != $links2"
3771 links3=$(stat -c %h .)
3772 [ $(($links1 + 1)) != $links3 ] &&
3773 error "wrong links count $links1 != $links3"
3776 run_test 39p "remote directory cached attributes updated after create ========"
3779 test_39q() { # LU-8041
3780 local testdir=$DIR/$tdir
3782 multiop_bg_pause $testdir D_c || error "multiop failed"
3784 cancel_lru_locks mdc
3785 kill -USR1 $multipid
3786 local atime=$(stat -c %X $testdir)
3787 [ "$atime" -ne 0 ] || error "atime is zero"
3789 run_test 39q "close won't zero out atime"
3792 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3793 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3794 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3795 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3796 error "$tfile is not 4096 bytes in size"
3798 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3802 small_write $DIR/f41 18
3804 run_test 41 "test small file write + fstat ====================="
3806 count_ost_writes() {
3807 lctl get_param -n ${OSC}.*.stats |
3808 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3809 END { printf("%0.0f", writes) }'
3816 BG_DIRTY_RATIO_SAVE=10
3817 MAX_BG_DIRTY_RATIO=25
3821 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3822 # dirty_ratio, dirty_background_ratio
3823 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3824 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3825 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3826 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3828 # if file not here, we are a 2.4 kernel
3829 kill -CONT `pidof kupdated`
3834 # setup the trap first, so someone cannot exit the test at the
3835 # exact wrong time and mess up a machine
3836 trap start_writeback EXIT
3837 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3838 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3839 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3840 sysctl -w vm.dirty_writeback_centisecs=0
3841 sysctl -w vm.dirty_writeback_centisecs=0
3842 # save and increase /proc/sys/vm/dirty_ratio
3843 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3844 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3845 # save and increase /proc/sys/vm/dirty_background_ratio
3846 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3847 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3849 # if file not here, we are a 2.4 kernel
3850 kill -STOP `pidof kupdated`
3854 # ensure that all stripes have some grant before we test client-side cache
3856 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3857 dd if=/dev/zero of=$i bs=4k count=1
3862 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3863 # file truncation, and file removal.
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3868 cancel_lru_locks $OSC
3870 sync; sleep 1; sync # just to be safe
3871 BEFOREWRITES=`count_ost_writes`
3872 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3873 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3874 AFTERWRITES=`count_ost_writes`
3875 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3876 error "$BEFOREWRITES < $AFTERWRITES"
3879 run_test 42a "ensure that we don't flush on close"
3882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3885 cancel_lru_locks $OSC
3888 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3889 BEFOREWRITES=$(count_ost_writes)
3890 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3891 AFTERWRITES=$(count_ost_writes)
3892 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3893 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3895 BEFOREWRITES=$(count_ost_writes)
3896 sync || error "sync: $?"
3897 AFTERWRITES=$(count_ost_writes)
3898 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3899 error "$BEFOREWRITES < $AFTERWRITES on sync"
3901 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3905 run_test 42b "test destroy of file with cached dirty data ======"
3907 # if these tests just want to test the effect of truncation,
3908 # they have to be very careful. consider:
3909 # - the first open gets a {0,EOF}PR lock
3910 # - the first write conflicts and gets a {0, count-1}PW
3911 # - the rest of the writes are under {count,EOF}PW
3912 # - the open for truncate tries to match a {0,EOF}PR
3913 # for the filesize and cancels the PWs.
3914 # any number of fixes (don't get {0,EOF} on open, match
3915 # composite locks, do smarter file size management) fix
3916 # this, but for now we want these tests to verify that
3917 # the cancellation with truncate intent works, so we
3918 # start the file with a full-file pw lock to match against
3919 # until the truncate.
3924 cancel_lru_locks $OSC
3926 # prime the file with 0,EOF PW to match
3930 # now the real test..
3931 dd if=/dev/zero of=$file bs=1024 count=100
3932 BEFOREWRITES=`count_ost_writes`
3933 $TRUNCATE $file $offset
3934 cancel_lru_locks $OSC
3935 AFTERWRITES=`count_ost_writes`
3940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3943 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
3944 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3947 run_test 42c "test partial truncate of file with cached dirty data"
3950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3953 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
3954 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3957 run_test 42d "test complete truncate of file with cached dirty data"
3959 test_42e() { # bug22074
3960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3962 local TDIR=$DIR/${tdir}e
3963 local pagesz=$(page_size)
3964 local pages=16 # hardcoded 16 pages, don't change it.
3965 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3966 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3970 test_mkdir $DIR/${tdir}e
3971 $SETSTRIPE -c 1 $TDIR
3972 createmany -o $TDIR/f $files
3974 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3976 # we assume that with $OSTCOUNT files, at least one of them will
3977 # be allocated on OST0.
3978 warmup_files=$((OSTCOUNT * max_dirty_mb))
3979 createmany -o $TDIR/w $warmup_files
3981 # write a large amount of data into one file and sync, to get good
3982 # avail_grant number from OST.
3983 for ((i=0; i<$warmup_files; i++)); do
3984 idx=$($GETSTRIPE -i $TDIR/w$i)
3985 [ $idx -ne 0 ] && continue
3986 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3989 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3991 $LCTL get_param $proc_osc0/cur_dirty_bytes
3992 $LCTL get_param $proc_osc0/cur_grant_bytes
3994 # create as much dirty pages as we can while not to trigger the actual
3995 # RPCs directly. but depends on the env, VFS may trigger flush during this
3996 # period, hopefully we are good.
3997 for ((i=0; i<$warmup_files; i++)); do
3998 idx=$($GETSTRIPE -i $TDIR/w$i)
3999 [ $idx -ne 0 ] && continue
4000 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4002 $LCTL get_param $proc_osc0/cur_dirty_bytes
4003 $LCTL get_param $proc_osc0/cur_grant_bytes
4005 # perform the real test
4006 $LCTL set_param $proc_osc0/rpc_stats 0
4007 for ((;i<$files; i++)); do
4008 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4009 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
4012 $LCTL get_param $proc_osc0/rpc_stats
4015 local have_ppr=false
4016 $LCTL get_param $proc_osc0/rpc_stats |
4017 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4018 # skip lines until we are at the RPC histogram data
4019 [ "$PPR" == "pages" ] && have_ppr=true && continue
4020 $have_ppr || continue
4022 # we only want the percent stat for < 16 pages
4023 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4025 percent=$((percent + WPCT))
4026 if [[ $percent -gt 15 ]]; then
4027 error "less than 16-pages write RPCs" \
4034 run_test 42e "verify sub-RPC writes are not done synchronously"
4036 test_43A() { # was test_43
4037 test_mkdir $DIR/$tdir
4038 cp -p /bin/ls $DIR/$tdir/$tfile
4039 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4041 # give multiop a chance to open
4044 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4047 run_test 43A "execution of file opened for write should return -ETXTBSY"
4050 test_mkdir $DIR/$tdir
4051 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4052 cp -p multiop $DIR/$tdir/multiop
4053 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4054 error "multiop open $TMP/$tfile.junk failed"
4055 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4057 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
4058 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4059 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4061 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4066 test_mkdir $DIR/$tdir
4067 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4068 cp -p multiop $DIR/$tdir/multiop
4069 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4070 error "multiop open $TMP/$tfile.junk failed"
4071 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4073 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
4074 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4075 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4077 run_test 43b "truncate of file being executed should return -ETXTBSY"
4080 local testdir="$DIR/$tdir"
4083 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4084 ( cd $testdir && md5sum -c )
4086 run_test 43c "md5sum of copy into lustre"
4088 test_44A() { # was test_44
4089 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4091 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4092 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4094 run_test 44A "zero length read from a sparse stripe"
4097 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4099 [ -z "$nstripe" ] && skip "can't get stripe info"
4100 [[ $nstripe -gt $OSTCOUNT ]] &&
4101 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4103 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4105 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4106 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4110 OFFSETS="0 $((stride/2)) $((stride-1))"
4111 for offset in $OFFSETS; do
4112 for i in $(seq 0 $((nstripe-1))); do
4113 local GLOBALOFFSETS=""
4115 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4116 local myfn=$DIR/d44a-$size
4117 echo "--------writing $myfn at $size"
4118 ll_sparseness_write $myfn $size ||
4119 error "ll_sparseness_write"
4120 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4121 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4122 error "ll_sparseness_verify $GLOBALOFFSETS"
4124 for j in $(seq 0 $((nstripe-1))); do
4126 size=$((((j + $nstripe )*$stride + $offset)))
4127 ll_sparseness_write $myfn $size ||
4128 error "ll_sparseness_write"
4129 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4131 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4132 error "ll_sparseness_verify $GLOBALOFFSETS"
4137 run_test 44a "test sparse pwrite ==============================="
4141 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4147 before=`dirty_osc_total`
4148 echo executing "\"$*\""
4150 after=`dirty_osc_total`
4151 echo before $before, after $after
4154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4157 # Obtain grants from OST if it supports it
4158 echo blah > ${f}_grant
4161 do_dirty_record "echo blah > $f"
4162 [[ $before -eq $after ]] && error "write wasn't cached"
4163 do_dirty_record "> $f"
4164 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4165 do_dirty_record "echo blah > $f"
4166 [[ $before -eq $after ]] && error "write wasn't cached"
4167 do_dirty_record "sync"
4168 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4169 do_dirty_record "echo blah > $f"
4170 [[ $before -eq $after ]] && error "write wasn't cached"
4171 do_dirty_record "cancel_lru_locks osc"
4172 [[ $before -gt $after ]] ||
4173 error "lock cancellation didn't lower dirty count"
4176 run_test 45 "osc io page accounting ============================"
4178 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4179 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4180 # objects offset and an assert hit when an rpc was built with 1023's mapped
4181 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4188 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4190 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4191 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4195 run_test 46 "dirtying a previously written page ================"
4197 # test_47 is removed "Device nodes check" is moved to test_28
4199 test_48a() { # bug 2399
4200 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4201 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4202 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4204 test_mkdir $DIR/$tdir
4206 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4207 test_mkdir $DIR/$tdir
4208 touch foo || error "'touch foo' failed after recreating cwd"
4210 touch .foo || error "'touch .foo' failed after recreating cwd"
4212 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4213 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4214 cd . || error "'cd .' failed after recreating cwd"
4215 mkdir . && error "'mkdir .' worked after recreating cwd"
4216 rmdir . && error "'rmdir .' worked after recreating cwd"
4217 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4218 cd .. || error "'cd ..' failed after recreating cwd"
4220 run_test 48a "Access renamed working dir (should return errors)="
4222 test_48b() { # bug 2399
4224 test_mkdir $DIR/$tdir
4226 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4227 touch foo && error "'touch foo' worked after removing cwd"
4228 mkdir foo && error "'mkdir foo' worked after removing cwd"
4229 touch .foo && error "'touch .foo' worked after removing cwd"
4230 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4231 ls . > /dev/null && error "'ls .' worked after removing cwd"
4232 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4233 mkdir . && error "'mkdir .' worked after removing cwd"
4234 rmdir . && error "'rmdir .' worked after removing cwd"
4235 ln -s . foo && error "'ln -s .' worked after removing cwd"
4236 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4238 run_test 48b "Access removed working dir (should return errors)="
4240 test_48c() { # bug 2350
4241 #lctl set_param debug=-1
4244 test_mkdir -p $DIR/$tdir/dir
4246 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4247 $TRACE touch foo && error "touch foo worked after removing cwd"
4248 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4249 touch .foo && error "touch .foo worked after removing cwd"
4250 mkdir .foo && error "mkdir .foo worked after removing cwd"
4251 $TRACE ls . && error "'ls .' worked after removing cwd"
4252 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4253 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4254 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4255 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4256 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4258 run_test 48c "Access removed working subdir (should return errors)"
4260 test_48d() { # bug 2350
4261 #lctl set_param debug=-1
4264 test_mkdir -p $DIR/$tdir/dir
4266 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4267 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4268 $TRACE touch foo && error "'touch foo' worked after removing parent"
4269 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4270 touch .foo && error "'touch .foo' worked after removing parent"
4271 mkdir .foo && error "mkdir .foo worked after removing parent"
4272 $TRACE ls . && error "'ls .' worked after removing parent"
4273 $TRACE ls .. && error "'ls ..' worked after removing parent"
4274 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4275 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4276 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4279 run_test 48d "Access removed parent subdir (should return errors)"
4281 test_48e() { # bug 4134
4282 #lctl set_param debug=-1
4285 test_mkdir -p $DIR/$tdir/dir
4287 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4288 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4289 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4290 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4291 # On a buggy kernel addition of "touch foo" after cd .. will
4292 # produce kernel oops in lookup_hash_it
4293 touch ../foo && error "'cd ..' worked after recreate parent"
4295 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4297 run_test 48e "Access to recreated parent subdir (should return errors)"
4299 test_49() { # LU-1030
4300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4301 remote_ost_nodsh && skip "remote OST with nodsh"
4303 # get ost1 size - lustre-OST0000
4304 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4306 # write 800M at maximum
4307 [[ $ost1_size -lt 2 ]] && ost1_size=2
4308 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4310 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4311 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4314 # change max_pages_per_rpc while writing the file
4315 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4316 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4317 # loop until dd process exits
4318 while ps ax -opid | grep -wq $dd_pid; do
4319 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4320 sleep $((RANDOM % 5 + 1))
4322 # restore original max_pages_per_rpc
4323 $LCTL set_param $osc1_mppc=$orig_mppc
4324 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4326 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4330 test_mkdir $DIR/$tdir
4332 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4334 run_test 50 "special situations: /proc symlinks ==============="
4336 test_51a() { # was test_51
4337 # bug 1516 - create an empty entry right after ".." then split dir
4338 test_mkdir -c1 $DIR/$tdir
4339 touch $DIR/$tdir/foo
4340 $MCREATE $DIR/$tdir/bar
4342 createmany -m $DIR/$tdir/longfile 201
4344 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4345 $MCREATE $DIR/$tdir/longfile$FNUM
4350 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4352 run_test 51a "special situations: split htree with empty entry =="
4354 cleanup_print_lfs_df () {
4361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4363 local dir=$DIR/$tdir
4364 local nrdirs=$((65536 + 100))
4366 # cleanup the directory
4373 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4374 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4375 [[ $numfree -lt $nrdirs ]] &&
4376 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4378 # need to check free space for the directories as well
4379 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4380 numfree=$(( blkfree / $(fs_inode_ksize) ))
4381 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4383 trap cleanup_print_lfs_df EXIT
4386 createmany -d $dir/d $nrdirs || {
4387 unlinkmany $dir/d $nrdirs
4388 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4392 nrdirs=$(ls -U $dir | wc -l)
4394 # unlink all but 100 subdirectories, then check it still works
4396 local delete=$((nrdirs - left))
4401 # for ldiskfs the nlink count should be 1, but this is OSD specific
4402 # and so this is listed for informational purposes only
4403 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4404 unlinkmany -d $dir/d $delete ||
4405 error "unlink of first $delete subdirs failed"
4407 echo "nlink between: $(stat -c %h $dir)"
4408 local found=$(ls -U $dir | wc -l)
4409 [ $found -ne $left ] &&
4410 error "can't find subdirs: found only $found, expected $left"
4412 unlinkmany -d $dir/d $delete $left ||
4413 error "unlink of second $left subdirs failed"
4414 # regardless of whether the backing filesystem tracks nlink accurately
4415 # or not, the nlink count shouldn't be more than "." and ".." here
4416 local after=$(stat -c %h $dir)
4417 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4418 echo "nlink after: $after"
4420 cleanup_print_lfs_df
4422 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4426 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4428 test_mkdir $DIR/$tdir
4429 createmany -o $DIR/$tdir/t- 1000
4430 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4431 for N in $(seq 0 $((OSTCOUNT - 1))); do
4432 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4433 END { printf("%0.0f", objs) }' $TMP/$tfile)
4434 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4435 '($1 == '$N') { objs += 1 } \
4436 END { printf("%0.0f", objs) }')
4437 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4439 unlinkmany $DIR/$tdir/t- 1000
4442 for N in $(seq 1 $((OSTCOUNT - 1))); do
4443 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4444 error "OST $N has less objects vs OST $NLAST" \
4445 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4446 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4447 error "OST $N has less objects vs OST $NLAST" \
4448 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4450 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4451 error "OST $N has less #0 objects vs OST $NLAST" \
4452 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4453 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4454 error "OST $N has less #0 objects vs OST $NLAST" \
4455 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4460 run_test 51d "check object distribution"
4463 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4464 skip_env "ldiskfs only test"
4467 test_mkdir -c1 $DIR/$tdir
4468 test_mkdir -c1 $DIR/$tdir/d0
4470 touch $DIR/$tdir/d0/foo
4471 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4472 error "file exceed 65000 nlink limit!"
4473 unlinkmany $DIR/$tdir/d0/f- 65001
4476 run_test 51e "check file nlink limit"
4479 test_mkdir $DIR/$tdir
4482 local ulimit_old=$(ulimit -n)
4483 local spare=20 # number of spare fd's for scripts/libraries, etc.
4484 local mdt=$($LFS getstripe -m $DIR/$tdir)
4485 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4487 echo "MDT$mdt numfree=$numfree, max=$max"
4488 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4489 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4490 while ! ulimit -n $((numfree + spare)); do
4491 numfree=$((numfree * 3 / 4))
4493 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4495 echo "left ulimit at $ulimit_old"
4498 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4499 unlinkmany $DIR/$tdir/f $numfree
4500 error "create+open $numfree files in $DIR/$tdir failed"
4502 ulimit -n $ulimit_old
4504 # if createmany exits at 120s there will be fewer than $numfree files
4505 unlinkmany $DIR/$tdir/f $numfree || true
4507 run_test 51f "check many open files limit"
4510 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4511 test_mkdir $DIR/$tdir
4512 touch $DIR/$tdir/foo
4513 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4514 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4515 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4516 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4517 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4519 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4520 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4521 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4523 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4524 cp -r $DIR/$tdir $TMP/
4525 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4527 run_test 52a "append-only flag test (should return errors)"
4530 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4531 test_mkdir $DIR/$tdir
4532 touch $DIR/$tdir/foo
4533 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4534 cat test > $DIR/$tdir/foo && error "cat test worked"
4535 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4536 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4537 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4539 echo foo >> $DIR/$tdir/foo && error "echo worked"
4540 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4541 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4542 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4543 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4545 chattr -i $DIR/$tdir/foo || error "chattr failed"
4547 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4549 run_test 52b "immutable flag test (should return errors) ======="
4552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4553 remote_mds_nodsh && skip "remote MDS with nodsh"
4554 remote_ost_nodsh && skip "remote OST with nodsh"
4567 local support_last_seq=true
4569 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4570 support_last_seq=false
4573 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4575 for value in $(do_facet $SINGLEMDS \
4576 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4577 param=$(echo ${value[0]} | cut -d "=" -f1)
4578 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4580 if $support_last_seq; then
4581 param_seq=$(echo $param |
4582 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4583 mds_last_seq=$(do_facet $SINGLEMDS \
4584 $LCTL get_param -n $param_seq)
4586 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4588 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4589 node=$(facet_active_host ost$((ostnum+1)))
4590 param="obdfilter.$ostname.last_id"
4591 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4592 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4593 ost_last_id=$ost_last
4595 if $support_last_seq; then
4596 ost_last_id=$(echo $ost_last |
4597 awk -F':' '{print $2}' |
4599 ost_last_seq=$(echo $ost_last |
4600 awk -F':' '{print $1}')
4601 [[ $ost_last_seq = $mds_last_seq ]] || continue
4604 if [[ $ost_last_id != $mds_last ]]; then
4605 error "$ost_last_id != $mds_last"
4612 $found || error "can not match last_seq/last_id for $mdtosc"
4615 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4618 perl -MSocket -e ';' || skip "no Socket perl module installed"
4620 $SOCKETSERVER $DIR/socket ||
4621 error "$SOCKETSERVER $DIR/socket failed: $?"
4622 $SOCKETCLIENT $DIR/socket ||
4623 error "$SOCKETCLIENT $DIR/socket failed: $?"
4624 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4626 run_test 54a "unix domain socket test =========================="
4632 dd if=/dev/zero of=$f bs=$(page_size) count=1
4634 run_test 54b "char device works in lustre ======================"
4637 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4638 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4639 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4641 for i in $(seq 3 7); do
4642 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4651 loopdev="$DIR/loop54c"
4654 $UMOUNT $DIR/$tdir || rc=$?
4655 losetup -d $loopdev || true
4656 losetup -d $LOOPDEV || true
4657 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4662 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4664 loopdev="$DIR/loop54c"
4667 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4668 trap cleanup_54c EXIT
4669 mknod $loopdev b 7 $LOOPNUM
4670 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4671 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4672 losetup $loopdev $DIR/$tfile ||
4673 error "can't set up $loopdev for $DIR/$tfile"
4674 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4675 test_mkdir $DIR/$tdir
4676 mount -t ext2 $loopdev $DIR/$tdir ||
4677 error "error mounting $loopdev on $DIR/$tdir"
4678 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4681 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4685 run_test 54c "block device works in lustre ====================="
4691 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4693 run_test 54d "fifo device works in lustre ======================"
4698 cp -aL /dev/console $f
4699 echo $string > $f || error "echo $string to $f failed"
4701 run_test 54e "console/tty device works in lustre ======================"
4705 local dir=$DIR/$tdir
4708 test_mkdir -p $dir/dir
4709 for i in $(seq $numfiles); do
4711 touch $dir/dir/file$i
4714 local numcomp=$($LFS getstripe --component-count $dir)
4716 [[ $numcomp == 0 ]] && numcomp=1
4718 # test lfs getstripe with --recursive
4719 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4721 [[ $filenum -eq $((numfiles * 2)) ]] ||
4722 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4723 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4724 [[ $filenum -eq $numfiles ]] ||
4725 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4726 echo "$LFS getstripe showed obdidx or l_ost_idx"
4728 # test lfs getstripe with file instead of dir
4729 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4730 [[ $filenum -eq 1 ]] ||
4731 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4732 echo "$LFS getstripe file1 passed"
4734 #test lfs getstripe with --verbose
4735 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4736 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4737 error "$LFS getstripe --verbose $dir: "\
4738 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4739 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4740 error "$LFS getstripe $dir: showed lmm_magic"
4742 #test lfs getstripe with -v prints lmm_fid
4743 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4744 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4745 error "$LFS getstripe -v $dir: "\
4746 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4747 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4748 error "$LFS getstripe $dir: showed lmm_fid by default"
4749 echo "$LFS getstripe --verbose passed"
4751 #check for FID information
4752 local fid1=$($LFS getstripe --fid $dir/file1)
4753 local fid2=$($LFS getstripe --verbose $dir/file1 |
4754 awk '/lmm_fid: / { print $2; exit; }')
4755 local fid3=$($LFS path2fid $dir/file1)
4757 [ "$fid1" != "$fid2" ] &&
4758 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4759 [ "$fid1" != "$fid3" ] &&
4760 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4761 echo "$LFS getstripe --fid passed"
4763 #test lfs getstripe with --obd
4764 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4765 error "$LFS getstripe --obd wrong_uuid: should return error"
4767 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4770 local obduuid=$(ostuuid_from_index $ostidx)
4771 local found=$($LFS getstripe -r --obd $obduuid $dir |
4772 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
4774 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
4775 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
4777 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
4780 [[ $found -eq $filenum ]] ||
4781 error "$LFS getstripe --obd: found $found expect $filenum"
4782 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4783 sed '/^[ ]*'${ostidx}'[ ]/d' |
4784 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4785 error "$LFS getstripe --obd: should not show file on other obd"
4786 echo "$LFS getstripe --obd passed"
4788 run_test 56a "check $LFS getstripe"
4791 local dir=$DIR/$tdir
4795 for i in $(seq $numdirs); do
4796 test_mkdir $dir/dir$i
4799 # test lfs getdirstripe default mode is non-recursion, which is
4800 # different from lfs getstripe
4801 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4803 [[ $dircnt -eq 1 ]] ||
4804 error "$LFS getdirstripe: found $dircnt, not 1"
4805 dircnt=$($LFS getdirstripe --recursive $dir |
4806 grep -c lmv_stripe_count)
4807 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4808 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4810 run_test 56b "check $LFS getdirstripe"
4813 remote_ost_nodsh && skip "remote OST with nodsh"
4816 local ost_name=$(ostname_from_index $ost_idx)
4817 local old_status=$(ost_dev_status $ost_idx)
4819 [[ -z "$old_status" ]] ||
4820 skip_env "OST $ost_name is in $old_status status"
4822 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4825 local new_status=$(ost_dev_status $ost_idx)
4827 [[ "$new_status" = "D" ]] ||
4828 error "OST $ost_name is in status of '$new_status', not 'D'"
4830 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4833 new_status=$(ost_dev_status $ost_idx)
4834 [[ -z "$new_status" ]] ||
4835 error "OST $ost_name is in status of '$new_status', not ''"
4837 run_test 56c "check 'lfs df' showing device status"
4842 local local_tdir="$1"
4843 local local_numfiles="$2"
4844 local local_numdirs="$3"
4845 local dir_params="$4"
4846 local dir_stripe_params="$5"
4848 if [ ! -d "$local_tdir" ] ; then
4849 test_mkdir -p $dir_stripe_params $local_tdir
4850 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4851 for i in $(seq $local_numfiles) ; do
4852 touch $local_tdir/file$i
4854 for i in $(seq $local_numdirs) ; do
4855 test_mkdir $dir_stripe_params $local_tdir/dir$i
4856 for j in $(seq $local_numfiles) ; do
4857 touch $local_tdir/dir$i/file$j
4863 setup_56_special() {
4865 local local_numfiles=$2
4866 local local_numdirs=$3
4868 setup_56 $local_tdir $local_numfiles $local_numdirs
4870 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4871 for i in $(seq $local_numfiles) ; do
4872 mknod $local_tdir/loop${i}b b 7 $i
4873 mknod $local_tdir/null${i}c c 1 3
4874 ln -s $local_tdir/file1 $local_tdir/link${i}
4876 for i in $(seq $local_numdirs) ; do
4877 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4878 mknod $local_tdir/dir$i/null${i}c c 1 3
4879 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4885 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4886 local expected=$(($NUMDIRS + 2))
4888 setup_56 $dir $NUMFILES $NUMDIRS
4890 # test lfs find with -name
4891 for i in $(seq $NUMFILES) ; do
4892 local nums=$($LFS find -name "*$i" $dir | wc -l)
4894 [ $nums -eq $expected ] ||
4895 error "lfs find -name '*$i' $dir wrong: "\
4896 "found $nums, expected $expected"
4899 run_test 56g "check lfs find -name"
4902 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4903 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4905 setup_56 $dir $NUMFILES $NUMDIRS
4907 # test lfs find with ! -name
4908 for i in $(seq $NUMFILES) ; do
4909 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
4911 [ $nums -eq $expected ] ||
4912 error "lfs find ! -name '*$i' $dir wrong: "\
4913 "found $nums, expected $expected"
4916 run_test 56h "check lfs find ! -name"
4919 local dir=$DIR/$tdir
4923 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
4926 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
4928 run_test 56i "check 'lfs find -ost UUID' skips directories"
4931 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4933 setup_56_special $dir $NUMFILES $NUMDIRS
4935 local expected=$((NUMDIRS + 1))
4936 local cmd="$LFS find -type d $dir"
4937 local nums=$($cmd | wc -l)
4939 [ $nums -eq $expected ] ||
4940 error "'$cmd' wrong: found $nums, expected $expected"
4942 run_test 56j "check lfs find -type d"
4945 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4947 setup_56_special $dir $NUMFILES $NUMDIRS
4949 local expected=$(((NUMDIRS + 1) * NUMFILES))
4950 local cmd="$LFS find -type f $dir"
4951 local nums=$($cmd | wc -l)
4953 [ $nums -eq $expected ] ||
4954 error "'$cmd' wrong: found $nums, expected $expected"
4956 run_test 56k "check lfs find -type f"
4959 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4961 setup_56_special $dir $NUMFILES $NUMDIRS
4963 local expected=$((NUMDIRS + NUMFILES))
4964 local cmd="$LFS find -type b $dir"
4965 local nums=$($cmd | wc -l)
4967 [ $nums -eq $expected ] ||
4968 error "'$cmd' wrong: found $nums, expected $expected"
4970 run_test 56l "check lfs find -type b"
4973 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4975 setup_56_special $dir $NUMFILES $NUMDIRS
4977 local expected=$((NUMDIRS + NUMFILES))
4978 local cmd="$LFS find -type c $dir"
4979 local nums=$($cmd | wc -l)
4980 [ $nums -eq $expected ] ||
4981 error "'$cmd' wrong: found $nums, expected $expected"
4983 run_test 56m "check lfs find -type c"
4986 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4987 setup_56_special $dir $NUMFILES $NUMDIRS
4989 local expected=$((NUMDIRS + NUMFILES))
4990 local cmd="$LFS find -type l $dir"
4991 local nums=$($cmd | wc -l)
4993 [ $nums -eq $expected ] ||
4994 error "'$cmd' wrong: found $nums, expected $expected"
4996 run_test 56n "check lfs find -type l"
4999 local dir=$DIR/$tdir
5001 setup_56 $dir $NUMFILES $NUMDIRS
5002 utime $dir/file1 > /dev/null || error "utime (1)"
5003 utime $dir/file2 > /dev/null || error "utime (2)"
5004 utime $dir/dir1 > /dev/null || error "utime (3)"
5005 utime $dir/dir2 > /dev/null || error "utime (4)"
5006 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5007 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5010 local nums=$($LFS find -mtime +0 $dir | wc -l)
5012 [ $nums -eq $expected ] ||
5013 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5016 cmd="$LFS find -mtime 0 $dir"
5017 nums=$($cmd | wc -l)
5018 [ $nums -eq $expected ] ||
5019 error "'$cmd' wrong: found $nums, expected $expected"
5021 run_test 56o "check lfs find -mtime for old files"
5024 [ $RUNAS_ID -eq $UID ] &&
5025 skip_env "RUNAS_ID = UID = $UID -- skipping"
5027 local dir=$DIR/$tdir
5029 setup_56 $dir $NUMFILES $NUMDIRS
5030 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5032 local expected=$NUMFILES
5033 local cmd="$LFS find -uid $RUNAS_ID $dir"
5034 local nums=$($cmd | wc -l)
5036 [ $nums -eq $expected ] ||
5037 error "'$cmd' wrong: found $nums, expected $expected"
5039 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5040 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5041 nums=$($cmd | wc -l)
5042 [ $nums -eq $expected ] ||
5043 error "'$cmd' wrong: found $nums, expected $expected"
5045 run_test 56p "check lfs find -uid and ! -uid"
5048 [ $RUNAS_ID -eq $UID ] &&
5049 skip_env "RUNAS_ID = UID = $UID -- skipping"
5051 local dir=$DIR/$tdir
5053 setup_56 $dir $NUMFILES $NUMDIRS
5054 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5056 local expected=$NUMFILES
5057 local cmd="$LFS find -gid $RUNAS_GID $dir"
5058 local nums=$($cmd | wc -l)
5060 [ $nums -eq $expected ] ||
5061 error "'$cmd' wrong: found $nums, expected $expected"
5063 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5064 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5065 nums=$($cmd | wc -l)
5066 [ $nums -eq $expected ] ||
5067 error "'$cmd' wrong: found $nums, expected $expected"
5069 run_test 56q "check lfs find -gid and ! -gid"
5072 local dir=$DIR/$tdir
5074 setup_56 $dir $NUMFILES $NUMDIRS
5077 local cmd="$LFS find -size 0 -type f $dir"
5078 local nums=$($cmd | wc -l)
5080 [ $nums -eq $expected ] ||
5081 error "'$cmd' wrong: found $nums, expected $expected"
5083 cmd="$LFS find ! -size 0 -type f $dir"
5084 nums=$($cmd | wc -l)
5085 [ $nums -eq $expected ] ||
5086 error "'$cmd' wrong: found $nums, expected $expected"
5087 echo "test" > $dir/$tfile
5088 echo "test2" > $dir/$tfile.2 && sync
5090 cmd="$LFS find -size 5 -type f $dir"
5091 nums=$($cmd | wc -l)
5092 [ $nums -eq $expected ] ||
5093 error "'$cmd' wrong: found $nums, expected $expected"
5095 cmd="$LFS find -size +5 -type f $dir"
5096 nums=$($cmd | wc -l)
5097 [ $nums -eq $expected ] ||
5098 error "'$cmd' wrong: found $nums, expected $expected"
5100 cmd="$LFS find -size +0 -type f $dir"
5101 nums=$($cmd | wc -l)
5102 [ $nums -eq $expected ] ||
5103 error "'$cmd' wrong: found $nums, expected $expected"
5105 cmd="$LFS find ! -size -5 -type f $dir"
5106 nums=$($cmd | wc -l)
5107 [ $nums -eq $expected ] ||
5108 error "'$cmd' wrong: found $nums, expected $expected"
5110 cmd="$LFS find -size -5 -type f $dir"
5111 nums=$($cmd | wc -l)
5112 [ $nums -eq $expected ] ||
5113 error "'$cmd' wrong: found $nums, expected $expected"
5115 run_test 56r "check lfs find -size works"
5117 test_56s() { # LU-611 #LU-9369
5118 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5120 local dir=$DIR/$tdir
5121 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5123 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5124 for i in $(seq $NUMDIRS); do
5125 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5128 local expected=$NUMDIRS
5129 local cmd="$LFS find -c $OSTCOUNT $dir"
5130 local nums=$($cmd | wc -l)
5132 [ $nums -eq $expected ] || {
5133 $LFS getstripe -R $dir
5134 error "'$cmd' wrong: found $nums, expected $expected"
5137 expected=$((NUMDIRS + onestripe))
5138 cmd="$LFS find -stripe-count +0 -type f $dir"
5139 nums=$($cmd | wc -l)
5140 [ $nums -eq $expected ] || {
5141 $LFS getstripe -R $dir
5142 error "'$cmd' wrong: found $nums, expected $expected"
5146 cmd="$LFS find -stripe-count 1 -type f $dir"
5147 nums=$($cmd | wc -l)
5148 [ $nums -eq $expected ] || {
5149 $LFS getstripe -R $dir
5150 error "'$cmd' wrong: found $nums, expected $expected"
5153 cmd="$LFS find -stripe-count -2 -type f $dir"
5154 nums=$($cmd | wc -l)
5155 [ $nums -eq $expected ] || {
5156 $LFS getstripe -R $dir
5157 error "'$cmd' wrong: found $nums, expected $expected"
5161 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5162 nums=$($cmd | wc -l)
5163 [ $nums -eq $expected ] || {
5164 $LFS getstripe -R $dir
5165 error "'$cmd' wrong: found $nums, expected $expected"
5168 run_test 56s "check lfs find -stripe-count works"
5170 test_56t() { # LU-611 #LU-9369
5171 local dir=$DIR/$tdir
5173 setup_56 $dir 0 $NUMDIRS
5174 for i in $(seq $NUMDIRS); do
5175 $LFS setstripe -S 8M $dir/dir$i/$tfile
5178 local expected=$NUMDIRS
5179 local cmd="$LFS find -S 8M $dir"
5180 local nums=$($cmd | wc -l)
5182 [ $nums -eq $expected ] || {
5183 $LFS getstripe -R $dir
5184 error "'$cmd' wrong: found $nums, expected $expected"
5188 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5190 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5192 expected=$(((NUMDIRS + 1) * NUMFILES))
5193 cmd="$LFS find -stripe-size 512k -type f $dir"
5194 nums=$($cmd | wc -l)
5195 [ $nums -eq $expected ] ||
5196 error "'$cmd' wrong: found $nums, expected $expected"
5198 cmd="$LFS find -stripe-size +320k -type f $dir"
5199 nums=$($cmd | wc -l)
5200 [ $nums -eq $expected ] ||
5201 error "'$cmd' wrong: found $nums, expected $expected"
5203 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5204 cmd="$LFS find -stripe-size +200k -type f $dir"
5205 nums=$($cmd | wc -l)
5206 [ $nums -eq $expected ] ||
5207 error "'$cmd' wrong: found $nums, expected $expected"
5209 cmd="$LFS find -stripe-size -640k -type f $dir"
5210 nums=$($cmd | wc -l)
5211 [ $nums -eq $expected ] ||
5212 error "'$cmd' wrong: found $nums, expected $expected"
5215 cmd="$LFS find -stripe-size 256k -type f $dir"
5216 nums=$($cmd | wc -l)
5217 [ $nums -eq $expected ] ||
5218 error "'$cmd' wrong: found $nums, expected $expected"
5220 cmd="$LFS find -stripe-size -320k -type f $dir"
5221 nums=$($cmd | wc -l)
5222 [ $nums -eq $expected ] ||
5223 error "'$cmd' wrong: found $nums, expected $expected"
5226 cmd="$LFS find -stripe-size 1024k -type f $dir"
5227 nums=$($cmd | wc -l)
5228 [ $nums -eq $expected ] ||
5229 error "'$cmd' wrong: found $nums, expected $expected"
5231 run_test 56t "check lfs find -stripe-size works"
5233 test_56u() { # LU-611
5234 local dir=$DIR/$tdir
5236 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5238 if [[ $OSTCOUNT -gt 1 ]]; then
5239 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5245 local expected=$(((NUMDIRS + 1) * NUMFILES))
5246 local cmd="$LFS find -stripe-index 0 -type f $dir"
5247 local nums=$($cmd | wc -l)
5249 [ $nums -eq $expected ] ||
5250 error "'$cmd' wrong: found $nums, expected $expected"
5253 cmd="$LFS find -stripe-index 1 -type f $dir"
5254 nums=$($cmd | wc -l)
5255 [ $nums -eq $expected ] ||
5256 error "'$cmd' wrong: found $nums, expected $expected"
5258 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5259 nums=$($cmd | wc -l)
5260 [ $nums -eq $expected ] ||
5261 error "'$cmd' wrong: found $nums, expected $expected"
5264 # This should produce an error and not return any files
5265 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5266 nums=$($cmd 2>/dev/null | wc -l)
5267 [ $nums -eq $expected ] ||
5268 error "'$cmd' wrong: found $nums, expected $expected"
5270 if [[ $OSTCOUNT -gt 1 ]]; then
5271 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5272 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5273 nums=$($cmd | wc -l)
5274 [ $nums -eq $expected ] ||
5275 error "'$cmd' wrong: found $nums, expected $expected"
5278 run_test 56u "check lfs find -stripe-index works"
5282 local dir=$DIR/$tdir
5284 setup_56 $dir $NUMFILES $NUMDIRS
5286 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5287 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5289 for file in $($LFS find -m $UUID $dir); do
5290 file_midx=$($LFS getstripe -m $file)
5291 [ $file_midx -eq $mdt_idx ] ||
5292 error "lfs find -m $UUID != getstripe -m $file_midx"
5295 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5298 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5301 local dir=$DIR/$tdir
5303 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5305 local stripe_size=$($LFS getstripe -S -d $dir) ||
5306 error "$LFS getstripe -S -d $dir failed"
5307 stripe_size=${stripe_size%% *}
5309 local file_size=$((stripe_size * OSTCOUNT))
5310 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5311 local required_space=$((file_num * file_size))
5312 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5314 [[ $free_space -le $((required_space / 1024)) ]] &&
5315 skip_env "need $required_space, have $free_space kbytes"
5318 local dd_count=$((file_size / dd_bs))
5320 # write data into the files
5325 for i in $(seq $NUMFILES); do
5327 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5328 error "write data into $file failed"
5330 for i in $(seq $NUMDIRS); do
5331 for j in $(seq $NUMFILES); do
5332 file=$dir/dir$i/file$j
5333 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5334 error "write data into $file failed"
5338 # $LFS_MIGRATE will fail if hard link migration is unsupported
5339 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5340 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5341 error "creating links to $dir/dir1/file1 failed"
5346 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5349 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5352 eval $cmd || error "$cmd failed"
5354 check_stripe_count $dir/file1 $expected
5356 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5358 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5359 # OST 1 if it is on OST 0. This file is small enough to
5360 # be on only one stripe.
5361 file=$dir/migr_1_ost
5362 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5363 error "write data into $file failed"
5364 local obdidx=$($LFS getstripe -i $file)
5365 local oldmd5=$(md5sum $file)
5368 [[ $obdidx -eq 0 ]] && newobdidx=1
5369 cmd="$LFS migrate -i $newobdidx $file"
5371 eval $cmd || error "$cmd failed"
5373 local realobdix=$($LFS getstripe -i $file)
5374 local newmd5=$(md5sum $file)
5376 [[ $newobdidx -ne $realobdix ]] &&
5377 error "new OST is different (was=$obdidx, "\
5378 "wanted=$newobdidx, got=$realobdix)"
5379 [[ "$oldmd5" != "$newmd5" ]] &&
5380 error "md5sum differ: $oldmd5, $newmd5"
5384 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5386 eval $cmd || error "$cmd failed"
5388 for j in $(seq $NUMFILES); do
5389 check_stripe_count $dir/dir1/file$j $expected
5392 # lfs_migrate works with lfs find
5393 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5394 $LFS_MIGRATE -y -c $expected"
5396 eval $cmd || error "$cmd failed"
5398 for i in $(seq 2 $NUMFILES); do
5399 check_stripe_count $dir/file$i $expected
5401 for i in $(seq 2 $NUMDIRS); do
5402 for j in $(seq $NUMFILES); do
5403 check_stripe_count $dir/dir$i/file$j $expected
5407 run_test 56w "check lfs_migrate -c stripe_count works"
5410 local file1=$DIR/$tdir/file1
5411 local create_pool=false
5412 local initial_pool=$($LFS getstripe -p $DIR)
5416 echo -n "Creating test dir..."
5417 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5420 echo -n "Creating test file..."
5421 touch $file1 || error "cannot create file"
5424 echo -n "Detecting existing pools..."
5425 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5427 if [ ${#pool_list[@]} -gt 0 ]; then
5428 echo "${pool_list[@]}"
5429 for thispool in "${pool_list[@]}"; do
5430 if [[ -z "$initial_pool" ||
5431 "$initial_pool" != "$thispool" ]]; then
5433 echo "Using existing pool '$pool'"
5438 echo "none detected."
5440 if [ -z "$pool" ]; then
5441 pool=${POOL:-testpool}
5442 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5443 echo -n "Creating pool '$pool'..."
5445 pool_add $pool &> /dev/null ||
5446 error "pool_add failed"
5449 echo -n "Adding target to pool..."
5450 pool_add_targets $pool 0 0 1 &> /dev/null ||
5451 error "pool_add_targets failed"
5455 echo -n "Setting pool using -p option..."
5456 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5457 error "migrate failed rc = $?"
5460 echo -n "Verifying test file is in pool after migrating..."
5461 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5462 error "file was not migrated to pool $pool"
5465 echo -n "Removing test file from pool '$pool'..."
5466 $LFS migrate $file1 &> /dev/null ||
5467 error "cannot remove from pool"
5468 [ "$($LFS getstripe -p $file1)" ] &&
5469 error "pool still set"
5472 echo -n "Setting pool using --pool option..."
5473 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5474 error "migrate failed rc = $?"
5479 if $create_pool; then
5480 destroy_test_pools 2> /dev/null ||
5481 error "destroy test pools failed"
5484 run_test 56wb "check lfs_migrate pool support"
5487 local file1="$DIR/$tdir/file 1"
5489 echo -n "Creating test dir..."
5490 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5491 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5492 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5493 error "cannot set stripe"
5496 echo -n "Setting initial stripe for test file..."
5497 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5498 error "cannot set stripe"
5499 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5500 error "stripe size not set"
5503 # File currently set to -S 512K -c 1
5505 # Ensure -c and -S options are rejected when -R is set
5506 echo -n "Verifying incompatible options are detected..."
5507 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5508 error "incompatible -c and -R options not detected"
5509 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5510 error "incompatible -S and -R options not detected"
5513 # Ensure unrecognized options are passed through to 'lfs migrate'
5514 echo -n "Verifying -S option is passed through to lfs migrate..."
5515 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5516 error "migration failed"
5517 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5518 error "file was not restriped"
5521 # File currently set to -S 1M -c 1
5523 # Ensure long options are supported
5524 echo -n "Verifying long options supported..."
5525 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5526 error "long option without argument not supported"
5527 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5528 error "long option with argument not supported"
5529 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5530 error "file not restriped with --stripe-size option"
5533 # File currently set to -S 512K -c 1
5535 if [ "$OSTCOUNT" -gt 1 ]; then
5536 echo -n "Verifying explicit stripe count can be set..."
5537 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5538 error "migrate failed"
5539 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5540 error "file not restriped to explicit count"
5544 # File currently set to -S 512K -c 1 or -S 512K -c 2
5546 # Ensure parent striping is used if -R is set, and no stripe
5547 # count or size is specified
5548 echo -n "Setting stripe for parent directory..."
5549 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5550 error "cannot set stripe"
5553 echo -n "Verifying restripe option uses parent stripe settings..."
5554 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5555 error "migrate failed"
5556 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
5557 error "file not restriped to parent settings"
5558 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5559 error "file not restriped to parent settings"
5562 # File currently set to -S 1M -c 1
5564 # Ensure striping is preserved if -R is not set, and no stripe
5565 # count or size is specified
5566 echo -n "Verifying striping size preserved when not specified..."
5567 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
5568 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5569 error "cannot set stripe on parent directory"
5570 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5571 error "migrate failed"
5572 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
5573 error "file was restriped"
5576 # Ensure file name properly detected when final option has no argument
5577 echo -n "Verifying file name properly detected..."
5578 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5579 error "file name interpreted as option argument"
5585 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5588 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5590 local file1=$DIR/$tdir/file1
5592 echo -n "Creating test dir..."
5593 test_mkdir $DIR/$tdir || error "cannot create dir"
5596 echo -n "Creating test file..."
5600 # Ensure 'lfs migrate' will fail by using a non-existent option,
5601 # and make sure rsync is not called to recover
5602 echo -n "Make sure --no-rsync option works..."
5603 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5604 grep -q 'refusing to fall back to rsync' ||
5605 error "rsync was called with --no-rsync set"
5608 # Ensure rsync is called without trying 'lfs migrate' first
5609 echo -n "Make sure --rsync option works..."
5610 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5611 grep -q 'falling back to rsync' &&
5612 error "lfs migrate was called with --rsync set"
5615 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5616 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5617 grep -q 'at the same time' ||
5618 error "--rsync and --no-rsync accepted concurrently"
5624 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5627 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5628 check_swap_layouts_support
5630 local dir=$DIR/$tdir
5631 local ref1=/etc/passwd
5632 local file1=$dir/file1
5634 test_mkdir $dir || error "creating dir $dir"
5635 $LFS setstripe -c 2 $file1
5637 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5638 stripe=$($LFS getstripe -c $file1)
5639 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5640 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5645 run_test 56x "lfs migration support"
5648 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5649 check_swap_layouts_support
5651 local dir=$DIR/$tdir/$testnum
5655 local ref1=/etc/passwd
5656 local file1=$dir/file1
5658 $LFS setstripe -c 2 $file1
5660 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5662 local stripe=$($LFS getstripe -c $file1)
5664 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5665 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5670 run_test 56xa "lfs migration --block support"
5672 check_migrate_links() {
5674 local file1="$dir/file1"
5677 local total_count=$(($begin + $count - 1))
5678 local symlink_count=10
5681 if [ ! -f "$file1" ]; then
5682 echo -n "creating initial file..."
5683 $LFS setstripe -c 1 -S "512k" "$file1" ||
5684 error "cannot setstripe initial file"
5687 echo -n "creating symlinks..."
5688 for s in $(seq 1 $symlink_count); do
5689 ln -s "$file1" "$dir/slink$s" ||
5690 error "cannot create symlinks"
5694 echo -n "creating nonlinked files..."
5695 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5696 error "cannot create nonlinked files"
5701 if [ ! -f "$dir/file$total_count" ]; then
5702 echo -n "creating hard links $begin:$total_count..."
5703 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5704 /dev/null || error "cannot create hard links"
5708 echo -n "checking number of hard links listed in xattrs..."
5709 local fid=$($LFS getstripe -F "$file1")
5710 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5713 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5714 skip "hard link list has unexpected size, skipping test"
5716 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5717 error "link names should exceed xattrs size"
5720 echo -n "migrating files..."
5721 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5723 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5726 # make sure all links have been properly migrated
5727 echo -n "verifying files..."
5728 fid=$($LFS getstripe -F "$file1") ||
5729 error "cannot get fid for file $file1"
5730 for i in $(seq 2 $total_count); do
5731 local fid2=$($LFS getstripe -F $dir/file$i)
5733 [ "$fid2" == "$fid" ] ||
5734 error "migrated hard link has mismatched FID"
5737 # make sure hard links were properly detected, and migration was
5738 # performed only once for the entire link set; nonlinked files should
5740 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5741 local expected=$(($uniq_count + 1))
5743 [ "$actual" -eq "$expected" ] ||
5744 error "hard links individually migrated ($actual != $expected)"
5746 # make sure the correct number of hard links are present
5747 local hardlinks=$(stat -c '%h' "$file1")
5749 [ $hardlinks -eq $total_count ] ||
5750 error "num hard links $hardlinks != $total_count"
5757 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
5758 skip "Need MDS version at least 2.10.55"
5760 local dir="$DIR/$tdir"
5762 test_mkdir "$dir" || error "cannot create dir $dir"
5764 echo "testing lfs migrate mode when all links fit within xattrs"
5765 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
5767 echo "testing rsync mode when all links fit within xattrs"
5768 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
5770 echo "testing lfs migrate mode when all links do not fit within xattrs"
5771 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
5773 echo "testing rsync mode when all links do not fit within xattrs"
5774 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
5779 run_test 56xb "lfs migration hard link support"
5782 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5783 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
5786 local dir=$DIR/$tdir
5790 test_mkdir -p $dir || error "creating dir $dir"
5791 touch $f1 || error "creating std file $f1"
5792 $MULTIOP $f2 H2c || error "creating released file $f2"
5794 # a directory can be raid0, so ask only for files
5795 res=$($LFS find $dir -L raid0 -type f | wc -l)
5796 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5798 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5799 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5801 # only files can be released, so no need to force file search
5802 res=$($LFS find $dir -L released)
5803 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5805 res=$($LFS find $dir -type f \! -L released)
5806 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5808 run_test 56y "lfs find -L raid0|released"
5810 test_56z() { # LU-4824
5811 # This checks to make sure 'lfs find' continues after errors
5812 # There are two classes of errors that should be caught:
5813 # - If multiple paths are provided, all should be searched even if one
5815 # - If errors are encountered during the search, it should not terminate
5817 local dir=$DIR/$tdir
5821 for i in d{0..9}; do
5824 touch $dir/d{0..9}/$tfile
5825 $LFS find $DIR/non_existent_dir $dir &&
5826 error "$LFS find did not return an error"
5827 # Make a directory unsearchable. This should NOT be the last entry in
5828 # directory order. Arbitrarily pick the 6th entry
5829 chmod 700 $($LFS find $dir -type d | sed '6!d')
5831 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5833 # The user should be able to see 10 directories and 9 files
5834 [ $count == 19 ] || error "$LFS find did not continue after error"
5836 run_test 56z "lfs find should continue after an error"
5838 test_56aa() { # LU-5937
5839 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
5841 local dir=$DIR/$tdir
5844 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5846 createmany -o $dir/striped_dir/${tfile}- 1024
5847 local dirs=$($LFS find --size +8k $dir/)
5849 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5851 run_test 56aa "lfs find --size under striped dir"
5853 test_56ab() { # LU-10705
5854 test_mkdir $DIR/$tdir
5855 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
5856 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
5857 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
5858 # Flush writes to ensure valid blocks. Need to be more thorough for
5859 # ZFS, since blocks are not allocated/returned to client immediately.
5861 wait_zfs_commit ost1 2
5862 cancel_lru_locks osc
5865 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
5867 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
5869 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
5870 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
5872 rm -f $DIR/$tdir/$tfile.[123]
5874 run_test 56ab "lfs find --blocks"
5877 # Create composite files with one component
5878 local dir=$DIR/$tdir
5880 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
5881 # Create composite files with three components
5882 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
5883 # Create non-composite files
5884 createmany -o $dir/${tfile}- 10
5886 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
5888 [[ $nfiles == 10 ]] ||
5889 error "lfs find -E 1M found $nfiles != 10 files"
5891 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
5892 [[ $nfiles == 25 ]] ||
5893 error "lfs find ! -E 1M found $nfiles != 25 files"
5895 # All files have a component that starts at 0
5896 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
5897 [[ $nfiles == 35 ]] ||
5898 error "lfs find --component-start 0 - $nfiles != 35 files"
5900 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
5901 [[ $nfiles == 15 ]] ||
5902 error "lfs find --component-start 2M - $nfiles != 15 files"
5904 # All files created here have a componenet that does not starts at 2M
5905 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
5906 [[ $nfiles == 35 ]] ||
5907 error "lfs find ! --component-start 2M - $nfiles != 35 files"
5909 # Find files with a specified number of components
5910 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
5911 [[ $nfiles == 15 ]] ||
5912 error "lfs find --component-count 3 - $nfiles != 15 files"
5914 # Remember non-composite files have a component count of zero
5915 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
5916 [[ $nfiles == 10 ]] ||
5917 error "lfs find --component-count 0 - $nfiles != 10 files"
5919 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
5920 [[ $nfiles == 20 ]] ||
5921 error "lfs find ! --component-count 3 - $nfiles != 20 files"
5923 # All files have a flag called "init"
5924 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
5925 [[ $nfiles == 35 ]] ||
5926 error "lfs find --component-flags init - $nfiles != 35 files"
5928 # Multi-component files will have a component not initialized
5929 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
5930 [[ $nfiles == 15 ]] ||
5931 error "lfs find !--component-flags init - $nfiles != 15 files"
5936 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
5939 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
5940 skip "Need MDS version at least 2.10.57"
5950 # create mirrored directories and mirrored files
5951 mkdir $td || error "mkdir $td failed"
5952 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
5953 createmany -o $tf- 10 || error "create $tf- failed"
5955 for i in $(seq 2); do
5957 mkdir $dir || error "mkdir $dir failed"
5958 $LFS mirror create -N$((3 + i)) $dir ||
5959 error "create mirrored dir $dir failed"
5960 createmany -o $dir/$tfile- 10 ||
5961 error "create $dir/$tfile- failed"
5964 # change the states of some mirrored files
5966 for i in $(seq 2); do
5968 for j in $(seq 4 9); do
5969 echo foo > $dir/$tfile-$j
5973 # find mirrored files with specific mirror count
5974 cmd="$LFS find --mirror-count 3 --type f $td"
5975 nfiles=$($cmd | wc -l)
5976 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
5978 cmd="$LFS find ! --mirror-count 3 --type f $td"
5979 nfiles=$($cmd | wc -l)
5980 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
5982 cmd="$LFS find --mirror-count +2 --type f $td"
5983 nfiles=$($cmd | wc -l)
5984 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5986 cmd="$LFS find --mirror-count -6 --type f $td"
5987 nfiles=$($cmd | wc -l)
5988 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5990 # find mirrored files with specific file state
5991 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
5992 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
5994 cmd="$LFS find --mirror-state=ro --type f $td"
5995 nfiles=$($cmd | wc -l)
5996 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
5998 cmd="$LFS find ! --mirror-state=ro --type f $td"
5999 nfiles=$($cmd | wc -l)
6000 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6002 cmd="$LFS find --mirror-state=wp --type f $td"
6003 nfiles=$($cmd | wc -l)
6004 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6006 cmd="$LFS find ! --mirror-state=sp --type f $td"
6007 nfiles=$($cmd | wc -l)
6008 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6010 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6014 # note test will not do anything if MDS is not local
6015 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
6016 skip_env "ldiskfs only test"
6018 remote_mds_nodsh && skip "remote MDS with nodsh"
6020 local MNTDEV="osd*.*MDT*.mntdev"
6021 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6022 [ -z "$DEV" ] && error "can't access $MNTDEV"
6023 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6024 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6025 error "can't access $DEV"
6026 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6027 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6031 run_test 57a "verify MDS filesystem created with large inodes =="
6034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6035 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
6036 skip_env "ldiskfs only test"
6038 remote_mds_nodsh && skip "remote MDS with nodsh"
6040 local dir=$DIR/$tdir
6043 local fileN=$dir/f$filecount
6045 rm -rf $dir || error "removing $dir"
6047 local mdtidx=$($LFS getstripe -m $dir)
6048 local mdtname=MDT$(printf %04x $mdtidx)
6049 local facet=mds$((mdtidx + 1))
6051 echo "mcreating $filecount files"
6052 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6054 # verify that files do not have EAs yet
6055 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6056 error "$file1 has an EA"
6057 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6058 error "$fileN has an EA"
6062 df $dir #make sure we get new statfs data
6063 local mdsfree=$(do_facet $facet \
6064 lctl get_param -n osd*.*$mdtname.kbytesfree)
6065 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6068 echo "opening files to create objects/EAs"
6069 for file in $(seq -f $dir/f%g 1 $filecount); do
6070 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6071 error "opening $file"
6074 # verify that files have EAs now
6075 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6076 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6078 sleep 1 #make sure we get new statfs data
6080 local mdsfree2=$(do_facet $facet \
6081 lctl get_param -n osd*.*$mdtname.kbytesfree)
6082 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6084 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6085 if [ "$mdsfree" != "$mdsfree2" ]; then
6086 error "MDC before $mdcfree != after $mdcfree2"
6088 echo "MDC before $mdcfree != after $mdcfree2"
6089 echo "unable to confirm if MDS has large inodes"
6094 run_test 57b "default LOV EAs are stored inside large inodes ==="
6097 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6098 [ -z "$(which wiretest 2>/dev/null)" ] &&
6099 skip_env "could not find wiretest"
6103 run_test 58 "verify cross-platform wire constants =============="
6106 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6108 echo "touch 130 files"
6109 createmany -o $DIR/f59- 130
6111 unlinkmany $DIR/f59- 130
6113 # wait for commitment of removal
6114 wait_delete_completed
6116 run_test 59 "verify cancellation of llog records async ========="
6118 TEST60_HEAD="test_60 run $RANDOM"
6120 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6121 remote_mgs_nodsh && skip "remote MGS with nodsh"
6122 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6123 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6124 skip_env "missing subtest run-llog.sh"
6126 log "$TEST60_HEAD - from kernel mode"
6127 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
6128 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6129 do_facet mgs $LCTL dk > $TMP/$tfile
6131 # LU-6388: test llog_reader
6132 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6133 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6134 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6135 skip_env "missing llog_reader"
6136 local fstype=$(facet_fstype mgs)
6137 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6138 skip_env "Only for ldiskfs or zfs type mgs"
6140 local mntpt=$(facet_mntpt mgs)
6141 local mgsdev=$(mgsdevname 1)
6153 #get fid and record list
6154 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6156 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6158 #remount mgs as ldiskfs or zfs type
6159 stop mgs || error "stop mgs failed"
6160 mount_fstype mgs || error "remount mgs failed"
6161 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6164 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6165 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6170 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6172 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6174 echo "obj_file is $obj_file"
6175 do_facet mgs $llog_reader $obj_file
6177 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6178 awk '{ print $3 }' | sed -e "s/^type=//g")
6179 if [ $rec_type != $rec ]; then
6180 echo "FAILED test_60a wrong record type $rec_type," \
6186 #check obj path if record type is LLOG_LOGID_MAGIC
6187 if [ "$rec" == "1064553b" ]; then
6188 path=$(do_facet mgs $llog_reader $obj_file |
6189 grep "path=" | awk '{ print $NF }' |
6190 sed -e "s/^path=//g")
6191 if [ $obj_file != $mntpt/$path ]; then
6192 echo "FAILED test_60a wrong obj path" \
6193 "$montpt/$path, should be $obj_file"
6200 #restart mgs before "error", otherwise it will block the next test
6201 stop mgs || error "stop mgs failed"
6202 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6203 $pass || error "test failed, see FAILED test_60a messages for specifics"
6205 run_test 60a "llog_test run from kernel module and test llog_reader"
6208 remote_mgs_nodsh && skip "remote MGS with nodsh"
6210 # test old logid format
6211 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
6212 do_facet mgs $LCTL dl | grep MGS
6213 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
6214 error "old llog_print failed"
6217 # test new logid format
6218 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
6219 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
6220 error "new llog_print failed"
6223 run_test 60aa "llog_print works with FIDs and simple names"
6226 # test llog_print with params
6228 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.51) ]] ||
6229 skip "Need server version greater than 2.11.51"
6234 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
6235 do_facet mgs $LCTL set_param -P jobid_name="testname"
6237 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
6238 grep jobid_name | tail -n 1)
6240 local param=`awk '{ print $10 }' <<< "$yaml"`
6241 local val=`awk '{ print $12 }' <<< "$yaml"`
6242 #return to the default
6243 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
6244 [ $val = "testname" ] || error "bad value: $val"
6245 [ $param = "jobid_name," ] || error "Bad param: $param"
6247 run_test 60ab "llog_print params output values from set_param -P"
6249 test_60b() { # bug 6411
6250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6253 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6265 [[ $LLOG_COUNT -gt 100 ]] &&
6266 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6268 run_test 60b "limit repeated messages from CERROR/CWARN ========"
6271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6273 echo "create 5000 files"
6274 createmany -o $DIR/f60c- 5000
6275 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6276 lctl set_param fail_loc=0x80000137
6277 unlinkmany $DIR/f60c- 5000
6278 lctl set_param fail_loc=0
6280 run_test 60c "unlink file when mds full"
6283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6285 SAVEPRINTK=$(lctl get_param -n printk)
6286 # verify "lctl mark" is even working"
6287 MESSAGE="test message ID $RANDOM $$"
6288 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6289 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6291 lctl set_param printk=0 || error "set lnet.printk failed"
6292 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6293 MESSAGE="new test message ID $RANDOM $$"
6294 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6295 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6296 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6298 lctl set_param -n printk="$SAVEPRINTK"
6300 run_test 60d "test printk console message masking"
6303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6304 remote_mds_nodsh && skip "remote MDS with nodsh"
6307 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6308 do_facet mds1 lctl set_param fail_loc=0x15b
6311 run_test 60e "no space while new llog is being created"
6314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6317 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
6318 cancel_lru_locks osc
6319 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6322 run_test 61 "mmap() writes don't make sync hang ================"
6324 # bug 2330 - insufficient obd_match error checking causes LBUG
6326 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6330 cancel_lru_locks osc
6331 lctl set_param fail_loc=0x405
6332 cat $f && error "cat succeeded, expect -EIO"
6333 lctl set_param fail_loc=0
6335 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6336 # match every page all of the time.
6337 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6339 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6340 # Though this test is irrelevant anymore, it helped to reveal some
6341 # other grant bugs (LU-4482), let's keep it.
6342 test_63a() { # was test_63
6343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6345 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6347 for i in `seq 10` ; do
6348 dd if=/dev/zero of=$DIR/f63 bs=8k &
6354 rm -f $DIR/f63 || true
6356 run_test 63a "Verify oig_wait interruption does not crash ======="
6358 # bug 2248 - async write errors didn't return to application on sync
6359 # bug 3677 - async write errors left page locked
6361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6364 lctl set_param debug=-1
6366 # ensure we have a grant to do async writes
6367 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6370 sync # sync lest earlier test intercept the fail_loc
6372 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6373 lctl set_param fail_loc=0x80000406
6374 $MULTIOP $DIR/$tfile Owy && \
6375 error "sync didn't return ENOMEM"
6376 sync; sleep 2; sync # do a real sync this time to flush page
6377 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6378 error "locked page left in cache after async error" || true
6381 run_test 63b "async write errors should be returned to fsync ==="
6384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6387 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6389 run_test 64a "verify filter grant calculations (in kernel) ====="
6392 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6394 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6396 run_test 64b "check out-of-space detection on client"
6399 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6401 run_test 64c "verify grant shrink"
6403 # this does exactly what osc_request.c:osc_announce_cached() does in
6404 # order to calculate max amount of grants to ask from server
6408 local page_size=$(get_page_size client)
6410 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6411 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6413 ((rpc_in_flight ++));
6414 nrpages=$((nrpages * rpc_in_flight))
6416 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6418 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
6420 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6421 local undirty=$((nrpages * page_size))
6423 local max_extent_pages
6424 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6425 grep grant_max_extent_size | awk '{print $2}')
6426 max_extent_pages=$((max_extent_pages / page_size))
6427 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6428 local grant_extent_tax
6429 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6430 grep grant_extent_tax | awk '{print $2}')
6432 undirty=$((undirty + nrextents * grant_extent_tax))
6437 # this is size of unit for grant allocation. It should be equal to
6438 # what tgt_grant.c:tgt_grant_chunk() calculates
6442 local grant_extent_tax
6444 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6445 grep max_brw_size | awk '{print $2}')
6447 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6448 grep grant_extent_tax | awk '{print $2}')
6450 echo $(((max_brw_size + grant_extent_tax) * 2))
6454 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
6455 skip "OST < 2.10.55 doesn't limit grants enough"
6457 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6458 local file=$DIR/$tfile
6460 [[ $($LCTL get_param osc.${tgt}.import |
6461 grep "connect_flags:.*grant_param") ]] ||
6462 skip "no grant_param connect flag"
6464 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6466 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6468 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6469 stack_trap "rm -f $file" EXIT
6471 $SETSTRIPE $file -i 0 -c 1
6472 dd if=/dev/zero of=$file bs=1M count=1000 &
6477 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6478 if [[ $cur_grant -gt $max_cur_granted ]]
6481 error "cur_grant $cur_grant > $max_cur_granted"
6484 [[ $? -ne 0 ]] && break;
6489 wait_delete_completed
6490 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6492 run_test 64d "check grant limit exceed"
6494 # bug 1414 - set/get directories' stripe info
6496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6498 test_mkdir $DIR/$tdir
6500 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6502 run_test 65a "directory with no stripe info"
6505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6507 test_mkdir $DIR/$tdir
6508 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6510 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6513 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6515 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6519 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
6521 test_mkdir $DIR/$tdir
6522 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
6524 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6525 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6527 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6529 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6532 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6534 test_mkdir $DIR/$tdir
6535 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
6536 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6538 if [[ $STRIPECOUNT -le 0 ]]; then
6540 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6541 #LOV_MAX_STRIPE_COUNT is 2000
6542 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6544 sc=$(($STRIPECOUNT - 1))
6546 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6547 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6548 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6549 error "lverify failed"
6551 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6556 test_mkdir $DIR/$tdir
6558 $SETSTRIPE $DIR/$tdir || error "setstripe"
6559 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
6560 error "no stripe info failed"
6562 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6564 run_test 65e "directory setstripe defaults"
6567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6569 test_mkdir $DIR/${tdir}f
6570 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
6572 run_test 65f "dir setstripe permission (should return error) ==="
6575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6577 test_mkdir $DIR/$tdir
6578 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6580 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6581 error "setstripe -S failed"
6582 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6583 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6584 error "delete default stripe failed"
6586 run_test 65g "directory setstripe -d"
6589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6591 test_mkdir $DIR/$tdir
6592 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6594 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6595 error "setstripe -S failed"
6596 test_mkdir $DIR/$tdir/dd1
6597 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
6598 error "stripe info inherit failed"
6600 run_test 65h "directory stripe info inherit ===================="
6603 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6605 save_layout_restore_at_exit $MOUNT
6607 # bug6367: set non-default striping on root directory
6608 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
6610 # bug12836: getstripe on -1 default directory striping
6611 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
6613 # bug12836: getstripe -v on -1 default directory striping
6614 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
6616 # bug12836: new find on -1 default directory striping
6617 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6619 run_test 65i "various tests to set root directory striping"
6621 test_65j() { # bug6367
6622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6626 # if we aren't already remounting for each test, do so for this test
6627 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6628 cleanup || error "failed to unmount"
6632 save_layout_restore_at_exit $MOUNT
6634 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6636 run_test 65j "set default striping on root directory (bug 6367)="
6640 wait_delete_completed
6641 do_facet $SINGLEMDS "lctl set_param -n \
6642 osp.$ost*MDT0000.max_create_count=$max_count"
6643 do_facet $SINGLEMDS "lctl set_param -n \
6644 osp.$ost*MDT0000.create_count=$count"
6645 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6646 echo $INACTIVE_OSC "is Activate"
6648 wait_osc_import_state mds ost$ostnum FULL
6651 test_65k() { # bug11679
6652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6653 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6654 remote_mds_nodsh && skip "remote MDS with nodsh"
6656 local disable_precreate=true
6657 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6658 disable_precreate=false
6660 echo "Check OST status: "
6661 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6662 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6664 for OSC in $MDS_OSCS; do
6665 echo $OSC "is active"
6666 do_facet $SINGLEMDS lctl --device %$OSC activate
6669 for INACTIVE_OSC in $MDS_OSCS; do
6670 local ost=$(osc_to_ost $INACTIVE_OSC)
6671 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6672 lov.*md*.target_obd |
6673 awk -F: /$ost/'{ print $1 }' | head -n 1)
6676 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6677 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6679 echo "Deactivate: " $INACTIVE_OSC
6680 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6682 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6683 osp.$ost*MDT0000.create_count")
6684 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6685 osp.$ost*MDT0000.max_create_count")
6686 $disable_precreate &&
6687 do_facet $SINGLEMDS "lctl set_param -n \
6688 osp.$ost*MDT0000.max_create_count=0"
6690 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6691 [ -f $DIR/$tdir/$idx ] && continue
6692 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6693 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6695 error "setstripe $idx should succeed"; }
6696 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6698 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6701 do_facet $SINGLEMDS "lctl set_param -n \
6702 osp.$ost*MDT0000.max_create_count=$max_count"
6703 do_facet $SINGLEMDS "lctl set_param -n \
6704 osp.$ost*MDT0000.create_count=$count"
6705 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6706 echo $INACTIVE_OSC "is Activate"
6708 wait_osc_import_state mds ost$ostnum FULL
6711 run_test 65k "validate manual striping works properly with deactivated OSCs"
6713 test_65l() { # bug 12836
6714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6716 test_mkdir -p $DIR/$tdir/test_dir
6717 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6718 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6720 run_test 65l "lfs find on -1 stripe dir ========================"
6723 local layout=$(save_layout $MOUNT)
6724 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
6725 restore_layout $MOUNT $layout
6726 error "setstripe should fail by non-root users"
6730 run_test 65m "normal user can't set filesystem default stripe"
6732 # bug 2543 - update blocks count on client
6734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6737 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6738 sync; sync_all_data; sync; sync_all_data
6739 cancel_lru_locks osc
6740 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6741 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6743 run_test 66 "update inode blocks count on client ==============="
6746 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6750 swapon -s | awk '($1 == "'$1'") { print $4 }'
6753 # bug5265, obdfilter oa2dentry return -ENOENT
6754 # #define OBD_FAIL_SRV_ENOENT 0x217
6756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6757 remote_ost_nodsh && skip "remote OST with nodsh"
6760 $SETSTRIPE -c 1 -i 0 $f
6762 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6764 do_facet ost1 lctl set_param fail_loc=0x217
6765 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6766 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6768 do_facet ost1 lctl set_param fail_loc=0
6769 $DIRECTIO write $f 0 2 || error "write error"
6771 cancel_lru_locks osc
6772 $DIRECTIO read $f 0 1 || error "read error"
6774 do_facet ost1 lctl set_param fail_loc=0x217
6775 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6777 do_facet ost1 lctl set_param fail_loc=0
6780 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6783 test_mkdir $DIR/$tdir
6784 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6785 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6787 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6789 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6791 [ "$RUNAS_ID" = "$UID" ] &&
6792 skip_env "RUNAS_ID = UID = $UID -- skipping"
6793 # Check that testing environment is properly set up. Skip if not
6794 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
6795 skip_env "User $RUNAS_ID does not exist - skipping"
6798 chmod 777 $DIR/$tfile
6799 chmod ug+s $DIR/$tfile
6800 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6801 error "$RUNAS dd $DIR/$tfile failed"
6802 # See if we are still setuid/sgid
6803 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6804 error "S/gid is not dropped on write"
6805 # Now test that MDS is updated too
6806 cancel_lru_locks mdc
6807 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6808 error "S/gid is not dropped on MDS"
6811 run_test 72a "Test that remove suid works properly (bug5695) ===="
6813 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6816 [ "$RUNAS_ID" = "$UID" ] &&
6817 skip_env "RUNAS_ID = UID = $UID -- skipping"
6818 [ "$RUNAS_ID" -eq 0 ] &&
6819 skip_env "RUNAS_ID = 0 -- skipping"
6820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6821 # Check that testing environment is properly set up. Skip if not
6822 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
6823 skip_env "User $RUNAS_ID does not exist - skipping"
6825 touch $DIR/${tfile}-f{g,u}
6826 test_mkdir $DIR/${tfile}-dg
6827 test_mkdir $DIR/${tfile}-du
6828 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6829 chmod g+s $DIR/${tfile}-{f,d}g
6830 chmod u+s $DIR/${tfile}-{f,d}u
6831 for perm in 777 2777 4777; do
6832 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6833 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6834 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6835 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6839 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6841 # bug 3462 - multiple simultaneous MDC requests
6843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6845 test_mkdir $DIR/d73-1
6846 test_mkdir $DIR/d73-2
6847 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6850 lctl set_param fail_loc=0x80000129
6851 $MULTIOP $DIR/d73-1/f73-2 Oc &
6853 lctl set_param fail_loc=0
6855 $MULTIOP $DIR/d73-2/f73-3 Oc &
6859 wait $pid1 || return 1
6863 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6864 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6865 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6869 run_test 73 "multiple MDC requests (should not deadlock)"
6871 test_74a() { # bug 6149, 6184
6872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6875 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6877 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6878 # will spin in a tight reconnection loop
6879 $LCTL set_param fail_loc=0x8000030e
6880 # get any lock that won't be difficult - lookup works.
6882 $LCTL set_param fail_loc=0
6886 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6888 test_74b() { # bug 13310
6889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6891 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6893 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6894 # will spin in a tight reconnection loop
6895 $LCTL set_param fail_loc=0x8000030e
6896 # get a "difficult" lock
6898 $LCTL set_param fail_loc=0
6902 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6907 #define OBD_FAIL_LDLM_NEW_LOCK
6908 $LCTL set_param fail_loc=0x319
6909 touch $DIR/$tfile && error "touch successful"
6910 $LCTL set_param fail_loc=0
6913 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6916 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6919 test_76() { # Now for bug 20433, added originally in bug 1443
6920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6922 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6924 cancel_lru_locks osc
6925 BEFORE_INODES=$(num_inodes)
6926 echo "before inodes: $BEFORE_INODES"
6928 [ "$SLOW" = "no" ] && COUNT=100
6929 for i in $(seq $COUNT); do
6933 cancel_lru_locks osc
6934 AFTER_INODES=$(num_inodes)
6935 echo "after inodes: $AFTER_INODES"
6937 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6939 AFTER_INODES=$(num_inodes)
6941 echo "wait $wait seconds inodes: $AFTER_INODES"
6942 if [ $wait -gt 30 ]; then
6943 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6947 run_test 76 "confirm clients recycle inodes properly ===="
6953 # Note: in sptlrpc modes which enable its own bulk checksum, the
6954 # original crc32_le bulk checksum will be automatically disabled,
6955 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6956 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6957 # In this case set_checksums() will not be no-op, because sptlrpc
6958 # bulk checksum will be enabled all through the test.
6960 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6961 lctl set_param -n osc.*.checksums $1
6965 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6966 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6967 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6968 tr -d [] | head -n1)}
6971 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6972 log "set checksum type to $1"
6975 F77_TMP=$TMP/f77-temp
6978 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6979 error "error writing to $F77_TMP"
6982 test_77a() { # bug 10889
6983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6984 $GSS && skip_env "could not run with gss"
6986 [ ! -f $F77_TMP ] && setup_f77
6988 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6992 run_test 77a "normal checksum read/write operation"
6994 test_77b() { # bug 10889
6995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6996 $GSS && skip_env "could not run with gss"
6998 [ ! -f $F77_TMP ] && setup_f77
6999 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7000 $LCTL set_param fail_loc=0x80000409
7003 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7004 error "dd error: $?"
7005 $LCTL set_param fail_loc=0
7007 for algo in $CKSUM_TYPES; do
7008 cancel_lru_locks osc
7009 set_checksum_type $algo
7010 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7011 $LCTL set_param fail_loc=0x80000408
7012 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7013 $LCTL set_param fail_loc=0
7016 set_checksum_type $ORIG_CSUM_TYPE
7019 run_test 77b "checksum error on client write, read"
7024 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7026 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7027 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7028 $check_ost && [ -n "$ost_file_prefix" ] &&
7029 do_facet ost1 rm -f ${ost_file_prefix}\*
7033 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7034 $GSS && skip_env "could not run with gss"
7035 remote_ost_nodsh && skip "remote OST with nodsh"
7038 local osc_file_prefix
7040 local check_ost=false
7041 local ost_file_prefix
7047 # ensure corruption will occur on first OSS/OST
7048 $LFS setstripe -i 0 $DIR/$tfile
7050 [ ! -f $F77_TMP ] && setup_f77
7051 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7052 error "dd write error: $?"
7053 fid=$($LFS path2fid $DIR/$tfile)
7055 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
7058 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7059 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7061 echo "OSS do not support bulk pages dump upon error"
7064 osc_file_prefix=$($LCTL get_param -n debug_path)
7065 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7067 trap cleanup_77c EXIT
7070 # enable bulk pages dump upon error on Client
7071 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7072 # enable bulk pages dump upon error on OSS
7074 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7076 # flush Client cache to allow next read to reach OSS
7077 cancel_lru_locks osc
7079 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7080 $LCTL set_param fail_loc=0x80000408
7081 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7082 $LCTL set_param fail_loc=0
7086 # check cksum dump on Client
7087 osc_file=$(ls ${osc_file_prefix}*)
7088 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7089 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7090 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7091 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7092 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7094 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7095 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7096 error "dump content does not match on Client"
7098 $check_ost || skip "No need to check cksum dump on OSS"
7100 # check cksum dump on OSS
7101 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7102 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7103 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7104 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7105 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7106 error "dump content does not match on OSS"
7110 run_test 77c "checksum error on client read with debug"
7112 test_77d() { # bug 10889
7113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7114 $GSS && skip_env "could not run with gss"
7116 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7117 $LCTL set_param fail_loc=0x80000409
7119 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7120 error "direct write: rc=$?"
7121 $LCTL set_param fail_loc=0
7124 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7125 $LCTL set_param fail_loc=0x80000408
7127 cancel_lru_locks osc
7128 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7129 error "direct read: rc=$?"
7130 $LCTL set_param fail_loc=0
7133 run_test 77d "checksum error on OST direct write, read"
7135 test_77f() { # bug 10889
7136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7137 $GSS && skip_env "could not run with gss"
7140 for algo in $CKSUM_TYPES; do
7141 cancel_lru_locks osc
7142 set_checksum_type $algo
7143 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7144 $LCTL set_param fail_loc=0x409
7145 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7146 error "direct write succeeded"
7147 $LCTL set_param fail_loc=0
7149 set_checksum_type $ORIG_CSUM_TYPE
7152 run_test 77f "repeat checksum error on write (expect error)"
7154 test_77g() { # bug 10889
7155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7156 $GSS && skip_env "could not run with gss"
7157 remote_ost_nodsh && skip "remote OST with nodsh"
7159 [ ! -f $F77_TMP ] && setup_f77
7161 local file=$DIR/$tfile
7162 stack_trap "rm -f $file" EXIT
7164 $SETSTRIPE -c 1 -i 0 $file
7165 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7166 do_facet ost1 lctl set_param fail_loc=0x8000021a
7168 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7169 error "write error: rc=$?"
7170 do_facet ost1 lctl set_param fail_loc=0
7173 cancel_lru_locks osc
7174 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7175 do_facet ost1 lctl set_param fail_loc=0x8000021b
7177 cmp $F77_TMP $file || error "file compare failed"
7178 do_facet ost1 lctl set_param fail_loc=0
7181 run_test 77g "checksum error on OST write, read"
7183 test_77k() { # LU-10906
7184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7185 $GSS && skip_env "could not run with gss"
7187 local cksum_param="osc.$FSNAME*.checksums"
7188 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7192 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7193 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7194 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7198 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7199 error "failed to set checksum=$i on MGS"
7200 wait_update $HOSTNAME "$get_checksum" $i
7202 echo "remount client, checksum should be $i"
7203 remount_client $MOUNT || "failed to remount client"
7204 checksum=$(eval $get_checksum)
7205 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7208 for opt in "checksum" "nochecksum"; do
7209 #remount with mount option
7210 echo "remount client with option $opt, checksum should be $i"
7211 umount_client $MOUNT || "failed to umount client"
7212 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7213 "failed to mount client with option '$opt'"
7214 checksum=$(eval $get_checksum)
7215 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7219 remount_client $MOUNT || "failed to remount client"
7221 run_test 77k "enable/disable checksum correctly"
7223 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7232 test_78() { # bug 10901
7233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7234 remote_ost || skip_env "local OST"
7237 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7238 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7239 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7240 echo "MemTotal: $MEMTOTAL"
7242 # reserve 256MB of memory for the kernel and other running processes,
7243 # and then take 1/2 of the remaining memory for the read/write buffers.
7244 if [ $MEMTOTAL -gt 512 ] ;then
7245 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7247 # for those poor memory-starved high-end clusters...
7248 MEMTOTAL=$((MEMTOTAL / 2))
7250 echo "Mem to use for directio: $MEMTOTAL"
7252 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7253 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7254 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7255 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7257 echo "Smallest OST: $SMALLESTOST"
7258 [[ $SMALLESTOST -lt 10240 ]] &&
7259 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7261 trap cleanup_test_78 EXIT
7263 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7264 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7266 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7267 echo "File size: $F78SIZE"
7268 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7269 for i in $(seq 1 $NSEQ); do
7270 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7271 echo directIO rdwr round $i of $NSEQ
7272 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7277 run_test 78 "handle large O_DIRECT writes correctly ============"
7279 test_79() { # bug 12743
7280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7282 wait_delete_completed
7284 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7285 BKFREE=$(calc_osc_kbytes kbytesfree)
7286 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7288 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7289 DFTOTAL=`echo $STRING | cut -d, -f1`
7290 DFUSED=`echo $STRING | cut -d, -f2`
7291 DFAVAIL=`echo $STRING | cut -d, -f3`
7292 DFFREE=$(($DFTOTAL - $DFUSED))
7294 ALLOWANCE=$((64 * $OSTCOUNT))
7296 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7297 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7298 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7300 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7301 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7302 error "df free($DFFREE) mismatch OST free($BKFREE)"
7304 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7305 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7306 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7309 run_test 79 "df report consistency check ======================="
7311 test_80() { # bug 10718
7312 remote_ost_nodsh && skip "remote OST with nodsh"
7313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7315 # relax strong synchronous semantics for slow backends like ZFS
7316 local soc="obdfilter.*.sync_on_lock_cancel"
7317 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7319 if [ "$soc_old" != "never" ] &&
7320 [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
7321 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7322 facet_active_host $host; done | sort -u)
7323 do_nodes $hosts lctl set_param $soc=never
7326 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7328 local BEFORE=`date +%s`
7329 cancel_lru_locks osc
7330 local AFTER=`date +%s`
7331 local DIFF=$((AFTER-BEFORE))
7332 if [ $DIFF -gt 1 ] ; then
7333 error "elapsed for 1M@1T = $DIFF"
7336 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7340 run_test 80 "Page eviction is equally fast at high offsets too ===="
7342 test_81a() { # LU-456
7343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7344 remote_ost_nodsh && skip "remote OST with nodsh"
7346 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7347 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7348 do_facet ost1 lctl set_param fail_loc=0x80000228
7350 # write should trigger a retry and success
7351 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7352 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7354 if [ $RC -ne 0 ] ; then
7355 error "write should success, but failed for $RC"
7358 run_test 81a "OST should retry write when get -ENOSPC ==============="
7360 test_81b() { # LU-456
7361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7362 remote_ost_nodsh && skip "remote OST with nodsh"
7364 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7365 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7366 do_facet ost1 lctl set_param fail_loc=0x228
7368 # write should retry several times and return -ENOSPC finally
7369 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7370 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7373 if [ $RC -ne $ENOSPC ] ; then
7374 error "dd should fail for -ENOSPC, but succeed."
7377 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7379 test_82() { # LU-1031
7380 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7384 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7386 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7388 kill -USR1 $MULTIPID2
7390 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7391 error "First grouplock does not block second one"
7393 echo "Second grouplock blocks first one"
7395 kill -USR1 $MULTIPID1
7399 run_test 82 "Basic grouplock test"
7402 local sfile="/boot/System.map-$(uname -r)"
7403 [ ! -f $sfile ] && skip "No $sfile found"
7404 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
7405 $LCTL set_param fail_loc=0x140d
7406 cp $sfile $DIR/$tfile || error "write failed"
7407 diff -c $sfile $DIR/$tfile || error "files are different"
7408 $LCTL set_param fail_loc=0
7411 run_test 83 "Short write in ptask ==============================="
7414 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
7416 test_mkdir $DIR/$tdir.cvsroot
7417 chown $RUNAS_ID $DIR/$tdir.cvsroot
7420 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7423 # some versions of cvs import exit(1) when asked to import links or
7424 # files they can't read. ignore those files.
7425 local toignore=$(find . -type l -printf '-I %f\n' -o \
7426 ! -perm /4 -printf '-I %f\n')
7427 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7428 $tdir.reposname vtag rtag
7431 test_mkdir $DIR/$tdir.reposname
7432 chown $RUNAS_ID $DIR/$tdir.reposname
7433 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7435 cd $DIR/$tdir.reposname
7437 $RUNAS cvs add -m 'addmsg' foo99
7439 $RUNAS cvs commit -m 'nomsg' foo99
7440 rm -fr $DIR/$tdir.cvsroot
7442 run_test 99 "cvs strange file/directory operations"
7445 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7446 [[ "$NETTYPE" =~ tcp ]] ||
7447 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
7448 remote_ost_nodsh && skip "remote OST with nodsh"
7449 remote_mds_nodsh && skip "remote MDS with nodsh"
7451 skip "useless for local single node setup"
7453 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7454 [ "$PROT" != "tcp" ] && continue
7455 RPORT=$(echo $REMOTE | cut -d: -f2)
7456 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7459 LPORT=`echo $LOCAL | cut -d: -f2`
7460 if [ $LPORT -ge 1024 ]; then
7461 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7463 error_exit "local: $LPORT > 1024, remote: $RPORT"
7466 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7468 run_test 100 "check local port using privileged port ==========="
7470 function get_named_value()
7479 echo $line | sed "s/^$tag[ ]*//"
7486 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7487 awk '/^max_cached_mb/ { print $2 }')
7490 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7496 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
7501 local cache_limit=32
7503 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7504 trap cleanup_101a EXIT
7505 $LCTL set_param -n llite.*.read_ahead_stats 0
7506 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7509 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7511 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7512 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7515 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7516 get_named_value 'read but discarded' | cut -d" " -f1); do
7517 discard=$(($discard + $s))
7521 if [[ $(($discard * 10)) -gt $nreads ]]; then
7522 $LCTL get_param osc.*-osc*.rpc_stats
7523 $LCTL get_param llite.*.read_ahead_stats
7524 error "too many ($discard) discarded pages"
7526 rm -f $DIR/$tfile || true
7528 run_test 101a "check read-ahead for random reads"
7531 test_mkdir $DIR/$tdir
7532 local STRIPE_SIZE=$1
7533 local FILE_LENGTH=$2
7536 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
7538 local list=$(comma_list $(osts_nodes))
7539 set_osd_param $list '' read_cache_enable 0
7540 set_osd_param $list '' writethrough_cache_enable 0
7542 trap cleanup_test101bc EXIT
7543 # prepare the read-ahead file
7544 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7546 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
7547 count=$FILE_SIZE_MB 2> /dev/null
7551 cleanup_test101bc() {
7556 local list=$(comma_list $(osts_nodes))
7557 set_osd_param $list '' read_cache_enable 1
7558 set_osd_param $list '' writethrough_cache_enable 1
7562 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7567 local STRIPE_SIZE=$2
7568 local FILE_LENGTH=$3
7569 local RA_INC=1048576
7570 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7571 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7572 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7573 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7574 get_named_value 'read but discarded' |
7575 cut -d" " -f1 | calc_total)
7576 if [[ $DISCARD -gt $discard_limit ]]; then
7577 $LCTL get_param llite.*.read_ahead_stats
7578 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7580 echo "Read-ahead success for size ${READ_SIZE}"
7585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7586 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7588 local STRIPE_SIZE=1048576
7589 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7591 if [ $SLOW == "yes" ]; then
7592 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7594 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7597 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7599 # prepare the read-ahead file
7600 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7601 cancel_lru_locks osc
7602 for BIDX in 2 4 8 16 32 64 128 256
7604 local BSIZE=$((BIDX*4096))
7605 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7606 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7607 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7608 $LCTL set_param -n llite.*.read_ahead_stats 0
7609 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7610 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7611 cancel_lru_locks osc
7612 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7617 run_test 101b "check stride-io mode read-ahead ================="
7620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7622 local STRIPE_SIZE=1048576
7623 local FILE_LENGTH=$((STRIPE_SIZE*100))
7627 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7629 cancel_lru_locks osc
7630 $LCTL set_param osc.*.rpc_stats 0
7631 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7632 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7633 local stats=$($LCTL get_param -n $osc_rpc_stats)
7634 local lines=$(echo "$stats" | awk 'END {print NR;}')
7637 if [ $lines -le 20 ]; then
7640 for size in 1 2 4 8; do
7641 local rpc=$(echo "$stats" |
7642 awk '($1 == "'$size':") {print $2; exit; }')
7644 error "Small $((size*4))k read IO $rpc !"
7646 echo "$osc_rpc_stats check passed!"
7651 run_test 101c "check stripe_size aligned read-ahead ================="
7654 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7655 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7659 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7661 local file=$DIR/$tfile
7662 local sz_MB=${FILESIZE_101d:-500}
7663 local ra_MB=${READAHEAD_MB:-40}
7665 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7666 [ $free_MB -lt $sz_MB ] &&
7667 skip "Need free space ${sz_MB}M, have ${free_MB}M"
7669 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7670 $SETSTRIPE -c -1 $file || error "setstripe failed"
7672 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7673 echo Cancel LRU locks on lustre client to flush the client cache
7674 cancel_lru_locks osc
7676 echo Disable read-ahead
7677 local old_READAHEAD=$(set_read_ahead 0)
7679 echo Reading the test file $file with read-ahead disabled
7680 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7682 echo Cancel LRU locks on lustre client to flush the client cache
7683 cancel_lru_locks osc
7684 echo Enable read-ahead with ${ra_MB}MB
7685 set_read_ahead $ra_MB
7687 echo Reading the test file $file with read-ahead enabled
7688 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7690 echo "read-ahead disabled time read $raOFF"
7691 echo "read-ahead enabled time read $raON"
7693 set_read_ahead $old_READAHEAD
7695 wait_delete_completed
7697 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7698 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7700 run_test 101d "file read with and without read-ahead enabled"
7703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7705 local file=$DIR/$tfile
7706 local size_KB=500 #KB
7710 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7711 local need_KB=$((count * size_KB))
7712 [[ $free_KB -le $need_KB ]] &&
7713 skip_env "Need free space $need_KB, have $free_KB"
7715 echo "Creating $count ${size_KB}K test files"
7716 for ((i = 0; i < $count; i++)); do
7717 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7720 echo "Cancel LRU locks on lustre client to flush the client cache"
7721 cancel_lru_locks $OSC
7723 echo "Reset readahead stats"
7724 $LCTL set_param -n llite.*.read_ahead_stats 0
7726 for ((i = 0; i < $count; i++)); do
7727 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7730 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7731 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7733 for ((i = 0; i < $count; i++)); do
7734 rm -rf $file.$i 2>/dev/null
7737 #10000 means 20% reads are missing in readahead
7738 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7740 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7743 which iozone || skip_env "no iozone installed"
7745 local old_debug=$($LCTL get_param debug)
7746 old_debug=${old_debug#*=}
7747 $LCTL set_param debug="reada mmap"
7749 # create a test file
7750 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7752 echo Cancel LRU locks on lustre client to flush the client cache
7753 cancel_lru_locks osc
7755 echo Reset readahead stats
7756 $LCTL set_param -n llite.*.read_ahead_stats 0
7758 echo mmap read the file with small block size
7759 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7762 echo checking missing pages
7763 $LCTL get_param llite.*.read_ahead_stats
7764 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7765 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7767 $LCTL set_param debug="$old_debug"
7768 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7771 run_test 101f "check mmap read performance"
7773 test_101g_brw_size_test() {
7775 local pages=$((mb * 1048576 / $(page_size)))
7776 local file=$DIR/$tfile
7778 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7779 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7780 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7781 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7785 stack_trap "rm -f $file" EXIT
7786 $LCTL set_param -n osc.*.rpc_stats=0
7788 # 10 RPCs should be enough for the test
7790 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
7791 { error "dd write ${mb} MB blocks failed"; return 3; }
7792 cancel_lru_locks osc
7793 dd of=/dev/null if=$file bs=${mb}M count=$count ||
7794 { error "dd write ${mb} MB blocks failed"; return 4; }
7796 # calculate number of full-sized read and write RPCs
7797 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7798 sed -n '/pages per rpc/,/^$/p' |
7799 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7800 END { print reads,writes }'))
7801 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7803 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7810 remote_ost_nodsh && skip "remote OST with nodsh"
7813 local osts=$(get_facets OST)
7814 local list=$(comma_list $(osts_nodes))
7815 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7816 local brw_size="obdfilter.*.brw_size"
7817 local ostver=$(lustre_version_code ost1)
7818 local cliver=$(lustre_version_code client)
7820 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7822 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7823 if [ $ostver -ge $(version_code 2.8.52) -o \
7824 \( $ostver -ge $(version_code 2.7.17) -a \
7825 $ostver -lt $(version_code 2.7.50) \) ] &&
7826 [ $cliver -ge $(version_code 2.8.52) -o \
7827 \( $cliver -ge $(version_code 2.7.17) -a \
7828 $cliver -lt $(version_code 2.7.50) \) ]; then
7829 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7830 if [[ $orig_mb -lt 16 ]]; then
7831 save_lustre_params $osts "$brw_size" > $p
7832 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7833 error "set 16MB RPC size failed"
7835 echo "remount client to enable new RPC size"
7836 remount_client $MOUNT || error "remount_client failed"
7839 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7840 # should be able to set brw_size=12, but no rpc_stats for that
7841 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7844 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7846 if [[ $orig_mb -lt 16 ]]; then
7847 restore_lustre_params < $p
7848 remount_client $MOUNT || error "remount_client restore failed"
7851 rm -f $p $DIR/$tfile
7853 run_test 101g "Big bulk(4/16 MiB) readahead"
7856 test_mkdir $DIR/$tdir
7857 chown $RUNAS_ID $DIR/$tdir
7860 STRIPE_COUNT=$OSTCOUNT
7861 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7863 trap cleanup_test102 EXIT
7865 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7867 for num in 1 2 3 4; do
7868 for count in $(seq 1 $STRIPE_COUNT); do
7869 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7870 local size=`expr $STRIPE_SIZE \* $num`
7871 local file=file"$num-$idx-$count"
7872 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7878 $1 tar cf $TMP/f102.tar $tdir --xattrs
7884 rm -rf $DIR/d0.sanity/d102
7888 [ "$UID" != 0 ] && skip "must run as root"
7889 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7890 skip_env "must have user_xattr"
7892 [ -z "$(which setfattr 2>/dev/null)" ] &&
7893 skip_env "could not find setfattr"
7895 local testfile=$DIR/$tfile
7898 echo "set/get xattr..."
7899 setfattr -n trusted.name1 -v value1 $testfile ||
7900 error "setfattr -n trusted.name1=value1 $testfile failed"
7901 getfattr -n trusted.name1 $testfile 2> /dev/null |
7902 grep "trusted.name1=.value1" ||
7903 error "$testfile missing trusted.name1=value1"
7905 setfattr -n user.author1 -v author1 $testfile ||
7906 error "setfattr -n user.author1=author1 $testfile failed"
7907 getfattr -n user.author1 $testfile 2> /dev/null |
7908 grep "user.author1=.author1" ||
7909 error "$testfile missing trusted.author1=author1"
7912 setfattr -n trusted.name2 -v value2 $testfile ||
7913 error "$testfile unable to set trusted.name2"
7914 setfattr -n trusted.name3 -v value3 $testfile ||
7915 error "$testfile unable to set trusted.name3"
7916 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7917 grep "trusted.name" | wc -l) -eq 3 ] ||
7918 error "$testfile missing 3 trusted.name xattrs"
7920 setfattr -n user.author2 -v author2 $testfile ||
7921 error "$testfile unable to set user.author2"
7922 setfattr -n user.author3 -v author3 $testfile ||
7923 error "$testfile unable to set user.author3"
7924 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7925 grep "user.author" | wc -l) -eq 3 ] ||
7926 error "$testfile missing 3 user.author xattrs"
7928 echo "remove xattr..."
7929 setfattr -x trusted.name1 $testfile ||
7930 error "$testfile error deleting trusted.name1"
7931 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7932 error "$testfile did not delete trusted.name1 xattr"
7934 setfattr -x user.author1 $testfile ||
7935 error "$testfile error deleting user.author1"
7936 echo "set lustre special xattr ..."
7937 $LFS setstripe -c1 $testfile
7938 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7939 awk -F "=" '/trusted.lov/ { print $2 }' )
7940 setfattr -n "trusted.lov" -v $lovea $testfile ||
7941 error "$testfile doesn't ignore setting trusted.lov again"
7942 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7943 error "$testfile allow setting invalid trusted.lov"
7946 run_test 102a "user xattr test =================================="
7949 [ -z "$(which setfattr 2>/dev/null)" ] &&
7950 skip_env "could not find setfattr"
7951 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7953 # b10930: get/set/list trusted.lov xattr
7954 echo "get/set/list trusted.lov xattr ..."
7955 local testfile=$DIR/$tfile
7956 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7957 error "setstripe failed"
7958 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7959 error "getstripe failed"
7960 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7961 error "can't get trusted.lov from $testfile"
7963 local testfile2=${testfile}2
7964 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7965 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7968 setfattr -n trusted.lov -v $value $testfile2
7969 local stripe_size=$($GETSTRIPE -S $testfile2)
7970 local stripe_count=$($GETSTRIPE -c $testfile2)
7971 [[ $stripe_size -eq 65536 ]] ||
7972 error "stripe size $stripe_size != 65536"
7973 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7974 error "stripe count $stripe_count != $STRIPECOUNT"
7977 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7980 [ -z "$(which setfattr 2>/dev/null)" ] &&
7981 skip_env "could not find setfattr"
7982 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7984 # b10930: get/set/list lustre.lov xattr
7985 echo "get/set/list lustre.lov xattr ..."
7986 test_mkdir $DIR/$tdir
7987 chown $RUNAS_ID $DIR/$tdir
7988 local testfile=$DIR/$tdir/$tfile
7989 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7990 error "setstripe failed"
7991 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7992 error "getstripe failed"
7993 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7994 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7996 local testfile2=${testfile}2
7997 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7998 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8000 $RUNAS $MCREATE $testfile2
8001 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8002 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8003 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8004 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8005 [ $stripe_count -eq $STRIPECOUNT ] ||
8006 error "stripe count $stripe_count != $STRIPECOUNT"
8008 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8010 compare_stripe_info1() {
8011 local stripe_index_all_zero=true
8013 for num in 1 2 3 4; do
8014 for count in $(seq 1 $STRIPE_COUNT); do
8015 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8016 local size=$((STRIPE_SIZE * num))
8017 local file=file"$num-$offset-$count"
8018 stripe_size=$($LFS getstripe -S $PWD/$file)
8019 [[ $stripe_size -ne $size ]] &&
8020 error "$file: size $stripe_size != $size"
8021 stripe_count=$($LFS getstripe -c $PWD/$file)
8022 # allow fewer stripes to be created, ORI-601
8023 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8024 error "$file: count $stripe_count != $count"
8025 stripe_index=$($LFS getstripe -i $PWD/$file)
8026 [[ $stripe_index -ne 0 ]] &&
8027 stripe_index_all_zero=false
8031 $stripe_index_all_zero &&
8032 error "all files are being extracted starting from OST index 0"
8036 have_xattrs_include() {
8037 tar --help | grep -q xattrs-include &&
8038 echo --xattrs-include="lustre.*"
8042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8043 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8045 XINC=$(have_xattrs_include)
8047 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8049 compare_stripe_info1
8051 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8054 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8055 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8057 XINC=$(have_xattrs_include)
8059 test_mkdir $DIR/$tdir.restore
8061 tar cf - --xattrs $tdir | tar xf - \
8062 -C $DIR/$tdir.restore --xattrs $XINC
8063 cd $DIR/$tdir.restore/$tdir
8064 compare_stripe_info1
8066 run_test 102f "tar copy files, not keep osts"
8069 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8070 skip "must have user_xattr"
8071 [ -z "$(which setfattr 2>/dev/null)" ] &&
8072 skip_env "could not find setfattr"
8073 [ -z "$(which getfattr 2>/dev/null)" ] &&
8074 skip_env "could not find getfattr"
8076 local xsize=${1:-1024} # in bytes
8077 local file=$DIR/$tfile
8078 local value="$(generate_string $xsize)"
8079 local xbig=trusted.big
8082 log "save $xbig on $file"
8083 setfattr -n $xbig -v $value $file ||
8084 error "saving $xbig on $file failed"
8086 local orig=$(get_xattr_value $xbig $file)
8087 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8089 local xsml=trusted.sml
8090 log "save $xsml on $file"
8091 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8093 local new=$(get_xattr_value $xbig $file)
8094 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8096 log "grow $xsml on $file"
8097 setfattr -n $xsml -v "$value" $file ||
8098 error "growing $xsml on $file failed"
8100 new=$(get_xattr_value $xbig $file)
8101 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8102 log "$xbig still valid after growing $xsml"
8107 test_102h() { # bug 15777
8110 run_test 102h "grow xattr from inside inode to external block"
8113 large_xattr_enabled || skip_env "large_xattr disabled"
8115 grow_xattr $(max_xattr_size)
8117 run_test 102ha "grow xattr from inside inode to external inode"
8119 test_102i() { # bug 17038
8120 [ -z "$(which getfattr 2>/dev/null)" ] &&
8121 skip "could not find getfattr"
8124 ln -s $DIR/$tfile $DIR/${tfile}link
8125 getfattr -n trusted.lov $DIR/$tfile ||
8126 error "lgetxattr on $DIR/$tfile failed"
8127 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8128 grep -i "no such attr" ||
8129 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8130 rm -f $DIR/$tfile $DIR/${tfile}link
8132 run_test 102i "lgetxattr test on symbolic link ============"
8135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8136 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8138 XINC=$(have_xattrs_include)
8139 setup_test102 "$RUNAS"
8140 chown $RUNAS_ID $DIR/$tdir
8141 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8143 compare_stripe_info1 "$RUNAS"
8145 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8148 [ -z "$(which setfattr 2>/dev/null)" ] &&
8149 skip "could not find setfattr"
8152 # b22187 just check that does not crash for regular file.
8153 setfattr -n trusted.lov $DIR/$tfile
8154 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8155 local test_kdir=$DIR/$tdir
8156 test_mkdir $test_kdir
8157 local default_size=$($LFS getstripe -S $test_kdir)
8158 local default_count=$($LFS getstripe -c $test_kdir)
8159 local default_offset=$($LFS getstripe -i $test_kdir)
8160 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8161 error 'dir setstripe failed'
8162 setfattr -n trusted.lov $test_kdir
8163 local stripe_size=$($LFS getstripe -S $test_kdir)
8164 local stripe_count=$($LFS getstripe -c $test_kdir)
8165 local stripe_offset=$($LFS getstripe -i $test_kdir)
8166 [ $stripe_size -eq $default_size ] ||
8167 error "stripe size $stripe_size != $default_size"
8168 [ $stripe_count -eq $default_count ] ||
8169 error "stripe count $stripe_count != $default_count"
8170 [ $stripe_offset -eq $default_offset ] ||
8171 error "stripe offset $stripe_offset != $default_offset"
8172 rm -rf $DIR/$tfile $test_kdir
8174 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8177 [ -z "$(which getfattr 2>/dev/null)" ] &&
8178 skip "could not find getfattr"
8180 # LU-532 trusted. xattr is invisible to non-root
8181 local testfile=$DIR/$tfile
8185 echo "listxattr as user..."
8186 chown $RUNAS_ID $testfile
8187 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8188 grep -q "trusted" &&
8189 error "$testfile trusted xattrs are user visible"
8193 run_test 102l "listxattr size test =================================="
8195 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8196 local path=$DIR/$tfile
8199 listxattr_size_check $path || error "listattr_size_check $path failed"
8201 run_test 102m "Ensure listxattr fails on small bufffer ========"
8205 getxattr() { # getxattr path name
8206 # Return the base64 encoding of the value of xattr name on path.
8210 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8212 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8214 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8216 getfattr --absolute-names --encoding=base64 --name=$name $path |
8217 awk -F= -v name=$name '$1 == name {
8218 print substr($0, index($0, "=") + 1);
8222 test_102n() { # LU-4101 mdt: protect internal xattrs
8223 [ -z "$(which setfattr 2>/dev/null)" ] &&
8224 skip "could not find setfattr"
8225 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
8227 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8230 local file0=$DIR/$tfile.0
8231 local file1=$DIR/$tfile.1
8232 local xattr0=$TMP/$tfile.0
8233 local xattr1=$TMP/$tfile.1
8234 local namelist="lov lma lmv link fid version som hsm"
8238 rm -rf $file0 $file1 $xattr0 $xattr1
8241 # Get 'before' xattrs of $file1.
8242 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8244 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
8245 namelist+=" lfsck_namespace"
8246 for name in $namelist; do
8247 # Try to copy xattr from $file0 to $file1.
8248 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8250 setfattr --name=trusted.$name --value="$value" $file1 ||
8251 error "setxattr 'trusted.$name' failed"
8253 # Try to set a garbage xattr.
8254 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8256 if [[ x$name == "xlov" ]]; then
8257 setfattr --name=trusted.lov --value="$value" $file1 &&
8258 error "setxattr invalid 'trusted.lov' success"
8260 setfattr --name=trusted.$name --value="$value" $file1 ||
8261 error "setxattr invalid 'trusted.$name' failed"
8264 # Try to remove the xattr from $file1. We don't care if this
8265 # appears to succeed or fail, we just don't want there to be
8266 # any changes or crashes.
8267 setfattr --remove=$trusted.$name $file1 2> /dev/null
8270 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
8273 # Try to copy xattr from $file0 to $file1.
8274 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8276 setfattr --name=trusted.$name --value="$value" $file1 ||
8277 error "setxattr 'trusted.$name' failed"
8279 # Try to set a garbage xattr.
8280 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8282 setfattr --name=trusted.$name --value="$value" $file1 ||
8283 error "setxattr 'trusted.$name' failed"
8285 # Try to remove the xattr from $file1. We don't care if this
8286 # appears to succeed or fail, we just don't want there to be
8287 # any changes or crashes.
8288 setfattr --remove=$trusted.$name $file1 2> /dev/null
8291 # Get 'after' xattrs of file1.
8292 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8294 if ! diff $xattr0 $xattr1; then
8295 error "before and after xattrs of '$file1' differ"
8298 rm -rf $file0 $file1 $xattr0 $xattr1
8302 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8304 test_102p() { # LU-4703 setxattr did not check ownership
8305 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
8306 skip "MDS needs to be at least 2.5.56"
8308 local testfile=$DIR/$tfile
8312 echo "setfacl as user..."
8313 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8314 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8316 echo "setfattr as user..."
8317 setfacl -m "u:$RUNAS_ID:---" $testfile
8318 $RUNAS setfattr -x system.posix_acl_access $testfile
8319 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8321 run_test 102p "check setxattr(2) correctly fails without permission"
8324 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
8325 skip "MDS needs to be at least 2.6.92"
8327 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8329 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8332 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
8333 skip "MDS needs to be at least 2.6.93"
8335 touch $DIR/$tfile || error "touch"
8336 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8337 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8338 rm $DIR/$tfile || error "rm"
8341 mkdir -p $DIR/$tdir || error "mkdir"
8342 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8343 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8344 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8345 error "$testfile error deleting user.author1"
8346 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8347 grep "user.$(basename $tdir)" &&
8348 error "$tdir did not delete user.$(basename $tdir)"
8349 rmdir $DIR/$tdir || error "rmdir"
8352 test_mkdir $DIR/$tdir
8353 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8354 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8355 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8356 error "$testfile error deleting user.author1"
8357 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8358 grep "user.$(basename $tdir)" &&
8359 error "$tdir did not delete user.$(basename $tdir)"
8360 rmdir $DIR/$tdir || error "rm striped dir"
8362 run_test 102r "set EAs with empty values"
8366 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8371 [ "$UID" != 0 ] && skip "must run as root"
8372 $GSS && skip_env "could not run under gss"
8373 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8374 skip_env "must have acl enabled"
8375 [ -z "$(which setfacl 2>/dev/null)" ] &&
8376 skip_env "could not find setfacl"
8377 remote_mds_nodsh && skip "remote MDS with nodsh"
8379 gpasswd -a daemon bin # LU-5641
8380 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8382 declare -a identity_old
8384 for num in $(seq $MDSCOUNT); do
8385 switch_identity $num true || identity_old[$num]=$?
8393 echo "performing cp ..."
8394 run_acl_subtest cp || error "run_acl_subtest cp failed"
8395 echo "performing getfacl-noacl..."
8396 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8397 echo "performing misc..."
8398 run_acl_subtest misc || error "misc test failed"
8399 echo "performing permissions..."
8400 run_acl_subtest permissions || error "permissions failed"
8401 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8402 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
8403 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
8404 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
8406 echo "performing permissions xattr..."
8407 run_acl_subtest permissions_xattr ||
8408 error "permissions_xattr failed"
8410 echo "performing setfacl..."
8411 run_acl_subtest setfacl || error "setfacl test failed"
8413 # inheritance test got from HP
8414 echo "performing inheritance..."
8415 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8416 chmod +x make-tree || error "chmod +x failed"
8417 run_acl_subtest inheritance || error "inheritance test failed"
8420 echo "LU-974 ignore umask when acl is enabled..."
8421 run_acl_subtest 974 || error "LU-974 umask test failed"
8422 if [ $MDSCOUNT -ge 2 ]; then
8423 run_acl_subtest 974_remote ||
8424 error "LU-974 umask test failed under remote dir"
8427 echo "LU-2561 newly created file is same size as directory..."
8428 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
8429 run_acl_subtest 2561 || error "LU-2561 test failed"
8431 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8434 run_acl_subtest 4924 || error "LU-4924 test failed"
8439 for num in $(seq $MDSCOUNT); do
8440 if [ "${identity_old[$num]}" = 1 ]; then
8441 switch_identity $num false || identity_old[$num]=$?
8445 run_test 103a "acl test"
8450 for U in {0..511}; do
8452 local O=$(printf "%04o" $U)
8454 umask $(printf "%04o" $((511 ^ $O)))
8455 $LFS setstripe -c 1 $DIR/$tfile.s$O
8456 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
8458 (( $S == ($O & 0666) )) ||
8459 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
8461 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
8462 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
8463 (( $S == ($O & 0666) )) ||
8464 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
8466 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
8467 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
8468 (( $S == ($O & 0666) )) ||
8469 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
8470 rm -f $DIR/$tfile.[smp]$0
8475 run_test 103b "umask lfs setstripe"
8479 cp -rp $DIR/$tdir $DIR/$tdir.bak
8481 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8482 error "$DIR/$tdir shouldn't contain default ACL"
8483 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8484 error "$DIR/$tdir.bak shouldn't contain default ACL"
8487 run_test 103c "'cp -rp' won't set empty acl"
8490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8493 lfs df || error "lfs df failed"
8494 lfs df -ih || error "lfs df -ih failed"
8495 lfs df -h $DIR || error "lfs df -h $DIR failed"
8496 lfs df -i $DIR || error "lfs df -i $DIR failed"
8497 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8498 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8500 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8501 lctl --device %$OSC deactivate
8502 lfs df || error "lfs df with deactivated OSC failed"
8503 lctl --device %$OSC activate
8504 # wait the osc back to normal
8505 wait_osc_import_state client ost FULL
8507 lfs df || error "lfs df with reactivated OSC failed"
8510 run_test 104a "lfs df [-ih] [path] test ========================="
8513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8514 [ $RUNAS_ID -eq $UID ] &&
8515 skip_env "RUNAS_ID = UID = $UID -- skipping"
8518 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8519 grep "Permission denied" | wc -l)))
8520 if [ $denied_cnt -ne 0 ]; then
8521 error "lfs check servers test failed"
8524 run_test 104b "$RUNAS lfs check servers test ===================="
8527 # doesn't work on 2.4 kernels
8529 if $(flock_is_enabled); then
8530 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8532 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8536 run_test 105a "flock when mounted without -o flock test ========"
8540 if $(flock_is_enabled); then
8541 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8543 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8547 run_test 105b "fcntl when mounted without -o flock test ========"
8551 if $(flock_is_enabled); then
8552 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8554 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8558 run_test 105c "lockf when mounted without -o flock test"
8560 test_105d() { # bug 15924
8561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8563 test_mkdir $DIR/$tdir
8564 flock_is_enabled || skip_env "mount w/o flock enabled"
8565 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8566 $LCTL set_param fail_loc=0x80000315
8567 flocks_test 2 $DIR/$tdir
8569 run_test 105d "flock race (should not freeze) ========"
8571 test_105e() { # bug 22660 && 22040
8572 flock_is_enabled || skip_env "mount w/o flock enabled"
8575 flocks_test 3 $DIR/$tfile
8577 run_test 105e "Two conflicting flocks from same process"
8579 test_106() { #bug 10921
8580 test_mkdir $DIR/$tdir
8581 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8582 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8584 run_test 106 "attempt exec of dir followed by chown of that dir"
8587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8595 local save_pattern=$(sysctl -n kernel.core_pattern)
8596 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8597 sysctl -w kernel.core_pattern=$file
8598 sysctl -w kernel.core_uses_pid=0
8606 kill -s 11 $SLEEPPID
8608 if [ -e $file ]; then
8609 size=`stat -c%s $file`
8610 [ $size -eq 0 ] && error "Fail to create core file $file"
8612 error "Fail to create core file $file"
8615 sysctl -w kernel.core_pattern=$save_pattern
8616 sysctl -w kernel.core_uses_pid=$save_uses_pid
8619 run_test 107 "Coredump on SIG"
8622 test_mkdir $DIR/$tdir
8623 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8624 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8625 error "mkdir with 256 char should fail, but did not"
8626 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8627 error "create with 255 char failed"
8628 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8629 error "create with 256 char should fail, but did not"
8634 run_test 110 "filename length checking"
8637 # Purpose: To verify dynamic thread (OSS) creation.
8640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8641 remote_ost_nodsh && skip "remote OST with nodsh"
8643 # Lustre does not stop service threads once they are started.
8644 # Reset number of running threads to default.
8649 local save_params="$TMP/sanity-$TESTNAME.parameters"
8651 # Get ll_ost_io count before I/O
8652 OSTIO_pre=$(do_facet ost1 \
8653 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8654 # Exit if lustre is not running (ll_ost_io not running).
8655 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8657 echo "Starting with $OSTIO_pre threads"
8658 local thread_max=$((OSTIO_pre * 2))
8659 local rpc_in_flight=$((thread_max * 2))
8660 # Number of I/O Process proposed to be started.
8662 local facets=$(get_facets OST)
8664 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8665 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8667 # Set in_flight to $rpc_in_flight
8668 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8669 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8670 nfiles=${rpc_in_flight}
8671 # Set ost thread_max to $thread_max
8672 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8674 # 5 Minutes should be sufficient for max number of OSS
8675 # threads(thread_max) to be created.
8679 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8680 test_mkdir $DIR/$tdir
8681 for i in $(seq $nfiles); do
8682 local file=$DIR/$tdir/${tfile}-$i
8683 $LFS setstripe -c -1 -i 0 $file
8684 ($WTL $file $timeout)&
8687 # I/O Started - Wait for thread_started to reach thread_max or report
8688 # error if thread_started is more than thread_max.
8689 echo "Waiting for thread_started to reach thread_max"
8690 local thread_started=0
8691 local end_time=$((SECONDS + timeout))
8693 while [ $SECONDS -le $end_time ] ; do
8695 # Get ost i/o thread_started count.
8696 thread_started=$(do_facet ost1 \
8698 ost.OSS.ost_io.threads_started | cut -d= -f2")
8699 # Break out if thread_started is equal/greater than thread_max
8700 if [[ $thread_started -ge $thread_max ]]; then
8701 echo ll_ost_io thread_started $thread_started, \
8702 equal/greater than thread_max $thread_max
8708 # Cleanup - We have the numbers, Kill i/o jobs if running.
8709 jobcount=($(jobs -p))
8710 for i in $(seq 0 $((${#jobcount[@]}-1)))
8712 kill -9 ${jobcount[$i]}
8713 if [ $? -ne 0 ] ; then
8715 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8719 # Cleanup files left by WTL binary.
8720 for i in $(seq $nfiles); do
8721 local file=$DIR/$tdir/${tfile}-$i
8723 if [ $? -ne 0 ] ; then
8724 echo "Warning: Failed to delete file $file"
8728 restore_lustre_params <$save_params
8729 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8731 # Error out if no new thread has started or Thread started is greater
8733 if [[ $thread_started -le $OSTIO_pre ||
8734 $thread_started -gt $thread_max ]]; then
8735 error "ll_ost_io: thread_started $thread_started" \
8736 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8737 "No new thread started or thread started greater " \
8741 run_test 115 "verify dynamic thread creation===================="
8744 wait_delete_completed
8745 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8746 echo "OST kbytes available: ${AVAIL[@]}"
8751 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8752 #echo OST $i: ${AVAIL[i]}kb
8753 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8757 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8762 echo "Min free space: OST $MINI: $MINV"
8763 echo "Max free space: OST $MAXI: $MAXV"
8766 test_116a() { # was previously test_116()
8767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8768 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8769 remote_mds_nodsh && skip "remote MDS with nodsh"
8771 echo -n "Free space priority "
8772 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8777 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
8778 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
8779 trap simple_cleanup_common EXIT
8781 # Check if we need to generate uneven OSTs
8782 test_mkdir -p $DIR/$tdir/OST${MINI}
8783 local FILL=$((MINV / 4))
8784 local DIFF=$((MAXV - MINV))
8785 local DIFF2=$((DIFF * 100 / MINV))
8787 local threshold=$(do_facet $SINGLEMDS \
8788 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8789 threshold=${threshold%%%}
8790 echo -n "Check for uneven OSTs: "
8791 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8793 if [[ $DIFF2 -gt $threshold ]]; then
8795 echo "Don't need to fill OST$MINI"
8797 # generate uneven OSTs. Write 2% over the QOS threshold value
8799 DIFF=$((threshold - DIFF2 + 2))
8800 DIFF2=$((MINV * DIFF / 100))
8801 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8802 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8803 error "setstripe failed"
8804 DIFF=$((DIFF2 / 2048))
8806 while [ $i -lt $DIFF ]; do
8808 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8809 bs=2M count=1 2>/dev/null
8818 DIFF=$((MAXV - MINV))
8819 DIFF2=$((DIFF * 100 / MINV))
8820 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8821 if [ $DIFF2 -gt $threshold ]; then
8824 echo "failed - QOS mode won't be used"
8825 simple_cleanup_common
8826 skip "QOS imbalance criteria not met"
8834 # now fill using QOS
8835 $SETSTRIPE -c 1 $DIR/$tdir
8836 FILL=$((FILL / 200))
8837 if [ $FILL -gt 600 ]; then
8840 echo "writing $FILL files to QOS-assigned OSTs"
8842 while [ $i -lt $FILL ]; do
8844 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8848 echo "wrote $i 200k files"
8852 echo "Note: free space may not be updated, so measurements might be off"
8854 DIFF2=$((MAXV - MINV))
8855 echo "free space delta: orig $DIFF final $DIFF2"
8856 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8857 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8858 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8859 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8860 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8861 if [[ $DIFF -gt 0 ]]; then
8862 FILL=$((DIFF2 * 100 / DIFF - 100))
8863 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8866 # Figure out which files were written where
8867 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8868 awk '/'$MINI1': / {print $2; exit}')
8870 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8871 echo "$MINC files created on smaller OST $MINI1"
8872 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8873 awk '/'$MAXI1': / {print $2; exit}')
8875 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8876 echo "$MAXC files created on larger OST $MAXI1"
8877 if [[ $MINC -gt 0 ]]; then
8878 FILL=$((MAXC * 100 / MINC - 100))
8879 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8881 [[ $MAXC -gt $MINC ]] ||
8882 error_ignore LU-9 "stripe QOS didn't balance free space"
8883 simple_cleanup_common
8885 run_test 116a "stripe QOS: free space balance ==================="
8887 test_116b() { # LU-2093
8888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8889 remote_mds_nodsh && skip "remote MDS with nodsh"
8891 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8892 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8893 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8894 [ -z "$old_rr" ] && skip "no QOS"
8895 do_facet $SINGLEMDS lctl set_param \
8896 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8898 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8899 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8900 do_facet $SINGLEMDS lctl set_param fail_loc=0
8902 do_facet $SINGLEMDS lctl set_param \
8903 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8905 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8907 test_117() # bug 10891
8909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8911 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8912 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8913 lctl set_param fail_loc=0x21e
8914 > $DIR/$tfile || error "truncate failed"
8915 lctl set_param fail_loc=0
8916 echo "Truncate succeeded."
8919 run_test 117 "verify osd extend =========="
8921 NO_SLOW_RESENDCOUNT=4
8922 export OLD_RESENDCOUNT=""
8923 set_resend_count () {
8924 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8925 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8926 lctl set_param -n $PROC_RESENDCOUNT $1
8927 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8930 # for reduce test_118* time (b=14842)
8931 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8933 # Reset async IO behavior after error case
8935 FILE=$DIR/reset_async
8937 # Ensure all OSCs are cleared
8938 $SETSTRIPE -c -1 $FILE
8939 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8944 test_118a() #bug 11710
8946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8950 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8951 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8952 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8954 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8955 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8960 run_test 118a "verify O_SYNC works =========="
8964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8965 remote_ost_nodsh && skip "remote OST with nodsh"
8969 #define OBD_FAIL_SRV_ENOENT 0x217
8970 set_nodes_failloc "$(osts_nodes)" 0x217
8971 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8973 set_nodes_failloc "$(osts_nodes)" 0
8974 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8975 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8978 if [[ $RC -eq 0 ]]; then
8979 error "Must return error due to dropped pages, rc=$RC"
8983 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8984 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8988 echo "Dirty pages not leaked on ENOENT"
8990 # Due to the above error the OSC will issue all RPCs syncronously
8991 # until a subsequent RPC completes successfully without error.
8992 $MULTIOP $DIR/$tfile Ow4096yc
8997 run_test 118b "Reclaim dirty pages on fatal error =========="
9001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9003 # for 118c, restore the original resend count, LU-1940
9004 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9005 set_resend_count $OLD_RESENDCOUNT
9006 remote_ost_nodsh && skip "remote OST with nodsh"
9010 #define OBD_FAIL_OST_EROFS 0x216
9011 set_nodes_failloc "$(osts_nodes)" 0x216
9013 # multiop should block due to fsync until pages are written
9014 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9018 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9019 error "Multiop failed to block on fsync, pid=$MULTIPID"
9022 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9024 if [[ $WRITEBACK -eq 0 ]]; then
9025 error "No page in writeback, writeback=$WRITEBACK"
9028 set_nodes_failloc "$(osts_nodes)" 0
9031 if [[ $RC -ne 0 ]]; then
9032 error "Multiop fsync failed, rc=$RC"
9035 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9036 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9038 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9039 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9043 echo "Dirty pages flushed via fsync on EROFS"
9046 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9048 # continue to use small resend count to reduce test_118* time (b=14842)
9049 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9054 remote_ost_nodsh && skip "remote OST with nodsh"
9058 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9059 set_nodes_failloc "$(osts_nodes)" 0x214
9060 # multiop should block due to fsync until pages are written
9061 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9065 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9066 error "Multiop failed to block on fsync, pid=$MULTIPID"
9069 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9071 if [[ $WRITEBACK -eq 0 ]]; then
9072 error "No page in writeback, writeback=$WRITEBACK"
9075 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9076 set_nodes_failloc "$(osts_nodes)" 0
9078 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9079 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9081 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9082 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9086 echo "Dirty pages gaurenteed flushed via fsync"
9089 run_test 118d "Fsync validation inject a delay of the bulk =========="
9092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9096 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9097 lctl set_param fail_loc=0x8000040a
9099 # Should simulate EINVAL error which is fatal
9100 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9102 if [[ $RC -eq 0 ]]; then
9103 error "Must return error due to dropped pages, rc=$RC"
9106 lctl set_param fail_loc=0x0
9108 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9109 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9110 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9112 if [[ $LOCKED -ne 0 ]]; then
9113 error "Locked pages remain in cache, locked=$LOCKED"
9116 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9117 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9121 echo "No pages locked after fsync"
9126 run_test 118f "Simulate unrecoverable OSC side error =========="
9129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9133 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9134 lctl set_param fail_loc=0x406
9136 # simulate local -ENOMEM
9137 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9140 lctl set_param fail_loc=0
9141 if [[ $RC -eq 0 ]]; then
9142 error "Must return error due to dropped pages, rc=$RC"
9145 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9146 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9147 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9149 if [[ $LOCKED -ne 0 ]]; then
9150 error "Locked pages remain in cache, locked=$LOCKED"
9153 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9154 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9158 echo "No pages locked after fsync"
9163 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9167 remote_ost_nodsh && skip "remote OST with nodsh"
9171 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9172 set_nodes_failloc "$(osts_nodes)" 0x20e
9173 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9174 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9177 set_nodes_failloc "$(osts_nodes)" 0
9178 if [[ $RC -eq 0 ]]; then
9179 error "Must return error due to dropped pages, rc=$RC"
9182 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9183 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9184 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9186 if [[ $LOCKED -ne 0 ]]; then
9187 error "Locked pages remain in cache, locked=$LOCKED"
9190 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9191 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9195 echo "No pages locked after fsync"
9199 run_test 118h "Verify timeout in handling recoverables errors =========="
9201 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9205 remote_ost_nodsh && skip "remote OST with nodsh"
9209 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9210 set_nodes_failloc "$(osts_nodes)" 0x20e
9212 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9213 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9216 set_nodes_failloc "$(osts_nodes)" 0
9220 if [[ $RC -ne 0 ]]; then
9221 error "got error, but should be not, rc=$RC"
9224 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9225 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9226 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9227 if [[ $LOCKED -ne 0 ]]; then
9228 error "Locked pages remain in cache, locked=$LOCKED"
9231 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9232 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9236 echo "No pages locked after fsync"
9240 run_test 118i "Fix error before timeout in recoverable error =========="
9242 [ "$SLOW" = "no" ] && set_resend_count 4
9245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9246 remote_ost_nodsh && skip "remote OST with nodsh"
9250 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9251 set_nodes_failloc "$(osts_nodes)" 0x220
9253 # return -EIO from OST
9254 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9256 set_nodes_failloc "$(osts_nodes)" 0x0
9257 if [[ $RC -eq 0 ]]; then
9258 error "Must return error due to dropped pages, rc=$RC"
9261 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9262 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9263 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9264 if [[ $LOCKED -ne 0 ]]; then
9265 error "Locked pages remain in cache, locked=$LOCKED"
9268 # in recoverable error on OST we want resend and stay until it finished
9269 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9270 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9274 echo "No pages locked after fsync"
9278 run_test 118j "Simulate unrecoverable OST side error =========="
9282 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9283 remote_ost_nodsh && skip "remote OSTs with nodsh"
9285 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9286 set_nodes_failloc "$(osts_nodes)" 0x20e
9287 test_mkdir $DIR/$tdir
9289 for ((i=0;i<10;i++)); do
9290 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9291 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9298 set_nodes_failloc "$(osts_nodes)" 0
9301 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9303 test_118l() # LU-646
9305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9307 test_mkdir $DIR/$tdir
9308 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9311 run_test 118l "fsync dir"
9313 test_118m() # LU-3066
9315 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9317 test_mkdir $DIR/$tdir
9318 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9321 run_test 118m "fdatasync dir ========="
9323 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9331 remote_ost_nodsh && skip "remote OSTs with nodsh"
9333 # Sleep to avoid a cached response.
9334 #define OBD_STATFS_CACHE_SECONDS 1
9337 # Inject a 10 second delay in the OST_STATFS handler.
9338 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9339 set_nodes_failloc "$(osts_nodes)" 0x242
9342 stat --file-system $MOUNT > /dev/null
9345 set_nodes_failloc "$(osts_nodes)" 0
9347 if ((end - begin > 20)); then
9348 error "statfs took $((end - begin)) seconds, expected 10"
9351 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9353 test_119a() # bug 11737
9355 BSIZE=$((512 * 1024))
9356 directio write $DIR/$tfile 0 1 $BSIZE
9357 # We ask to read two blocks, which is more than a file size.
9358 # directio will indicate an error when requested and actual
9359 # sizes aren't equeal (a normal situation in this case) and
9360 # print actual read amount.
9361 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9362 if [ "$NOB" != "$BSIZE" ]; then
9363 error "read $NOB bytes instead of $BSIZE"
9367 run_test 119a "Short directIO read must return actual read amount"
9369 test_119b() # bug 11737
9371 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9373 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
9374 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9376 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
9377 error "direct read failed"
9380 run_test 119b "Sparse directIO read must return actual read amount"
9382 test_119c() # bug 13099
9385 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9386 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9389 run_test 119c "Testing for direct read hitting hole"
9391 test_119d() # bug 15950
9393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9395 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9396 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9398 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9399 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9400 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9401 lctl set_param fail_loc=0x40d
9402 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9405 cat $DIR/$tfile > /dev/null &
9406 lctl set_param fail_loc=0
9409 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9411 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9412 error "the read rpcs have not completed in 2s"
9414 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
9416 run_test 119d "The DIO path should try to send a new rpc once one is completed"
9419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9420 remote_mds_nodsh && skip "remote MDS with nodsh"
9421 test_mkdir $DIR/$tdir
9422 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9423 skip_env "no early lock cancel on server"
9425 lru_resize_disable mdc
9426 lru_resize_disable osc
9427 cancel_lru_locks mdc
9428 # asynchronous object destroy at MDT could cause bl ast to client
9429 cancel_lru_locks osc
9431 stat $DIR/$tdir > /dev/null
9432 can1=$(do_facet $SINGLEMDS \
9433 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9434 awk '/ldlm_cancel/ {print $2}')
9435 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9436 awk '/ldlm_bl_callback/ {print $2}')
9437 test_mkdir -c1 $DIR/$tdir/d1
9438 can2=$(do_facet $SINGLEMDS \
9439 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9440 awk '/ldlm_cancel/ {print $2}')
9441 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9442 awk '/ldlm_bl_callback/ {print $2}')
9443 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9444 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9445 lru_resize_enable mdc
9446 lru_resize_enable osc
9448 run_test 120a "Early Lock Cancel: mkdir test"
9451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9452 remote_mds_nodsh && skip "remote MDS with nodsh"
9453 test_mkdir $DIR/$tdir
9454 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9455 skip_env "no early lock cancel on server"
9457 lru_resize_disable mdc
9458 lru_resize_disable osc
9459 cancel_lru_locks mdc
9460 stat $DIR/$tdir > /dev/null
9461 can1=$(do_facet $SINGLEMDS \
9462 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9463 awk '/ldlm_cancel/ {print $2}')
9464 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9465 awk '/ldlm_bl_callback/ {print $2}')
9467 can2=$(do_facet $SINGLEMDS \
9468 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9469 awk '/ldlm_cancel/ {print $2}')
9470 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9471 awk '/ldlm_bl_callback/ {print $2}')
9472 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9473 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9474 lru_resize_enable mdc
9475 lru_resize_enable osc
9477 run_test 120b "Early Lock Cancel: create test"
9480 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9481 remote_mds_nodsh && skip "remote MDS with nodsh"
9482 test_mkdir -c1 $DIR/$tdir
9483 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9484 skip "no early lock cancel on server"
9486 lru_resize_disable mdc
9487 lru_resize_disable osc
9488 test_mkdir -c1 $DIR/$tdir/d1
9489 test_mkdir -c1 $DIR/$tdir/d2
9490 touch $DIR/$tdir/d1/f1
9491 cancel_lru_locks mdc
9492 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9493 can1=$(do_facet $SINGLEMDS \
9494 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9495 awk '/ldlm_cancel/ {print $2}')
9496 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9497 awk '/ldlm_bl_callback/ {print $2}')
9498 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9499 can2=$(do_facet $SINGLEMDS \
9500 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9501 awk '/ldlm_cancel/ {print $2}')
9502 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9503 awk '/ldlm_bl_callback/ {print $2}')
9504 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9505 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9506 lru_resize_enable mdc
9507 lru_resize_enable osc
9509 run_test 120c "Early Lock Cancel: link test"
9512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9513 remote_mds_nodsh && skip "remote MDS with nodsh"
9514 test_mkdir -c1 $DIR/$tdir
9515 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9516 skip_env "no early lock cancel on server"
9518 lru_resize_disable mdc
9519 lru_resize_disable osc
9521 cancel_lru_locks mdc
9522 stat $DIR/$tdir > /dev/null
9523 can1=$(do_facet $SINGLEMDS \
9524 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9525 awk '/ldlm_cancel/ {print $2}')
9526 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9527 awk '/ldlm_bl_callback/ {print $2}')
9528 chmod a+x $DIR/$tdir
9529 can2=$(do_facet $SINGLEMDS \
9530 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9531 awk '/ldlm_cancel/ {print $2}')
9532 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9533 awk '/ldlm_bl_callback/ {print $2}')
9534 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9535 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9536 lru_resize_enable mdc
9537 lru_resize_enable osc
9539 run_test 120d "Early Lock Cancel: setattr test"
9542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9543 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9544 skip_env "no early lock cancel on server"
9545 remote_mds_nodsh && skip "remote MDS with nodsh"
9547 local dlmtrace_set=false
9549 test_mkdir -c1 $DIR/$tdir
9550 lru_resize_disable mdc
9551 lru_resize_disable osc
9552 ! $LCTL get_param debug | grep -q dlmtrace &&
9553 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9554 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9555 cancel_lru_locks mdc
9556 cancel_lru_locks osc
9557 dd if=$DIR/$tdir/f1 of=/dev/null
9558 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9559 # XXX client can not do early lock cancel of OST lock
9560 # during unlink (LU-4206), so cancel osc lock now.
9562 cancel_lru_locks osc
9563 can1=$(do_facet $SINGLEMDS \
9564 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9565 awk '/ldlm_cancel/ {print $2}')
9566 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9567 awk '/ldlm_bl_callback/ {print $2}')
9568 unlink $DIR/$tdir/f1
9570 can2=$(do_facet $SINGLEMDS \
9571 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9572 awk '/ldlm_cancel/ {print $2}')
9573 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9574 awk '/ldlm_bl_callback/ {print $2}')
9575 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9576 $LCTL dk $TMP/cancel.debug.txt
9577 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9578 $LCTL dk $TMP/blocking.debug.txt
9579 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9580 lru_resize_enable mdc
9581 lru_resize_enable osc
9583 run_test 120e "Early Lock Cancel: unlink test"
9586 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9587 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9588 skip_env "no early lock cancel on server"
9589 remote_mds_nodsh && skip "remote MDS with nodsh"
9591 test_mkdir -c1 $DIR/$tdir
9592 lru_resize_disable mdc
9593 lru_resize_disable osc
9594 test_mkdir -c1 $DIR/$tdir/d1
9595 test_mkdir -c1 $DIR/$tdir/d2
9596 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9597 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9598 cancel_lru_locks mdc
9599 cancel_lru_locks osc
9600 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9601 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9602 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9603 # XXX client can not do early lock cancel of OST lock
9604 # during rename (LU-4206), so cancel osc lock now.
9606 cancel_lru_locks osc
9607 can1=$(do_facet $SINGLEMDS \
9608 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9609 awk '/ldlm_cancel/ {print $2}')
9610 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9611 awk '/ldlm_bl_callback/ {print $2}')
9612 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9614 can2=$(do_facet $SINGLEMDS \
9615 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9616 awk '/ldlm_cancel/ {print $2}')
9617 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9618 awk '/ldlm_bl_callback/ {print $2}')
9619 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9620 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9621 lru_resize_enable mdc
9622 lru_resize_enable osc
9624 run_test 120f "Early Lock Cancel: rename test"
9627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9628 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9629 skip_env "no early lock cancel on server"
9630 remote_mds_nodsh && skip "remote MDS with nodsh"
9632 lru_resize_disable mdc
9633 lru_resize_disable osc
9635 echo create $count files
9636 test_mkdir $DIR/$tdir
9637 cancel_lru_locks mdc
9638 cancel_lru_locks osc
9641 can0=$(do_facet $SINGLEMDS \
9642 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9643 awk '/ldlm_cancel/ {print $2}')
9644 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9645 awk '/ldlm_bl_callback/ {print $2}')
9646 createmany -o $DIR/$tdir/f $count
9648 can1=$(do_facet $SINGLEMDS \
9649 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9650 awk '/ldlm_cancel/ {print $2}')
9651 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9652 awk '/ldlm_bl_callback/ {print $2}')
9654 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9655 echo rm $count files
9658 can2=$(do_facet $SINGLEMDS \
9659 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9660 awk '/ldlm_cancel/ {print $2}')
9661 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9662 awk '/ldlm_bl_callback/ {print $2}')
9664 echo total: $count removes in $((t2-t1))
9665 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9667 # wait for commitment of removal
9668 lru_resize_enable mdc
9669 lru_resize_enable osc
9671 run_test 120g "Early Lock Cancel: performance test"
9673 test_121() { #bug #10589
9674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9677 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9678 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9679 lctl set_param fail_loc=0x310
9680 cancel_lru_locks osc > /dev/null
9681 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9682 lctl set_param fail_loc=0
9683 [[ $reads -eq $writes ]] ||
9684 error "read $reads blocks, must be $writes blocks"
9686 run_test 121 "read cancel race ========="
9688 test_123a() { # was test 123, statahead(bug 11401)
9689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9692 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9693 log "testing UP system. Performance may be lower than expected."
9698 test_mkdir $DIR/$tdir
9699 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9700 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9702 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9703 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9705 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9706 lctl set_param -n llite.*.statahead_max 0
9707 lctl get_param llite.*.statahead_max
9708 cancel_lru_locks mdc
9709 cancel_lru_locks osc
9711 time ls -l $DIR/$tdir | wc -l
9713 delta=$((etime - stime))
9714 log "ls $i files without statahead: $delta sec"
9715 lctl set_param llite.*.statahead_max=$max
9717 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9718 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9719 cancel_lru_locks mdc
9720 cancel_lru_locks osc
9722 time ls -l $DIR/$tdir | wc -l
9724 delta_sa=$((etime - stime))
9725 log "ls $i files with statahead: $delta_sa sec"
9726 lctl get_param -n llite.*.statahead_stats
9727 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9729 [[ $swrong -lt $ewrong ]] &&
9730 log "statahead was stopped, maybe too many locks held!"
9731 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9733 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9734 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9735 lctl set_param -n llite.*.statahead_max 0
9736 lctl get_param llite.*.statahead_max
9737 cancel_lru_locks mdc
9738 cancel_lru_locks osc
9740 time ls -l $DIR/$tdir | wc -l
9742 delta=$((etime - stime))
9743 log "ls $i files again without statahead: $delta sec"
9744 lctl set_param llite.*.statahead_max=$max
9745 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9746 if [ $SLOWOK -eq 0 ]; then
9747 error "ls $i files is slower with statahead!"
9749 log "ls $i files is slower with statahead!"
9755 [ $delta -gt 20 ] && break
9756 [ $delta -gt 8 ] && MULT=$((50 / delta))
9757 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9765 delta=$((etime - stime))
9766 log "rm -r $DIR/$tdir/: $delta seconds"
9768 lctl get_param -n llite.*.statahead_stats
9770 run_test 123a "verify statahead work"
9772 test_123b () { # statahead(bug 15027)
9773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9775 test_mkdir $DIR/$tdir
9776 createmany -o $DIR/$tdir/$tfile-%d 1000
9778 cancel_lru_locks mdc
9779 cancel_lru_locks osc
9781 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9782 lctl set_param fail_loc=0x80000803
9783 ls -lR $DIR/$tdir > /dev/null
9785 lctl set_param fail_loc=0x0
9786 lctl get_param -n llite.*.statahead_stats
9791 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9795 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9796 skip_env "no lru resize on server"
9800 test_mkdir $DIR/$tdir
9802 log "create $NR files at $DIR/$tdir"
9803 createmany -o $DIR/$tdir/f $NR ||
9804 error "failed to create $NR files in $DIR/$tdir"
9806 cancel_lru_locks mdc
9807 ls -l $DIR/$tdir > /dev/null
9811 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9812 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9813 LRU_SIZE=$($LCTL get_param -n $PARAM)
9814 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9815 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9817 log "NS=$(basename $NSDIR)"
9822 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9823 skip "Not enough cached locks created!"
9829 # We know that lru resize allows one client to hold $LIMIT locks
9830 # for 10h. After that locks begin to be killed by client.
9832 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9834 if [ $LIMIT -lt $LRU_SIZE ]; then
9835 skip "Limit is too small $LIMIT"
9838 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9839 # killing locks. Some time was spent for creating locks. This means
9840 # that up to the moment of sleep finish we must have killed some of
9841 # them (10-100 locks). This depends on how fast ther were created.
9842 # Many of them were touched in almost the same moment and thus will
9843 # be killed in groups.
9844 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9846 # Use $LRU_SIZE_B here to take into account real number of locks
9847 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9848 local LRU_SIZE_B=$LRU_SIZE
9850 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9851 log "OLD_LVF=$OLD_LVF"
9852 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9854 # Let's make sure that we really have some margin. Client checks
9855 # cached locks every 10 sec.
9857 log "Sleep ${SLEEP} sec"
9859 while ((SEC<$SLEEP)); do
9863 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9867 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9868 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9870 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9871 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9872 unlinkmany $DIR/$tdir/f $NR
9876 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9877 log "unlink $NR files at $DIR/$tdir"
9878 unlinkmany $DIR/$tdir/f $NR
9880 run_test 124a "lru resize ======================================="
9882 get_max_pool_limit()
9884 local limit=$($LCTL get_param \
9885 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9888 if [[ $l -gt $max ]]; then
9896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9897 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9898 skip_env "no lru resize on server"
9900 LIMIT=$(get_max_pool_limit)
9902 NR=$(($(default_lru_size)*20))
9903 if [[ $NR -gt $LIMIT ]]; then
9904 log "Limit lock number by $LIMIT locks"
9908 IFree=$(mdsrate_inodes_available)
9909 if [ $IFree -lt $NR ]; then
9910 log "Limit lock number by $IFree inodes"
9914 lru_resize_disable mdc
9915 test_mkdir -p $DIR/$tdir/disable_lru_resize
9917 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9918 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9919 cancel_lru_locks mdc
9922 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9925 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9928 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9932 nolruresize_delta=$((etime-stime))
9933 log "ls -la time: $nolruresize_delta seconds"
9934 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9935 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9937 lru_resize_enable mdc
9938 test_mkdir -p $DIR/$tdir/enable_lru_resize
9940 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9941 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9942 cancel_lru_locks mdc
9945 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9948 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9951 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9955 lruresize_delta=$((etime-stime))
9956 log "ls -la time: $lruresize_delta seconds"
9957 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9959 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9960 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9961 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9962 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9964 log "lru resize performs the same with no lru resize"
9966 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9968 run_test 124b "lru resize (performance test) ======================="
9971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9972 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9973 skip_env "no lru resize on server"
9975 # cache ununsed locks on client
9977 cancel_lru_locks mdc
9978 test_mkdir $DIR/$tdir
9979 createmany -o $DIR/$tdir/f $nr ||
9980 error "failed to create $nr files in $DIR/$tdir"
9981 ls -l $DIR/$tdir > /dev/null
9983 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9984 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9985 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9986 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9987 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9989 # set lru_max_age to 1 sec
9990 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9991 echo "sleep $((recalc_p * 2)) seconds..."
9992 sleep $((recalc_p * 2))
9994 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9995 # restore lru_max_age
9996 $LCTL set_param -n $nsdir.lru_max_age $max_age
9997 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9998 unlinkmany $DIR/$tdir/f $nr
10000 run_test 124c "LRUR cancel very aged locks"
10002 test_125() { # 13358
10003 $LCTL get_param -n llite.*.client_type | grep -q local ||
10004 skip "must run as local client"
10005 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10006 skip_env "must have acl enabled"
10007 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10009 test_mkdir $DIR/$tdir
10010 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10011 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10012 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10014 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10016 test_126() { # bug 12829/13455
10017 $GSS && skip_env "must run as gss disabled"
10018 $LCTL get_param -n llite.*.client_type | grep -q local ||
10019 skip "must run as local client"
10020 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10022 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10023 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10025 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10027 run_test 126 "check that the fsgid provided by the client is taken into account"
10029 test_127a() { # bug 15521
10030 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10032 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10033 $LCTL set_param osc.*.stats=0
10034 FSIZE=$((2048 * 1024))
10035 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10036 cancel_lru_locks osc
10037 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10039 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10040 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10041 echo "got $COUNT $NAME"
10042 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10043 eval $NAME=$COUNT || error "Wrong proc format"
10046 read_bytes|write_bytes)
10047 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10048 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10049 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10050 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10051 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10052 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10053 error "sumsquare is too small: $SUMSQ"
10054 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10055 error "sumsquare is too big: $SUMSQ"
10059 done < $DIR/${tfile}.tmp
10061 #check that we actually got some stats
10062 [ "$read_bytes" ] || error "Missing read_bytes stats"
10063 [ "$write_bytes" ] || error "Missing write_bytes stats"
10064 [ "$read_bytes" != 0 ] || error "no read done"
10065 [ "$write_bytes" != 0 ] || error "no write done"
10067 run_test 127a "verify the client stats are sane"
10069 test_127b() { # bug LU-333
10070 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10072 $LCTL set_param llite.*.stats=0
10073 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
10075 # perform 2 reads and writes so MAX is different from SUM.
10076 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10077 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10078 cancel_lru_locks osc
10079 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
10080 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
10082 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
10083 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10084 echo "got $COUNT $NAME"
10085 eval $NAME=$COUNT || error "Wrong proc format"
10089 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
10090 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
10091 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
10092 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
10095 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
10096 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
10097 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
10098 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
10102 done < $TMP/${tfile}.tmp
10104 #check that we actually got some stats
10105 [ "$read_bytes" ] || error "Missing read_bytes stats"
10106 [ "$write_bytes" ] || error "Missing write_bytes stats"
10107 [ "$read_bytes" != 0 ] || error "no read done"
10108 [ "$write_bytes" != 0 ] || error "no write done"
10110 rm -f $TMP/${tfile}.tmp
10112 run_test 127b "verify the llite client stats are sane"
10114 test_128() { # bug 15212
10116 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10121 result=$(grep error $TMP/$tfile.log)
10122 rm -f $DIR/$tfile $TMP/$tfile.log
10123 [ -z "$result" ] ||
10124 error "consecutive find's under interactive lfs failed"
10126 run_test 128 "interactive lfs for 2 consecutive find's"
10128 set_dir_limits () {
10133 local ldproc=/proc/fs/ldiskfs
10134 local facets=$(get_facets MDS)
10136 for facet in ${facets//,/ }; do
10137 canondev=$(ldiskfs_canon \
10138 *.$(convert_facet2label $facet).mntdev $facet)
10139 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10140 ldproc=/sys/fs/ldiskfs
10141 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10142 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10146 check_mds_dmesg() {
10147 local facets=$(get_facets MDS)
10148 for facet in ${facets//,/ }; do
10149 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10156 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
10157 skip "Need MDS version with at least 2.5.56"
10158 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
10159 skip_env "ldiskfs only test"
10161 remote_mds_nodsh && skip "remote MDS with nodsh"
10165 local has_warning=false
10168 mkdir -p $DIR/$tdir
10170 # block size of mds1
10171 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
10172 set_dir_limits $maxsize $maxsize
10173 local dirsize=$(stat -c%s "$DIR/$tdir")
10175 while [[ $dirsize -le $maxsize ]]; do
10176 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
10178 if ! $has_warning; then
10179 check_mds_dmesg '"is approaching"' && has_warning=true
10181 # check two errors:
10182 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
10183 # EFBIG for previous versions included in ldiskfs series
10184 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
10186 echo "return code $rc received as expected"
10188 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
10189 error_exit "create failed w/o dir size limit"
10191 check_mds_dmesg '"has reached"' ||
10192 error_exit "reached message should be output"
10194 [ $has_warning = "false" ] &&
10195 error_exit "warning message should be output"
10197 dirsize=$(stat -c%s "$DIR/$tdir")
10199 [[ $dirsize -ge $maxsize ]] && return 0
10200 error_exit "current dir size $dirsize, " \
10201 "previous limit $maxsize"
10202 elif [ $rc -ne 0 ]; then
10204 error_exit "return $rc received instead of expected " \
10205 "$EFBIG or $ENOSPC, files in dir $dirsize"
10207 nfiles=$((nfiles + 1))
10208 dirsize=$(stat -c%s "$DIR/$tdir")
10212 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
10214 run_test 129 "test directory size limit ========================"
10223 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10224 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10226 trap cleanup_130 EXIT RETURN
10228 local fm_file=$DIR/$tfile
10229 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
10230 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
10231 error "dd failed for $fm_file"
10233 # LU-1795: test filefrag/FIEMAP once, even if unsupported
10234 filefrag -ves $fm_file
10236 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10237 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10238 [ $RC != 0 ] && error "filefrag $fm_file failed"
10240 filefrag_op=$(filefrag -ve -k $fm_file |
10241 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10242 lun=$($GETSTRIPE -i $fm_file)
10244 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10247 for line in $filefrag_op
10249 frag_lun=`echo $line | cut -d: -f5`
10250 ext_len=`echo $line | cut -d: -f4`
10251 if (( $frag_lun != $lun )); then
10253 error "FIEMAP on 1-stripe file($fm_file) failed"
10256 (( tot_len += ext_len ))
10259 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10261 error "FIEMAP on 1-stripe file($fm_file) failed;"
10267 echo "FIEMAP on single striped file succeeded"
10269 run_test 130a "FIEMAP (1-stripe file)"
10272 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10274 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10275 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10277 trap cleanup_130 EXIT RETURN
10279 local fm_file=$DIR/$tfile
10280 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10281 error "setstripe on $fm_file"
10282 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10283 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10285 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10286 error "dd failed on $fm_file"
10288 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10289 filefrag_op=$(filefrag -ve -k $fm_file |
10290 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10292 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10293 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10298 for line in $filefrag_op
10300 frag_lun=$(echo $line | cut -d: -f5 |
10301 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10302 ext_len=$(echo $line | cut -d: -f4)
10303 if (( $frag_lun != $last_lun )); then
10304 if (( tot_len != 1024 )); then
10306 error "FIEMAP on $fm_file failed; returned " \
10307 "len $tot_len for OST $last_lun instead of 1024"
10310 (( num_luns += 1 ))
10314 (( tot_len += ext_len ))
10317 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10319 error "FIEMAP on $fm_file failed; returned wrong number of " \
10320 "luns or wrong len for OST $last_lun"
10326 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10328 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10331 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10333 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10334 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10336 trap cleanup_130 EXIT RETURN
10338 local fm_file=$DIR/$tfile
10339 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10340 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10341 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10343 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10344 error "dd failed on $fm_file"
10346 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10347 filefrag_op=$(filefrag -ve -k $fm_file |
10348 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10350 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10351 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10356 for line in $filefrag_op
10358 frag_lun=$(echo $line | cut -d: -f5 |
10359 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10360 ext_len=$(echo $line | cut -d: -f4)
10361 if (( $frag_lun != $last_lun )); then
10362 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10363 if (( logical != 512 )); then
10365 error "FIEMAP on $fm_file failed; returned " \
10366 "logical start for lun $logical instead of 512"
10369 if (( tot_len != 512 )); then
10371 error "FIEMAP on $fm_file failed; returned " \
10372 "len $tot_len for OST $last_lun instead of 1024"
10375 (( num_luns += 1 ))
10379 (( tot_len += ext_len ))
10382 if (( num_luns != 2 || tot_len != 512 )); then
10384 error "FIEMAP on $fm_file failed; returned wrong number of " \
10385 "luns or wrong len for OST $last_lun"
10391 echo "FIEMAP on 2-stripe file with hole succeeded"
10393 run_test 130c "FIEMAP (2-stripe file with hole)"
10396 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
10398 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10399 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10401 trap cleanup_130 EXIT RETURN
10403 local fm_file=$DIR/$tfile
10404 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10405 error "setstripe on $fm_file"
10406 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10407 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10409 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
10410 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
10411 error "dd failed on $fm_file"
10413 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10414 filefrag_op=$(filefrag -ve -k $fm_file |
10415 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10417 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10418 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10423 for line in $filefrag_op
10425 frag_lun=$(echo $line | cut -d: -f5 |
10426 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10427 ext_len=$(echo $line | cut -d: -f4)
10428 if (( $frag_lun != $last_lun )); then
10429 if (( tot_len != 1024 )); then
10431 error "FIEMAP on $fm_file failed; returned " \
10432 "len $tot_len for OST $last_lun instead of 1024"
10435 (( num_luns += 1 ))
10439 (( tot_len += ext_len ))
10442 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
10444 error "FIEMAP on $fm_file failed; returned wrong number of " \
10445 "luns or wrong len for OST $last_lun"
10451 echo "FIEMAP on N-stripe file succeeded"
10453 run_test 130d "FIEMAP (N-stripe file)"
10456 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10458 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10459 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10461 trap cleanup_130 EXIT RETURN
10463 local fm_file=$DIR/$tfile
10464 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
10465 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10466 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10469 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
10470 for ((i = 0; i < $NUM_BLKS; i++))
10472 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
10475 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10476 filefrag_op=$(filefrag -ve -k $fm_file |
10477 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10479 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10480 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10485 for line in $filefrag_op
10487 frag_lun=$(echo $line | cut -d: -f5 |
10488 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10489 ext_len=$(echo $line | cut -d: -f4)
10490 if (( $frag_lun != $last_lun )); then
10491 if (( tot_len != $EXPECTED_LEN )); then
10493 error "FIEMAP on $fm_file failed; returned " \
10494 "len $tot_len for OST $last_lun instead " \
10498 (( num_luns += 1 ))
10502 (( tot_len += ext_len ))
10505 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10507 error "FIEMAP on $fm_file failed; returned wrong number " \
10508 "of luns or wrong len for OST $last_lun"
10514 echo "FIEMAP with continuation calls succeeded"
10516 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10519 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10520 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10522 local fm_file=$DIR/$tfile
10523 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
10524 error "multiop create with lov_delay_create on $fm_file"
10526 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10527 filefrag_extents=$(filefrag -vek $fm_file |
10528 awk '/extents? found/ { print $2 }')
10529 if [[ "$filefrag_extents" != "0" ]]; then
10530 error "FIEMAP on $fm_file failed; " \
10531 "returned $filefrag_extents expected 0"
10536 run_test 130f "FIEMAP (unstriped file)"
10538 # Test for writev/readv
10540 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10541 error "writev test failed"
10542 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10543 error "readv failed"
10546 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10549 local fsize=$((524288 + 1048576 + 1572864))
10550 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10551 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10552 error "append writev test failed"
10554 ((fsize += 1572864 + 1048576))
10555 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10556 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10557 error "append writev test failed"
10560 run_test 131b "test append writev"
10563 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10566 run_test 131c "test read/write on file w/o objects"
10569 rwv -f $DIR/$tfile -w -n 1 1572864
10570 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10571 if [ "$NOB" != 1572864 ]; then
10572 error "Short read filed: read $NOB bytes instead of 1572864"
10576 run_test 131d "test short read"
10579 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10580 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10581 error "read hitting hole failed"
10584 run_test 131e "test read hitting hole"
10593 mds*) res=$(do_facet $facet \
10594 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10596 ost*) res=$(do_facet $facet \
10597 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10599 *) error "Wrong facet '$facet'" ;;
10602 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10603 # if the argument $3 is zero, it means any stat increment is ok.
10604 if [[ $want -gt 0 ]]; then
10605 local count=$(echo $res | awk '{ print $2 }')
10606 [[ $count -ne $want ]] &&
10607 error "The $op counter on $facet is $count, not $want"
10612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10613 remote_ost_nodsh && skip "remote OST with nodsh"
10614 remote_mds_nodsh && skip "remote MDS with nodsh"
10615 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10616 skip_env "MDS doesn't support rename stats"
10618 local testdir=$DIR/${tdir}/stats_testdir
10620 mkdir -p $DIR/${tdir}
10623 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10624 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10626 # verify mdt stats first.
10627 mkdir ${testdir} || error "mkdir failed"
10628 check_stats $SINGLEMDS "mkdir" 1
10629 touch ${testdir}/${tfile} || error "touch failed"
10630 check_stats $SINGLEMDS "open" 1
10631 check_stats $SINGLEMDS "close" 1
10632 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10633 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10634 check_stats $SINGLEMDS "mknod" 2
10636 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10637 check_stats $SINGLEMDS "unlink" 1
10638 rm -f ${testdir}/${tfile} || error "file remove failed"
10639 check_stats $SINGLEMDS "unlink" 2
10641 # remove working dir and check mdt stats again.
10642 rmdir ${testdir} || error "rmdir failed"
10643 check_stats $SINGLEMDS "rmdir" 1
10645 local testdir1=$DIR/${tdir}/stats_testdir1
10646 mkdir -p ${testdir}
10647 mkdir -p ${testdir1}
10648 touch ${testdir1}/test1
10649 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10650 check_stats $SINGLEMDS "crossdir_rename" 1
10652 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10653 check_stats $SINGLEMDS "samedir_rename" 1
10655 rm -rf $DIR/${tdir}
10657 run_test 133a "Verifying MDT stats ========================================"
10660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10661 remote_ost_nodsh && skip "remote OST with nodsh"
10662 remote_mds_nodsh && skip "remote MDS with nodsh"
10664 local testdir=$DIR/${tdir}/stats_testdir
10666 mkdir -p ${testdir} || error "mkdir failed"
10667 touch ${testdir}/${tfile} || error "touch failed"
10668 cancel_lru_locks mdc
10671 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10672 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10674 # extra mdt stats verification.
10675 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10676 check_stats $SINGLEMDS "setattr" 1
10677 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10678 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10680 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10681 check_stats $SINGLEMDS "getattr" 1
10683 $LFS df || error "lfs failed"
10684 check_stats $SINGLEMDS "statfs" 1
10686 rm -rf $DIR/${tdir}
10688 run_test 133b "Verifying extra MDT stats =================================="
10691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10692 remote_ost_nodsh && skip "remote OST with nodsh"
10693 remote_mds_nodsh && skip "remote MDS with nodsh"
10695 local testdir=$DIR/$tdir/stats_testdir
10697 test_mkdir -p $testdir
10699 # verify obdfilter stats.
10700 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10702 cancel_lru_locks osc
10703 wait_delete_completed
10706 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10707 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10709 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10712 cancel_lru_locks osc
10713 check_stats ost1 "write" 1
10715 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10716 check_stats ost1 "read" 1
10718 > $testdir/$tfile || error "truncate failed"
10719 check_stats ost1 "punch" 1
10721 rm -f $testdir/$tfile || error "file remove failed"
10722 wait_delete_completed
10723 check_stats ost1 "destroy" 1
10727 run_test 133c "Verifying OST stats ========================================"
10734 while [ $value -ge 2 ]; do
10739 if [ $orig -gt $order ]; then
10747 local size=('K' 'M' 'G' 'T');
10749 local size_string=$value
10751 while [ $value -ge 1024 ]; do
10752 if [ $i -gt 3 ]; then
10753 #T is the biggest unit we get here, if that is bigger,
10755 size_string=${value}T
10758 value=$((value >> 10))
10759 if [ $value -lt 1024 ]; then
10760 size_string=${value}${size[$i]}
10769 get_rename_size() {
10771 local context=${2:-.}
10772 local sample=$(do_facet $SINGLEMDS $LCTL \
10773 get_param mdt.$FSNAME-MDT0000.rename_stats |
10774 grep -A1 $context |
10775 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10781 remote_ost_nodsh && skip "remote OST with nodsh"
10782 remote_mds_nodsh && skip "remote MDS with nodsh"
10783 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10784 skip_env "MDS doesn't support rename stats"
10786 local testdir1=$DIR/${tdir}/stats_testdir1
10787 local testdir2=$DIR/${tdir}/stats_testdir2
10788 mkdir -p $DIR/${tdir}
10790 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10792 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
10793 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
10795 createmany -o $testdir1/test 512 || error "createmany failed"
10797 # check samedir rename size
10798 mv ${testdir1}/test0 ${testdir1}/test_0
10800 local testdir1_size=$(ls -l $DIR/${tdir} |
10801 awk '/stats_testdir1/ {print $5}')
10802 local testdir2_size=$(ls -l $DIR/${tdir} |
10803 awk '/stats_testdir2/ {print $5}')
10805 testdir1_size=$(order_2 $testdir1_size)
10806 testdir2_size=$(order_2 $testdir2_size)
10808 testdir1_size=$(size_in_KMGT $testdir1_size)
10809 testdir2_size=$(size_in_KMGT $testdir2_size)
10811 echo "source rename dir size: ${testdir1_size}"
10812 echo "target rename dir size: ${testdir2_size}"
10814 local cmd="do_facet $SINGLEMDS $LCTL "
10815 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10817 eval $cmd || error "$cmd failed"
10818 local samedir=$($cmd | grep 'same_dir')
10819 local same_sample=$(get_rename_size $testdir1_size)
10820 [ -z "$samedir" ] && error "samedir_rename_size count error"
10821 [[ $same_sample -eq 1 ]] ||
10822 error "samedir_rename_size error $same_sample"
10823 echo "Check same dir rename stats success"
10825 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10827 # check crossdir rename size
10828 mv ${testdir1}/test_0 ${testdir2}/test_0
10830 testdir1_size=$(ls -l $DIR/${tdir} |
10831 awk '/stats_testdir1/ {print $5}')
10832 testdir2_size=$(ls -l $DIR/${tdir} |
10833 awk '/stats_testdir2/ {print $5}')
10835 testdir1_size=$(order_2 $testdir1_size)
10836 testdir2_size=$(order_2 $testdir2_size)
10838 testdir1_size=$(size_in_KMGT $testdir1_size)
10839 testdir2_size=$(size_in_KMGT $testdir2_size)
10841 echo "source rename dir size: ${testdir1_size}"
10842 echo "target rename dir size: ${testdir2_size}"
10844 eval $cmd || error "$cmd failed"
10845 local crossdir=$($cmd | grep 'crossdir')
10846 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10847 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10848 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10849 [[ $src_sample -eq 1 ]] ||
10850 error "crossdir_rename_size error $src_sample"
10851 [[ $tgt_sample -eq 1 ]] ||
10852 error "crossdir_rename_size error $tgt_sample"
10853 echo "Check cross dir rename stats success"
10854 rm -rf $DIR/${tdir}
10856 run_test 133d "Verifying rename_stats ========================================"
10859 remote_mds_nodsh && skip "remote MDS with nodsh"
10860 remote_ost_nodsh && skip "remote OST with nodsh"
10861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10863 local testdir=$DIR/${tdir}/stats_testdir
10864 local ctr f0 f1 bs=32768 count=42 sum
10866 mkdir -p ${testdir} || error "mkdir failed"
10868 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10870 for ctr in {write,read}_bytes; do
10872 cancel_lru_locks osc
10874 do_facet ost1 $LCTL set_param -n \
10875 "obdfilter.*.exports.clear=clear"
10877 if [ $ctr = write_bytes ]; then
10879 f1=${testdir}/${tfile}
10881 f0=${testdir}/${tfile}
10885 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10888 cancel_lru_locks osc
10890 sum=$(do_facet ost1 $LCTL get_param \
10891 "obdfilter.*.exports.*.stats" |
10892 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10893 $1 == ctr { sum += $7 }
10894 END { printf("%0.0f", sum) }')
10896 if ((sum != bs * count)); then
10897 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10901 rm -rf $DIR/${tdir}
10903 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10905 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10908 # First without trusting modes.
10909 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10910 echo "proc_dirs='$proc_dirs'"
10911 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10912 find $proc_dirs -exec cat '{}' \; &> /dev/null
10914 # Second verifying readability.
10915 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10917 # Verifing writability with badarea_io.
10919 -ignore_readdir_race \
10921 -not -name force_lbug \
10922 -not -name changelog_mask \
10923 -exec badarea_io '{}' \; ||
10924 error "find $proc_dirs failed"
10926 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
10929 remote_mds_nodsh && skip "remote MDS with nodsh"
10930 remote_ost_nodsh && skip "remote OST with nodsh"
10932 # eventually, this can also be replaced with "lctl get_param -R",
10933 # but not until that option is always available on the server
10935 for facet in mds1 ost1; do
10936 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10937 skip_noexit "Too old lustre on $facet"
10938 local facet_proc_dirs=$(do_facet $facet \
10939 \\\ls -d $proc_regexp 2>/dev/null)
10940 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10941 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10942 do_facet $facet find $facet_proc_dirs \
10943 ! -name req_history \
10944 -exec cat '{}' \\\; &> /dev/null
10946 do_facet $facet find $facet_proc_dirs \
10947 ! -name req_history \
10949 -exec cat '{}' \\\; &> /dev/null ||
10950 error "proc file read failed"
10952 do_facet $facet find $facet_proc_dirs \
10953 -ignore_readdir_race \
10955 -not -name force_lbug \
10956 -not -name changelog_mask \
10957 -exec badarea_io '{}' \\\; ||
10958 error "$facet find $facet_proc_dirs failed"
10961 # remount the FS in case writes/reads /proc break the FS
10962 cleanup || error "failed to unmount"
10963 setup || error "failed to setup"
10966 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
10969 remote_mds_nodsh && skip "remote MDS with nodsh"
10970 remote_ost_nodsh && skip "remote OST with nodsh"
10971 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10972 skip "Need MDS version at least 2.9.54"
10976 for facet in client mds1 ost1; do
10977 local facet_proc_dirs=$(do_facet $facet \
10978 \\\ls -d $proc_regexp 2> /dev/null)
10979 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10980 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10981 # Get the list of files that are missing the terminating newline
10982 local missing=($(do_facet $facet \
10983 find ${facet_proc_dirs} -type f \| \
10984 while read F\; do \
10985 awk -v FS='\v' -v RS='\v\v' \
10986 "'END { if(NR>0 && \
10987 \\\$NF !~ /.*\\\n\$/) \
10988 print FILENAME}'" \
10991 [ ${#missing[*]} -eq 0 ] ||
10992 error "files do not end with newline: ${missing[*]}"
10995 run_test 133h "Proc files should end with newlines"
10998 remote_mds_nodsh && skip "remote MDS with nodsh"
10999 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
11000 skip "Need MDS version at least 2.7.54"
11002 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11003 cancel_lru_locks mdc
11005 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11006 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11007 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11010 createmany -o $DIR/$tdir/f $nr ||
11011 error "failed to create $nr files in $DIR/$tdir"
11012 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11014 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11015 do_facet mds1 $LCTL set_param fail_loc=0x327
11016 do_facet mds1 $LCTL set_param fail_val=500
11019 echo "sleep 10 seconds ..."
11021 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11023 do_facet mds1 $LCTL set_param fail_loc=0
11024 do_facet mds1 $LCTL set_param fail_val=0
11025 [ $lck_cnt -lt $unused ] ||
11026 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11029 unlinkmany $DIR/$tdir/f $nr
11031 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11034 remote_mds_nodsh && skip "remote MDS with nodsh"
11035 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
11036 skip "Need MDS version at least 2.7.54"
11038 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11039 cancel_lru_locks mdc
11041 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11042 ldlm.lock_reclaim_threshold_mb)
11043 # disable reclaim temporarily
11044 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11046 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11047 do_facet mds1 $LCTL set_param fail_loc=0x328
11048 do_facet mds1 $LCTL set_param fail_val=500
11050 $LCTL set_param debug=+trace
11053 createmany -o $DIR/$tdir/f $nr &
11054 local create_pid=$!
11056 echo "Sleep $TIMEOUT seconds ..."
11058 if ! ps -p $create_pid > /dev/null 2>&1; then
11059 do_facet mds1 $LCTL set_param fail_loc=0
11060 do_facet mds1 $LCTL set_param fail_val=0
11061 do_facet mds1 $LCTL set_param \
11062 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11063 error "createmany finished incorrectly!"
11065 do_facet mds1 $LCTL set_param fail_loc=0
11066 do_facet mds1 $LCTL set_param fail_val=0
11067 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11068 wait $create_pid || return 1
11070 unlinkmany $DIR/$tdir/f $nr
11072 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11074 test_140() { #bug-17379
11075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11077 test_mkdir $DIR/$tdir
11078 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11079 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11081 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11082 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11084 while i=$((i + 1)); do
11086 cd $i || error "Changing to $i"
11087 ln -s ../stat stat || error "Creating stat symlink"
11088 # Read the symlink until ELOOP present,
11089 # not LBUGing the system is considered success,
11090 # we didn't overrun the stack.
11091 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11092 if [ $ret -ne 0 ]; then
11093 if [ $ret -eq 40 ]; then
11096 error "Open stat symlink"
11102 echo "The symlink depth = $i"
11103 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
11104 error "Invalid symlink depth"
11106 # Test recursive symlink
11107 ln -s symlink_self symlink_self
11108 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11109 echo "open symlink_self returns $ret"
11110 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11112 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11117 local TF="$TMP/$tfile"
11119 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11121 cancel_lru_locks $OSC
11122 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
11123 remount_client $MOUNT
11125 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
11128 $TRUNCATE $DIR/$tfile 6000
11129 cancel_lru_locks $OSC
11130 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
11133 echo "12345" >>$DIR/$tfile
11134 cancel_lru_locks $OSC
11135 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
11138 echo "12345" >>$DIR/$tfile
11139 cancel_lru_locks $OSC
11140 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
11145 run_test 150 "truncate/append tests"
11147 #LU-2902 roc_hit was not able to read all values from lproc
11148 function roc_hit_init() {
11149 local list=$(comma_list $(osts_nodes))
11150 local dir=$DIR/$tdir-check
11151 local file=$dir/$tfile
11157 #use setstripe to do a write to every ost
11158 for i in $(seq 0 $((OSTCOUNT-1))); do
11159 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
11160 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
11161 idx=$(printf %04x $i)
11162 BEFORE=$(get_osd_param $list *OST*$idx stats |
11163 awk '$1 == "cache_access" {sum += $7}
11164 END { printf("%0.0f", sum) }')
11166 cancel_lru_locks osc
11167 cat $file >/dev/null
11169 AFTER=$(get_osd_param $list *OST*$idx stats |
11170 awk '$1 == "cache_access" {sum += $7}
11171 END { printf("%0.0f", sum) }')
11173 echo BEFORE:$BEFORE AFTER:$AFTER
11174 if ! let "AFTER - BEFORE == 4"; then
11176 error "roc_hit is not safe to use"
11184 function roc_hit() {
11185 local list=$(comma_list $(osts_nodes))
11186 echo $(get_osd_param $list '' stats |
11187 awk '$1 == "cache_hit" {sum += $7}
11188 END { printf("%0.0f", sum) }')
11191 function set_cache() {
11194 if [ "$2" == "off" ]; then
11197 local list=$(comma_list $(osts_nodes))
11198 set_osd_param $list '' $1_cache_enable $on
11200 cancel_lru_locks osc
11204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11205 remote_ost_nodsh && skip "remote OST with nodsh"
11208 local list=$(comma_list $(osts_nodes))
11210 # check whether obdfilter is cache capable at all
11211 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
11212 skip "not cache-capable obdfilter"
11215 # check cache is enabled on all obdfilters
11216 if get_osd_param $list '' read_cache_enable | grep 0; then
11217 skip "oss cache is disabled"
11220 set_osd_param $list '' writethrough_cache_enable 1
11222 # check write cache is enabled on all obdfilters
11223 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
11224 skip "oss write cache is NOT enabled"
11229 #define OBD_FAIL_OBD_NO_LRU 0x609
11230 do_nodes $list $LCTL set_param fail_loc=0x609
11232 # pages should be in the case right after write
11233 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
11236 local BEFORE=$(roc_hit)
11237 cancel_lru_locks osc
11238 cat $DIR/$tfile >/dev/null
11239 local AFTER=$(roc_hit)
11241 do_nodes $list $LCTL set_param fail_loc=0
11243 if ! let "AFTER - BEFORE == CPAGES"; then
11244 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11247 # the following read invalidates the cache
11248 cancel_lru_locks osc
11249 set_osd_param $list '' read_cache_enable 0
11250 cat $DIR/$tfile >/dev/null
11252 # now data shouldn't be found in the cache
11254 cancel_lru_locks osc
11255 cat $DIR/$tfile >/dev/null
11257 if let "AFTER - BEFORE != 0"; then
11258 error "IN CACHE: before: $BEFORE, after: $AFTER"
11261 set_osd_param $list '' read_cache_enable 1
11264 run_test 151 "test cache on oss and controls ==============================="
11267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11269 local TF="$TMP/$tfile"
11271 # simulate ENOMEM during write
11272 #define OBD_FAIL_OST_NOMEM 0x226
11273 lctl set_param fail_loc=0x80000226
11274 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11276 sync || error "sync failed"
11277 lctl set_param fail_loc=0
11279 # discard client's cache
11280 cancel_lru_locks osc
11282 # simulate ENOMEM during read
11283 lctl set_param fail_loc=0x80000226
11284 cmp $TF $DIR/$tfile || error "cmp failed"
11285 lctl set_param fail_loc=0
11289 run_test 152 "test read/write with enomem ============================"
11292 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11294 run_test 153 "test if fdatasync does not crash ======================="
11296 dot_lustre_fid_permission_check() {
11298 local ffid=$MOUNT/.lustre/fid/$fid
11301 echo "stat fid $fid"
11302 stat $ffid > /dev/null || error "stat $ffid failed."
11303 echo "touch fid $fid"
11304 touch $ffid || error "touch $ffid failed."
11305 echo "write to fid $fid"
11306 cat /etc/hosts > $ffid || error "write $ffid failed."
11307 echo "read fid $fid"
11308 diff /etc/hosts $ffid || error "read $ffid failed."
11309 echo "append write to fid $fid"
11310 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11311 echo "rename fid $fid"
11312 mv $ffid $test_dir/$tfile.1 &&
11313 error "rename $ffid to $tfile.1 should fail."
11314 touch $test_dir/$tfile.1
11315 mv $test_dir/$tfile.1 $ffid &&
11316 error "rename $tfile.1 to $ffid should fail."
11317 rm -f $test_dir/$tfile.1
11318 echo "truncate fid $fid"
11319 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11320 echo "link fid $fid"
11321 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11322 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11323 echo "setfacl fid $fid"
11324 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11325 echo "getfacl fid $fid"
11326 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11328 echo "unlink fid $fid"
11329 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11330 echo "mknod fid $fid"
11331 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11333 fid=[0xf00000400:0x1:0x0]
11334 ffid=$MOUNT/.lustre/fid/$fid
11336 echo "stat non-exist fid $fid"
11337 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11338 echo "write to non-exist fid $fid"
11339 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11340 echo "link new fid $fid"
11341 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11343 mkdir -p $test_dir/$tdir
11344 touch $test_dir/$tdir/$tfile
11345 fid=$($LFS path2fid $test_dir/$tdir)
11348 error "error: could not get fid for $test_dir/$dir/$tfile."
11350 ffid=$MOUNT/.lustre/fid/$fid
11353 ls $ffid > /dev/null || error "ls $ffid failed."
11354 echo "touch $fid/$tfile.1"
11355 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11357 echo "touch $MOUNT/.lustre/fid/$tfile"
11358 touch $MOUNT/.lustre/fid/$tfile && \
11359 error "touch $MOUNT/.lustre/fid/$tfile should fail."
11361 echo "setxattr to $MOUNT/.lustre/fid"
11362 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
11364 echo "listxattr for $MOUNT/.lustre/fid"
11365 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
11367 echo "delxattr from $MOUNT/.lustre/fid"
11368 setfattr -x trusted.name1 $MOUNT/.lustre/fid
11370 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
11371 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
11372 error "touch invalid fid should fail."
11374 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
11375 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
11376 error "touch non-normal fid should fail."
11378 echo "rename $tdir to $MOUNT/.lustre/fid"
11379 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
11380 error "rename to $MOUNT/.lustre/fid should fail."
11382 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
11384 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
11385 local new_obf_mode=777
11387 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
11388 chmod $new_obf_mode $DIR/.lustre/fid ||
11389 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
11391 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
11392 [ $obf_mode -eq $new_obf_mode ] ||
11393 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
11395 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
11396 chmod $old_obf_mode $DIR/.lustre/fid ||
11397 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
11400 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
11401 fid=$($LFS path2fid $test_dir/$tfile-2)
11403 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
11405 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
11406 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
11407 error "create lov data thru .lustre failed"
11409 echo "cp /etc/passwd $test_dir/$tfile-2"
11410 cp /etc/passwd $test_dir/$tfile-2 ||
11411 error "copy to $test_dir/$tfile-2 failed."
11412 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
11413 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
11414 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
11416 rm -rf $test_dir/tfile.lnk
11417 rm -rf $test_dir/$tfile-2
11421 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11422 skip "Need MDS version at least 2.4.1"
11424 local tf=$DIR/$tfile
11427 local fid=$($LFS path2fid $tf)
11428 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
11430 # check that we get the same pathname back
11431 local found=$($LFS fid2path $MOUNT "$fid")
11432 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
11433 [ "$found" == "$tf" ] ||
11434 error "fid2path($fid=path2fid($tf)) = $found != $tf"
11436 run_test 154A "lfs path2fid and fid2path basic checks"
11439 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11440 skip "Need MDS version at least 2.4.1"
11442 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11443 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11444 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
11445 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
11447 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
11448 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
11450 # check that we get the same pathname
11451 echo "PFID: $PFID, name: $name"
11452 local FOUND=$($LFS fid2path $MOUNT "$PFID")
11453 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
11454 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
11455 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
11457 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
11459 run_test 154B "verify the ll_decode_linkea tool"
11462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11463 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11464 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11465 skip "Need MDS version at least 2.2.51"
11466 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11468 cp /etc/hosts $DIR/$tfile
11470 fid=$($LFS path2fid $DIR/$tfile)
11472 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
11474 dot_lustre_fid_permission_check "$fid" $DIR ||
11475 error "dot lustre permission check $fid failed"
11477 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
11479 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
11481 touch $MOUNT/.lustre/file &&
11482 error "creation is not allowed under .lustre"
11484 mkdir $MOUNT/.lustre/dir &&
11485 error "mkdir is not allowed under .lustre"
11489 run_test 154a "Open-by-FID"
11492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11493 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11494 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
11495 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11496 skip "Need MDS version at least 2.2.51"
11498 local remote_dir=$DIR/$tdir/remote_dir
11502 mkdir -p $DIR/$tdir
11503 $LFS mkdir -i $MDTIDX $remote_dir ||
11504 error "create remote directory failed"
11506 cp /etc/hosts $remote_dir/$tfile
11508 fid=$($LFS path2fid $remote_dir/$tfile)
11510 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11512 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11513 error "dot lustre permission check $fid failed"
11516 run_test 154b "Open-by-FID for remote directory"
11519 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11520 skip "Need MDS version at least 2.4.1"
11522 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11523 local FID1=$($LFS path2fid $DIR/$tfile.1)
11524 local FID2=$($LFS path2fid $DIR/$tfile.2)
11525 local FID3=$($LFS path2fid $DIR/$tfile.3)
11528 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11529 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11530 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11532 [ "$FID" = "${!want}" ] ||
11533 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11537 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11539 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11540 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11544 run_test 154c "lfs path2fid and fid2path multiple arguments"
11547 remote_mds_nodsh && skip "remote MDS with nodsh"
11548 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
11549 skip "Need MDS version at least 2.5.53"
11551 if remote_mds; then
11552 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11556 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11563 local fid=$($LFS path2fid $DIR/$tfile)
11566 cmd="exec $fd<$DIR/$tfile"
11568 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11569 echo "$fid_list" | grep "$fid"
11572 cmd="exec $fd>/dev/null"
11574 if [ $rc -ne 0 ]; then
11575 error "FID $fid not found in open files list $fid_list"
11578 run_test 154d "Verify open file fid"
11582 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
11583 skip "Need MDS version at least 2.6.50"
11585 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11586 error ".lustre returned by readdir"
11589 run_test 154e ".lustre is not returned by readdir"
11592 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11594 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11595 test_mkdir -p -c1 $DIR/$tdir/d
11596 # test dirs inherit from its stripe
11597 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11598 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11599 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11600 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11603 # get fid of parents
11604 local FID0=$($LFS path2fid $DIR/$tdir/d)
11605 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11606 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11607 local FID3=$($LFS path2fid $DIR)
11609 # check that path2fid --parents returns expected <parent_fid>/name
11610 # 1) test for a directory (single parent)
11611 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11612 [ "$parent" == "$FID0/foo1" ] ||
11613 error "expected parent: $FID0/foo1, got: $parent"
11615 # 2) test for a file with nlink > 1 (multiple parents)
11616 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11617 echo "$parent" | grep -F "$FID1/$tfile" ||
11618 error "$FID1/$tfile not returned in parent list"
11619 echo "$parent" | grep -F "$FID2/link" ||
11620 error "$FID2/link not returned in parent list"
11622 # 3) get parent by fid
11623 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11624 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11625 echo "$parent" | grep -F "$FID1/$tfile" ||
11626 error "$FID1/$tfile not returned in parent list (by fid)"
11627 echo "$parent" | grep -F "$FID2/link" ||
11628 error "$FID2/link not returned in parent list (by fid)"
11630 # 4) test for entry in root directory
11631 parent=$($LFS path2fid --parents $DIR/f)
11632 echo "$parent" | grep -F "$FID3/f" ||
11633 error "$FID3/f not returned in parent list"
11635 # 5) test it on root directory
11636 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11637 error "$MOUNT should not have parents"
11639 # enable xattr caching and check that linkea is correctly updated
11640 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11641 save_lustre_params client "llite.*.xattr_cache" > $save
11642 lctl set_param llite.*.xattr_cache 1
11644 # 6.1) linkea update on rename
11645 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11647 # get parents by fid
11648 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11649 # foo1 should no longer be returned in parent list
11650 echo "$parent" | grep -F "$FID1" &&
11651 error "$FID1 should no longer be in parent list"
11652 # the new path should appear
11653 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11654 error "$FID2/$tfile.moved is not in parent list"
11656 # 6.2) linkea update on unlink
11657 rm -f $DIR/$tdir/d/foo2/link
11658 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11659 # foo2/link should no longer be returned in parent list
11660 echo "$parent" | grep -F "$FID2/link" &&
11661 error "$FID2/link should no longer be in parent list"
11665 restore_lustre_params < $save
11668 run_test 154f "get parent fids by reading link ea"
11672 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11673 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11674 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11675 skip "Need MDS version at least 2.6.92"
11677 mkdir -p $DIR/$tdir
11678 llapi_fid_test -d $DIR/$tdir
11680 run_test 154g "various llapi FID tests"
11682 test_155_small_load() {
11683 local temp=$TMP/$tfile
11684 local file=$DIR/$tfile
11686 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11687 error "dd of=$temp bs=6096 count=1 failed"
11689 cancel_lru_locks $OSC
11690 cmp $temp $file || error "$temp $file differ"
11692 $TRUNCATE $temp 6000
11693 $TRUNCATE $file 6000
11694 cmp $temp $file || error "$temp $file differ (truncate1)"
11696 echo "12345" >>$temp
11697 echo "12345" >>$file
11698 cmp $temp $file || error "$temp $file differ (append1)"
11700 echo "12345" >>$temp
11701 echo "12345" >>$file
11702 cmp $temp $file || error "$temp $file differ (append2)"
11708 test_155_big_load() {
11709 remote_ost_nodsh && skip "remote OST with nodsh"
11711 local temp=$TMP/$tfile
11712 local file=$DIR/$tfile
11715 local cache_size=$(do_facet ost$((MAXI+1)) \
11716 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11717 local large_file_size=$((cache_size * 2))
11719 echo "OSS cache size: $cache_size KB"
11720 echo "Large file size: $large_file_size KB"
11722 [ $MAXV -le $large_file_size ] &&
11723 skip_env "max available OST size needs > $large_file_size KB"
11725 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11727 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
11728 error "dd of=$temp bs=$large_file_size count=1k failed"
11731 cancel_lru_locks osc
11732 cmp $temp $file || error "$temp $file differ"
11738 save_writethrough() {
11739 local facets=$(get_facets OST)
11741 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11742 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11746 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11748 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11750 save_writethrough $p
11753 set_cache writethrough on
11754 test_155_small_load
11755 restore_lustre_params < $p
11758 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11763 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11765 save_writethrough $p
11768 set_cache writethrough off
11769 test_155_small_load
11770 restore_lustre_params < $p
11773 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11778 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11780 save_writethrough $p
11783 set_cache writethrough on
11784 test_155_small_load
11785 restore_lustre_params < $p
11788 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11793 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11795 save_writethrough $p
11798 set_cache writethrough off
11799 test_155_small_load
11800 restore_lustre_params < $p
11803 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11808 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11810 save_writethrough $p
11813 set_cache writethrough on
11815 restore_lustre_params < $p
11818 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11821 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11823 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11825 save_writethrough $p
11828 set_cache writethrough off
11830 restore_lustre_params < $p
11833 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11838 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11840 save_writethrough $p
11843 set_cache writethrough on
11845 restore_lustre_params < $p
11848 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11853 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11855 save_writethrough $p
11858 set_cache writethrough off
11860 restore_lustre_params < $p
11863 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11866 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11867 remote_ost_nodsh && skip "remote OST with nodsh"
11868 [ "$(facet_fstype ost1)" = "zfs" -a \
11869 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11870 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
11875 local file="$DIR/$tfile"
11876 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11878 save_writethrough $p
11881 log "Turn on read and write cache"
11883 set_cache writethrough on
11885 log "Write data and read it back."
11886 log "Read should be satisfied from the cache."
11887 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11889 cancel_lru_locks osc
11890 cat $file >/dev/null
11892 if ! let "AFTER - BEFORE == CPAGES"; then
11893 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11895 log "cache hits:: before: $BEFORE, after: $AFTER"
11898 log "Read again; it should be satisfied from the cache."
11900 cancel_lru_locks osc
11901 cat $file >/dev/null
11903 if ! let "AFTER - BEFORE == CPAGES"; then
11904 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11906 log "cache hits:: before: $BEFORE, after: $AFTER"
11909 log "Turn off the read cache and turn on the write cache"
11911 set_cache writethrough on
11913 log "Read again; it should be satisfied from the cache."
11915 cancel_lru_locks osc
11916 cat $file >/dev/null
11918 if ! let "AFTER - BEFORE == CPAGES"; then
11919 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11921 log "cache hits:: before: $BEFORE, after: $AFTER"
11924 log "Read again; it should not be satisfied from the cache."
11926 cancel_lru_locks osc
11927 cat $file >/dev/null
11929 if ! let "AFTER - BEFORE == 0"; then
11930 error "IN CACHE: before: $BEFORE, after: $AFTER"
11932 log "cache hits:: before: $BEFORE, after: $AFTER"
11935 log "Write data and read it back."
11936 log "Read should be satisfied from the cache."
11937 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11939 cancel_lru_locks osc
11940 cat $file >/dev/null
11942 if ! let "AFTER - BEFORE == CPAGES"; then
11943 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11945 log "cache hits:: before: $BEFORE, after: $AFTER"
11948 log "Read again; it should not be satisfied from the cache."
11950 cancel_lru_locks osc
11951 cat $file >/dev/null
11953 if ! let "AFTER - BEFORE == 0"; then
11954 error "IN CACHE: before: $BEFORE, after: $AFTER"
11956 log "cache hits:: before: $BEFORE, after: $AFTER"
11959 log "Turn off read and write cache"
11961 set_cache writethrough off
11963 log "Write data and read it back"
11964 log "It should not be satisfied from the cache."
11966 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11967 cancel_lru_locks osc
11969 cat $file >/dev/null
11971 if ! let "AFTER - BEFORE == 0"; then
11972 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11974 log "cache hits:: before: $BEFORE, after: $AFTER"
11977 log "Turn on the read cache and turn off the write cache"
11979 set_cache writethrough off
11981 log "Write data and read it back"
11982 log "It should not be satisfied from the cache."
11984 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11986 cancel_lru_locks osc
11987 cat $file >/dev/null
11989 if ! let "AFTER - BEFORE == 0"; then
11990 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11992 log "cache hits:: before: $BEFORE, after: $AFTER"
11995 log "Read again; it should be satisfied from the cache."
11997 cancel_lru_locks osc
11998 cat $file >/dev/null
12000 if ! let "AFTER - BEFORE == CPAGES"; then
12001 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12003 log "cache hits:: before: $BEFORE, after: $AFTER"
12006 restore_lustre_params < $p
12009 run_test 156 "Verification of tunables"
12012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12013 remote_mds_nodsh && skip "remote MDS with nodsh"
12014 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
12015 skip "Need MDS version at least 2.2.0"
12017 changelog_register || error "changelog_register failed"
12018 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12019 changelog_users $SINGLEMDS | grep -q $cl_user ||
12020 error "User $cl_user not found in changelog_users"
12023 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12024 changelog_clear 0 || error "changelog_clear failed"
12025 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12026 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12027 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12028 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12029 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12030 rm $DIR/$tdir/pics/desktop.jpg
12032 changelog_dump | tail -10
12034 echo "verifying changelog mask"
12035 changelog_chmask "-MKDIR"
12036 changelog_chmask "-CLOSE"
12038 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12039 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12041 changelog_chmask "+MKDIR"
12042 changelog_chmask "+CLOSE"
12044 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12045 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12047 changelog_dump | tail -10
12048 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12049 CLOSES=$(changelog_dump | grep -c "CLOSE")
12050 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12051 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12054 echo "verifying target fid"
12055 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12056 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12057 [ "$fidc" == "$fidf" ] ||
12058 error "changelog '$tfile' fid $fidc != file fid $fidf"
12059 echo "verifying parent fid"
12060 # The FID returned from the Changelog may be the directory shard on
12061 # a different MDT, and not the FID returned by path2fid on the parent.
12062 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12063 # since this is what will matter when recreating this file in the tree.
12064 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12065 local pathp=$($LFS fid2path $MOUNT "$fidp")
12066 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12067 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12069 echo "getting records for $cl_user"
12070 changelog_users $SINGLEMDS
12071 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12073 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12074 error "changelog_clear failed"
12075 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12076 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12077 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12078 error "user index expect $user_rec1 + $nclr != $user_rec2"
12080 local min0_rec=$(changelog_users $SINGLEMDS |
12081 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12082 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12083 awk '{ print $1; exit; }')
12085 changelog_dump | tail -n 5
12086 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12087 [ $first_rec == $((min0_rec + 1)) ] ||
12088 error "first index should be $min0_rec + 1 not $first_rec"
12090 # LU-3446 changelog index reset on MDT restart
12091 local cur_rec1=$(changelog_users $SINGLEMDS |
12092 awk '/^current.index:/ { print $NF }')
12093 changelog_clear 0 ||
12094 error "clear all changelog records for $cl_user failed"
12095 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12096 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12097 error "Fail to start $SINGLEMDS"
12098 local cur_rec2=$(changelog_users $SINGLEMDS |
12099 awk '/^current.index:/ { print $NF }')
12100 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12101 [ $cur_rec1 == $cur_rec2 ] ||
12102 error "current index should be $cur_rec1 not $cur_rec2"
12104 echo "verifying users from this test are deregistered"
12105 changelog_deregister || error "changelog_deregister failed"
12106 changelog_users $SINGLEMDS | grep -q $cl_user &&
12107 error "User '$cl_user' still in changelog_users"
12109 # lctl get_param -n mdd.*.changelog_users
12110 # current index: 144
12111 # ID index (idle seconds)
12113 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12114 # this is the normal case where all users were deregistered
12115 # make sure no new records are added when no users are present
12116 local last_rec1=$(changelog_users $SINGLEMDS |
12117 awk '/^current.index:/ { print $NF }')
12118 touch $DIR/$tdir/chloe
12119 local last_rec2=$(changelog_users $SINGLEMDS |
12120 awk '/^current.index:/ { print $NF }')
12121 echo "verify changelogs are off: $last_rec1 == $last_rec2"
12122 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
12124 # any changelog users must be leftovers from a previous test
12125 changelog_users $SINGLEMDS
12126 echo "other changelog users; can't verify off"
12129 run_test 160a "changelog sanity"
12131 test_160b() { # LU-3587
12132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12133 remote_mds_nodsh && skip "remote MDS with nodsh"
12134 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
12135 skip "Need MDS version at least 2.2.0"
12137 changelog_register || error "changelog_register failed"
12138 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12139 changelog_users $SINGLEMDS | grep -q $cl_user ||
12140 error "User '$cl_user' not found in changelog_users"
12142 local longname1=$(str_repeat a 255)
12143 local longname2=$(str_repeat b 255)
12146 echo "creating very long named file"
12147 touch $longname1 || error "create of '$longname1' failed"
12148 echo "renaming very long named file"
12149 mv $longname1 $longname2
12151 changelog_dump | grep RENME | tail -n 5
12154 run_test 160b "Verify that very long rename doesn't crash in changelog"
12157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12158 remote_mds_nodsh && skip "remote MDS with nodsh"
12161 local server_version=$(lustre_version_code $SINGLEMDS)
12163 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12164 [[ $server_version -gt $(version_code 2.5.1) &&
12165 $server_version -lt $(version_code 2.5.50) ]] ||
12166 skip "Need MDS version at least 2.5.58 or 2.5.2+"
12168 # Registration step
12169 changelog_register || error "changelog_register failed"
12172 mkdir -p $DIR/$tdir
12173 $MCREATE $DIR/$tdir/foo_160c
12174 changelog_chmask "-TRUNC"
12175 $TRUNCATE $DIR/$tdir/foo_160c 200
12176 changelog_chmask "+TRUNC"
12177 $TRUNCATE $DIR/$tdir/foo_160c 199
12178 changelog_dump | tail -n 5
12179 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
12180 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
12182 run_test 160c "verify that changelog log catch the truncate event"
12185 remote_mds_nodsh && skip "remote MDS with nodsh"
12186 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12188 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]] ||
12189 skip "Need MDS version at least 2.7.60"
12191 # Registration step
12192 changelog_register || error "changelog_register failed"
12194 mkdir -p $DIR/$tdir/migrate_dir
12195 changelog_clear 0 || error "changelog_clear failed"
12197 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
12198 changelog_dump | tail -n 5
12199 local migrates=$(changelog_dump | grep -c "MIGRT")
12200 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
12202 run_test 160d "verify that changelog log catch the migrate event"
12205 remote_mds_nodsh && skip "remote MDS with nodsh"
12208 changelog_register || error "changelog_register failed"
12210 # Delete a future user (expect fail)
12211 local MDT0=$(facet_svc $SINGLEMDS)
12212 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
12215 if [ $rc -eq 0 ]; then
12216 error "Deleted non-existant user cl77"
12217 elif [ $rc -ne 2 ]; then
12218 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
12221 # Clear to a bad index (1 billion should be safe)
12222 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
12225 if [ $rc -eq 0 ]; then
12226 error "Successfully cleared to invalid CL index"
12227 elif [ $rc -ne 22 ]; then
12228 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
12231 run_test 160e "changelog negative testing (should return errors)"
12234 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12235 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12236 { skip "Need MDS version at least 2.10.56"; return 0; }
12238 local mdts=$(comma_list $(mdts_nodes))
12241 changelog_register || error "first changelog_register failed"
12242 changelog_register || error "second changelog_register failed"
12244 declare -A cl_user1
12245 declare -A cl_user2
12250 # generate some changelog records to accumulate on each MDT
12251 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12252 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12253 error "create $DIR/$tdir/$tfile failed"
12255 # check changelogs have been generated
12256 local nbcl=$(changelog_dump | wc -l)
12257 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12259 for param in "changelog_max_idle_time=10" \
12261 "changelog_min_gc_interval=2" \
12262 "changelog_min_free_cat_entries=3"; do
12263 local MDT0=$(facet_svc $SINGLEMDS)
12264 local var="${param%=*}"
12265 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12267 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12268 do_nodes $mdts $LCTL set_param mdd.*.$param
12271 # force cl_user2 to be idle (1st part)
12274 # simulate changelog catalog almost full
12275 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12276 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12278 for i in $(seq $MDSCOUNT); do
12279 cl_users=(${CL_USERS[mds$i]})
12280 cl_user1[mds$i]="${cl_users[0]}"
12281 cl_user2[mds$i]="${cl_users[1]}"
12283 [ -n "${cl_user1[mds$i]}" ] ||
12284 error "mds$i: no user registered"
12285 [ -n "${cl_user2[mds$i]}" ] ||
12286 error "mds$i: only ${cl_user2[mds$i]} is registered"
12288 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12289 [ -n "$user_rec1" ] ||
12290 error "mds$i: User ${cl_user1[mds$i]} not registered"
12291 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12292 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12293 [ -n "$user_rec2" ] ||
12294 error "mds$i: User ${cl_user1[mds$i]} not registered"
12295 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12296 "$user_rec1 + 2 == $user_rec2"
12297 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12298 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12299 "$user_rec1 + 2, but is $user_rec2"
12300 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12301 [ -n "$user_rec2" ] ||
12302 error "mds$i: User ${cl_user2[mds$i]} not registered"
12303 [ $user_rec1 == $user_rec2 ] ||
12304 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12305 "$user_rec1, but is $user_rec2"
12308 # force cl_user2 to be idle (2nd part) and to reach
12309 # changelog_max_idle_time
12312 # generate one more changelog to trigger fail_loc
12313 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12314 error "create $DIR/$tdir/${tfile}bis failed"
12316 # ensure gc thread is done
12317 for i in $(mdts_nodes); do
12319 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12320 error "$i: GC-thread not done"
12324 for i in $(seq $MDSCOUNT); do
12325 # check cl_user1 still registered
12326 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12327 error "mds$i: User ${cl_user1[mds$i]} not registered"
12328 # check cl_user2 unregistered
12329 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12330 error "mds$i: User ${cl_user2[mds$i]} still registered"
12332 # check changelogs are present and starting at $user_rec1 + 1
12333 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12334 [ -n "$user_rec1" ] ||
12335 error "mds$i: User ${cl_user1[mds$i]} not registered"
12336 first_rec=$($LFS changelog $(facet_svc mds$i) |
12337 awk '{ print $1; exit; }')
12339 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12340 [ $((user_rec1 + 1)) == $first_rec ] ||
12341 error "mds$i: first index should be $user_rec1 + 1, " \
12342 "but is $first_rec"
12345 run_test 160f "changelog garbage collect (timestamped users)"
12348 remote_mds_nodsh && skip "remote MDS with nodsh"
12349 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12350 skip "Need MDS version at least 2.10.56"
12352 local mdts=$(comma_list $(mdts_nodes))
12354 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12355 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12358 changelog_register || error "first changelog_register failed"
12359 changelog_register || error "second changelog_register failed"
12361 declare -A cl_user1
12362 declare -A cl_user2
12367 # generate some changelog records to accumulate on each MDT
12368 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12369 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12370 error "create $DIR/$tdir/$tfile failed"
12372 # check changelogs have been generated
12373 local nbcl=$(changelog_dump | wc -l)
12374 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12376 for param in "changelog_max_idle_indexes=$((nbcl / 2))" \
12378 "changelog_min_gc_interval=2" \
12379 "changelog_min_free_cat_entries=3"; do
12380 local MDT0=$(facet_svc $SINGLEMDS)
12381 local var="${param%=*}"
12382 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12384 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12385 do_nodes $mdts $LCTL set_param mdd.*.$param ||
12386 error "unable to set mdd.*.$param"
12389 # simulate changelog catalog almost full
12390 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12391 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12393 for i in $(seq $MDSCOUNT); do
12394 cl_users=(${CL_USERS[mds$i]})
12395 cl_user1[mds$i]="${cl_users[0]}"
12396 cl_user2[mds$i]="${cl_users[1]}"
12398 [ -n "${cl_user1[mds$i]}" ] ||
12399 error "mds$i: no user registered"
12400 [ -n "${cl_user2[mds$i]}" ] ||
12401 error "mds$i: only ${cl_user1[mds$i]} is registered"
12403 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12404 [ -n "$user_rec1" ] ||
12405 error "mds$i: User ${cl_user1[mds$i]} not registered"
12406 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12407 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12408 [ -n "$user_rec2" ] ||
12409 error "mds$i: User ${cl_user1[mds$i]} not registered"
12410 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12411 "$user_rec1 + 2 == $user_rec2"
12412 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12413 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12414 "$user_rec1 + 2, but is $user_rec2"
12415 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12416 [ -n "$user_rec2" ] ||
12417 error "mds$i: User ${cl_user2[mds$i]} not registered"
12418 [ $user_rec1 == $user_rec2 ] ||
12419 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12420 "$user_rec1, but is $user_rec2"
12423 # ensure we are past the previous changelog_min_gc_interval set above
12426 # generate one more changelog to trigger fail_loc
12427 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12428 error "create $DIR/$tdir/${tfile}bis failed"
12430 # ensure gc thread is done
12431 for i in $(mdts_nodes); do
12433 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12434 error "$i: GC-thread not done"
12438 for i in $(seq $MDSCOUNT); do
12439 # check cl_user1 still registered
12440 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12441 error "mds$i: User ${cl_user1[mds$i]} not registered"
12442 # check cl_user2 unregistered
12443 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12444 error "mds$i: User ${cl_user2[mds$i]} still registered"
12446 # check changelogs are present and starting at $user_rec1 + 1
12447 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12448 [ -n "$user_rec1" ] ||
12449 error "mds$i: User ${cl_user1[mds$i]} not registered"
12450 first_rec=$($LFS changelog $(facet_svc mds$i) |
12451 awk '{ print $1; exit; }')
12453 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12454 [ $((user_rec1 + 1)) == $first_rec ] ||
12455 error "mds$i: first index should be $user_rec1 + 1, " \
12456 "but is $first_rec"
12459 run_test 160g "changelog garbage collect (old users)"
12462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12463 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12464 { skip "Need MDS version at least 2.10.56"; return 0; }
12466 local mdts=$(comma_list $(mdts_nodes))
12469 changelog_register || error "first changelog_register failed"
12470 changelog_register || error "second changelog_register failed"
12472 declare -A cl_user1
12473 declare -A cl_user2
12478 # generate some changelog records to accumulate on each MDT
12479 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12480 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12481 error "create $DIR/$tdir/$tfile failed"
12483 # check changelogs have been generated
12484 local nbcl=$(changelog_dump | wc -l)
12485 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12487 for param in "changelog_max_idle_time=10" \
12489 "changelog_min_gc_interval=2"; do
12490 local MDT0=$(facet_svc $SINGLEMDS)
12491 local var="${param%=*}"
12492 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12494 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12495 do_nodes $mdts $LCTL set_param mdd.*.$param
12498 # force cl_user2 to be idle (1st part)
12501 for i in $(seq $MDSCOUNT); do
12502 cl_users=(${CL_USERS[mds$i]})
12503 cl_user1[mds$i]="${cl_users[0]}"
12504 cl_user2[mds$i]="${cl_users[1]}"
12506 [ -n "${cl_user1[mds$i]}" ] ||
12507 error "mds$i: no user registered"
12508 [ -n "${cl_user2[mds$i]}" ] ||
12509 error "mds$i: only ${cl_user2[mds$i]} is registered"
12511 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12512 [ -n "$user_rec1" ] ||
12513 error "mds$i: User ${cl_user1[mds$i]} not registered"
12514 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12515 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12516 [ -n "$user_rec2" ] ||
12517 error "mds$i: User ${cl_user1[mds$i]} not registered"
12518 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12519 "$user_rec1 + 2 == $user_rec2"
12520 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12521 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12522 "$user_rec1 + 2, but is $user_rec2"
12523 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12524 [ -n "$user_rec2" ] ||
12525 error "mds$i: User ${cl_user2[mds$i]} not registered"
12526 [ $user_rec1 == $user_rec2 ] ||
12527 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12528 "$user_rec1, but is $user_rec2"
12531 # force cl_user2 to be idle (2nd part) and to reach
12532 # changelog_max_idle_time
12535 # force each GC-thread start and block then
12536 # one per MDT/MDD, set fail_val accordingly
12537 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
12538 do_nodes $mdts $LCTL set_param fail_loc=0x1316
12540 # generate more changelogs to trigger fail_loc
12541 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12542 error "create $DIR/$tdir/${tfile}bis failed"
12544 # stop MDT to stop GC-thread, should be done in back-ground as it will
12545 # block waiting for the thread to be released and exit
12546 declare -A stop_pids
12547 for i in $(seq $MDSCOUNT); do
12549 stop_pids[mds$i]=$!
12552 for i in $(mdts_nodes); do
12555 local facets=$(facets_up_on_host $i)
12557 for facet in ${facets//,/ }; do
12558 if [[ $facet == mds* ]]; then
12562 # ensure each MDS's gc threads are still present and all in "R"
12563 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
12564 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
12565 error "$i: expected $nb GC-thread"
12567 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
12569 error "$i: GC-thread not found in R-state"
12570 # check umounts of each MDT on MDS have reached kthread_stop()
12571 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
12572 error "$i: expected $nb umount"
12574 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
12575 error "$i: umount not found in D-state"
12578 # release all GC-threads
12579 do_nodes $mdts $LCTL set_param fail_loc=0
12581 # wait for MDT stop to complete
12582 for i in $(seq $MDSCOUNT); do
12583 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
12587 # may try to check if any orphan changelog records are present
12588 # via ldiskfs/zfs and llog_reader...
12590 # re-start/mount MDTs
12591 for i in $(seq $MDSCOUNT); do
12592 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
12593 error "Fail to start mds$i"
12597 for i in $(seq $MDSCOUNT); do
12598 # check cl_user1 still registered
12599 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12600 error "mds$i: User ${cl_user1[mds$i]} not registered"
12601 # check cl_user2 unregistered
12602 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12603 error "mds$i: User ${cl_user2[mds$i]} still registered"
12605 # check changelogs are present and starting at $user_rec1 + 1
12606 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12607 [ -n "$user_rec1" ] ||
12608 error "mds$i: User ${cl_user1[mds$i]} not registered"
12609 first_rec=$($LFS changelog $(facet_svc mds$i) |
12610 awk '{ print $1; exit; }')
12612 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12613 [ $((user_rec1 + 1)) == $first_rec ] ||
12614 error "mds$i: first index should be $user_rec1 + 1, " \
12615 "but is $first_rec"
12618 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
12623 local mdts=$(comma_list $(mdts_nodes))
12625 changelog_register || error "first changelog_register failed"
12627 # generate some changelog records to accumulate on each MDT
12628 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12629 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12630 error "create $DIR/$tdir/$tfile failed"
12632 # check changelogs have been generated
12633 local nbcl=$(changelog_dump | wc -l)
12634 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12636 # simulate race between register and unregister
12637 # XXX as fail_loc is set per-MDS, with DNE configs the race
12638 # simulation will only occur for one MDT per MDS and for the
12639 # others the normal race scenario will take place
12640 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
12641 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
12642 do_nodes $mdts $LCTL set_param fail_val=1
12644 # unregister 1st user
12645 changelog_deregister &
12647 # wait some time for deregister work to reach race rdv
12649 # register 2nd user
12650 changelog_register || error "2nd user register failed"
12652 wait $pid1 || error "1st user deregister failed"
12656 declare -A LAST_REC
12657 for i in $(seq $MDSCOUNT); do
12658 if changelog_users mds$i | grep "^cl"; then
12659 # make sure new records are added with one user present
12660 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
12661 awk '/^current.index:/ { print $NF }')
12663 error "mds$i has no user registered"
12667 # generate more changelog records to accumulate on each MDT
12668 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12669 error "create $DIR/$tdir/${tfile}bis failed"
12671 for i in $(seq $MDSCOUNT); do
12672 last_rec=$(changelog_users $SINGLEMDS |
12673 awk '/^current.index:/ { print $NF }')
12674 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
12675 [ $last_rec != ${LAST_REC[mds$i]} ] ||
12676 error "changelogs are off on mds$i"
12679 run_test 160i "changelog user register/unregister race"
12682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12684 test_mkdir -c1 $DIR/$tdir
12685 cp /etc/hosts $DIR/$tdir/$tfile
12686 test_mkdir -c1 $DIR/$tdir/foo1
12687 test_mkdir -c1 $DIR/$tdir/foo2
12688 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
12689 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
12690 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
12691 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
12692 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
12693 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12694 $LFS fid2path $DIR $FID
12695 error "bad link ea"
12698 rm $DIR/$tdir/foo2/zachary
12700 rm $DIR/$tdir/foo2/thor
12702 rm $DIR/$tdir/$tfile
12704 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
12705 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
12706 { $LFS fid2path $DIR $FID; error "bad link rename"; }
12707 rm $DIR/$tdir/foo2/maggie
12710 local longname=$tfile.avg_len_is_thirty_two_
12711 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
12712 error_noexit 'failed to unlink many hardlinks'" EXIT
12713 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
12714 error "failed to hardlink many files"
12715 links=$($LFS fid2path $DIR $FID | wc -l)
12716 echo -n "${links}/1000 links in link EA"
12717 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
12719 run_test 161a "link ea sanity"
12722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12723 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
12726 local remote_dir=$DIR/$tdir/remote_dir
12728 mkdir -p $DIR/$tdir
12729 $LFS mkdir -i $MDTIDX $remote_dir ||
12730 error "create remote directory failed"
12732 cp /etc/hosts $remote_dir/$tfile
12733 mkdir -p $remote_dir/foo1
12734 mkdir -p $remote_dir/foo2
12735 ln $remote_dir/$tfile $remote_dir/foo1/sofia
12736 ln $remote_dir/$tfile $remote_dir/foo2/zachary
12737 ln $remote_dir/$tfile $remote_dir/foo1/luna
12738 ln $remote_dir/$tfile $remote_dir/foo2/thor
12740 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
12742 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12743 $LFS fid2path $DIR $FID
12744 error "bad link ea"
12747 rm $remote_dir/foo2/zachary
12749 rm $remote_dir/foo2/thor
12751 rm $remote_dir/$tfile
12753 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
12754 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
12755 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
12756 $LFS fid2path $DIR $FID
12757 error "bad link rename"
12759 rm $remote_dir/foo2/maggie
12762 local longname=filename_avg_len_is_thirty_two_
12763 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
12764 error "failed to hardlink many files"
12765 links=$($LFS fid2path $DIR $FID | wc -l)
12766 echo -n "${links}/1000 links in link EA"
12767 [[ ${links} -gt 60 ]] ||
12768 error "expected at least 60 links in link EA"
12769 unlinkmany $remote_dir/foo2/$longname 1000 ||
12770 error "failed to unlink many hardlinks"
12772 run_test 161b "link ea sanity under remote directory"
12775 remote_mds_nodsh && skip "remote MDS with nodsh"
12776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12777 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
12778 skip "Need MDS version at least 2.1.5"
12780 # define CLF_RENAME_LAST 0x0001
12781 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
12782 changelog_register || error "changelog_register failed"
12785 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
12786 touch $DIR/$tdir/foo_161c
12787 touch $DIR/$tdir/bar_161c
12788 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12789 changelog_dump | grep RENME | tail -n 5
12790 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
12791 changelog_clear 0 || error "changelog_clear failed"
12792 if [ x$flags != "x0x1" ]; then
12793 error "flag $flags is not 0x1"
12796 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
12797 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
12798 touch $DIR/$tdir/foo_161c
12799 touch $DIR/$tdir/bar_161c
12800 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12801 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12802 changelog_dump | grep RENME | tail -n 5
12803 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
12804 changelog_clear 0 || error "changelog_clear failed"
12805 if [ x$flags != "x0x0" ]; then
12806 error "flag $flags is not 0x0"
12808 echo "rename overwrite a target having nlink > 1," \
12809 "changelog record has flags of $flags"
12811 # rename doesn't overwrite a target (changelog flag 0x0)
12812 touch $DIR/$tdir/foo_161c
12813 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
12814 changelog_dump | grep RENME | tail -n 5
12815 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
12816 changelog_clear 0 || error "changelog_clear failed"
12817 if [ x$flags != "x0x0" ]; then
12818 error "flag $flags is not 0x0"
12820 echo "rename doesn't overwrite a target," \
12821 "changelog record has flags of $flags"
12823 # define CLF_UNLINK_LAST 0x0001
12824 # unlink a file having nlink = 1 (changelog flag 0x1)
12825 rm -f $DIR/$tdir/foo2_161c
12826 changelog_dump | grep UNLNK | tail -n 5
12827 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
12828 changelog_clear 0 || error "changelog_clear failed"
12829 if [ x$flags != "x0x1" ]; then
12830 error "flag $flags is not 0x1"
12832 echo "unlink a file having nlink = 1," \
12833 "changelog record has flags of $flags"
12835 # unlink a file having nlink > 1 (changelog flag 0x0)
12836 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12837 rm -f $DIR/$tdir/foobar_161c
12838 changelog_dump | grep UNLNK | tail -n 5
12839 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
12840 changelog_clear 0 || error "changelog_clear failed"
12841 if [ x$flags != "x0x0" ]; then
12842 error "flag $flags is not 0x0"
12844 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
12846 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
12849 remote_mds_nodsh && skip "remote MDS with nodsh"
12854 changelog_register || error "changelog_register failed"
12856 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
12857 # interfer with $MOUNT/.lustre/fid/ access
12859 [[ $? -eq 0 ]] || error "mkdir failed"
12861 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
12862 $LCTL set_param fail_loc=0x8000140c
12864 $LCTL set_param fail_val=5
12867 echo foofoo > $DIR/$tdir/$tfile &
12870 # wait for create to be delayed
12874 [[ $? -eq 0 ]] || error "create should be blocked"
12876 local tempfile=$(mktemp)
12877 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
12878 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
12879 # some delay may occur during ChangeLog publishing and file read just
12880 # above, that could allow file write to happen finally
12881 [[ -s $tempfile ]] && echo "file should be empty"
12883 $LCTL set_param fail_loc=0
12886 [[ $? -eq 0 ]] || error "create failed"
12888 run_test 161d "create with concurrent .lustre/fid access"
12891 local expected="$1"
12896 path=$($LFS fid2path "$@")
12899 if [ $rc -ne 0 ]; then
12900 error "path looked up of '$expected' failed: rc=$rc"
12901 elif [ "$path" != "$expected" ]; then
12902 error "path looked up '$path' instead of '$expected'"
12904 echo "FID '$fid' resolves to path '$path' as expected"
12908 test_162a() { # was test_162
12909 test_mkdir -p -c1 $DIR/$tdir/d2
12910 touch $DIR/$tdir/d2/$tfile
12911 touch $DIR/$tdir/d2/x1
12912 touch $DIR/$tdir/d2/x2
12913 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
12914 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
12916 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
12917 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
12920 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
12921 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
12922 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
12924 # softlink to wrong file
12925 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
12926 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
12927 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
12930 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
12931 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
12932 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
12933 # fid2path dir/fsname should both work
12934 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
12935 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
12937 # hardlink count: check that there are 2 links
12938 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
12939 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
12941 # hardlink indexing: remove the first link
12942 rm $DIR/$tdir/d2/p/q/r/hlink
12943 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
12945 run_test 162a "path lookup sanity"
12948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12949 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12952 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
12953 error "create striped dir failed"
12955 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
12956 tail -n 1 | awk '{print $2}')
12957 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
12959 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
12960 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
12963 for ((i=0;i<5;i++)); do
12964 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
12965 error "get fid for f$i failed"
12966 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
12968 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
12969 error "get fid for d$i failed"
12970 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
12975 run_test 162b "striped directory path lookup sanity"
12977 # LU-4239: Verify fid2path works with paths 100 or more directories deep
12979 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
12980 skip "Need MDS version at least 2.7.51"
12982 local lpath=$tdir.local
12983 local rpath=$tdir.remote
12985 test_mkdir $DIR/$lpath
12986 test_mkdir $DIR/$rpath
12988 for ((i = 0; i <= 101; i++)); do
12991 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
12992 error "get fid for local directory $DIR/$lpath failed"
12993 check_path "$DIR/$lpath" $MOUNT $FID --link 0
12996 test_mkdir $DIR/$rpath
12997 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
12998 error "get fid for remote directory $DIR/$rpath failed"
12999 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13004 run_test 162c "fid2path works with paths 100 or more directories deep"
13007 # do directio so as not to populate the page cache
13008 log "creating a 10 Mb file"
13009 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13010 log "starting reads"
13011 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13012 log "truncating the file"
13013 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13015 kill %+ || true # reads might have finished
13016 echo "wait until dd is finished"
13018 log "removing the temporary file"
13019 rm -rf $DIR/$tfile || error "tmp file removal failed"
13021 run_test 169 "parallel read and truncate should not deadlock"
13024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13026 $LCTL clear # bug 18514
13027 $LCTL debug_daemon start $TMP/${tfile}_log_good
13029 $LCTL debug_daemon stop
13030 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13031 error "sed failed to read log_good"
13033 $LCTL debug_daemon start $TMP/${tfile}_log_good
13035 $LCTL debug_daemon stop
13037 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13038 error "lctl df log_bad failed"
13040 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13041 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13043 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13044 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13046 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13047 error "bad_line good_line1 good_line2 are empty"
13049 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13050 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
13051 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13053 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
13054 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13055 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13057 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
13058 error "bad_line_new good_line_new are empty"
13060 local expected_good=$((good_line1 + good_line2*2))
13062 rm -f $TMP/${tfile}*
13063 # LU-231, short malformed line may not be counted into bad lines
13064 if [ $bad_line -ne $bad_line_new ] &&
13065 [ $bad_line -ne $((bad_line_new - 1)) ]; then
13066 error "expected $bad_line bad lines, but got $bad_line_new"
13070 if [ $expected_good -ne $good_line_new ]; then
13071 error "expected $expected_good good lines, but got $good_line_new"
13076 run_test 170 "test lctl df to handle corrupted log ====================="
13078 test_171() { # bug20592
13079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13081 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
13082 $LCTL set_param fail_loc=0x50e
13083 $LCTL set_param fail_val=3000
13084 multiop_bg_pause $DIR/$tfile O_s || true
13086 kill -USR1 $MULTIPID
13090 if dmesg | grep "recursive fault"; then
13091 error "caught a recursive fault"
13093 $LCTL set_param fail_loc=0
13096 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
13098 # it would be good to share it with obdfilter-survey/iokit-libecho code
13099 setup_obdecho_osc () {
13102 local obdfilter_name=$2
13103 echo "Creating new osc for $obdfilter_name on $ost_nid"
13104 # make sure we can find loopback nid
13105 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
13107 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
13108 ${obdfilter_name}_osc_UUID || rc=2; }
13109 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
13110 ${obdfilter_name}_UUID $ost_nid || rc=3; }
13114 cleanup_obdecho_osc () {
13115 local obdfilter_name=$1
13116 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
13117 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
13124 local pages=${3:-64}
13129 local obd_size=$(get_obd_size $node $OBD)
13130 local page_size=$(get_page_size $node)
13131 if [[ -n "$obd_size" ]]; then
13132 local new_count=$((obd_size / (pages * page_size / 1024)))
13133 [[ $new_count -ge $count ]] || count=$new_count
13136 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
13137 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
13139 if [ $rc -eq 0 ]; then
13140 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
13141 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
13143 echo "New object id is $id"
13144 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
13146 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
13147 "test_brw $count w v $pages $id" || rc=4; }
13148 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
13150 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
13151 "cleanup" || rc=5; }
13152 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
13153 "detach" || rc=6; }
13154 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
13159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13161 if ! module_loaded obdecho; then
13162 load_module obdecho/obdecho &&
13163 stack_trap "rmmod obdecho" EXIT ||
13164 error "unable to load obdecho on client"
13167 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
13168 local host=$($LCTL get_param -n osc.$osc.import |
13169 awk '/current_connection:/ { print $2 }' )
13170 local target=$($LCTL get_param -n osc.$osc.import |
13171 awk '/target:/ { print $2 }' )
13172 target=${target%_UUID}
13174 if [ -n "$target" ]; then
13175 setup_obdecho_osc $host $target &&
13176 stack_trap "cleanup_obdecho_osc $target" EXIT ||
13177 { error "obdecho setup failed with $?"; return; }
13179 obdecho_test ${target}_osc client ||
13180 error "obdecho_test failed on ${target}_osc"
13182 $LCTL get_param osc.$osc.import
13183 error "there is no osc.$osc.import target"
13186 run_test 180a "test obdecho on osc"
13189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13190 remote_ost_nodsh && skip "remote OST with nodsh"
13192 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13193 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13194 error "failed to load module obdecho"
13196 local target=$(do_facet ost1 $LCTL dl |
13197 awk '/obdfilter/ { print $4; exit; }')
13199 if [ -n "$target" ]; then
13200 obdecho_test $target ost1 || error "obdecho_test failed with $?"
13202 do_facet ost1 $LCTL dl
13203 error "there is no obdfilter target on ost1"
13206 run_test 180b "test obdecho directly on obdfilter"
13208 test_180c() { # LU-2598
13209 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13210 remote_ost_nodsh && skip "remote OST with nodsh"
13211 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
13212 skip "Need MDS version at least 2.4.0"
13214 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13215 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13216 error "failed to load module obdecho"
13218 local target=$(do_facet ost1 $LCTL dl |
13219 awk '/obdfilter/ { print $4; exit; }')
13221 if [ -n "$target" ]; then
13222 local pages=16384 # 64MB bulk I/O RPC size
13224 obdecho_test "$target" ost1 "$pages" ||
13225 error "obdecho_test with pages=$pages failed with $?"
13227 do_facet ost1 $LCTL dl
13228 error "there is no obdfilter target on ost1"
13231 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
13233 test_181() { # bug 22177
13234 test_mkdir $DIR/$tdir
13235 # create enough files to index the directory
13236 createmany -o $DIR/$tdir/foobar 4000
13237 # print attributes for debug purpose
13240 multiop_bg_pause $DIR/$tdir D_Sc || return 1
13242 # remove the files & current working dir
13243 unlinkmany $DIR/$tdir/foobar 4000
13245 kill -USR1 $MULTIPID
13247 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
13250 run_test 181 "Test open-unlinked dir ========================"
13256 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13258 $LCTL set_param mdc.*.rpc_stats=clear
13260 for (( i = 0; i < $tcount; i++ )) ; do
13261 mkdir $DIR/$tdir/$i
13264 for (( i = 0; i < $tcount; i++ )) ; do
13265 createmany -o $DIR/$tdir/$i/f- $fcount &
13269 for (( i = 0; i < $tcount; i++ )) ; do
13270 unlinkmany $DIR/$tdir/$i/f- $fcount &
13274 $LCTL get_param mdc.*.rpc_stats
13278 run_test 182 "Test parallel modify metadata operations ================"
13280 test_183() { # LU-2275
13281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13282 remote_mds_nodsh && skip "remote MDS with nodsh"
13283 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
13284 skip "Need MDS version at least 2.3.56"
13286 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13287 echo aaa > $DIR/$tdir/$tfile
13289 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
13290 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
13292 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
13293 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
13295 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13297 # Flush negative dentry cache
13298 touch $DIR/$tdir/$tfile
13300 # We are not checking for any leaked references here, they'll
13301 # become evident next time we do cleanup with module unload.
13304 run_test 183 "No crash or request leak in case of strange dispositions ========"
13306 # test suite 184 is for LU-2016, LU-2017
13308 check_swap_layouts_support
13310 dir0=$DIR/$tdir/$testnum
13311 test_mkdir -p -c1 $dir0
13316 $SETSTRIPE -c1 $file1
13318 $SETSTRIPE -c2 $file2
13320 gen1=$($GETSTRIPE -g $file1)
13321 gen2=$($GETSTRIPE -g $file2)
13323 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
13324 gen=$($GETSTRIPE -g $file1)
13325 [[ $gen1 != $gen ]] ||
13326 "Layout generation on $file1 does not change"
13327 gen=$($GETSTRIPE -g $file2)
13328 [[ $gen2 != $gen ]] ||
13329 "Layout generation on $file2 does not change"
13331 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
13332 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13334 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
13336 run_test 184a "Basic layout swap"
13339 check_swap_layouts_support
13341 dir0=$DIR/$tdir/$testnum
13342 mkdir -p $dir0 || error "creating dir $dir0"
13349 $SETSTRIPE -c1 $file1
13350 $SETSTRIPE -c2 $file2
13351 $SETSTRIPE -c1 $file3
13352 chown $RUNAS_ID $file3
13353 gen1=$($GETSTRIPE -g $file1)
13354 gen2=$($GETSTRIPE -g $file2)
13356 $LFS swap_layouts $dir1 $dir2 &&
13357 error "swap of directories layouts should fail"
13358 $LFS swap_layouts $dir1 $file1 &&
13359 error "swap of directory and file layouts should fail"
13360 $RUNAS $LFS swap_layouts $file1 $file2 &&
13361 error "swap of file we cannot write should fail"
13362 $LFS swap_layouts $file1 $file3 &&
13363 error "swap of file with different owner should fail"
13364 /bin/true # to clear error code
13366 run_test 184b "Forbidden layout swap (will generate errors)"
13369 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
13370 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
13371 check_swap_layouts_support
13373 local dir0=$DIR/$tdir/$testnum
13374 mkdir -p $dir0 || error "creating dir $dir0"
13376 local ref1=$dir0/ref1
13377 local ref2=$dir0/ref2
13378 local file1=$dir0/file1
13379 local file2=$dir0/file2
13380 # create a file large enough for the concurrent test
13381 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
13382 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
13383 echo "ref file size: ref1($(stat -c %s $ref1))," \
13384 "ref2($(stat -c %s $ref2))"
13387 dd if=$ref1 of=$file1 bs=16k &
13390 # Make sure dd starts to copy file
13391 while [ ! -f $file1 ]; do sleep 0.1; done
13393 $LFS swap_layouts $file1 $file2
13396 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
13397 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
13399 # how many bytes copied before swapping layout
13400 local copied=$(stat -c %s $file2)
13401 local remaining=$(stat -c %s $ref1)
13402 remaining=$((remaining - copied))
13403 echo "Copied $copied bytes before swapping layout..."
13405 cmp -n $copied $file1 $ref2 | grep differ &&
13406 error "Content mismatch [0, $copied) of ref2 and file1"
13407 cmp -n $copied $file2 $ref1 ||
13408 error "Content mismatch [0, $copied) of ref1 and file2"
13409 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
13410 error "Content mismatch [$copied, EOF) of ref1 and file1"
13413 rm -f $ref1 $ref2 $file1 $file2
13415 run_test 184c "Concurrent write and layout swap"
13418 check_swap_layouts_support
13419 [ -z "$(which getfattr 2>/dev/null)" ] &&
13420 skip_env "no getfattr command"
13422 local file1=$DIR/$tdir/$tfile-1
13423 local file2=$DIR/$tdir/$tfile-2
13424 local file3=$DIR/$tdir/$tfile-3
13428 mkdir -p $DIR/$tdir
13429 touch $file1 || error "create $file1 failed"
13430 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13431 error "create $file2 failed"
13432 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13433 error "create $file3 failed"
13434 lovea1=$(get_layout_param $file1)
13436 $LFS swap_layouts $file2 $file3 ||
13437 error "swap $file2 $file3 layouts failed"
13438 $LFS swap_layouts $file1 $file2 ||
13439 error "swap $file1 $file2 layouts failed"
13441 lovea2=$(get_layout_param $file2)
13444 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
13446 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13447 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
13449 run_test 184d "allow stripeless layouts swap"
13452 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
13453 skip "Need MDS version at least 2.6.94"
13454 check_swap_layouts_support
13455 [ -z "$(which getfattr 2>/dev/null)" ] &&
13456 skip_env "no getfattr command"
13458 local file1=$DIR/$tdir/$tfile-1
13459 local file2=$DIR/$tdir/$tfile-2
13460 local file3=$DIR/$tdir/$tfile-3
13463 mkdir -p $DIR/$tdir
13464 touch $file1 || error "create $file1 failed"
13465 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13466 error "create $file2 failed"
13467 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13468 error "create $file3 failed"
13470 $LFS swap_layouts $file1 $file2 ||
13471 error "swap $file1 $file2 layouts failed"
13473 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13474 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
13476 echo 123 > $file1 || error "Should be able to write into $file1"
13478 $LFS swap_layouts $file1 $file3 ||
13479 error "swap $file1 $file3 layouts failed"
13481 echo 123 > $file1 || error "Should be able to write into $file1"
13483 rm -rf $file1 $file2 $file3
13485 run_test 184e "Recreate layout after stripeless layout swaps"
13487 test_185() { # LU-2441
13488 # LU-3553 - no volatile file support in old servers
13489 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
13490 skip "Need MDS version at least 2.3.60"
13492 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13493 touch $DIR/$tdir/spoo
13494 local mtime1=$(stat -c "%Y" $DIR/$tdir)
13495 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
13496 error "cannot create/write a volatile file"
13497 [ "$FILESET" == "" ] &&
13498 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
13499 error "FID is still valid after close"
13501 multiop_bg_pause $DIR/$tdir vVw4096_c
13508 # assume that the next FID for this client is sequential, since stdout
13509 # is unfortunately eaten by multiop_bg_pause
13510 local n=$((${fidv[1]} + 1))
13511 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
13512 if [ "$FILESET" == "" ]; then
13513 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
13514 error "FID is missing before close"
13516 kill -USR1 $multi_pid
13517 # 1 second delay, so if mtime change we will see it
13519 local mtime2=$(stat -c "%Y" $DIR/$tdir)
13520 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
13522 run_test 185 "Volatile file support"
13525 remote_mds_nodsh && skip "remote MDS with nodsh"
13526 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
13527 skip "Need MDS version at least 2.3.0"
13529 local dir0=$DIR/$tdir/$testnum
13530 mkdir -p $dir0 || error "creating dir $dir0"
13532 local file=$dir0/file1
13533 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
13534 local dv1=$($LFS data_version $file)
13535 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
13536 local dv2=$($LFS data_version $file)
13537 [[ $dv1 != $dv2 ]] ||
13538 error "data version did not change on write $dv1 == $dv2"
13543 run_test 187a "Test data version change"
13546 remote_mds_nodsh && skip "remote MDS with nodsh"
13547 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
13548 skip "Need MDS version at least 2.3.0"
13550 local dir0=$DIR/$tdir/$testnum
13551 mkdir -p $dir0 || error "creating dir $dir0"
13553 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
13554 [[ ${DV[0]} != ${DV[1]} ]] ||
13555 error "data version did not change on write"\
13556 " ${DV[0]} == ${DV[1]}"
13561 run_test 187b "Test data version change on volatile file"
13564 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13565 remote_mgs_nodsh && skip "remote MGS with nodsh"
13566 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13568 local POOL=${POOL:-cea1}
13569 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
13570 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
13573 local last_ost=$(($OSTCOUNT - 1))
13575 local ost_list=$(seq $first_ost $ost_step $last_ost)
13576 local ost_range="$first_ost $last_ost $ost_step"
13577 local test_path=$POOL_ROOT/$POOL_DIR_NAME
13578 local file_dir=$POOL_ROOT/file_tst
13579 local subdir=$test_path/subdir
13582 if ! combined_mgs_mds ; then
13587 # former test_200a test_200b
13588 pool_add $POOL || { rc=$? ; break; }
13589 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
13590 # former test_200c test_200d
13591 mkdir -p $test_path
13592 pool_set_dir $POOL $test_path || { rc=$? ; break; }
13593 pool_check_dir $POOL $test_path || { rc=$? ; break; }
13595 pool_check_dir $POOL $subdir || { rc=$? ; break; }
13596 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
13597 || { rc=$? ; break; }
13598 # former test_200e test_200f
13599 local files=$((OSTCOUNT*3))
13600 pool_alloc_files $POOL $test_path $files "$ost_list" \
13601 || { rc=$? ; break; }
13602 pool_create_files $POOL $file_dir $files "$ost_list" \
13603 || { rc=$? ; break; }
13604 # former test_200g test_200h
13605 pool_lfs_df $POOL || { rc=$? ; break; }
13606 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
13608 # former test_201a test_201b test_201c
13609 pool_remove_first_target $POOL || { rc=$? ; break; }
13611 local f=$test_path/$tfile
13612 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
13613 pool_remove $POOL $f || { rc=$? ; break; }
13619 if ! combined_mgs_mds ; then
13624 run_test 200 "OST pools"
13626 # usage: default_attr <count | size | offset>
13628 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
13631 # usage: check_default_stripe_attr
13632 check_default_stripe_attr() {
13633 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
13636 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
13638 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
13642 error "unknown getstripe attr '$1'"
13645 [ $ACTUAL == $EXPECTED ] ||
13646 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
13650 test_mkdir $DIR/$tdir
13651 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
13653 check_default_stripe_attr --stripe-count
13654 check_default_stripe_attr --stripe-size
13655 check_default_stripe_attr --stripe-index
13657 run_test 204a "Print default stripe attributes"
13660 test_mkdir $DIR/$tdir
13661 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13663 check_default_stripe_attr --stripe-size
13664 check_default_stripe_attr --stripe-index
13666 run_test 204b "Print default stripe size and offset"
13669 test_mkdir $DIR/$tdir
13670 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13672 check_default_stripe_attr --stripe-count
13673 check_default_stripe_attr --stripe-index
13675 run_test 204c "Print default stripe count and offset"
13678 test_mkdir $DIR/$tdir
13679 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13681 check_default_stripe_attr --stripe-count
13682 check_default_stripe_attr --stripe-size
13684 run_test 204d "Print default stripe count and size"
13687 test_mkdir $DIR/$tdir
13688 $SETSTRIPE -d $DIR/$tdir
13690 check_default_stripe_attr --stripe-count --raw
13691 check_default_stripe_attr --stripe-size --raw
13692 check_default_stripe_attr --stripe-index --raw
13694 run_test 204e "Print raw stripe attributes"
13697 test_mkdir $DIR/$tdir
13698 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13700 check_default_stripe_attr --stripe-size --raw
13701 check_default_stripe_attr --stripe-index --raw
13703 run_test 204f "Print raw stripe size and offset"
13706 test_mkdir $DIR/$tdir
13707 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13709 check_default_stripe_attr --stripe-count --raw
13710 check_default_stripe_attr --stripe-index --raw
13712 run_test 204g "Print raw stripe count and offset"
13715 test_mkdir $DIR/$tdir
13716 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13718 check_default_stripe_attr --stripe-count --raw
13719 check_default_stripe_attr --stripe-size --raw
13721 run_test 204h "Print raw stripe count and size"
13723 # Figure out which job scheduler is being used, if any,
13724 # or use a fake one
13725 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
13726 JOBENV=SLURM_JOB_ID
13727 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
13729 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
13731 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
13732 JOBENV=LOADL_STEP_ID
13733 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
13736 $LCTL list_param jobid_name > /dev/null 2>&1
13737 if [ $? -eq 0 ]; then
13743 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
13745 verify_jobstats() {
13750 # we don't really need to clear the stats for this test to work, since each
13751 # command has a unique jobid, but it makes debugging easier if needed.
13752 # for facet in $facets; do
13753 # local dev=$(convert_facet2label $facet)
13754 # # clear old jobstats
13755 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
13758 # use a new JobID for each test, or we might see an old one
13759 [ "$JOBENV" = "FAKE_JOBID" ] &&
13760 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13762 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
13764 [ "$JOBENV" = "nodelocal" ] && {
13765 FAKE_JOBID=id.$testnum.%e.$RANDOM
13766 $LCTL set_param jobid_name=$FAKE_JOBID
13767 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
13770 log "Test: ${cmd[*]}"
13771 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
13773 if [ $JOBENV = "FAKE_JOBID" ]; then
13774 FAKE_JOBID=$JOBVAL ${cmd[*]}
13779 # all files are created on OST0000
13780 for facet in $facets; do
13781 local stats="*.$(convert_facet2label $facet).job_stats"
13783 # strip out libtool wrappers for in-tree executables
13784 if [ $(do_facet $facet lctl get_param $stats |
13785 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
13786 do_facet $facet lctl get_param $stats
13787 error "No jobstats for $JOBVAL found on $facet::$stats"
13793 local new_jobenv=$1
13795 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$new_jobenv
13796 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $new_jobenv
13799 test_205() { # Job stats
13800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13801 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
13802 skip "Need MDS version with at least 2.7.1"
13803 remote_mgs_nodsh && skip "remote MGS with nodsh"
13804 remote_mds_nodsh && skip "remote MDS with nodsh"
13805 remote_ost_nodsh && skip "remote OST with nodsh"
13806 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
13807 skip "Server doesn't support jobstats"
13808 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
13810 local old_jobenv=$($LCTL get_param -n jobid_var)
13811 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
13812 stack_trap "do_facet mgs \
13813 $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
13817 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
13818 mdt.*.job_cleanup_interval | head -n 1)
13819 local new_interval=5
13820 do_facet $SINGLEMDS \
13821 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
13822 stack_trap "do_facet $SINGLEMDS \
13823 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
13824 local start=$SECONDS
13828 cmd="mkdir $DIR/$tdir"
13829 verify_jobstats "$cmd" "$SINGLEMDS"
13831 cmd="rmdir $DIR/$tdir"
13832 verify_jobstats "$cmd" "$SINGLEMDS"
13833 # mkdir on secondary MDT
13834 if [ $MDSCOUNT -gt 1 ]; then
13835 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
13836 verify_jobstats "$cmd" "mds2"
13839 cmd="mknod $DIR/$tfile c 1 3"
13840 verify_jobstats "$cmd" "$SINGLEMDS"
13842 cmd="rm -f $DIR/$tfile"
13843 verify_jobstats "$cmd" "$SINGLEMDS"
13844 # create all files on OST0000 so verify_jobstats can find OST stats
13846 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
13847 verify_jobstats "$cmd" "$SINGLEMDS"
13849 cmd="touch $DIR/$tfile"
13850 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13852 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
13853 verify_jobstats "$cmd" "ost1"
13855 cancel_lru_locks osc
13856 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
13857 verify_jobstats "$cmd" "ost1"
13859 cmd="$TRUNCATE $DIR/$tfile 0"
13860 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13862 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
13863 verify_jobstats "$cmd" "$SINGLEMDS"
13864 # jobstats expiry - sleep until old stats should be expired
13865 local left=$((new_interval + 5 - (SECONDS - start)))
13866 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
13867 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
13869 cmd="mkdir $DIR/$tdir.expire"
13870 verify_jobstats "$cmd" "$SINGLEMDS"
13871 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
13872 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
13874 # Ensure that jobid are present in changelog (if supported by MDS)
13875 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ];then
13876 changelog_dump | tail -10
13877 jobids=$(changelog_dump | tail -9 | grep -c "j=")
13878 [ $jobids -eq 9 ] ||
13879 error "Wrong changelog jobid count $jobids != 9"
13883 jobstats_set $JOBENV
13885 changelog_dump | grep $tfile
13886 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
13887 [ $jobids -eq 0 ] ||
13888 error "Unexpected jobids when jobid_var=$JOBENV"
13891 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
13892 JOBENV="JOBCOMPLEX"
13893 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
13895 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
13897 run_test 205 "Verify job stats"
13899 # LU-1480, LU-1773 and LU-1657
13901 mkdir -p $DIR/$tdir
13902 $SETSTRIPE -c -1 $DIR/$tdir
13903 #define OBD_FAIL_LOV_INIT 0x1403
13904 $LCTL set_param fail_loc=0xa0001403
13905 $LCTL set_param fail_val=1
13906 touch $DIR/$tdir/$tfile || true
13908 run_test 206 "fail lov_init_raid0() doesn't lbug"
13911 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13912 local fsz=`stat -c %s $DIR/$tfile`
13913 cancel_lru_locks mdc
13915 # do not return layout in getattr intent
13916 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
13917 $LCTL set_param fail_loc=0x170
13918 local sz=`stat -c %s $DIR/$tfile`
13920 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
13924 run_test 207a "can refresh layout at glimpse"
13927 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13928 local cksum=`md5sum $DIR/$tfile`
13929 local fsz=`stat -c %s $DIR/$tfile`
13930 cancel_lru_locks mdc
13931 cancel_lru_locks osc
13933 # do not return layout in getattr intent
13934 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
13935 $LCTL set_param fail_loc=0x171
13937 # it will refresh layout after the file is opened but before read issues
13938 echo checksum is "$cksum"
13939 echo "$cksum" |md5sum -c --quiet || error "file differs"
13943 run_test 207b "can refresh layout at open"
13946 # FIXME: in this test suite, only RD lease is used. This is okay
13947 # for now as only exclusive open is supported. After generic lease
13948 # is done, this test suite should be revised. - Jinshan
13950 remote_mds_nodsh && skip "remote MDS with nodsh"
13951 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
13952 skip "Need MDS version at least 2.4.52"
13954 echo "==== test 1: verify get lease work"
13955 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
13957 echo "==== test 2: verify lease can be broken by upcoming open"
13958 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13962 $MULTIOP $DIR/$tfile oO_RDONLY:c
13963 kill -USR1 $PID && wait $PID || error "break lease error"
13965 echo "==== test 3: verify lease can't be granted if an open already exists"
13966 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
13970 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
13971 kill -USR1 $PID && wait $PID || error "open file error"
13973 echo "==== test 4: lease can sustain over recovery"
13974 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
13980 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
13982 echo "==== test 5: lease broken can't be regained by replay"
13983 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13987 # open file to break lease and then recovery
13988 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
13991 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
13995 run_test 208 "Exclusive open"
13998 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
13999 skip_env "must have disp_stripe"
14002 sync; sleep 5; sync;
14004 echo 3 > /proc/sys/vm/drop_caches
14005 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14007 # open/close 500 times
14008 for i in $(seq 500); do
14012 echo 3 > /proc/sys/vm/drop_caches
14013 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14015 echo "before: $req_before, after: $req_after"
14016 [ $((req_after - req_before)) -ge 300 ] &&
14017 error "open/close requests are not freed"
14020 run_test 209 "read-only open/close requests should be freed promptly"
14024 size=$((size % 8192 + 1))
14025 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
14026 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
14027 rm -f $DIR/f212 $DIR/f212.xyz
14029 run_test 212 "Sendfile test ============================================"
14032 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
14033 cancel_lru_locks osc
14034 lctl set_param fail_loc=0x8000040f
14035 # generate a read lock
14036 cat $DIR/$tfile > /dev/null
14037 # write to the file, it will try to cancel the above read lock.
14038 cat /etc/hosts >> $DIR/$tfile
14040 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
14042 test_214() { # for bug 20133
14043 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
14044 for (( i=0; i < 340; i++ )) ; do
14045 touch $DIR/$tdir/d214c/a$i
14048 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
14049 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
14050 ls $DIR/d214c || error "ls $DIR/d214c failed"
14051 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
14052 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
14054 run_test 214 "hash-indexed directory test - bug 20133"
14056 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
14057 create_lnet_proc_files() {
14058 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
14061 # counterpart of create_lnet_proc_files
14062 remove_lnet_proc_files() {
14063 rm -f $TMP/lnet_$1.sys
14066 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14067 # 3rd arg as regexp for body
14068 check_lnet_proc_stats() {
14069 local l=$(cat "$TMP/lnet_$1" |wc -l)
14070 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
14072 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
14075 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14076 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
14077 # optional and can be regexp for 2nd line (lnet.routes case)
14078 check_lnet_proc_entry() {
14079 local blp=2 # blp stands for 'position of 1st line of body'
14080 [ -z "$5" ] || blp=3 # lnet.routes case
14082 local l=$(cat "$TMP/lnet_$1" |wc -l)
14083 # subtracting one from $blp because the body can be empty
14084 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
14086 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
14087 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
14089 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
14090 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
14092 # bail out if any unexpected line happened
14093 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
14094 [ "$?" != 0 ] || error "$2 misformatted"
14097 test_215() { # for bugs 18102, 21079, 21517
14098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14100 local N='(0|[1-9][0-9]*)' # non-negative numeric
14101 local P='[1-9][0-9]*' # positive numeric
14102 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
14103 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
14104 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
14105 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
14107 local L1 # regexp for 1st line
14108 local L2 # regexp for 2nd line (optional)
14109 local BR # regexp for the rest (body)
14111 # lnet.stats should look as 11 space-separated non-negative numerics
14112 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
14113 create_lnet_proc_files "stats"
14114 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
14115 remove_lnet_proc_files "stats"
14117 # lnet.routes should look like this:
14118 # Routing disabled/enabled
14119 # net hops priority state router
14120 # where net is a string like tcp0, hops > 0, priority >= 0,
14121 # state is up/down,
14122 # router is a string like 192.168.1.1@tcp2
14123 L1="^Routing (disabled|enabled)$"
14124 L2="^net +hops +priority +state +router$"
14125 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
14126 create_lnet_proc_files "routes"
14127 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
14128 remove_lnet_proc_files "routes"
14130 # lnet.routers should look like this:
14131 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
14132 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
14133 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
14134 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
14135 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
14136 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
14137 create_lnet_proc_files "routers"
14138 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
14139 remove_lnet_proc_files "routers"
14141 # lnet.peers should look like this:
14142 # nid refs state last max rtr min tx min queue
14143 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
14144 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
14145 # numeric (0 or >0 or <0), queue >= 0.
14146 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
14147 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
14148 create_lnet_proc_files "peers"
14149 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
14150 remove_lnet_proc_files "peers"
14152 # lnet.buffers should look like this:
14153 # pages count credits min
14154 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
14155 L1="^pages +count +credits +min$"
14156 BR="^ +$N +$N +$I +$I$"
14157 create_lnet_proc_files "buffers"
14158 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
14159 remove_lnet_proc_files "buffers"
14161 # lnet.nis should look like this:
14162 # nid status alive refs peer rtr max tx min
14163 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
14164 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
14165 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
14166 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
14167 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
14168 create_lnet_proc_files "nis"
14169 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
14170 remove_lnet_proc_files "nis"
14172 # can we successfully write to lnet.stats?
14173 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
14175 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
14177 test_216() { # bug 20317
14178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14179 remote_ost_nodsh && skip "remote OST with nodsh"
14182 local facets=$(get_facets OST)
14183 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14185 save_lustre_params client "osc.*.contention_seconds" > $p
14186 save_lustre_params $facets \
14187 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
14188 save_lustre_params $facets \
14189 "ldlm.namespaces.filter-*.contended_locks" >> $p
14190 save_lustre_params $facets \
14191 "ldlm.namespaces.filter-*.contention_seconds" >> $p
14192 clear_stats osc.*.osc_stats
14194 # agressive lockless i/o settings
14195 do_nodes $(comma_list $(osts_nodes)) \
14196 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
14197 ldlm.namespaces.filter-*.contended_locks=0 \
14198 ldlm.namespaces.filter-*.contention_seconds=60"
14199 lctl set_param -n osc.*.contention_seconds=60
14201 $DIRECTIO write $DIR/$tfile 0 10 4096
14202 $CHECKSTAT -s 40960 $DIR/$tfile
14204 # disable lockless i/o
14205 do_nodes $(comma_list $(osts_nodes)) \
14206 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
14207 ldlm.namespaces.filter-*.contended_locks=32 \
14208 ldlm.namespaces.filter-*.contention_seconds=0"
14209 lctl set_param -n osc.*.contention_seconds=0
14210 clear_stats osc.*.osc_stats
14212 dd if=/dev/zero of=$DIR/$tfile count=0
14213 $CHECKSTAT -s 0 $DIR/$tfile
14215 restore_lustre_params <$p
14219 run_test 216 "check lockless direct write updates file size and kms correctly"
14221 test_217() { # bug 22430
14222 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14227 for node in $(nodes_list); do
14228 nid=$(host_nids_address $node $NETTYPE)
14229 if [[ $nid = *-* ]] ; then
14230 echo "lctl ping $(h2nettype $nid)"
14231 lctl ping $(h2nettype $nid)
14233 echo "skipping $node (no hyphen detected)"
14237 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
14240 # do directio so as not to populate the page cache
14241 log "creating a 10 Mb file"
14242 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14243 log "starting reads"
14244 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14245 log "truncating the file"
14246 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14248 kill %+ || true # reads might have finished
14249 echo "wait until dd is finished"
14251 log "removing the temporary file"
14252 rm -rf $DIR/$tfile || error "tmp file removal failed"
14254 run_test 218 "parallel read and truncate should not deadlock"
14257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14259 # write one partial page
14260 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
14261 # set no grant so vvp_io_commit_write will do sync write
14262 $LCTL set_param fail_loc=0x411
14263 # write a full page at the end of file
14264 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
14266 $LCTL set_param fail_loc=0
14267 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
14268 $LCTL set_param fail_loc=0x411
14269 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
14272 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
14273 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
14275 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
14277 test_220() { #LU-325
14278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14279 remote_ost_nodsh && skip "remote OST with nodsh"
14280 remote_mds_nodsh && skip "remote MDS with nodsh"
14281 remote_mgs_nodsh && skip "remote MGS with nodsh"
14285 # create on MDT0000 so the last_id and next_id are correct
14287 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
14291 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
14292 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
14293 osc.$mdtosc_proc1.prealloc_last_id)
14294 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
14295 osc.$mdtosc_proc1.prealloc_next_id)
14299 if ! combined_mgs_mds ; then
14303 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
14304 #define OBD_FAIL_OST_ENOINO 0x229
14305 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
14306 create_pool $FSNAME.$TESTNAME || return 1
14307 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
14309 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
14311 MDSOBJS=$((last_id - next_id))
14312 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
14314 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
14315 echo "OST still has $count kbytes free"
14317 echo "create $MDSOBJS files @next_id..."
14318 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
14320 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14321 osc.$mdtosc_proc1.prealloc_last_id)
14322 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14323 osc.$mdtosc_proc1.prealloc_next_id)
14325 echo "after creation, last_id=$last_id2, next_id=$next_id2"
14330 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
14331 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
14333 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
14334 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
14335 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14336 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
14337 echo "unlink $MDSOBJS files @$next_id..."
14338 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
14340 if ! combined_mgs_mds ; then
14344 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
14347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14349 dd if=`which date` of=$MOUNT/date oflag=sync
14350 chmod +x $MOUNT/date
14352 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
14353 $LCTL set_param fail_loc=0x80001401
14355 $MOUNT/date > /dev/null
14358 run_test 221 "make sure fault and truncate race to not cause OOM"
14361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14364 test_mkdir $DIR/$tdir
14365 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14366 createmany -o $DIR/$tdir/$tfile 10
14367 cancel_lru_locks mdc
14368 cancel_lru_locks osc
14369 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14370 $LCTL set_param fail_loc=0x31a
14371 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
14372 $LCTL set_param fail_loc=0
14375 run_test 222a "AGL for ls should not trigger CLIO lock failure"
14378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14381 test_mkdir $DIR/$tdir
14382 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14383 createmany -o $DIR/$tdir/$tfile 10
14384 cancel_lru_locks mdc
14385 cancel_lru_locks osc
14386 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14387 $LCTL set_param fail_loc=0x31a
14388 rm -r $DIR/$tdir || error "AGL for rmdir failed"
14389 $LCTL set_param fail_loc=0
14391 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
14394 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14397 test_mkdir $DIR/$tdir
14398 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14399 createmany -o $DIR/$tdir/$tfile 10
14400 cancel_lru_locks mdc
14401 cancel_lru_locks osc
14402 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
14403 $LCTL set_param fail_loc=0x31b
14404 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
14405 $LCTL set_param fail_loc=0
14408 run_test 223 "osc reenqueue if without AGL lock granted ======================="
14410 test_224a() { # LU-1039, MRP-303
14411 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14413 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
14414 $LCTL set_param fail_loc=0x508
14415 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
14416 $LCTL set_param fail_loc=0
14419 run_test 224a "Don't panic on bulk IO failure"
14421 test_224b() { # LU-1039, MRP-303
14422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14424 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
14425 cancel_lru_locks osc
14426 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
14427 $LCTL set_param fail_loc=0x515
14428 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
14429 $LCTL set_param fail_loc=0
14432 run_test 224b "Don't panic on bulk IO failure"
14434 test_224c() { # LU-6441
14435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14436 remote_mds_nodsh && skip "remote MDS with nodsh"
14438 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14439 save_writethrough $p
14440 set_cache writethrough on
14442 local pages_per_rpc=$($LCTL get_param \
14443 osc.*.max_pages_per_rpc)
14444 local at_max=$($LCTL get_param -n at_max)
14445 local timeout=$($LCTL get_param -n timeout)
14446 local test_at="$LCTL get_param -n at_max"
14447 local param_at="$FSNAME.sys.at_max"
14448 local test_timeout="$LCTL get_param -n timeout"
14449 local param_timeout="$FSNAME.sys.timeout"
14451 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
14453 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
14454 error "conf_param at_max=0 failed"
14455 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
14456 error "conf_param timeout=5 failed"
14458 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
14459 do_facet ost1 $LCTL set_param fail_loc=0x520
14460 $LFS setstripe -c 1 -i 0 $DIR/$tfile
14461 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
14463 do_facet ost1 $LCTL set_param fail_loc=0
14465 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
14466 error "conf_param at_max=$at_max failed"
14467 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
14468 $timeout || error "conf_param timeout=$timeout failed"
14470 $LCTL set_param -n $pages_per_rpc
14471 restore_lustre_params < $p
14474 run_test 224c "Don't hang if one of md lost during large bulk RPC"
14476 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
14478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14479 if [ -z ${MDSSURVEY} ]; then
14480 skip_env "mds-survey not found"
14482 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
14483 skip "Need MDS version at least 2.2.51"
14485 local mds=$(facet_host $SINGLEMDS)
14486 local target=$(do_nodes $mds 'lctl dl' |
14487 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14489 local cmd1="file_count=1000 thrhi=4"
14490 local cmd2="dir_count=2 layer=mdd stripe_count=0"
14491 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14492 local cmd="$cmd1 $cmd2 $cmd3"
14494 rm -f ${TMP}/mds_survey*
14496 eval $cmd || error "mds-survey with zero-stripe failed"
14497 cat ${TMP}/mds_survey*
14498 rm -f ${TMP}/mds_survey*
14500 run_test 225a "Metadata survey sanity with zero-stripe"
14503 if [ -z ${MDSSURVEY} ]; then
14504 skip_env "mds-survey not found"
14506 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
14507 skip "Need MDS version at least 2.2.51"
14508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14509 remote_mds_nodsh && skip "remote MDS with nodsh"
14510 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
14511 skip_env "Need to mount OST to test"
14514 local mds=$(facet_host $SINGLEMDS)
14515 local target=$(do_nodes $mds 'lctl dl' |
14516 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14518 local cmd1="file_count=1000 thrhi=4"
14519 local cmd2="dir_count=2 layer=mdd stripe_count=1"
14520 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14521 local cmd="$cmd1 $cmd2 $cmd3"
14523 rm -f ${TMP}/mds_survey*
14525 eval $cmd || error "mds-survey with stripe_count failed"
14526 cat ${TMP}/mds_survey*
14527 rm -f ${TMP}/mds_survey*
14529 run_test 225b "Metadata survey sanity with stripe_count = 1"
14531 mcreate_path2fid () {
14537 local path=$DIR/$tdir/$name
14542 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
14543 error "cannot create $desc"
14545 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
14547 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
14549 fid_path=$($LFS fid2path $MOUNT $fid)
14551 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
14553 [ "$path" == "$fid_path" ] ||
14554 error "fid2path returned $fid_path, expected $path"
14556 echo "pass with $path and $fid"
14561 mkdir -p $DIR/$tdir
14563 mcreate_path2fid 0010666 0 0 fifo "FIFO"
14564 mcreate_path2fid 0020666 1 3 null "character special file (null)"
14565 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
14566 mcreate_path2fid 0040666 0 0 dir "directory"
14567 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
14568 mcreate_path2fid 0100666 0 0 file "regular file"
14569 mcreate_path2fid 0120666 0 0 link "symbolic link"
14570 mcreate_path2fid 0140666 0 0 sock "socket"
14572 run_test 226a "call path2fid and fid2path on files of all type"
14575 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14580 mkdir -p $DIR/$tdir
14581 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
14582 error "create remote directory failed"
14583 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
14584 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
14585 "character special file (null)"
14586 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
14587 "character special file (no device)"
14588 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
14589 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
14590 "block special file (loop)"
14591 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
14592 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
14593 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
14595 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
14597 # LU-1299 Executing or running ldd on a truncated executable does not
14598 # cause an out-of-memory condition.
14600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14601 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
14603 dd if=$(which date) of=$MOUNT/date bs=1k count=1
14604 chmod +x $MOUNT/date
14606 $MOUNT/date > /dev/null
14607 ldd $MOUNT/date > /dev/null
14610 run_test 227 "running truncated executable does not cause OOM"
14612 # LU-1512 try to reuse idle OI blocks
14614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14615 remote_mds_nodsh && skip "remote MDS with nodsh"
14616 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14617 skip_env "ldiskfs only test"
14619 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14620 local myDIR=$DIR/$tdir
14623 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14624 $LCTL set_param fail_loc=0x80001002
14625 createmany -o $myDIR/t- 10000
14626 $LCTL set_param fail_loc=0
14627 # The guard is current the largest FID holder
14629 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14631 local IDX=$(($SEQ % 64))
14633 do_facet $SINGLEMDS sync
14634 # Make sure journal flushed.
14636 local blk1=$(do_facet $SINGLEMDS \
14637 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14638 grep Blockcount | awk '{print $4}')
14640 # Remove old files, some OI blocks will become idle.
14641 unlinkmany $myDIR/t- 10000
14642 # Create new files, idle OI blocks should be reused.
14643 createmany -o $myDIR/t- 2000
14644 do_facet $SINGLEMDS sync
14645 # Make sure journal flushed.
14647 local blk2=$(do_facet $SINGLEMDS \
14648 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14649 grep Blockcount | awk '{print $4}')
14651 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14653 run_test 228a "try to reuse idle OI blocks"
14656 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14657 remote_mds_nodsh && skip "remote MDS with nodsh"
14658 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14659 skip_env "ldiskfs only test"
14661 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14662 local myDIR=$DIR/$tdir
14665 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14666 $LCTL set_param fail_loc=0x80001002
14667 createmany -o $myDIR/t- 10000
14668 $LCTL set_param fail_loc=0
14669 # The guard is current the largest FID holder
14671 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14673 local IDX=$(($SEQ % 64))
14675 do_facet $SINGLEMDS sync
14676 # Make sure journal flushed.
14678 local blk1=$(do_facet $SINGLEMDS \
14679 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14680 grep Blockcount | awk '{print $4}')
14682 # Remove old files, some OI blocks will become idle.
14683 unlinkmany $myDIR/t- 10000
14686 stop $SINGLEMDS || error "Fail to stop MDT."
14688 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
14690 df $MOUNT || error "Fail to df."
14691 # Create new files, idle OI blocks should be reused.
14692 createmany -o $myDIR/t- 2000
14693 do_facet $SINGLEMDS sync
14694 # Make sure journal flushed.
14696 local blk2=$(do_facet $SINGLEMDS \
14697 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14698 grep Blockcount | awk '{print $4}')
14700 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14702 run_test 228b "idle OI blocks can be reused after MDT restart"
14706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14707 remote_mds_nodsh && skip "remote MDS with nodsh"
14708 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14709 skip_env "ldiskfs only test"
14711 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14712 local myDIR=$DIR/$tdir
14715 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14716 $LCTL set_param fail_loc=0x80001002
14717 # 20000 files can guarantee there are index nodes in the OI file
14718 createmany -o $myDIR/t- 20000
14719 $LCTL set_param fail_loc=0
14720 # The guard is current the largest FID holder
14722 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14724 local IDX=$(($SEQ % 64))
14726 do_facet $SINGLEMDS sync
14727 # Make sure journal flushed.
14729 local blk1=$(do_facet $SINGLEMDS \
14730 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14731 grep Blockcount | awk '{print $4}')
14733 # Remove old files, some OI blocks will become idle.
14734 unlinkmany $myDIR/t- 20000
14736 # The OI file should become empty now
14738 # Create new files, idle OI blocks should be reused.
14739 createmany -o $myDIR/t- 2000
14740 do_facet $SINGLEMDS sync
14741 # Make sure journal flushed.
14743 local blk2=$(do_facet $SINGLEMDS \
14744 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14745 grep Blockcount | awk '{print $4}')
14747 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14749 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
14751 test_229() { # LU-2482, LU-3448
14752 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14753 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
14754 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
14755 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
14759 # Create a file with a released layout and stripe count 2.
14760 $MULTIOP $DIR/$tfile H2c ||
14761 error "failed to create file with released layout"
14763 $GETSTRIPE -v $DIR/$tfile
14765 local pattern=$($GETSTRIPE -L $DIR/$tfile)
14766 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
14768 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
14769 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
14770 stat $DIR/$tfile || error "failed to stat released file"
14772 chown $RUNAS_ID $DIR/$tfile ||
14773 error "chown $RUNAS_ID $DIR/$tfile failed"
14775 chgrp $RUNAS_ID $DIR/$tfile ||
14776 error "chgrp $RUNAS_ID $DIR/$tfile failed"
14778 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
14779 rm $DIR/$tfile || error "failed to remove released file"
14781 run_test 229 "getstripe/stat/rm/attr changes work on released files"
14784 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14785 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14789 test_mkdir $DIR/$tdir
14790 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
14791 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
14792 [ $mdt_idx -ne 0 ] &&
14793 error "create local directory on wrong MDT $mdt_idx"
14795 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
14796 error "create remote directory failed"
14797 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
14798 [ $mdt_idx -ne $MDTIDX ] &&
14799 error "create remote directory on wrong MDT $mdt_idx"
14801 createmany -o $DIR/$tdir/test_230/t- 10 ||
14802 error "create files on remote directory failed"
14803 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
14804 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
14805 rm -r $DIR/$tdir || error "unlink remote directory failed"
14807 run_test 230a "Create remote directory and files under the remote directory"
14810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14811 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14819 local migrate_dir=$DIR/$tdir/migrate_dir
14820 local other_dir=$DIR/$tdir/other_dir
14822 test_mkdir $DIR/$tdir
14823 test_mkdir -i0 -c1 $migrate_dir
14824 test_mkdir -i0 -c1 $other_dir
14825 for ((i=0; i<10; i++)); do
14826 mkdir -p $migrate_dir/dir_${i}
14827 createmany -o $migrate_dir/dir_${i}/f 10 ||
14828 error "create files under remote dir failed $i"
14831 cp /etc/passwd $migrate_dir/$tfile
14832 cp /etc/passwd $other_dir/$tfile
14833 chattr +SAD $migrate_dir
14834 chattr +SAD $migrate_dir/$tfile
14836 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14837 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14838 local old_dir_mode=$(stat -c%f $migrate_dir)
14839 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
14841 mkdir -p $migrate_dir/dir_default_stripe2
14842 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
14843 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
14845 mkdir -p $other_dir
14846 ln $migrate_dir/$tfile $other_dir/luna
14847 ln $migrate_dir/$tfile $migrate_dir/sofia
14848 ln $other_dir/$tfile $migrate_dir/david
14849 ln -s $migrate_dir/$tfile $other_dir/zachary
14850 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
14851 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
14853 $LFS migrate -m $MDTIDX $migrate_dir ||
14854 error "fails on migrating remote dir to MDT1"
14856 echo "migratate to MDT1, then checking.."
14857 for ((i = 0; i < 10; i++)); do
14858 for file in $(find $migrate_dir/dir_${i}); do
14859 mdt_index=$($LFS getstripe -m $file)
14860 [ $mdt_index == $MDTIDX ] ||
14861 error "$file is not on MDT${MDTIDX}"
14865 # the multiple link file should still in MDT0
14866 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
14867 [ $mdt_index == 0 ] ||
14868 error "$file is not on MDT${MDTIDX}"
14870 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14871 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14872 error " expect $old_dir_flag get $new_dir_flag"
14874 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14875 [ "$old_file_flag" = "$new_file_flag" ] ||
14876 error " expect $old_file_flag get $new_file_flag"
14878 local new_dir_mode=$(stat -c%f $migrate_dir)
14879 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14880 error "expect mode $old_dir_mode get $new_dir_mode"
14882 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14883 [ "$old_file_mode" = "$new_file_mode" ] ||
14884 error "expect mode $old_file_mode get $new_file_mode"
14886 diff /etc/passwd $migrate_dir/$tfile ||
14887 error "$tfile different after migration"
14889 diff /etc/passwd $other_dir/luna ||
14890 error "luna different after migration"
14892 diff /etc/passwd $migrate_dir/sofia ||
14893 error "sofia different after migration"
14895 diff /etc/passwd $migrate_dir/david ||
14896 error "david different after migration"
14898 diff /etc/passwd $other_dir/zachary ||
14899 error "zachary different after migration"
14901 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14902 error "${tfile}_ln different after migration"
14904 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14905 error "${tfile}_ln_other different after migration"
14907 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
14908 [ $stripe_count = 2 ] ||
14909 error "dir strpe_count $d != 2 after migration."
14911 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
14912 [ $stripe_count = 2 ] ||
14913 error "file strpe_count $d != 2 after migration."
14915 #migrate back to MDT0
14918 $LFS migrate -m $MDTIDX $migrate_dir ||
14919 error "fails on migrating remote dir to MDT0"
14921 echo "migrate back to MDT0, checking.."
14922 for file in $(find $migrate_dir); do
14923 mdt_index=$($LFS getstripe -m $file)
14924 [ $mdt_index == $MDTIDX ] ||
14925 error "$file is not on MDT${MDTIDX}"
14928 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14929 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14930 error " expect $old_dir_flag get $new_dir_flag"
14932 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14933 [ "$old_file_flag" = "$new_file_flag" ] ||
14934 error " expect $old_file_flag get $new_file_flag"
14936 local new_dir_mode=$(stat -c%f $migrate_dir)
14937 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14938 error "expect mode $old_dir_mode get $new_dir_mode"
14940 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14941 [ "$old_file_mode" = "$new_file_mode" ] ||
14942 error "expect mode $old_file_mode get $new_file_mode"
14944 diff /etc/passwd ${migrate_dir}/$tfile ||
14945 error "$tfile different after migration"
14947 diff /etc/passwd ${other_dir}/luna ||
14948 error "luna different after migration"
14950 diff /etc/passwd ${migrate_dir}/sofia ||
14951 error "sofia different after migration"
14953 diff /etc/passwd ${other_dir}/zachary ||
14954 error "zachary different after migration"
14956 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14957 error "${tfile}_ln different after migration"
14959 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14960 error "${tfile}_ln_other different after migration"
14962 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
14963 [ $stripe_count = 2 ] ||
14964 error "dir strpe_count $d != 2 after migration."
14966 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
14967 [ $stripe_count = 2 ] ||
14968 error "file strpe_count $d != 2 after migration."
14970 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14972 run_test 230b "migrate directory"
14975 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14977 remote_mds_nodsh && skip "remote MDS with nodsh"
14982 local migrate_dir=$DIR/$tdir/migrate_dir
14984 #If migrating directory fails in the middle, all entries of
14985 #the directory is still accessiable.
14986 test_mkdir $DIR/$tdir
14987 test_mkdir -i0 -c1 $migrate_dir
14989 createmany -o $migrate_dir/f 10 ||
14990 error "create files under ${migrate_dir} failed"
14992 #failed after migrating 5 entries
14993 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
14994 do_facet mds1 lctl set_param fail_loc=0x20001801
14995 do_facet mds1 lctl set_param fail_val=5
14996 local t=$(ls $migrate_dir | wc -l)
14997 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
14998 error "migrate should fail after 5 entries"
15000 mkdir $migrate_dir/dir &&
15001 error "mkdir succeeds under migrating directory"
15002 touch $migrate_dir/file &&
15003 error "touch file succeeds under migrating directory"
15005 local u=$(ls $migrate_dir | wc -l)
15006 [ "$u" == "$t" ] || error "$u != $t during migration"
15008 for file in $(find $migrate_dir); do
15009 stat $file || error "stat $file failed"
15012 do_facet mds1 lctl set_param fail_loc=0
15013 do_facet mds1 lctl set_param fail_val=0
15015 $LFS migrate -m $MDTIDX $migrate_dir ||
15016 error "migrate open files should failed with open files"
15018 echo "Finish migration, then checking.."
15019 for file in $(find $migrate_dir); do
15020 mdt_index=$($LFS getstripe -m $file)
15021 [ $mdt_index == $MDTIDX ] ||
15022 error "$file is not on MDT${MDTIDX}"
15025 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15027 run_test 230c "check directory accessiblity if migration is failed"
15030 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15031 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15035 local migrate_dir=$DIR/$tdir/migrate_dir
15039 test_mkdir $DIR/$tdir
15040 test_mkdir -i0 -c1 $migrate_dir
15042 for ((i=0; i<100; i++)); do
15043 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
15044 createmany -o $migrate_dir/dir_${i}/f 100 ||
15045 error "create files under remote dir failed $i"
15048 $LFS migrate -m $MDTIDX $migrate_dir ||
15049 error "migrate remote dir error"
15051 echo "Finish migration, then checking.."
15052 for file in $(find $migrate_dir); do
15053 mdt_index=$($LFS getstripe -m $file)
15054 [ $mdt_index == $MDTIDX ] ||
15055 error "$file is not on MDT${MDTIDX}"
15058 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15060 run_test 230d "check migrate big directory"
15063 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15064 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15071 mkdir -p $DIR/$tdir
15072 mkdir $DIR/$tdir/migrate_dir
15073 mkdir $DIR/$tdir/other_dir
15074 touch $DIR/$tdir/migrate_dir/a
15075 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
15076 ls $DIR/$tdir/other_dir
15078 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15079 error "migrate dir fails"
15081 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15082 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15084 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15085 [ $mdt_index == 0 ] || error "a is not on MDT0"
15087 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
15088 error "migrate dir fails"
15090 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
15091 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
15093 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15094 [ $mdt_index == 1 ] || error "a is not on MDT1"
15096 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
15097 [ $mdt_index == 1 ] || error "b is not on MDT1"
15099 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15100 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
15102 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
15104 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15106 run_test 230e "migrate mulitple local link files"
15109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15110 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15115 mkdir -p $DIR/$tdir
15116 mkdir $DIR/$tdir/migrate_dir
15117 $LFS mkdir -i1 $DIR/$tdir/other_dir
15118 touch $DIR/$tdir/migrate_dir/a
15119 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
15120 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
15121 ls $DIR/$tdir/other_dir
15123 # a should be migrated to MDT1, since no other links on MDT0
15124 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15125 error "#1 migrate dir fails"
15126 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15127 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15128 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15129 [ $mdt_index == 1 ] || error "a is not on MDT1"
15131 # a should stay on MDT1, because it is a mulitple link file
15132 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15133 error "#2 migrate dir fails"
15134 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15135 [ $mdt_index == 1 ] || error "a is not on MDT1"
15137 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15138 error "#3 migrate dir fails"
15140 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15141 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
15142 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
15144 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
15145 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
15147 # a should be migrated to MDT0, since no other links on MDT1
15148 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15149 error "#4 migrate dir fails"
15150 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15151 [ $mdt_index == 0 ] || error "a is not on MDT0"
15153 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15155 run_test 230f "migrate mulitple remote link files"
15158 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15159 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15161 mkdir -p $DIR/$tdir/migrate_dir
15163 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
15164 error "migrating dir to non-exist MDT succeeds"
15167 run_test 230g "migrate dir to non-exist MDT"
15170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15171 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15172 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
15173 skip "Need MDS version at least 2.7.64"
15177 mkdir -p $DIR/$tdir/migrate_dir
15179 $LFS migrate -m1 $DIR &&
15180 error "migrating mountpoint1 should fail"
15182 $LFS migrate -m1 $DIR/$tdir/.. &&
15183 error "migrating mountpoint2 should fail"
15185 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
15186 error "migrating $tdir fail"
15188 mdt_index=$($LFS getstripe -m $DIR/$tdir)
15189 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
15191 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15192 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
15195 run_test 230h "migrate .. and root"
15198 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15199 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15201 mkdir -p $DIR/$tdir/migrate_dir
15203 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
15204 error "migration fails with a tailing slash"
15206 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
15207 error "migration fails with two tailing slashes"
15209 run_test 230i "lfs migrate -m tolerates trailing slashes"
15213 # For simplicity this test assumes that max_pages_per_rpc
15214 # is the same across all OSCs
15215 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
15216 local bulk_size=$((max_pages * 4096))
15217 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
15220 mkdir -p $DIR/$tdir
15221 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
15222 error "failed to set stripe with -S ${brw_size}M option"
15224 # clear the OSC stats
15225 $LCTL set_param osc.*.stats=0 &>/dev/null
15228 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
15229 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
15230 oflag=direct &>/dev/null || error "dd failed"
15232 sync; sleep 1; sync # just to be safe
15233 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
15234 if [ x$nrpcs != "x1" ]; then
15235 $LCTL get_param osc.*.stats
15236 error "found $nrpcs ost_write RPCs, not 1 as expected"
15240 # Drop the OSC cache, otherwise we will read from it
15241 cancel_lru_locks osc
15243 # clear the OSC stats
15244 $LCTL set_param osc.*.stats=0 &>/dev/null
15246 # Client reads $bulk_size.
15247 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
15248 iflag=direct &>/dev/null || error "dd failed"
15250 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
15251 if [ x$nrpcs != "x1" ]; then
15252 $LCTL get_param osc.*.stats
15253 error "found $nrpcs ost_read RPCs, not 1 as expected"
15256 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
15259 mkdir -p $DIR/$tdir
15261 for i in {0..1023}; do
15262 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
15263 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
15264 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
15268 run_test 231b "must not assert on fully utilized OST request buffer"
15271 mkdir -p $DIR/$tdir
15272 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15274 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15275 do_facet ost1 $LCTL set_param fail_loc=0x31c
15277 # ignore dd failure
15278 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
15280 do_facet ost1 $LCTL set_param fail_loc=0
15281 umount_client $MOUNT || error "umount failed"
15282 mount_client $MOUNT || error "mount failed"
15283 stop ost1 || error "cannot stop ost1"
15284 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15286 run_test 232a "failed lock should not block umount"
15289 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.58) ] ||
15290 skip "Need MDS version at least 2.10.58"
15292 mkdir -p $DIR/$tdir
15293 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15294 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
15296 cancel_lru_locks osc
15298 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15299 do_facet ost1 $LCTL set_param fail_loc=0x31c
15302 $LFS data_version $DIR/$tdir/$tfile || true
15304 do_facet ost1 $LCTL set_param fail_loc=0
15305 umount_client $MOUNT || error "umount failed"
15306 mount_client $MOUNT || error "mount failed"
15307 stop ost1 || error "cannot stop ost1"
15308 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15310 run_test 232b "failed data version lock should not block umount"
15313 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
15314 skip "Need MDS version at least 2.3.64"
15315 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15317 local fid=$($LFS path2fid $MOUNT)
15319 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15320 error "cannot access $MOUNT using its FID '$fid'"
15322 run_test 233a "checking that OBF of the FS root succeeds"
15325 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
15326 skip "Need MDS version at least 2.5.90"
15327 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15329 local fid=$($LFS path2fid $MOUNT/.lustre)
15331 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15332 error "cannot access $MOUNT/.lustre using its FID '$fid'"
15334 fid=$($LFS path2fid $MOUNT/.lustre/fid)
15335 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15336 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
15338 run_test 233b "checking that OBF of the FS .lustre succeeds"
15341 local p="$TMP/sanityN-$TESTNAME.parameters"
15342 save_lustre_params client "llite.*.xattr_cache" > $p
15343 lctl set_param llite.*.xattr_cache 1 ||
15344 skip_env "xattr cache is not supported"
15346 mkdir -p $DIR/$tdir || error "mkdir failed"
15347 touch $DIR/$tdir/$tfile || error "touch failed"
15348 # OBD_FAIL_LLITE_XATTR_ENOMEM
15349 $LCTL set_param fail_loc=0x1405
15350 getfattr -n user.attr $DIR/$tdir/$tfile &&
15351 error "getfattr should have failed with ENOMEM"
15352 $LCTL set_param fail_loc=0x0
15355 restore_lustre_params < $p
15358 run_test 234 "xattr cache should not crash on ENOMEM"
15361 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
15362 skip "Need MDS version at least 2.4.52"
15364 flock_deadlock $DIR/$tfile
15369 124) error "process hangs on a deadlock"
15371 *) error "error executing flock_deadlock $DIR/$tfile"
15375 run_test 235 "LU-1715: flock deadlock detection does not work properly"
15379 check_swap_layouts_support
15381 local ref1=/etc/passwd
15382 local ref2=/etc/group
15383 local file1=$DIR/$tdir/f1
15384 local file2=$DIR/$tdir/f2
15386 test_mkdir -c1 $DIR/$tdir
15387 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
15388 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
15389 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
15390 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
15391 local fd=$(free_fd)
15392 local cmd="exec $fd<>$file2"
15395 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
15396 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
15399 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15404 run_test 236 "Layout swap on open unlinked file"
15406 # test to verify file handle related system calls
15407 # (name_to_handle_at/open_by_handle_at)
15408 # The new system calls are supported in glibc >= 2.14.
15411 echo "Test file_handle syscalls" > $DIR/$tfile ||
15412 error "write failed"
15413 check_fhandle_syscalls $DIR/$tfile ||
15414 error "check_fhandle_syscalls failed"
15416 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
15418 # LU-4659 linkea consistency
15420 local server_version=$(lustre_version_code $SINGLEMDS)
15422 [[ $server_version -gt $(version_code 2.5.57) ]] ||
15423 [[ $server_version -gt $(version_code 2.5.1) &&
15424 $server_version -lt $(version_code 2.5.50) ]] ||
15425 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15428 ln $DIR/$tfile $DIR/$tfile.lnk
15429 touch $DIR/$tfile.new
15430 mv $DIR/$tfile.new $DIR/$tfile
15431 local fid1=$($LFS path2fid $DIR/$tfile)
15432 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
15433 local path1=$($LFS fid2path $FSNAME "$fid1")
15434 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
15435 local path2=$($LFS fid2path $FSNAME "$fid2")
15436 [ $tfile.lnk == $path2 ] ||
15437 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
15440 run_test 238 "Verify linkea consistency"
15442 test_239A() { # was test_239
15443 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
15444 skip "Need MDS version at least 2.5.60"
15446 local list=$(comma_list $(mdts_nodes))
15448 mkdir -p $DIR/$tdir
15449 createmany -o $DIR/$tdir/f- 5000
15450 unlinkmany $DIR/$tdir/f- 5000
15451 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
15452 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
15453 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
15454 osp.*MDT*.sync_in_flight" | calc_sum)
15455 [ "$changes" -eq 0 ] || error "$changes not synced"
15457 run_test 239A "osp_sync test"
15459 test_239a() { #LU-5297
15460 remote_mds_nodsh && skip "remote MDS with nodsh"
15463 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
15464 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
15465 chgrp $RUNAS_GID $DIR/$tfile
15466 wait_delete_completed
15468 run_test 239a "process invalid osp sync record correctly"
15470 test_239b() { #LU-5297
15471 remote_mds_nodsh && skip "remote MDS with nodsh"
15474 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
15475 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
15476 chgrp $RUNAS_GID $DIR/$tfile1
15477 wait_delete_completed
15478 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15480 chgrp $RUNAS_GID $DIR/$tfile2
15481 wait_delete_completed
15483 run_test 239b "process osp sync record with ENOMEM error correctly"
15486 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15487 remote_mds_nodsh && skip "remote MDS with nodsh"
15489 mkdir -p $DIR/$tdir
15491 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
15492 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
15493 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
15494 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
15496 umount_client $MOUNT || error "umount failed"
15497 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
15498 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
15499 mount_client $MOUNT || error "failed to mount client"
15501 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
15502 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
15504 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
15507 for LOOP in $(seq $1); do
15508 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
15509 cancel_lru_locks $OSC || true
15514 for LOOP in $(seq $1); do
15515 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
15516 iflag=direct 2>/dev/null
15520 test_241a() { # was test_241
15521 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
15523 cancel_lru_locks $OSC
15524 test_241_bio 1000 &
15529 run_test 241a "bio vs dio"
15532 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
15534 test_241_dio 1000 &
15539 run_test 241b "dio vs dio"
15542 remote_mds_nodsh && skip "remote MDS with nodsh"
15544 mkdir -p $DIR/$tdir
15545 touch $DIR/$tdir/$tfile
15547 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
15548 do_facet mds1 lctl set_param fail_loc=0x105
15549 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
15551 do_facet mds1 lctl set_param fail_loc=0
15552 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
15554 run_test 242 "mdt_readpage failure should not cause directory unreadable"
15558 test_mkdir $DIR/$tdir
15559 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
15561 run_test 243 "various group lock tests"
15565 test_mkdir $DIR/$tdir
15566 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
15567 sendfile_grouplock $DIR/$tdir/$tfile || \
15568 error "sendfile+grouplock failed"
15571 run_test 244 "sendfile with group lock tests"
15574 local flagname="multi_mod_rpcs"
15575 local connect_data_name="max_mod_rpcs"
15578 # check if multiple modify RPCs flag is set
15579 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
15580 grep "connect_flags:")
15583 echo "$out" | grep -qw $flagname
15584 if [ $? -ne 0 ]; then
15585 echo "connect flag $flagname is not set"
15589 # check if multiple modify RPCs data is set
15590 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
15593 echo "$out" | grep -qw $connect_data_name ||
15594 error "import should have connect data $connect_data_name"
15596 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
15598 test_246() { # LU-7371
15599 remote_ost_nodsh && skip "remote OST with nodsh"
15600 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
15601 skip "Need OST version >= 2.7.62"
15603 do_facet ost1 $LCTL set_param fail_val=4095
15604 #define OBD_FAIL_OST_READ_SIZE 0x234
15605 do_facet ost1 $LCTL set_param fail_loc=0x234
15606 $LFS setstripe $DIR/$tfile -i 0 -c 1
15607 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
15608 cancel_lru_locks $FSNAME-OST0000
15609 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
15611 run_test 246 "Read file of size 4095 should return right length"
15617 umount_client $submount
15622 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
15624 skip_env "Fileset feature is not supported"
15626 local submount=${MOUNT}_$tdir
15629 mkdir -p $submount || error "mkdir $submount failed"
15630 FILESET="$FILESET/$tdir" mount_client $submount ||
15631 error "mount $submount failed"
15632 trap "cleanup_247 $submount" EXIT
15633 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
15634 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
15635 error "read $MOUNT/$tdir/$tfile failed"
15636 cleanup_247 $submount
15638 run_test 247a "mount subdir as fileset"
15641 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15642 skip_env "Fileset feature is not supported"
15644 local submount=${MOUNT}_$tdir
15646 rm -rf $MOUNT/$tdir
15647 mkdir -p $submount || error "mkdir $submount failed"
15649 FILESET="$FILESET/$tdir" mount_client $submount &&
15650 error "mount $submount should fail"
15653 run_test 247b "mount subdir that dose not exist"
15656 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15657 skip_env "Fileset feature is not supported"
15659 local submount=${MOUNT}_$tdir
15661 mkdir -p $MOUNT/$tdir/dir1
15662 mkdir -p $submount || error "mkdir $submount failed"
15663 trap "cleanup_247 $submount" EXIT
15664 FILESET="$FILESET/$tdir" mount_client $submount ||
15665 error "mount $submount failed"
15666 local fid=$($LFS path2fid $MOUNT/)
15667 $LFS fid2path $submount $fid && error "fid2path should fail"
15668 cleanup_247 $submount
15670 run_test 247c "running fid2path outside root"
15673 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15674 skip "Fileset feature is not supported"
15676 local submount=${MOUNT}_$tdir
15678 mkdir -p $MOUNT/$tdir/dir1
15679 mkdir -p $submount || error "mkdir $submount failed"
15680 FILESET="$FILESET/$tdir" mount_client $submount ||
15681 error "mount $submount failed"
15682 trap "cleanup_247 $submount" EXIT
15683 local fid=$($LFS path2fid $submount/dir1)
15684 $LFS fid2path $submount $fid || error "fid2path should succeed"
15685 cleanup_247 $submount
15687 run_test 247d "running fid2path inside root"
15691 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
15693 skip "Fileset feature is not supported"
15695 local submount=${MOUNT}_$tdir
15698 mkdir -p $submount || error "mkdir $submount failed"
15699 FILESET="$FILESET/.." mount_client $submount &&
15700 error "mount $submount should fail"
15703 run_test 247e "mount .. as fileset"
15706 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
15707 [ -z "$fast_read_sav" ] && skip "no fast read support"
15709 # create a large file for fast read verification
15710 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
15712 # make sure the file is created correctly
15713 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
15714 { rm -f $DIR/$tfile; skip "file creation error"; }
15716 echo "Test 1: verify that fast read is 4 times faster on cache read"
15718 # small read with fast read enabled
15719 $LCTL set_param -n llite.*.fast_read=1
15720 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15721 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15722 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15723 # small read with fast read disabled
15724 $LCTL set_param -n llite.*.fast_read=0
15725 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15726 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15727 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15729 # verify that fast read is 4 times faster for cache read
15730 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
15731 error_not_in_vm "fast read was not 4 times faster: " \
15732 "$t_fast vs $t_slow"
15734 echo "Test 2: verify the performance between big and small read"
15735 $LCTL set_param -n llite.*.fast_read=1
15737 # 1k non-cache read
15738 cancel_lru_locks osc
15739 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15740 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15741 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15743 # 1M non-cache read
15744 cancel_lru_locks osc
15745 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15746 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15747 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15749 # verify that big IO is not 4 times faster than small IO
15750 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
15751 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
15753 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
15756 run_test 248 "fast read verification"
15758 test_249() { # LU-7890
15759 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
15760 skip "Need at least version 2.8.54"
15763 $SETSTRIPE -c 1 $DIR/$tfile
15764 # Offset 2T == 4k * 512M
15765 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
15766 error "dd to 2T offset failed"
15768 run_test 249 "Write above 2T file size"
15771 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
15772 && skip "no 16TB file size limit on ZFS"
15774 $SETSTRIPE -c 1 $DIR/$tfile
15775 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
15776 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
15777 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
15778 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
15779 conv=notrunc,fsync && error "append succeeded"
15782 run_test 250 "Write above 16T limit"
15785 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
15787 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
15788 #Skip once - writing the first stripe will succeed
15789 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15790 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
15791 error "short write happened"
15793 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15794 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
15795 error "short read happened"
15799 run_test 251 "Handling short read and write correctly"
15802 remote_mds_nodsh && skip "remote MDS with nodsh"
15803 remote_ost_nodsh && skip "remote OST with nodsh"
15804 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
15805 "$(facet_fstype mds1)" != "ldiskfs" ]; then
15806 skip_env "ldiskfs only test"
15816 # check lr_reader on OST0000
15818 dev=$(facet_device $tgt)
15819 out=$(do_facet $tgt $LR_READER $dev)
15820 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15822 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
15823 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
15824 error "Invalid uuid returned by $LR_READER on target $tgt"
15825 echo -e "uuid returned by $LR_READER is '$uuid'\n"
15827 # check lr_reader -c on MDT0000
15829 dev=$(facet_device $tgt)
15830 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
15831 skip "$LR_READER does not support additional options"
15833 out=$(do_facet $tgt $LR_READER -c $dev)
15834 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15836 num=$(echo "$out" | grep -c "mdtlov")
15837 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
15838 error "Invalid number of mdtlov clients returned by $LR_READER"
15839 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
15841 # check lr_reader -cr on MDT0000
15842 out=$(do_facet $tgt $LR_READER -cr $dev)
15843 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15845 echo "$out" | grep -q "^reply_data:$" ||
15846 error "$LR_READER should have returned 'reply_data' section"
15847 num=$(echo "$out" | grep -c "client_generation")
15848 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
15850 run_test 252 "check lr_reader tool"
15852 test_253_fill_ost() {
15853 local size_mb #how many MB should we write to pass watermark
15854 local lwm=$3 #low watermark
15855 local free_10mb #10% of free space
15857 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15858 size_mb=$((free_kb / 1024 - lwm))
15859 free_10mb=$((free_kb / 10240))
15860 #If 10% of free space cross low watermark use it
15861 if (( free_10mb > size_mb )); then
15864 #At least we need to store 1.1 of difference between
15865 #free space and low watermark
15866 size_mb=$((size_mb + size_mb / 10))
15868 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
15869 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
15870 oflag=append conv=notrunc
15875 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15876 echo "OST still has $((free_kb / 1024)) mbytes free"
15880 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15881 remote_mds_nodsh && skip "remote MDS with nodsh"
15882 remote_mgs_nodsh && skip "remote MGS with nodsh"
15887 local ost_name=$($LFS osts |
15888 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
15890 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
15891 do_facet $SINGLEMDS $LCTL get_param -n \
15892 osp.$mdtosc_proc1.reserved_mb_high ||
15893 skip "remote MDS does not support reserved_mb_high"
15897 wait_delete_completed
15900 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
15901 osp.$mdtosc_proc1.reserved_mb_high)
15902 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
15903 osp.$mdtosc_proc1.reserved_mb_low)
15904 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
15906 if ! combined_mgs_mds ; then
15909 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
15910 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
15911 error "Adding $ost_name to pool failed"
15913 # Wait for client to see a OST at pool
15914 wait_update $HOSTNAME "$LCTL get_param -n
15915 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
15916 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
15917 error "Client can not see the pool"
15918 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
15919 error "Setstripe failed"
15921 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
15922 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
15923 echo "OST still has $((blocks/1024)) mbytes free"
15925 local new_lwm=$((blocks/1024-10))
15926 do_facet $SINGLEMDS $LCTL set_param \
15927 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
15928 do_facet $SINGLEMDS $LCTL set_param \
15929 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
15931 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15933 #First enospc could execute orphan deletion so repeat.
15934 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15936 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15937 osp.$mdtosc_proc1.prealloc_status)
15938 echo "prealloc_status $oa_status"
15940 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
15941 error "File creation should fail"
15942 #object allocation was stopped, but we still able to append files
15943 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
15944 error "Append failed"
15945 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
15947 wait_delete_completed
15951 for i in $(seq 10 12); do
15952 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
15953 error "File creation failed after rm";
15956 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15957 osp.$mdtosc_proc1.prealloc_status)
15958 echo "prealloc_status $oa_status"
15960 if (( oa_status != 0 )); then
15961 error "Object allocation still disable after rm"
15963 do_facet $SINGLEMDS $LCTL set_param \
15964 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
15965 do_facet $SINGLEMDS $LCTL set_param \
15966 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
15969 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
15970 error "Remove $ost_name from pool failed"
15971 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15972 error "Pool destroy fialed"
15974 if ! combined_mgs_mds ; then
15978 run_test 253 "Check object allocation limit"
15981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15982 remote_mds_nodsh && skip "remote MDS with nodsh"
15983 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
15984 skip "MDS does not support changelog_size"
15987 local MDT0=$(facet_svc $SINGLEMDS)
15989 changelog_register || error "changelog_register failed"
15991 changelog_clear 0 || error "changelog_clear failed"
15993 local size1=$(do_facet $SINGLEMDS \
15994 $LCTL get_param -n mdd.$MDT0.changelog_size)
15995 echo "Changelog size $size1"
15998 $LFS mkdir -i 0 $DIR/$tdir
16000 mkdir -p $DIR/$tdir/pics/2008/zachy
16001 touch $DIR/$tdir/pics/2008/zachy/timestamp
16002 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
16003 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16004 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16005 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16006 rm $DIR/$tdir/pics/desktop.jpg
16008 local size2=$(do_facet $SINGLEMDS \
16009 $LCTL get_param -n mdd.$MDT0.changelog_size)
16010 echo "Changelog size after work $size2"
16012 (( $size2 > $size1 )) ||
16013 error "new Changelog size=$size2 less than old size=$size1"
16015 run_test 254 "Check changelog size"
16022 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
16023 awk -F: '{print $2}' | grep $type > /dev/null
16024 if [ $? -ne 0 ]; then
16034 lfs ladvise -a willread $file > /dev/null 2>&1
16035 if [ $? -eq 0 ]; then
16039 lfs ladvise -a willread $file 2>&1 |
16040 grep "Inappropriate ioctl for device" > /dev/null
16041 if [ $? -eq 0 ]; then
16048 bc <<<"scale=2; ($1 - $2) * 100 / $2"
16051 # run a random read IO workload
16052 # usage: random_read_iops <filename> <filesize> <iosize>
16053 random_read_iops() {
16056 local iosize=${3:-4096}
16058 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
16059 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
16062 drop_file_oss_cache() {
16066 $LFS ladvise -a dontneed $file 2>/dev/null ||
16067 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
16070 ladvise_willread_performance()
16073 local average_origin=0
16074 local average_cache=0
16075 local average_ladvise=0
16077 for ((i = 1; i <= $repeat; i++)); do
16078 echo "Iter $i/$repeat: reading without willread hint"
16079 cancel_lru_locks osc
16080 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16081 local speed_origin=$(random_read_iops $DIR/$tfile $size)
16082 echo "Iter $i/$repeat: uncached speed: $speed_origin"
16083 average_origin=$(bc <<<"$average_origin + $speed_origin")
16085 cancel_lru_locks osc
16086 local speed_cache=$(random_read_iops $DIR/$tfile $size)
16087 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
16088 average_cache=$(bc <<<"$average_cache + $speed_cache")
16090 cancel_lru_locks osc
16091 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16092 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
16093 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
16094 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
16095 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
16097 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
16098 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
16099 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
16101 speedup_cache=$(percent $average_cache $average_origin)
16102 speedup_ladvise=$(percent $average_ladvise $average_origin)
16104 echo "Average uncached read: $average_origin"
16105 echo "Average speedup with OSS cached read: " \
16106 "$average_cache = +$speedup_cache%"
16107 echo "Average speedup with ladvise willread: " \
16108 "$average_ladvise = +$speedup_ladvise%"
16110 local lowest_speedup=20
16111 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
16112 echo "Speedup with OSS cached read less than $lowest_speedup%," \
16113 "got $average_cache%. Skipping ladvise willread check."
16117 # the test won't work on ZFS until it supports 'ladvise dontneed', but
16118 # it is still good to run until then to exercise 'ladvise willread'
16119 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16120 [ "$(facet_fstype ost1)" = "zfs" ] &&
16121 echo "osd-zfs does not support dontneed or drop_caches" &&
16124 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
16125 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
16126 error_not_in_vm "Speedup with willread is less than " \
16127 "$lowest_speedup%, got $average_ladvise%"
16131 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
16132 skip "lustre < 2.8.54 does not support ladvise "
16133 remote_ost_nodsh && skip "remote OST with nodsh"
16135 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
16137 ladvise_no_type willread $DIR/$tfile &&
16138 skip "willread ladvise is not supported"
16140 ladvise_no_ioctl $DIR/$tfile &&
16141 skip "ladvise ioctl is not supported"
16144 local size=$((size_mb * 1048576))
16145 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16146 error "dd to $DIR/$tfile failed"
16148 lfs ladvise -a willread $DIR/$tfile ||
16149 error "Ladvise failed with no range argument"
16151 lfs ladvise -a willread -s 0 $DIR/$tfile ||
16152 error "Ladvise failed with no -l or -e argument"
16154 lfs ladvise -a willread -e 1 $DIR/$tfile ||
16155 error "Ladvise failed with only -e argument"
16157 lfs ladvise -a willread -l 1 $DIR/$tfile ||
16158 error "Ladvise failed with only -l argument"
16160 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
16161 error "End offset should not be smaller than start offset"
16163 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
16164 error "End offset should not be equal to start offset"
16166 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
16167 error "Ladvise failed with overflowing -s argument"
16169 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
16170 error "Ladvise failed with overflowing -e argument"
16172 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
16173 error "Ladvise failed with overflowing -l argument"
16175 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
16176 error "Ladvise succeeded with conflicting -l and -e arguments"
16178 echo "Synchronous ladvise should wait"
16180 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
16181 do_nodes $(comma_list $(osts_nodes)) \
16182 $LCTL set_param fail_val=$delay fail_loc=0x237
16184 local start_ts=$SECONDS
16185 lfs ladvise -a willread $DIR/$tfile ||
16186 error "Ladvise failed with no range argument"
16187 local end_ts=$SECONDS
16188 local inteval_ts=$((end_ts - start_ts))
16190 if [ $inteval_ts -lt $(($delay - 1)) ]; then
16191 error "Synchronous advice didn't wait reply"
16194 echo "Asynchronous ladvise shouldn't wait"
16195 local start_ts=$SECONDS
16196 lfs ladvise -a willread -b $DIR/$tfile ||
16197 error "Ladvise failed with no range argument"
16198 local end_ts=$SECONDS
16199 local inteval_ts=$((end_ts - start_ts))
16201 if [ $inteval_ts -gt $(($delay / 2)) ]; then
16202 error "Asynchronous advice blocked"
16205 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
16206 ladvise_willread_performance
16208 run_test 255a "check 'lfs ladvise -a willread'"
16214 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
16218 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
16219 skip "lustre < 2.8.54 does not support ladvise "
16220 remote_ost_nodsh && skip "remote OST with nodsh"
16222 lfs setstripe -c 1 -i 0 $DIR/$tfile
16224 ladvise_no_type dontneed $DIR/$tfile &&
16225 skip "dontneed ladvise is not supported"
16227 ladvise_no_ioctl $DIR/$tfile &&
16228 skip "ladvise ioctl is not supported"
16230 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16231 [ "$(facet_fstype ost1)" = "zfs" ] &&
16232 skip "zfs-osd does not support 'ladvise dontneed'"
16235 local size=$((size_mb * 1048576))
16236 # In order to prevent disturbance of other processes, only check 3/4
16237 # of the memory usage
16238 local kibibytes=$((size_mb * 1024 * 3 / 4))
16240 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16241 error "dd to $DIR/$tfile failed"
16243 local total=$(facet_meminfo ost1 MemTotal)
16244 echo "Total memory: $total KiB"
16246 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
16247 local before_read=$(facet_meminfo ost1 Cached)
16248 echo "Cache used before read: $before_read KiB"
16250 lfs ladvise -a willread $DIR/$tfile ||
16251 error "Ladvise willread failed"
16252 local after_read=$(facet_meminfo ost1 Cached)
16253 echo "Cache used after read: $after_read KiB"
16255 lfs ladvise -a dontneed $DIR/$tfile ||
16256 error "Ladvise dontneed again failed"
16257 local no_read=$(facet_meminfo ost1 Cached)
16258 echo "Cache used after dontneed ladvise: $no_read KiB"
16260 if [ $total -lt $((before_read + kibibytes)) ]; then
16261 echo "Memory is too small, abort checking"
16265 if [ $((before_read + kibibytes)) -gt $after_read ]; then
16266 error "Ladvise willread should use more memory" \
16267 "than $kibibytes KiB"
16270 if [ $((no_read + kibibytes)) -gt $after_read ]; then
16271 error "Ladvise dontneed should release more memory" \
16272 "than $kibibytes KiB"
16275 run_test 255b "check 'lfs ladvise -a dontneed'"
16278 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
16279 skip "lustre < 2.10.53 does not support lockahead"
16287 test_mkdir -p $DIR/$tdir
16288 $SETSTRIPE -i 0 $DIR/$tdir
16290 #test 10 returns only success/failure
16292 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16294 if [ $rc -eq 255 ]; then
16295 error "Ladvise test${i} failed, ${rc}"
16298 #test 11 counts lock enqueue requests, all others count new locks
16300 count=$(do_facet ost1 \
16301 $LCTL get_param -n ost.OSS.ost.stats)
16302 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
16304 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16306 if [ $rc -eq 255 ]; then
16307 error "Ladvise test${i} failed, ${rc}"
16310 new_count=$(do_facet ost1 \
16311 $LCTL get_param -n ost.OSS.ost.stats)
16312 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
16313 awk '{ print $2 }')
16315 difference="$((new_count - count))"
16316 if [ $difference -ne $rc ]; then
16317 error "Ladvise test${i}, bad enqueue count, returned " \
16318 "${rc}, actual ${difference}"
16321 for i in $(seq 12 21); do
16322 # If we do not do this, we run the risk of having too many
16323 # locks and starting lock cancellation while we are checking
16325 cancel_lru_locks osc
16327 count=$($LCTL get_param -n \
16328 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
16330 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16332 if [ $rc -eq 255 ]; then
16333 error "Ladvise test ${i} failed, ${rc}"
16336 new_count=$($LCTL get_param -n \
16337 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
16338 difference="$((new_count - count))"
16340 # Test 15 output is divided by 100 to map down to valid return
16341 if [ $i -eq 15 ]; then
16345 if [ $difference -ne $rc ]; then
16346 error "Ladvise test ${i}, bad lock count, returned " \
16347 "${rc}, actual ${difference}"
16351 #test 22 returns only success/failure
16353 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16355 if [ $rc -eq 255 ]; then
16356 error "Ladvise test${i} failed, ${rc}"
16359 run_test 255c "suite of ladvise lockahead tests"
16362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16363 remote_mds_nodsh && skip "remote MDS with nodsh"
16364 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
16365 skip "ldiskfs only test"
16366 changelog_users $SINGLEMDS | grep "^cl" &&
16367 skip "active changelog user"
16373 mdt_dev=$(mdsdevname 1)
16376 changelog_register || error "changelog_register failed"
16379 mkdir -p $DIR/$tdir
16381 changelog_clear 0 || error "changelog_clear failed"
16384 touch $DIR/$tdir/{1..10}
16387 stop $SINGLEMDS || error "Fail to stop MDT"
16391 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
16393 #after mount new plainllog is used
16394 touch $DIR/$tdir/{11..19}
16395 local tmpfile=$(mktemp -u $tfile.XXXXXX)
16396 cat_sl=$(do_facet $SINGLEMDS "sync; \
16397 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16398 llog_reader $tmpfile | grep -c type=1064553b")
16399 do_facet $SINGLEMDS llog_reader $tmpfile
16401 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
16403 changelog_clear 0 || error "changelog_clear failed"
16405 cat_sl=$(do_facet $SINGLEMDS "sync; \
16406 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16407 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
16409 if (( cat_sl == 2 )); then
16410 error "Empty plain llog was not deleted from changelog catalog"
16411 elif (( cat_sl != 1 )); then
16412 error "Active plain llog shouldn't be deleted from catalog"
16415 run_test 256 "Check llog delete for empty and not full state"
16418 remote_mds_nodsh && skip "remote MDS with nodsh"
16419 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16420 skip "Need MDS version at least 2.8.55"
16422 test_mkdir $DIR/$tdir
16424 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
16425 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
16428 #define OBD_FAIL_MDS_XATTR_REP 0x161
16429 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
16430 local facet=mds$((mdtidx + 1))
16431 set_nodes_failloc $(facet_active_host $facet) 0x80000161
16432 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
16434 stop $facet || error "stop MDS failed"
16435 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
16436 error "start MDS fail"
16438 run_test 257 "xattr locks are not lost"
16440 # Verify we take the i_mutex when security requires it
16442 #define OBD_FAIL_IMUTEX_SEC 0x141c
16443 $LCTL set_param fail_loc=0x141c
16445 chmod u+s $DIR/$tfile
16446 chmod a+rwx $DIR/$tfile
16447 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16449 if [ $RC -ne 0 ]; then
16450 error "error, failed to take i_mutex, rc=$?"
16456 # Verify we do NOT take the i_mutex in the normal case
16458 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
16459 $LCTL set_param fail_loc=0x141d
16462 chmod a+rw $DIR/$tfile
16463 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16465 if [ $RC -ne 0 ]; then
16466 error "error, took i_mutex unnecessarily, rc=$?"
16471 run_test 258b "verify i_mutex security behavior"
16474 local file=$DIR/$tfile
16478 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
16479 skip "ldiskfs only test" && return
16481 stack_trap "rm -f $file" EXIT
16483 wait_delete_completed
16484 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16485 echo "before: $before"
16487 $LFS setstripe -i 0 -c 1 $file
16488 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
16490 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16491 echo "after write: $after"
16493 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
16494 do_facet ost1 $LCTL set_param fail_loc=0x2301
16496 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16497 echo "after truncate: $after"
16500 do_facet ost1 $LCTL set_param fail_loc=0
16501 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16503 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16504 echo "after restart: $after"
16505 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
16506 error "missing truncate?"
16510 run_test 259 "crash at delayed truncate"
16513 #define OBD_FAIL_MDC_CLOSE 0x806
16514 $LCTL set_param fail_loc=0x80000806
16518 run_test 260 "Check mdc_close fail"
16520 ### Data-on-MDT sanity tests ###
16522 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16523 skip "Need MDS version at least 2.10.55"
16526 local dom=$DIR/$tdir/dom_file
16527 local tmp=$DIR/$tdir/tmp_file
16529 mkdir -p $DIR/$tdir
16531 # basic checks for DoM component creation
16532 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
16533 error "Can set MDT layout to non-first entry"
16535 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
16536 error "Can define multiple entries as MDT layout"
16538 $LFS setstripe -E 1M -L mdt $dom ||
16539 error "Can't create DoM layout"
16541 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
16542 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
16543 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
16545 local mdtidx=$($LFS getstripe -m $dom)
16546 local mdtname=MDT$(printf %04x $mdtidx)
16547 local facet=mds$((mdtidx + 1))
16548 local space_check=1
16550 # Skip free space checks with ZFS
16551 if [ "$(facet_fstype $facet)" == "zfs" ]; then
16557 local mdtfree1=$(do_facet $facet \
16558 lctl get_param -n osd*.*$mdtname.kbytesfree)
16559 dd if=/dev/urandom of=$tmp bs=1024 count=100
16560 # check also direct IO along write
16561 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
16563 cmp $tmp $dom || error "file data is different"
16564 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
16565 if [ $space_check == 1 ]; then
16566 local mdtfree2=$(do_facet $facet \
16567 lctl get_param -n osd*.*$mdtname.kbytesfree)
16568 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
16569 error "MDT free space is wrong after write"
16573 $TRUNCATE $dom 10000
16574 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
16575 if [ $space_check == 1 ]; then
16576 mdtfree1=$(do_facet $facet \
16577 lctl get_param -n osd*.*$mdtname.kbytesfree)
16578 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
16579 error "MDT free space is wrong after truncate"
16585 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
16586 if [ $space_check == 1 ]; then
16587 mdtfree2=$(do_facet $facet \
16588 lctl get_param -n osd*.*$mdtname.kbytesfree)
16589 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
16590 error "MDT free space is wrong after append"
16595 if [ $space_check == 1 ]; then
16596 mdtfree1=$(do_facet $facet \
16597 lctl get_param -n osd*.*$mdtname.kbytesfree)
16598 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
16599 error "MDT free space is wrong after removal"
16602 # combined striping
16603 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
16604 error "Can't create DoM + OST striping"
16606 dd if=/dev/urandom of=$tmp bs=1024 count=2000
16607 # check also direct IO along write
16608 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
16610 cmp $tmp $dom || error "file data is different"
16611 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
16617 run_test 270a "DoM: basic functionality tests"
16620 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16621 skip "Need MDS version at least 2.10.55"
16623 local dom=$DIR/$tdir/dom_file
16624 local max_size=1048576
16626 mkdir -p $DIR/$tdir
16627 $LFS setstripe -E $max_size -L mdt $dom
16629 # truncate over the limit
16630 $TRUNCATE $dom $(($max_size + 1)) &&
16631 error "successful truncate over the maximum size"
16632 # write over the limit
16633 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
16634 error "successful write over the maximum size"
16635 # append over the limit
16636 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
16637 echo "12345" >> $dom && error "successful append over the maximum size"
16642 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
16645 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16646 skip "Need MDS version at least 2.10.55"
16648 mkdir -p $DIR/$tdir
16649 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16651 # check files inherit DoM EA
16652 touch $DIR/$tdir/first
16653 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
16654 error "bad pattern"
16655 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
16656 error "bad stripe count"
16657 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
16658 error "bad stripe size"
16660 # check directory inherits DoM EA and uses it as default
16661 mkdir $DIR/$tdir/subdir
16662 touch $DIR/$tdir/subdir/second
16663 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
16664 error "bad pattern in sub-directory"
16665 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
16666 error "bad stripe count in sub-directory"
16667 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
16668 error "bad stripe size in sub-directory"
16671 run_test 270c "DoM: DoM EA inheritance tests"
16674 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16675 skip "Need MDS version at least 2.10.55"
16677 mkdir -p $DIR/$tdir
16678 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16680 # inherit default DoM striping
16681 mkdir $DIR/$tdir/subdir
16682 touch $DIR/$tdir/subdir/f1
16684 # change default directory striping
16685 $LFS setstripe -c 1 $DIR/$tdir/subdir
16686 touch $DIR/$tdir/subdir/f2
16687 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
16688 error "wrong default striping in file 2"
16689 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
16690 error "bad pattern in file 2"
16693 run_test 270d "DoM: change striping from DoM to RAID0"
16696 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16697 skip "Need MDS version at least 2.10.55"
16699 mkdir -p $DIR/$tdir/dom
16700 mkdir -p $DIR/$tdir/norm
16703 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
16704 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
16706 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
16707 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
16709 # find DoM files by layout
16710 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
16711 [ $NUM -eq $DOMFILES ] ||
16712 error "lfs find -L: found $NUM, expected $DOMFILES"
16713 echo "Test 1: lfs find 20 DOM files by layout: OK"
16715 # there should be 1 dir with default DOM striping
16716 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
16718 error "lfs find -L: found $NUM, expected 1 dir"
16719 echo "Test 2: lfs find 1 DOM dir by layout: OK"
16721 # find DoM files by stripe size
16722 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
16723 [ $NUM -eq $DOMFILES ] ||
16724 error "lfs find -S: found $NUM, expected $DOMFILES"
16725 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
16727 # find files by stripe offset except DoM files
16728 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
16729 [ $NUM -eq $NORMFILES ] ||
16730 error "lfs find -i: found $NUM, expected $NORMFILES"
16731 echo "Test 5: lfs find no DOM files by stripe index: OK"
16734 run_test 270e "DoM: lfs find with DoM files test"
16737 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16738 skip "Need MDS version at least 2.10.55"
16740 local mdtname=${FSNAME}-MDT0000-mdtlov
16741 local dom=$DIR/$tdir/dom_file
16742 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
16743 lod.$mdtname.dom_stripesize)
16744 local dom_limit=131072
16746 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
16747 local dom_current=$(do_facet mds1 $LCTL get_param -n \
16748 lod.$mdtname.dom_stripesize)
16749 [ ${dom_limit} -eq ${dom_current} ] ||
16750 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
16752 $LFS mkdir -i 0 -c 1 $DIR/$tdir
16753 $LFS setstripe -d $DIR/$tdir
16754 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
16755 error "Can't set directory default striping"
16757 # exceed maximum stripe size
16758 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16759 error "Can't create file with $((dom_limit * 2)) DoM stripe"
16760 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
16761 error "Able to create DoM component size more than LOD limit"
16763 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
16764 dom_current=$(do_facet mds1 $LCTL get_param -n \
16765 lod.$mdtname.dom_stripesize)
16766 [ 0 -eq ${dom_current} ] ||
16767 error "Can't set zero DoM stripe limit"
16770 # attempt to create DoM file on server with disabled DoM should
16771 # remove DoM entry from layout and be succeed
16772 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
16773 error "Can't create DoM file (DoM is disabled)"
16774 [ $($LFS getstripe -L $dom) == "mdt" ] &&
16775 error "File has DoM component while DoM is disabled"
16778 # attempt to create DoM file with only DoM stripe should return error
16779 $LFS setstripe -E $dom_limit -L mdt $dom &&
16780 error "Able to create DoM-only file while DoM is disabled"
16782 # too low values to be aligned with smallest stripe size 64K
16783 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
16784 dom_current=$(do_facet mds1 $LCTL get_param -n \
16785 lod.$mdtname.dom_stripesize)
16786 [ 30000 -eq ${dom_current} ] &&
16787 error "Can set too small DoM stripe limit"
16789 # 64K is a minimal stripe size in Lustre, expect limit of that size
16790 [ 65536 -eq ${dom_current} ] ||
16791 error "Limit is not set to 64K but ${dom_current}"
16793 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
16794 dom_current=$(do_facet mds1 $LCTL get_param -n \
16795 lod.$mdtname.dom_stripesize)
16797 [ 2147483648 -eq ${dom_current} ] &&
16798 error "Can set too large DoM stripe limit"
16800 do_facet mds1 $LCTL set_param -n \
16801 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
16802 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16803 error "Can't create DoM component size after limit change"
16804 do_facet mds1 $LCTL set_param -n \
16805 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
16806 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
16807 error "Can't create DoM file after limit decrease"
16808 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
16809 error "Can create big DoM component after limit decrease"
16810 touch ${dom}_def ||
16811 error "Can't create file with old default layout"
16813 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
16816 run_test 270f "DoM: maximum DoM stripe size checks"
16819 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16820 skip "Need MDS version at least 2.10.55"
16822 local dom=$DIR/$tdir/dom
16824 mkdir -p $DIR/$tdir
16826 $LFS setstripe -E 1024K -L mdt $dom
16828 lctl set_param -n mdc.*.stats=clear
16829 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16830 cat $dom > /dev/null
16831 local reads=$(lctl get_param -n mdc.*.stats |
16832 awk '/ost_read/ {print $2}')
16833 [ -z $reads ] || error "Unexpected $reads READ RPCs"
16837 run_test 271a "DoM: data is cached for read after write"
16840 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16841 skip "Need MDS version at least 2.10.55"
16843 local dom=$DIR/$tdir/dom
16845 mkdir -p $DIR/$tdir
16847 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16849 lctl set_param -n mdc.*.stats=clear
16850 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16851 cancel_lru_locks mdc
16852 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
16853 # second stat to check size is cached on client
16854 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
16855 local gls=$(lctl get_param -n mdc.*.stats |
16856 awk '/ldlm_glimpse/ {print $2}')
16857 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16860 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
16863 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16864 skip "Need MDS version at least 2.10.55"
16866 local dom=$DIR/$tdir/dom
16868 mkdir -p $DIR/$tdir
16870 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16872 lctl set_param -n mdc.*.stats=clear
16873 lctl set_param -n osc.*.stats=clear
16874 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
16875 cancel_lru_locks mdc
16876 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16877 # second stat to check size is cached on client
16878 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16879 local gls=$(lctl get_param -n mdc.*.stats |
16880 awk '/ldlm_glimpse/ {print $2}')
16881 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16882 local gls=$(lctl get_param -n osc.*.stats |
16883 awk '/ldlm_glimpse/ {print $2}')
16884 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
16887 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
16890 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16891 skip "Need MDS version at least 2.10.55"
16893 local dom=$DIR/$tdir/dom
16895 mkdir -p $DIR/$tdir
16897 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16899 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
16900 local facet=mds$((mdtidx + 1))
16902 cancel_lru_locks mdc
16903 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
16904 createmany -o $dom 1000
16905 lctl set_param -n mdc.*.stats=clear
16906 smalliomany -w $dom 1000 200
16907 lctl get_param -n mdc.*.stats
16908 local enq=$(lctl get_param -n mdc.*.stats |
16909 awk '/ldlm_ibits_enqueue/ {print $2}')
16910 # Each file has 1 open, 1 IO enqueues, total 2000
16911 # but now we have also +1 getxattr for security.capability, total 3000
16912 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
16913 unlinkmany $dom 1000
16915 cancel_lru_locks mdc
16916 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
16917 createmany -o $dom 1000
16918 lctl set_param -n mdc.*.stats=clear
16919 smalliomany -w $dom 1000 200
16920 lctl get_param -n mdc.*.stats
16921 local enq_2=$(lctl get_param -n mdc.*.stats |
16922 awk '/ldlm_ibits_enqueue/ {print $2}')
16923 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
16924 # for OPEN and IO lock.
16925 [ $((enq - enq_2)) -ge 1000 ] ||
16926 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
16927 unlinkmany $dom 1000
16930 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
16933 remote_ost_nodsh && skip "remote OST with nodsh"
16934 [ $(lustre_version_code ost1) -lt $(version_code 2.10.57) ] &&
16935 skip "Need OST version >= 2.10.57"
16937 local file=$DIR/$tfile
16940 oss=$(comma_list $(osts_nodes))
16942 dd if=/dev/urandom of=$file bs=1M count=2 ||
16943 error "failed to create a file"
16944 cancel_lru_locks osc
16947 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
16948 error "failed to read a file"
16950 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
16951 $LCTL set_param fail_loc=0x8000031f
16953 cancel_lru_locks osc &
16956 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
16957 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
16958 #IO takes another lock, but matches the PENDING one
16959 #and places it to the IO RPC
16960 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
16961 error "failed to read a file with PENDING lock"
16963 run_test 275 "Read on a canceled duplicate lock"
16966 remote_ost_nodsh && skip "remote OST with nodsh"
16969 do_facet ost1 "(while true; do \
16970 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
16971 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
16974 for LOOP in $(seq 20); do
16976 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
16979 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
16980 rm $TMP/sanity_276_pid"
16982 run_test 276 "Race between mount and obd_statfs"
16984 cleanup_test_300() {
16988 test_striped_dir() {
16993 mkdir -p $DIR/$tdir
16995 SAVE_UMASK=$(umask)
16996 trap cleanup_test_300 RETURN EXIT
16998 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
16999 $DIR/$tdir/striped_dir ||
17000 error "set striped dir error"
17002 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
17003 [ "$mode" = "755" ] || error "expect 755 got $mode"
17005 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
17006 error "getdirstripe failed"
17007 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
17008 if [ "$stripe_count" != "2" ]; then
17009 error "1:stripe_count is $stripe_count, expect 2"
17011 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
17012 if [ "$stripe_count" != "2" ]; then
17013 error "2:stripe_count is $stripe_count, expect 2"
17016 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
17017 if [ "$stripe_index" != "$mdt_index" ]; then
17018 error "stripe_index is $stripe_index, expect $mdt_index"
17021 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17022 error "nlink error after create striped dir"
17024 mkdir $DIR/$tdir/striped_dir/a
17025 mkdir $DIR/$tdir/striped_dir/b
17027 stat $DIR/$tdir/striped_dir/a ||
17028 error "create dir under striped dir failed"
17029 stat $DIR/$tdir/striped_dir/b ||
17030 error "create dir under striped dir failed"
17032 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
17033 error "nlink error after mkdir"
17035 rmdir $DIR/$tdir/striped_dir/a
17036 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
17037 error "nlink error after rmdir"
17039 rmdir $DIR/$tdir/striped_dir/b
17040 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17041 error "nlink error after rmdir"
17043 chattr +i $DIR/$tdir/striped_dir
17044 createmany -o $DIR/$tdir/striped_dir/f 10 &&
17045 error "immutable flags not working under striped dir!"
17046 chattr -i $DIR/$tdir/striped_dir
17048 rmdir $DIR/$tdir/striped_dir ||
17049 error "rmdir striped dir error"
17057 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17058 skip "skipped for lustre < 2.7.0"
17059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17060 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17062 test_striped_dir 0 || error "failed on striped dir on MDT0"
17063 test_striped_dir 1 || error "failed on striped dir on MDT0"
17065 run_test 300a "basic striped dir sanity test"
17068 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17069 skip "skipped for lustre < 2.7.0"
17070 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17071 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17078 test_mkdir $DIR/$tdir || error "mkdir fail"
17079 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17080 error "set striped dir error"
17081 for i in {0..9}; do
17082 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
17084 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
17085 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
17086 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
17088 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
17089 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
17090 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
17094 run_test 300b "check ctime/mtime for striped dir"
17097 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17098 skip "skipped for lustre < 2.7.0"
17099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17100 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17104 mkdir -p $DIR/$tdir
17105 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
17106 error "set striped dir error"
17108 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
17109 error "chown striped dir failed"
17111 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
17112 error "create 5k files failed"
17114 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
17116 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
17120 run_test 300c "chown && check ls under striped directory"
17123 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17124 skip "skipped for lustre < 2.7.0"
17125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17126 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17131 mkdir -p $DIR/$tdir
17132 $SETSTRIPE -c 2 $DIR/$tdir
17134 #local striped directory
17135 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17136 error "set striped dir error"
17137 createmany -o $DIR/$tdir/striped_dir/f 10 ||
17138 error "create 10 files failed"
17140 #remote striped directory
17141 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
17142 error "set striped dir error"
17143 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
17144 error "create 10 files failed"
17146 for file in $(find $DIR/$tdir); do
17147 stripe_count=$($LFS getstripe -c $file)
17148 [ $stripe_count -eq 2 ] ||
17149 error "wrong stripe $stripe_count for $file"
17154 run_test 300d "check default stripe under striped directory"
17157 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17158 skip "Need MDS version at least 2.7.55"
17159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17160 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17165 mkdir -p $DIR/$tdir
17167 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17168 error "set striped dir error"
17170 touch $DIR/$tdir/striped_dir/a
17171 touch $DIR/$tdir/striped_dir/b
17172 touch $DIR/$tdir/striped_dir/c
17174 mkdir $DIR/$tdir/striped_dir/dir_a
17175 mkdir $DIR/$tdir/striped_dir/dir_b
17176 mkdir $DIR/$tdir/striped_dir/dir_c
17178 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
17179 error "set striped adir under striped dir error"
17181 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
17182 error "set striped bdir under striped dir error"
17184 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
17185 error "set striped cdir under striped dir error"
17187 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
17188 error "rename dir under striped dir fails"
17190 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
17191 error "rename dir under different stripes fails"
17193 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
17194 error "rename file under striped dir should succeed"
17196 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
17197 error "rename dir under striped dir should succeed"
17201 run_test 300e "check rename under striped directory"
17204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17205 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17206 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17207 skip "Need MDS version at least 2.7.55"
17213 mkdir -p $DIR/$tdir
17215 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17216 error "set striped dir error"
17218 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
17219 error "set striped dir error"
17221 touch $DIR/$tdir/striped_dir/a
17222 mkdir $DIR/$tdir/striped_dir/dir_a
17223 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
17224 error "create striped dir under striped dir fails"
17226 touch $DIR/$tdir/striped_dir1/b
17227 mkdir $DIR/$tdir/striped_dir1/dir_b
17228 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
17229 error "create striped dir under striped dir fails"
17231 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
17232 error "rename dir under different striped dir should fail"
17234 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
17235 error "rename striped dir under diff striped dir should fail"
17237 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
17238 error "rename file under diff striped dirs fails"
17242 run_test 300f "check rename cross striped directory"
17244 test_300_check_default_striped_dir()
17247 local default_count=$2
17248 local default_index=$3
17251 local dir_stripe_index
17254 echo "checking $dirname $default_count $default_index"
17255 $LFS setdirstripe -D -c $default_count -i $default_index \
17256 -t all_char $DIR/$tdir/$dirname ||
17257 error "set default stripe on striped dir error"
17258 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
17259 [ $stripe_count -eq $default_count ] ||
17260 error "expect $default_count get $stripe_count for $dirname"
17262 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
17263 [ $stripe_index -eq $default_index ] ||
17264 error "expect $default_index get $stripe_index for $dirname"
17266 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
17267 error "create dirs failed"
17269 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
17270 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
17271 for dir in $(find $DIR/$tdir/$dirname/*); do
17272 stripe_count=$($LFS getdirstripe -c $dir)
17273 [ $stripe_count -eq $default_count ] ||
17274 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
17275 error "stripe count $default_count != $stripe_count for $dir"
17277 stripe_index=$($LFS getdirstripe -i $dir)
17278 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
17279 error "$stripe_index != $default_index for $dir"
17281 #check default stripe
17282 stripe_count=$($LFS getdirstripe -D -c $dir)
17283 [ $stripe_count -eq $default_count ] ||
17284 error "default count $default_count != $stripe_count for $dir"
17286 stripe_index=$($LFS getdirstripe -D -i $dir)
17287 [ $stripe_index -eq $default_index ] ||
17288 error "default index $default_index != $stripe_index for $dir"
17290 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
17294 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17295 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17296 skip "Need MDS version at least 2.7.55"
17303 mkdir $DIR/$tdir/normal_dir
17305 #Checking when client cache stripe index
17306 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
17307 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
17308 error "create striped_dir failed"
17310 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
17311 error "create dir0 fails"
17312 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
17313 [ $stripe_index -eq 0 ] ||
17314 error "dir0 expect index 0 got $stripe_index"
17316 mkdir $DIR/$tdir/striped_dir/dir1 ||
17317 error "create dir1 fails"
17318 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
17319 [ $stripe_index -eq 1 ] ||
17320 error "dir1 expect index 1 got $stripe_index"
17322 #check default stripe count/stripe index
17323 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
17324 test_300_check_default_striped_dir normal_dir 1 0
17325 test_300_check_default_striped_dir normal_dir 2 1
17326 test_300_check_default_striped_dir normal_dir 2 -1
17328 #delete default stripe information
17329 echo "delete default stripeEA"
17330 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
17331 error "set default stripe on striped dir error"
17333 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
17334 for dir in $(find $DIR/$tdir/normal_dir/*); do
17335 stripe_count=$($LFS getdirstripe -c $dir)
17336 [ $stripe_count -eq 0 ] ||
17337 error "expect 1 get $stripe_count for $dir"
17338 stripe_index=$($LFS getdirstripe -i $dir)
17339 [ $stripe_index -eq 0 ] ||
17340 error "expect 0 get $stripe_index for $dir"
17343 run_test 300g "check default striped directory for normal directory"
17346 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17347 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17348 skip "Need MDS version at least 2.7.55"
17354 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17355 error "set striped dir error"
17357 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
17358 test_300_check_default_striped_dir striped_dir 1 0
17359 test_300_check_default_striped_dir striped_dir 2 1
17360 test_300_check_default_striped_dir striped_dir 2 -1
17362 #delete default stripe information
17363 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
17364 error "set default stripe on striped dir error"
17366 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
17367 for dir in $(find $DIR/$tdir/striped_dir/*); do
17368 stripe_count=$($LFS getdirstripe -c $dir)
17369 [ $stripe_count -eq 0 ] ||
17370 error "expect 1 get $stripe_count for $dir"
17373 run_test 300h "check default striped directory for striped directory"
17376 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17377 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17378 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17379 skip "Need MDS version at least 2.7.55"
17386 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17387 error "set striped dir error"
17389 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
17390 error "create files under striped dir failed"
17392 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
17393 error "set striped hashdir error"
17395 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
17396 error "create dir0 under hash dir failed"
17397 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
17398 error "create dir1 under hash dir failed"
17400 # unfortunately, we need to umount to clear dir layout cache for now
17401 # once we fully implement dir layout, we can drop this
17402 umount_client $MOUNT || error "umount failed"
17403 mount_client $MOUNT || error "mount failed"
17405 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
17406 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
17407 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
17409 #set the stripe to be unknown hash type
17410 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
17411 $LCTL set_param fail_loc=0x1901
17412 for ((i = 0; i < 10; i++)); do
17413 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
17414 error "stat f-$i failed"
17415 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
17418 touch $DIR/$tdir/striped_dir/f0 &&
17419 error "create under striped dir with unknown hash should fail"
17421 $LCTL set_param fail_loc=0
17423 umount_client $MOUNT || error "umount failed"
17424 mount_client $MOUNT || error "mount failed"
17428 run_test 300i "client handle unknown hash type striped directory"
17431 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17432 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17433 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17434 skip "Need MDS version at least 2.7.55"
17441 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
17442 $LCTL set_param fail_loc=0x1702
17443 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17444 error "set striped dir error"
17446 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
17447 error "create files under striped dir failed"
17449 $LCTL set_param fail_loc=0
17451 rm -rf $DIR/$tdir || error "unlink striped dir fails"
17455 run_test 300j "test large update record"
17458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17459 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17460 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17461 skip "Need MDS version at least 2.7.55"
17468 #define OBD_FAIL_LARGE_STRIPE 0x1703
17469 $LCTL set_param fail_loc=0x1703
17470 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
17471 error "set striped dir error"
17472 $LCTL set_param fail_loc=0
17474 $LFS getdirstripe $DIR/$tdir/striped_dir ||
17475 error "getstripeddir fails"
17476 rm -rf $DIR/$tdir/striped_dir ||
17477 error "unlink striped dir fails"
17481 run_test 300k "test large striped directory"
17484 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17485 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17486 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17487 skip "Need MDS version at least 2.7.55"
17491 test_mkdir -p $DIR/$tdir/striped_dir
17492 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
17493 error "chown $RUNAS_ID failed"
17494 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
17495 error "set default striped dir failed"
17497 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
17498 $LCTL set_param fail_loc=0x80000158
17499 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
17501 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
17502 [ $stripe_index -eq 1 ] ||
17503 error "expect 1 get $stripe_index for $dir"
17505 run_test 300l "non-root user to create dir under striped dir with stale layout"
17508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17509 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
17510 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17511 skip "Need MDS version at least 2.7.55"
17513 mkdir -p $DIR/$tdir/striped_dir
17514 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
17515 error "set default stripes dir error"
17517 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
17519 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
17520 [ $stripe_count -eq 0 ] ||
17521 error "expect 0 get $stripe_count for a"
17523 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
17524 error "set default stripes dir error"
17526 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
17528 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
17529 [ $stripe_count -eq 0 ] ||
17530 error "expect 0 get $stripe_count for b"
17532 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
17533 error "set default stripes dir error"
17535 mkdir $DIR/$tdir/striped_dir/c &&
17536 error "default stripe_index is invalid, mkdir c should fails"
17538 rm -rf $DIR/$tdir || error "rmdir fails"
17540 run_test 300m "setstriped directory on single MDT FS"
17543 local list=$(comma_list $(mdts_nodes))
17546 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
17550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17551 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17552 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17553 skip "Need MDS version at least 2.7.55"
17554 remote_mds_nodsh && skip "remote MDS with nodsh"
17557 local list=$(comma_list $(mdts_nodes))
17559 trap cleanup_300n RETURN EXIT
17560 mkdir -p $DIR/$tdir
17561 chmod 777 $DIR/$tdir
17562 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
17563 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
17564 error "create striped dir succeeds with gid=0"
17566 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
17567 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
17568 error "create striped dir fails with gid=-1"
17570 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
17571 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
17572 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
17573 error "set default striped dir succeeds with gid=0"
17576 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
17577 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
17578 error "set default striped dir fails with gid=-1"
17581 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
17582 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
17583 error "create test_dir fails"
17584 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
17585 error "create test_dir1 fails"
17586 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
17587 error "create test_dir2 fails"
17590 run_test 300n "non-root user to create dir under striped dir with default EA"
17593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17594 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17595 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17596 skip "Need MDS version at least 2.7.55"
17601 mkdir -p $DIR/$tdir
17603 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
17604 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
17605 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
17606 skip "not enough free inodes $numfree1 $numfree2"
17609 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
17610 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
17611 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
17612 skip "not enough free space $numfree1 $numfree2"
17615 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
17616 error "setdirstripe fails"
17618 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
17619 error "create dirs fails"
17621 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
17622 ls $DIR/$tdir/striped_dir > /dev/null ||
17623 error "ls striped dir fails"
17624 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
17625 error "unlink big striped dir fails"
17627 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
17630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17631 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17632 remote_mds_nodsh && skip "remote MDS with nodsh"
17634 mkdir -p $DIR/$tdir
17636 #define OBD_FAIL_OUT_ENOSPC 0x1704
17637 do_facet mds2 lctl set_param fail_loc=0x80001704
17638 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
17639 && error "create striped directory should fail"
17641 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
17643 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
17646 run_test 300p "create striped directory without space"
17649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17650 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17652 local fd=$(free_fd)
17653 local cmd="exec $fd<$tdir"
17655 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
17658 trap "eval $cmd" EXIT
17659 cd $tdir || error "cd $tdir fails"
17660 rmdir ../$tdir || error "rmdir $tdir fails"
17661 mkdir local_dir && error "create dir succeeds"
17662 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
17666 run_test 300q "create remote directory under orphan directory"
17668 prepare_remote_file() {
17669 mkdir $DIR/$tdir/src_dir ||
17670 error "create remote source failed"
17672 cp /etc/hosts $DIR/$tdir/src_dir/a ||
17673 error "cp to remote source failed"
17674 touch $DIR/$tdir/src_dir/a
17676 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
17677 error "create remote target dir failed"
17679 touch $DIR/$tdir/tgt_dir/b
17681 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
17682 error "rename dir cross MDT failed!"
17684 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
17685 error "src_child still exists after rename"
17687 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
17688 error "missing file(a) after rename"
17690 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
17691 error "diff after rename"
17695 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
17696 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17698 local remote_file=$DIR/$tdir/tgt_dir/b
17700 mkdir -p $DIR/$tdir
17702 prepare_remote_file || error "prepare remote file failed"
17705 $OPENUNLINK $remote_file $remote_file ||
17706 error "openunlink $remote_file failed"
17707 $CHECKSTAT -a $remote_file || error "$remote_file exists"
17709 run_test 310a "open unlink remote file"
17712 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
17713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17715 local remote_file=$DIR/$tdir/tgt_dir/b
17717 mkdir -p $DIR/$tdir
17719 prepare_remote_file || error "prepare remote file failed"
17721 ln $remote_file $DIR/$tfile || error "link failed for remote file"
17722 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
17723 $CHECKSTAT -t file $remote_file || error "check file failed"
17725 run_test 310b "unlink remote file with multiple links while open"
17728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17729 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
17731 local remote_file=$DIR/$tdir/tgt_dir/b
17733 mkdir -p $DIR/$tdir
17735 prepare_remote_file || error "prepare remote file failed"
17737 ln $remote_file $DIR/$tfile || error "link failed for remote file"
17738 multiop_bg_pause $remote_file O_uc ||
17739 error "mulitop failed for remote file"
17741 $MULTIOP $DIR/$tfile Ouc
17742 kill -USR1 $MULTIPID
17745 run_test 310c "open-unlink remote file with multiple links"
17749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17750 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
17751 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
17752 skip "lustre < 2.8.54 does not contain LU-4825 fix"
17753 remote_mds_nodsh && skip "remote MDS with nodsh"
17755 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
17757 mkdir -p $DIR/$tdir
17758 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
17759 createmany -o $DIR/$tdir/$tfile. 1000
17761 # statfs data is not real time, let's just calculate it
17762 old_iused=$((old_iused + 1000))
17764 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
17765 osp.*OST0000*MDT0000.create_count")
17766 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
17767 osp.*OST0000*MDT0000.max_create_count")
17768 for idx in $(seq $MDSCOUNT); do
17769 do_facet mds$idx "lctl set_param -n \
17770 osp.*OST0000*MDT000?.max_create_count=0"
17773 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
17774 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
17775 [ $index -ne 0 ] || error "$tfile stripe index is 0"
17777 unlinkmany $DIR/$tdir/$tfile. 1000
17779 for idx in $(seq $MDSCOUNT); do
17780 do_facet mds$idx "lctl set_param -n \
17781 osp.*OST0000*MDT000?.max_create_count=$max_count"
17782 do_facet mds$idx "lctl set_param -n \
17783 osp.*OST0000*MDT000?.create_count=$count"
17787 for i in $(seq 120); do
17788 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
17789 # system may be too busy to destroy all objs in time, use
17790 # a somewhat small value to not fail autotest
17791 [ $((old_iused - new_iused)) -gt 400 ] && break
17795 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
17796 [ $((old_iused - new_iused)) -gt 400 ] ||
17797 error "objs not destroyed after unlink"
17799 run_test 311 "disable OSP precreate, and unlink should destroy objs"
17806 local vdevdir=$(dirname $(facet_vdevice $ost))
17807 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
17808 local zfs_zapid=$(do_facet $ost $cmd |
17809 grep -w "/O/0/d$((objid%32))" -C 5 |
17810 awk '/Object/{getline; print $1}')
17811 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
17812 awk "/$objid = /"'{printf $3}')
17817 zfs_object_blksz() {
17821 local vdevdir=$(dirname $(facet_vdevice $ost))
17822 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
17823 local blksz=$(do_facet $ost $cmd $objid |
17824 awk '/dblk/{getline; printf $4}')
17826 case "${blksz: -1}" in
17827 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
17828 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
17835 test_312() { # LU-4856
17836 remote_ost_nodsh && skip "remote OST with nodsh"
17837 [ $(facet_fstype ost1) = "zfs" ] ||
17838 skip_env "the test only applies to zfs"
17840 local max_blksz=$(do_facet ost1 \
17841 $ZFS get -p recordsize $(facet_device ost1) |
17842 awk '!/VALUE/{print $3}')
17843 local min_blksz=$(getconf PAGE_SIZE)
17845 # to make life a little bit easier
17846 $LFS mkdir -c 1 -i 0 $DIR/$tdir
17847 $LFS setstripe -c 1 -i 0 $DIR/$tdir
17849 local tf=$DIR/$tdir/$tfile
17851 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17853 # Get ZFS object id
17854 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17856 # block size change by sequential over write
17858 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
17859 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
17861 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17862 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
17866 # block size change by sequential append write
17867 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
17868 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17869 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17871 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
17872 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
17873 oflag=sync conv=notrunc
17875 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17876 [ $blksz -eq $((2 * count * min_blksz)) ] ||
17877 error "blksz error, actual $blksz, " \
17878 "expected: 2 * $count * $min_blksz"
17884 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17885 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17887 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
17888 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17889 [ $blksz -eq $min_blksz ] ||
17890 error "blksz error: $blksz, expected: $min_blksz"
17892 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
17893 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17894 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
17896 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
17897 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17898 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
17900 run_test 312 "make sure ZFS adjusts its block size by write pattern"
17903 remote_ost_nodsh && skip "remote OST with nodsh"
17905 local file=$DIR/$tfile
17907 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
17909 # define OBD_FAIL_TGT_RCVD_EIO 0x720
17910 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17911 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
17912 error "write should failed"
17913 do_facet ost1 "$LCTL set_param fail_loc=0"
17916 run_test 313 "io should fail after last_rcvd update fail"
17919 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
17921 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
17922 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17924 wait_delete_completed
17925 do_facet ost1 "$LCTL set_param fail_loc=0"
17927 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
17929 test_315() { # LU-618
17930 local file=$DIR/$tfile
17933 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
17934 $MULTIOP $file oO_RDONLY:r4096000_c &
17939 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
17942 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
17945 run_test 315 "read should be accounted"
17948 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17949 large_xattr_enabled || skip_env "large_xattr disabled"
17951 rm -rf $DIR/$tdir/d
17952 mkdir -p $DIR/$tdir/d
17953 chown nobody $DIR/$tdir/d
17954 touch $DIR/$tdir/d/file
17956 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
17958 run_test 316 "lfs mv"
17962 local grant_blk_size
17964 if [ "$(facet_fstype $facet)" == "zfs" ]; then
17965 skip "LU-10370: no implementation for ZFS" && return
17968 stack_trap "rm -f $DIR/$tfile" EXIT
17969 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
17970 awk '/grant_block_size:/ { print $2; exit; }')
17972 # Create File of size 5M. Truncate it to below size's and verify
17975 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
17976 error "Create file : $DIR/$tfile"
17978 for trunc_sz in 2097152 4097 4000 509 0; do
17979 $TRUNCATE $DIR/$tfile $trunc_sz ||
17980 error "truncate $tfile to $trunc_sz failed"
17981 local sz=$(stat --format=%s $DIR/$tfile)
17982 local blk=$(stat --format=%b $DIR/$tfile)
17983 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
17984 grant_blk_size) * 8))
17986 if [[ $blk -ne $trunc_blk ]]; then
17987 $(which stat) $DIR/$tfile
17988 error "Expected Block $trunc_blk got $blk for $tfile"
17991 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
17992 error "Expected Size $trunc_sz got $sz for $tfile"
17997 # Create file with a hole and write actual two blocks. Block count
18000 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
18001 conv=fsync || error "Create file : $DIR/$tfile"
18003 # Calculate the final truncate size.
18004 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
18007 # truncate to size $trunc_sz bytes. Strip the last block
18008 # The block count must drop to 8
18010 $TRUNCATE $DIR/$tfile $trunc_sz ||
18011 error "truncate $tfile to $trunc_sz failed"
18013 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
18014 sz=$(stat --format=%s $DIR/$tfile)
18015 blk=$(stat --format=%b $DIR/$tfile)
18017 if [[ $blk -ne $trunc_bsz ]]; then
18018 $(which stat) $DIR/$tfile
18019 error "Expected Block $trunc_bsz got $blk for $tfile"
18022 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18023 error "Expected Size $trunc_sz got $sz for $tfile"
18025 run_test 317 "Verify blocks get correctly update after truncate"
18028 local read_write=$1
18029 if [ "$read_write" = "write" ]; then
18030 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
18031 elif [ "$read_write" = "read" ]; then
18032 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
18034 error "argument error"
18037 # turn off debug for performance testing
18038 local saved_debug=$($LCTL get_param -n debug)
18039 $LCTL set_param debug=0
18041 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
18043 # get ost1 size - lustre-OST0000
18044 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
18045 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
18046 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
18048 if [ "$read_write" = "read" ]; then
18049 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
18052 local start_time=$(date +%s.%N)
18053 $dd_cmd bs=1M count=$blocks oflag=sync ||
18054 error "real dd $read_write error"
18055 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
18057 if [ "$read_write" = "write" ]; then
18061 # define OBD_FAIL_OST_FAKE_RW 0x238
18062 do_facet ost1 $LCTL set_param fail_loc=0x238
18064 local start_time=$(date +%s.%N)
18065 $dd_cmd bs=1M count=$blocks oflag=sync ||
18066 error "fake dd $read_write error"
18067 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
18069 if [ "$read_write" = "write" ]; then
18071 cancel_lru_locks osc
18072 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
18073 error "$tfile size not $blocks MB"
18075 do_facet ost1 $LCTL set_param fail_loc=0
18077 echo "fake $read_write $duration_fake vs. normal $read_write" \
18078 "$duration in seconds"
18079 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
18080 error_not_in_vm "fake write is slower"
18082 $LCTL set_param -n debug="$saved_debug"
18085 test_399a() { # LU-7655 for OST fake write
18086 remote_ost_nodsh && skip "remote OST with nodsh"
18090 run_test 399a "fake write should not be slower than normal write"
18092 test_399b() { # LU-8726 for OST fake read
18093 remote_ost_nodsh && skip "remote OST with nodsh"
18094 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
18095 skip_env "ldiskfs only test"
18100 run_test 399b "fake read should not be slower than normal read"
18102 test_400a() { # LU-1606, was conf-sanity test_74
18103 if ! which $CC > /dev/null 2>&1; then
18104 skip_env "$CC is not installed"
18107 local extra_flags=''
18108 local out=$TMP/$tfile
18109 local prefix=/usr/include/lustre
18112 if ! [[ -d $prefix ]]; then
18113 # Assume we're running in tree and fixup the include path.
18114 extra_flags+=" -I$LUSTRE/include"
18115 extra_flags+=" -L$LUSTRE/utils"
18118 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
18119 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
18120 error "client api broken"
18124 run_test 400a "Lustre client api program can compile and link"
18126 test_400b() { # LU-1606, LU-5011
18128 local out=$TMP/$tfile
18129 local prefix=/usr/include/linux/lustre
18131 # We use a hard coded prefix so that this test will not fail
18132 # when run in tree. There are headers in lustre/include/lustre/
18133 # that are not packaged (like lustre_idl.h) and have more
18134 # complicated include dependencies (like config.h and lnet/types.h).
18135 # Since this test about correct packaging we just skip them when
18136 # they don't exist (see below) rather than try to fixup cppflags.
18138 if ! which $CC > /dev/null 2>&1; then
18139 skip_env "$CC is not installed"
18142 for header in $prefix/*.h; do
18143 if ! [[ -f "$header" ]]; then
18147 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
18148 continue # lustre_ioctl.h is internal header
18151 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
18152 error "cannot compile '$header'"
18156 run_test 400b "packaged headers can be compiled"
18158 test_401a() { #LU-7437
18159 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
18160 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
18162 #count the number of parameters by "list_param -R"
18163 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
18164 #count the number of parameters by listing proc files
18165 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
18166 echo "proc_dirs='$proc_dirs'"
18167 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
18168 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
18171 [ $params -eq $procs ] ||
18172 error "found $params parameters vs. $procs proc files"
18174 # test the list_param -D option only returns directories
18175 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
18176 #count the number of parameters by listing proc directories
18177 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
18180 [ $params -eq $procs ] ||
18181 error "found $params parameters vs. $procs proc files"
18183 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
18186 local save=$($LCTL get_param -n jobid_var)
18189 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
18190 error "no error returned when setting bad parameters"
18192 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
18193 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
18195 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
18196 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
18197 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
18199 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
18202 local jobid_var_old=$($LCTL get_param -n jobid_var)
18203 local jobid_var_new
18205 $LCTL set_param jobid_var= &&
18206 error "no error returned for 'set_param a='"
18208 jobid_var_new=$($LCTL get_param -n jobid_var)
18209 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
18210 error "jobid_var was changed by setting without value"
18212 $LCTL set_param jobid_var &&
18213 error "no error returned for 'set_param a'"
18215 jobid_var_new=$($LCTL get_param -n jobid_var)
18216 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
18217 error "jobid_var was changed by setting without value"
18219 run_test 401c "Verify 'lctl set_param' without value fails in either format."
18222 local jobid_var_old=$($LCTL get_param -n jobid_var)
18223 local jobid_var_new
18224 local new_value="foo=bar"
18226 $LCTL set_param jobid_var=$new_value ||
18227 error "'set_param a=b' did not accept a value containing '='"
18229 jobid_var_new=$($LCTL get_param -n jobid_var)
18230 [[ "$jobid_var_new" == "$new_value" ]] ||
18231 error "'set_param a=b' failed on a value containing '='"
18233 # Reset the jobid_var to test the other format
18234 $LCTL set_param jobid_var=$jobid_var_old
18235 jobid_var_new=$($LCTL get_param -n jobid_var)
18236 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
18237 error "failed to reset jobid_var"
18239 $LCTL set_param jobid_var $new_value ||
18240 error "'set_param a b' did not accept a value containing '='"
18242 jobid_var_new=$($LCTL get_param -n jobid_var)
18243 [[ "$jobid_var_new" == "$new_value" ]] ||
18244 error "'set_param a b' failed on a value containing '='"
18246 $LCTL set_param jobid_var $jobid_var_old
18247 jobid_var_new=$($LCTL get_param -n jobid_var)
18248 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
18249 error "failed to reset jobid_var"
18251 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
18254 local server_version=$(lustre_version_code $SINGLEMDS)
18255 [[ $server_version -ge $(version_code 2.7.66) ]] ||
18256 [[ $server_version -ge $(version_code 2.7.18.4) &&
18257 $server_version -lt $(version_code 2.7.50) ]] ||
18258 [[ $server_version -ge $(version_code 2.7.2) &&
18259 $server_version -lt $(version_code 2.7.11) ]] ||
18260 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
18261 remote_mds_nodsh && skip "remote MDS with nodsh"
18263 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
18264 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
18265 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
18266 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
18267 echo "Touch failed - OK"
18269 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
18272 local file1=$DIR/$tfile.1
18273 local file2=$DIR/$tfile.2
18274 local tfile=$TMP/$tfile
18276 rm -f $file1 $file2 $tfile
18281 # 30 sec OBD_TIMEOUT in ll_getattr()
18282 # right before populating st_nlink
18283 $LCTL set_param fail_loc=0x80001409
18284 stat -c %h $file1 > $tfile &
18286 # create an alias, drop all locks and reclaim the dentry
18288 cancel_lru_locks mdc
18289 cancel_lru_locks osc
18290 sysctl -w vm.drop_caches=2
18294 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
18296 rm -f $tfile $file1 $file2
18298 run_test 403 "i_nlink should not drop to zero due to aliasing"
18300 test_404() { # LU-6601
18301 local server_version=$(lustre_version_code $SINGLEMDS)
18302 [[ $server_version -ge $(version_code 2.8.53) ]] ||
18303 skip "Need server version newer than 2.8.52"
18304 remote_mds_nodsh && skip "remote MDS with nodsh"
18306 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
18307 awk '/osp .*-osc-MDT/ { print $4}')
18310 for osp in $mosps; do
18311 echo "Deactivate: " $osp
18312 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
18313 local stat=$(do_facet $SINGLEMDS $LCTL dl |
18314 awk -vp=$osp '$4 == p { print $2 }')
18315 [ $stat = IN ] || {
18316 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
18317 error "deactivate error"
18319 echo "Activate: " $osp
18320 do_facet $SINGLEMDS $LCTL --device %$osp activate
18321 local stat=$(do_facet $SINGLEMDS $LCTL dl |
18322 awk -vp=$osp '$4 == p { print $2 }')
18323 [ $stat = UP ] || {
18324 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
18325 error "activate error"
18329 run_test 404 "validate manual {de}activated works properly for OSPs"
18332 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
18333 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
18334 skip "Layout swap lock is not supported"
18335 check_swap_layouts_support
18337 test_mkdir $DIR/$tdir
18338 swap_lock_test -d $DIR/$tdir ||
18339 error "One layout swap locked test failed"
18341 run_test 405 "Various layout swap lock tests"
18344 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18345 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
18346 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18348 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
18349 skip "Need MDS version at least 2.8.50"
18351 local def_stripe_size=$($LFS getstripe -S $MOUNT)
18352 local test_pool=$TESTNAME
18354 if ! combined_mgs_mds ; then
18357 pool_add $test_pool || error "pool_add failed"
18358 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
18359 error "pool_add_targets failed"
18361 save_layout_restore_at_exit $MOUNT
18363 # parent set default stripe count only, child will stripe from both
18364 # parent and fs default
18365 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
18366 error "setstripe $MOUNT failed"
18367 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
18368 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
18369 for i in $(seq 10); do
18370 local f=$DIR/$tdir/$tfile.$i
18371 touch $f || error "touch failed"
18372 local count=$($LFS getstripe -c $f)
18373 [ $count -eq $OSTCOUNT ] ||
18374 error "$f stripe count $count != $OSTCOUNT"
18375 local offset=$($LFS getstripe -i $f)
18376 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
18377 local size=$($LFS getstripe -S $f)
18378 [ $size -eq $((def_stripe_size * 2)) ] ||
18379 error "$f stripe size $size != $((def_stripe_size * 2))"
18380 local pool=$($LFS getstripe -p $f)
18381 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
18384 # change fs default striping, delete parent default striping, now child
18385 # will stripe from new fs default striping only
18386 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
18387 error "change $MOUNT default stripe failed"
18388 $LFS setstripe -c 0 $DIR/$tdir ||
18389 error "delete $tdir default stripe failed"
18390 for i in $(seq 11 20); do
18391 local f=$DIR/$tdir/$tfile.$i
18392 touch $f || error "touch $f failed"
18393 local count=$($LFS getstripe -c $f)
18394 [ $count -eq 1 ] || error "$f stripe count $count != 1"
18395 local offset=$($LFS getstripe -i $f)
18396 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
18397 local size=$($LFS getstripe -S $f)
18398 [ $size -eq $def_stripe_size ] ||
18399 error "$f stripe size $size != $def_stripe_size"
18400 local pool=$($LFS getstripe -p $f)
18401 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
18404 unlinkmany $DIR/$tdir/$tfile. 1 20
18406 local f=$DIR/$tdir/$tfile
18407 pool_remove_all_targets $test_pool $f
18408 pool_remove $test_pool $f
18410 if ! combined_mgs_mds ; then
18414 run_test 406 "DNE support fs default striping"
18417 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18418 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
18419 skip "Need MDS version at least 2.8.55"
18420 remote_mds_nodsh && skip "remote MDS with nodsh"
18422 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
18423 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
18424 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
18425 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
18426 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
18428 #define OBD_FAIL_DT_TXN_STOP 0x2019
18429 for idx in $(seq $MDSCOUNT); do
18430 do_facet mds$idx "lctl set_param fail_loc=0x2019"
18432 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
18433 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
18434 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
18437 run_test 407 "transaction fail should cause operation fail"
18440 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
18442 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
18443 lctl set_param fail_loc=0x8000040a
18444 # let ll_prepare_partial_page() fail
18445 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
18449 # create at least 100 unused inodes so that
18450 # shrink_icache_memory(0) should not return 0
18451 touch $DIR/$tfile-{0..100}
18452 rm -f $DIR/$tfile-{0..100}
18455 echo 2 > /proc/sys/vm/drop_caches
18457 run_test 408 "drop_caches should not hang due to page leaks"
18461 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18462 check_mount_and_prep
18464 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
18465 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
18466 touch $DIR/$tdir/guard || error "(2) Fail to create"
18468 local PREFIX=$(str_repeat 'A' 128)
18469 echo "Create 1K hard links start at $(date)"
18470 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
18471 error "(3) Fail to hard link"
18473 echo "Links count should be right although linkEA overflow"
18474 stat $DIR/$tdir/guard || error "(4) Fail to stat"
18475 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
18476 [ $linkcount -eq 1001 ] ||
18477 error "(5) Unexpected hard links count: $linkcount"
18479 echo "List all links start at $(date)"
18480 ls -l $DIR/$tdir/foo > /dev/null ||
18481 error "(6) Fail to list $DIR/$tdir/foo"
18483 echo "Unlink hard links start at $(date)"
18484 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
18485 error "(7) Fail to unlink"
18487 run_test 409 "Large amount of cross-MDTs hard links on the same file"
18491 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
18492 skip "Need client version at least 2.9.59"
18494 # Create a file, and stat it from the kernel
18495 local testfile=$DIR/$tfile
18498 local run_id=$RANDOM
18499 local my_ino=$(stat --format "%i" $testfile)
18501 # Try to insert the module. This will always fail as the
18502 # module is designed to not be inserted.
18503 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
18506 # Anything but success is a test failure
18508 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
18509 error "no inode match"
18511 run_test 410 "Test inode number returned from kernel thread"
18513 cleanup_test411_cgroup() {
18519 local cg_basedir=/sys/fs/cgroup/memory
18521 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
18522 skip "no setup for cgroup"
18524 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
18525 error "test file creation failed"
18526 cancel_lru_locks osc
18528 # Create a very small memory cgroup to force a slab allocation error
18529 local cgdir=$cg_basedir/osc_slab_alloc
18530 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
18531 trap "cleanup_test411_cgroup $cgdir" EXIT
18532 echo 2M > $cgdir/memory.kmem.limit_in_bytes
18533 echo 1M > $cgdir/memory.limit_in_bytes
18535 # Should not LBUG, just be killed by oom-killer
18536 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
18537 error "fail to trigger a memory allocation error"
18539 cleanup_test411_cgroup $cgdir
18543 run_test 411 "Slab allocation error with cgroup does not LBUG"
18546 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18547 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
18548 skip "Need server version at least 2.10.55"
18551 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
18552 error "mkdir failed"
18553 $LFS getdirstripe $DIR/$tdir
18554 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
18555 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
18556 error "expect $((MDSCOUT - 1)) get $stripe_index"
18557 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
18558 [ $stripe_count -eq 2 ] ||
18559 error "expect 2 get $stripe_count"
18561 run_test 412 "mkdir on specific MDTs"
18564 [ $MDSCOUNT -lt 2 ] &&
18565 skip "We need at least 2 MDTs for this test"
18567 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
18568 skip "Need server version at least 2.10.55"
18571 mkdir $DIR/$tdir || error "mkdir failed"
18573 # find MDT that is the most full
18574 local max=$($LFS df | grep MDT |
18583 END { split(b, c, ":")
18588 for i in $(seq $((MDSCOUNT - 1))); do
18589 $LFS mkdir -c $i $DIR/$tdir/d$i ||
18590 error "mkdir d$i failed"
18591 $LFS getdirstripe $DIR/$tdir/d$i
18592 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
18593 [ $stripe_index -ne $max ] ||
18594 error "don't expect $max"
18597 run_test 413 "mkdir on less full MDTs"
18600 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
18601 $LCTL set_param fail_loc=0x80000521
18602 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
18605 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
18608 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
18609 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
18610 skip "Need server version at least 2.9.55"
18612 start_full_debug_logging
18616 stop_full_debug_logging
18620 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
18621 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
18622 awk '/The barrier for/ { print $7 }')
18625 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
18630 barrier_expired() {
18633 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
18634 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
18635 awk '/will be expired/ { print $7 }')
18637 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
18646 echo "Start barrier_freeze at: $(date)"
18647 #define OBD_FAIL_BARRIER_DELAY 0x2202
18648 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
18649 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
18652 local b_status=$(barrier_stat)
18653 echo "Got barrier status at: $(date)"
18654 [ "$b_status" = "'freezing_p1'" ] ||
18655 error "(1) unexpected barrier status $b_status"
18657 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
18659 b_status=$(barrier_stat)
18660 [ "$b_status" = "'frozen'" ] ||
18661 error "(2) unexpected barrier status $b_status"
18663 local expired=$(barrier_expired)
18664 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
18665 sleep $((expired + 3))
18667 b_status=$(barrier_stat)
18668 [ "$b_status" = "'expired'" ] ||
18669 error "(3) unexpected barrier status $b_status"
18671 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
18672 error "(4) fail to freeze barrier"
18674 b_status=$(barrier_stat)
18675 [ "$b_status" = "'frozen'" ] ||
18676 error "(5) unexpected barrier status $b_status"
18678 echo "Start barrier_thaw at: $(date)"
18679 #define OBD_FAIL_BARRIER_DELAY 0x2202
18680 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
18681 do_facet mgs $LCTL barrier_thaw $FSNAME &
18684 b_status=$(barrier_stat)
18685 echo "Got barrier status at: $(date)"
18686 [ "$b_status" = "'thawing'" ] ||
18687 error "(6) unexpected barrier status $b_status"
18689 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
18691 b_status=$(barrier_stat)
18692 [ "$b_status" = "'thawed'" ] ||
18693 error "(7) unexpected barrier status $b_status"
18695 #define OBD_FAIL_BARRIER_FAILURE 0x2203
18696 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
18697 do_facet mgs $LCTL barrier_freeze $FSNAME
18699 b_status=$(barrier_stat)
18700 [ "$b_status" = "'failed'" ] ||
18701 error "(8) unexpected barrier status $b_status"
18703 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18704 do_facet mgs $LCTL barrier_thaw $FSNAME
18708 run_test 801a "write barrier user interfaces and stat machine"
18713 mkdir $DIR/$tdir || error "(1) fail to mkdir"
18714 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
18715 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
18716 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
18717 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
18719 cancel_lru_locks mdc
18721 # 180 seconds should be long enough
18722 do_facet mgs $LCTL barrier_freeze $FSNAME 180
18724 local b_status=$(barrier_stat)
18725 [ "$b_status" = "'frozen'" ] ||
18726 error "(6) unexpected barrier status $b_status"
18728 mkdir $DIR/$tdir/d0/d10 &
18731 touch $DIR/$tdir/d1/f13 &
18734 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
18737 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
18740 rm -f $DIR/$tdir/d4/f12 &
18743 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
18745 # To guarantee taht the 'stat' is not blocked
18746 b_status=$(barrier_stat)
18747 [ "$b_status" = "'frozen'" ] ||
18748 error "(8) unexpected barrier status $b_status"
18750 # let above commands to run at background
18753 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
18754 ps -p $touch_pid || error "(10) touch should be blocked"
18755 ps -p $ln_pid || error "(11) link should be blocked"
18756 ps -p $mv_pid || error "(12) rename should be blocked"
18757 ps -p $rm_pid || error "(13) unlink should be blocked"
18759 b_status=$(barrier_stat)
18760 [ "$b_status" = "'frozen'" ] ||
18761 error "(14) unexpected barrier status $b_status"
18763 do_facet mgs $LCTL barrier_thaw $FSNAME
18764 b_status=$(barrier_stat)
18765 [ "$b_status" = "'thawed'" ] ||
18766 error "(15) unexpected barrier status $b_status"
18768 wait $mkdir_pid || error "(16) mkdir should succeed"
18769 wait $touch_pid || error "(17) touch should succeed"
18770 wait $ln_pid || error "(18) link should succeed"
18771 wait $mv_pid || error "(19) rename should succeed"
18772 wait $rm_pid || error "(20) unlink should succeed"
18776 run_test 801b "modification will be blocked by write barrier"
18779 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18783 stop mds2 || error "(1) Fail to stop mds2"
18785 do_facet mgs $LCTL barrier_freeze $FSNAME 30
18787 local b_status=$(barrier_stat)
18788 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
18789 do_facet mgs $LCTL barrier_thaw $FSNAME
18790 error "(2) unexpected barrier status $b_status"
18793 do_facet mgs $LCTL barrier_rescan $FSNAME ||
18794 error "(3) Fail to rescan barrier bitmap"
18796 do_facet mgs $LCTL barrier_freeze $FSNAME 10
18798 b_status=$(barrier_stat)
18799 [ "$b_status" = "'frozen'" ] ||
18800 error "(4) unexpected barrier status $b_status"
18802 do_facet mgs $LCTL barrier_thaw $FSNAME
18803 b_status=$(barrier_stat)
18804 [ "$b_status" = "'thawed'" ] ||
18805 error "(5) unexpected barrier status $b_status"
18807 local devname=$(mdsdevname 2)
18809 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
18811 do_facet mgs $LCTL barrier_rescan $FSNAME ||
18812 error "(7) Fail to rescan barrier bitmap"
18816 run_test 801c "rescan barrier bitmap"
18818 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
18819 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
18820 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
18826 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
18827 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
18828 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
18834 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
18835 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
18836 skip "Need server version at least 2.9.55"
18838 mkdir $DIR/$tdir || error "(1) fail to mkdir"
18840 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
18841 error "(2) Fail to copy"
18843 trap cleanup_802 EXIT
18845 # sync by force before remount as readonly
18846 sync; sync_all_data; sleep 3; sync_all_data
18850 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
18851 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
18852 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
18854 echo "Mount the server as read only"
18855 setupall server_only || error "(3) Fail to start servers"
18857 echo "Mount client without ro should fail"
18858 mount_client $MOUNT &&
18859 error "(4) Mount client without 'ro' should fail"
18861 echo "Mount client with ro should succeed"
18862 mount_client $MOUNT ro ||
18863 error "(5) Mount client with 'ro' should succeed"
18865 echo "Modify should be refused"
18866 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
18868 echo "Read should be allowed"
18869 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
18870 error "(7) Read should succeed under ro mode"
18874 run_test 802 "simulate readonly device"
18877 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18878 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18879 skip "MDS needs to be newer than 2.10.54"
18881 mkdir -p $DIR/$tdir
18882 # Create some objects on all MDTs to trigger related logs objects
18883 for idx in $(seq $MDSCOUNT); do
18884 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
18885 $DIR/$tdir/dir${idx} ||
18886 error "Fail to create $DIR/$tdir/dir${idx}"
18890 echo "before create:"
18892 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18894 for ((i=0; i<10; i++)); do
18895 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
18896 error "Fail to create $DIR/$tdir/foo$i"
18900 echo "after create:"
18902 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18904 [ $after_used -ge $((before_used + 10)) ] ||
18905 error "before ($before_used) + 10 > after ($after_used)"
18907 for ((i=0; i<10; i++)); do
18908 rm -rf $DIR/$tdir/foo$i ||
18909 error "Fail to remove $DIR/$tdir/foo$i"
18912 sleep 3 # avoid MDT return cached statfs
18913 wait_delete_completed
18914 echo "after unlink:"
18916 before_used=$after_used
18917 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18919 [ $after_used -le $((before_used - 8)) ] ||
18920 error "before ($before_used) - 8 < after ($after_used)"
18922 run_test 803 "verify agent object for remote object"
18925 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18926 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18927 skip "MDS needs to be newer than 2.10.54"
18928 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
18929 skip_env "ldiskfs only test"
18931 mkdir -p $DIR/$tdir
18932 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
18933 error "Fail to create $DIR/$tdir/dir0"
18935 local fid=$($LFS path2fid $DIR/$tdir/dir0)
18936 local dev=$(mdsdevname 2)
18938 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18939 grep ${fid} || error "NOT found agent entry for dir0"
18941 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
18942 error "Fail to create $DIR/$tdir/dir1"
18944 touch $DIR/$tdir/dir1/foo0 ||
18945 error "Fail to create $DIR/$tdir/dir1/foo0"
18946 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
18949 for idx in $(seq $MDSCOUNT); do
18950 dev=$(mdsdevname $idx)
18951 do_facet mds${idx} \
18952 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18953 grep ${fid} && rc=$idx
18956 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
18957 error "Fail to rename foo0 to foo1"
18958 if [ $rc -eq 0 ]; then
18959 for idx in $(seq $MDSCOUNT); do
18960 dev=$(mdsdevname $idx)
18961 do_facet mds${idx} \
18962 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18963 grep ${fid} && rc=$idx
18967 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
18968 error "Fail to rename foo1 to foo2"
18969 if [ $rc -eq 0 ]; then
18970 for idx in $(seq $MDSCOUNT); do
18971 dev=$(mdsdevname $idx)
18972 do_facet mds${idx} \
18973 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18974 grep ${fid} && rc=$idx
18978 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
18980 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
18981 error "Fail to link to $DIR/$tdir/dir1/foo2"
18982 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
18983 error "Fail to rename foo2 to foo0"
18984 unlink $DIR/$tdir/dir1/foo0 ||
18985 error "Fail to unlink $DIR/$tdir/dir1/foo0"
18986 rm -rf $DIR/$tdir/dir0 ||
18987 error "Fail to rm $DIR/$tdir/dir0"
18989 for idx in $(seq $MDSCOUNT); do
18990 dev=$(mdsdevname $idx)
18994 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
18996 start mds${idx} $dev $MDS_MOUNT_OPTS ||
18997 error "mount mds$idx failed"
18998 df $MOUNT > /dev/null 2>&1
19000 # e2fsck should not return error
19002 error "e2fsck detected error on MDT${idx}: rc=$rc"
19005 run_test 804 "verify agent entry for remote entry"
19008 do_facet $SINGLEMDS zfs set quota=$old $fsset
19009 unlinkmany $DIR/$tdir/f- 1000000
19014 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
19015 [ "$(facet_fstype mds1)" != "zfs" ] &&
19016 skip "ZFS specific test"
19017 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
19018 skip "netfree not implemented before 0.7"
19019 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
19020 skip "Need MDS version at least 2.10.57"
19027 local pref="osd-zfs.lustre-MDT0000."
19029 # limit available space on MDS dataset to meet nospace issue
19030 # quickly. then ZFS 0.7.2 can use reserved space if asked
19031 # properly (using netfree flag in osd_declare_destroy()
19032 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
19033 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
19035 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
19036 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
19037 let "usedkb=usedkb-freekb"
19038 let "freekb=freekb/2"
19039 if let "freekb > 5000"; then
19042 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
19043 trap cleanup_805 EXIT
19045 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
19046 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
19047 rm -rf $DIR/$tdir || error "not able to remove"
19048 do_facet $SINGLEMDS zfs set quota=$old $fsset
19051 run_test 805 "ZFS can remove from full fs"
19054 # tests that do cleanup/setup should be run at the end
19058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19061 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
19062 $LCTL set_param fail_loc=0x903
19064 cancel_lru_locks MGC
19066 FAIL_ON_ERROR=true cleanup
19067 FAIL_ON_ERROR=true setup
19069 run_test 900 "umount should not race with any mgc requeue thread"
19072 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
19073 check_and_cleanup_lustre
19074 if [ "$I_MOUNTED" != "yes" ]; then
19075 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true