2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 LU-10680 ..
16 ALWAYS_EXCEPT=" 407 253 312 160f 160g $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
21 SRCDIR=$(cd $(dirname $0); echo $PWD)
22 export PATH=$PATH:/sbin
28 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
29 CREATETEST=${CREATETEST:-createtest}
31 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
33 OPENFILE=${OPENFILE:-openfile}
34 OPENUNLINK=${OPENUNLINK:-openunlink}
35 export MULTIOP=${MULTIOP:-multiop}
36 READS=${READS:-"reads"}
37 MUNLINK=${MUNLINK:-munlink}
38 SOCKETSERVER=${SOCKETSERVER:-socketserver}
39 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
40 MEMHOG=${MEMHOG:-memhog}
41 DIRECTIO=${DIRECTIO:-directio}
42 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
57 . $LUSTRE/tests/test-framework.sh
59 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
63 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
65 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
66 # bug number for skipped test: LU-1957
67 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
69 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
72 # Get the SLES version so we can make decisions on if a test should be run
74 # Returns a version string that should only be used in comparing
75 # strings returned by version_code()
79 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
81 # All SuSE Linux versions have one decimal. version_code expects two
82 local sles_version=$version.0
83 version_code $sles_version
86 if [ -r /etc/SuSE-release ]; then
87 sles_version=$(sles_version_code)
88 [ $sles_version -lt $(version_code 11.4.0) ] &&
89 # bug number for skipped test: LU-4341
90 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
91 [ $sles_version -lt $(version_code 12.0.0) ] &&
92 # bug number for skipped test: LU-3703
93 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
100 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
101 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
110 check_swap_layouts_support()
112 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
113 { skip "Does not support layout lock."; return 0; }
117 check_and_setup_lustre
121 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
123 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
124 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
125 rm -rf $DIR/[Rdfs][0-9]*
127 # $RUNAS_ID may get set incorrectly somewhere else
128 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
130 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
134 if [ "${ONLY}" = "MOUNT" ] ; then
135 echo "Lustre is up, please go on"
139 echo "preparing for tests involving mounts"
140 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
142 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
143 echo # add a newline after mke2fs.
147 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
148 lctl set_param debug=-1 2> /dev/null || true
151 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
153 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
155 run_test 0a "touch; rm ====================="
158 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
159 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
161 run_test 0b "chmod 0755 $DIR ============================="
164 $LCTL get_param mdc.*.import | grep "state: FULL" ||
165 error "import not FULL"
166 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
169 run_test 0c "check import proc"
171 test_0d() { # LU-3397
172 [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
173 skip "proc exports not supported before 2.10.57" && return
175 local mgs_exp="mgs.MGS.exports"
176 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
178 local exp_client_version
181 local temp_imp=$DIR/$tfile.import
182 local temp_exp=$DIR/$tfile.export
184 # save mgc import file to $temp_imp
185 $LCTL get_param mgc.*.import | tee $temp_imp
186 # Check if client uuid is found in MGS export
187 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
188 [ $(do_facet mgs $LCTL get_param $exp_client_nid.uuid) == \
192 # save mgs export file to $temp_exp
193 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
195 # Compare the value of field "connect_flags"
196 imp_val=$(grep "connect_flags" $temp_imp)
197 exp_val=$(grep "connect_flags" $temp_exp)
198 [ "$exp_val" == "$imp_val" ] ||
199 error "export flags '$exp_val' != import flags '$imp_val'"
201 # Compare the value of client version
202 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
203 exp_val=$(version_code $exp_client_version)
204 imp_val=$(lustre_version_code client)
205 [ "$exp_val" == "$imp_val" ] ||
206 error "export client version '$exp_val' != '$imp_val'"
208 run_test 0d "check export proc ============================="
211 test_mkdir $DIR/$tdir
212 test_mkdir $DIR/$tdir/d2
213 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
214 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
217 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
219 run_test 1 "mkdir; remkdir; rmdir"
222 test_mkdir $DIR/$tdir
223 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
224 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
226 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
228 run_test 2 "mkdir; touch; rmdir; check file"
231 test_mkdir $DIR/$tdir
232 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
233 touch $DIR/$tdir/$tfile
234 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
236 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
238 run_test 3 "mkdir; touch; rmdir; check dir"
240 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
242 test_mkdir -i 1 $DIR/$tdir
244 touch $DIR/$tdir/$tfile ||
245 error "Create file under remote directory failed"
248 error "Expect error removing in-use dir $DIR/$tdir"
250 test -d $DIR/$tdir || error "Remote directory disappeared"
252 rm -rf $DIR/$tdir || error "remove remote dir error"
254 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
257 test_mkdir $DIR/$tdir
258 test_mkdir $DIR/$tdir/d2
259 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
260 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
261 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
263 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
266 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
267 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
268 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
269 error "$tfile does not have perm 0666 or UID $UID"
270 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
271 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
272 error "$tfile should be 0666 and owned by UID $UID"
274 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
279 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
280 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
281 error "$tfile should be owned by UID $RUNAS_ID"
282 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
283 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
284 error "$tfile should be owned by UID $RUNAS_ID"
286 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
289 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
291 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
292 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
293 error "$tfile should be owned by GID $UID"
294 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
295 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
296 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
298 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
301 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
302 test_mkdir $DIR/$tdir
303 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
304 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
305 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
306 test_mkdir $DIR/$tdir/d/subdir
307 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
308 error "$tdir/d/subdir should be GID $RUNAS_GID"
309 if [[ $MDSCOUNT -gt 1 ]]; then
310 # check remote dir sgid inherite
311 $LFS mkdir -i 0 $DIR/$tdir.local ||
312 error "mkdir $tdir.local failed"
313 chmod g+s $DIR/$tdir.local ||
314 error "chmod $tdir.local failed"
315 chgrp $RUNAS_GID $DIR/$tdir.local ||
316 error "chgrp $tdir.local failed"
317 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
318 error "mkdir $tdir.remote failed"
319 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
320 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
321 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
322 error "$tdir.remote should be mode 02755"
325 run_test 6g "verify new dir in sgid dir inherits group"
327 test_6h() { # bug 7331
328 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
329 touch $DIR/$tfile || error "touch failed"
330 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
331 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
332 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
333 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
334 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
336 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
339 test_mkdir $DIR/$tdir
340 $MCREATE $DIR/$tdir/$tfile
341 chmod 0666 $DIR/$tdir/$tfile
342 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
343 error "$tdir/$tfile should be mode 0666"
345 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
348 if [ ! -d $DIR/$tdir ]; then
349 test_mkdir $DIR/$tdir
351 $MCREATE $DIR/$tdir/$tfile
352 echo -n foo > $DIR/$tdir/$tfile
353 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
354 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
356 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
359 test_mkdir $DIR/$tdir
360 touch $DIR/$tdir/$tfile
361 chmod 0666 $DIR/$tdir/$tfile
362 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
363 error "$tfile mode not 0666"
365 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
368 test_mkdir $DIR/$tdir
369 test_mkdir $DIR/$tdir/d2
370 test_mkdir $DIR/$tdir/d2/d3
371 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
373 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
376 test_mkdir $DIR/$tdir
377 test_mkdir $DIR/$tdir/d2
378 touch $DIR/$tdir/d2/$tfile
379 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
380 error "$tdir/d2/$tfile not a file"
382 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
385 test_mkdir $DIR/$tdir
386 test_mkdir $DIR/$tdir/d2
387 chmod 0666 $DIR/$tdir/d2
388 chmod 0705 $DIR/$tdir/d2
389 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
390 error "$tdir/d2 mode not 0705"
392 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
395 test_mkdir $DIR/$tdir
396 touch $DIR/$tdir/$tfile
397 chmod 0666 $DIR/$tdir/$tfile
398 chmod 0654 $DIR/$tdir/$tfile
399 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
400 error "$tdir/d2 mode not 0654"
402 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
405 test_mkdir $DIR/$tdir
406 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
408 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
409 error "$tdir/$tfile size not 0 after truncate"
411 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
414 test_mkdir $DIR/$tdir
415 touch $DIR/$tdir/$tfile
417 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
419 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
422 test_mkdir $DIR/$tdir
423 touch $DIR/$tdir/$tfile
424 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
425 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
426 error "$tdir/${tfile_2} not a file after rename"
427 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
429 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
432 test_mkdir $DIR/$tdir
433 touch $DIR/$tdir/$tfile
434 rm -rf $DIR/$tdir/$tfile
435 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
437 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
440 test_mkdir $DIR/$tdir
441 touch $DIR/$tdir/$tfile
442 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
444 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
445 error "$tdir/l-exist not a symlink"
446 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
447 error "$tdir/l-exist not referencing a file"
448 rm -f $DIR/$tdir/l-exist
449 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
451 run_test 17a "symlinks: create, remove (real)"
454 test_mkdir $DIR/$tdir
455 ln -s no-such-file $DIR/$tdir/l-dangle
457 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
458 error "$tdir/l-dangle not referencing no-such-file"
459 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
460 error "$tdir/l-dangle not referencing non-existent file"
461 rm -f $DIR/$tdir/l-dangle
462 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
464 run_test 17b "symlinks: create, remove (dangling)"
466 test_17c() { # bug 3440 - don't save failed open RPC for replay
467 test_mkdir $DIR/$tdir
468 ln -s foo $DIR/$tdir/$tfile
469 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
471 run_test 17c "symlinks: open dangling (should return error)"
474 test_mkdir $DIR/$tdir
475 ln -s foo $DIR/$tdir/$tfile
476 touch $DIR/$tdir/$tfile || error "creating to new symlink"
478 run_test 17d "symlinks: create dangling"
481 test_mkdir $DIR/$tdir
482 local foo=$DIR/$tdir/$tfile
483 ln -s $foo $foo || error "create symlink failed"
484 ls -l $foo || error "ls -l failed"
485 ls $foo && error "ls not failed" || true
487 run_test 17e "symlinks: create recursive symlink (should return error)"
490 test_mkdir $DIR/$tdir
491 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
492 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
493 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
494 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
495 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
496 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
499 run_test 17f "symlinks: long and very long symlink name"
501 # str_repeat(S, N) generate a string that is string S repeated N times
506 while [ $((n -= 1)) -ge 0 ]; do
512 # Long symlinks and LU-2241
514 test_mkdir $DIR/$tdir
515 local TESTS="59 60 61 4094 4095"
517 # Fix for inode size boundary in 2.1.4
518 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
521 # Patch not applied to 2.2 or 2.3 branches
522 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
523 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
526 # skip long symlink name for rhel6.5.
527 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
528 grep -q '6.5' /etc/redhat-release &>/dev/null &&
529 TESTS="59 60 61 4062 4063"
532 local SYMNAME=$(str_repeat 'x' $i)
533 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
534 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
537 run_test 17g "symlinks: really long symlink name and inode boundaries"
539 test_17h() { #bug 17378
540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
543 test_mkdir $DIR/$tdir
544 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
545 $LFS setstripe -c -1 $DIR/$tdir
546 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
547 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
548 touch $DIR/$tdir/$tfile || true
550 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
552 test_17i() { #bug 20018
553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
555 test_mkdir -c1 $DIR/$tdir
556 local foo=$DIR/$tdir/$tfile
558 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
559 ln -s $foo $foo || error "create symlink failed"
560 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
561 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
562 ls -l $foo && error "error not detected"
565 run_test 17i "don't panic on short symlink (should return error)"
567 test_17k() { #bug 22301
568 [[ -z "$(which rsync 2>/dev/null)" ]] &&
569 skip "no rsync command" && return 0
570 rsync --help | grep -q xattr ||
571 skip_env "$(rsync --version | head -n1) does not support xattrs"
572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
573 test_mkdir $DIR/$tdir
574 test_mkdir $DIR/$tdir.new
575 touch $DIR/$tdir/$tfile
576 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
577 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
578 error "rsync failed with xattrs enabled"
580 run_test 17k "symlinks: rsync with xattrs enabled"
582 test_17l() { # LU-279
583 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
584 skip "no getfattr command" && return 0
585 test_mkdir $DIR/$tdir
586 touch $DIR/$tdir/$tfile
587 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
588 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
589 # -h to not follow symlinks. -m '' to list all the xattrs.
590 # grep to remove first line: '# file: $path'.
591 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
593 lgetxattr_size_check $path $xattr ||
594 error "lgetxattr_size_check $path $xattr failed"
598 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
602 local short_sym="0123456789"
603 local wdir=$DIR/$tdir
606 remote_mds_nodsh && skip "remote MDS with nodsh" && return
607 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
608 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
609 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
611 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
612 skip "ldiskfs only test" && return 0
614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
618 # create a long symlink file
619 for ((i = 0; i < 4; ++i)); do
620 long_sym=${long_sym}${long_sym}
623 echo "create 512 short and long symlink files under $wdir"
624 for ((i = 0; i < 256; ++i)); do
625 ln -sf ${long_sym}"a5a5" $wdir/long-$i
626 ln -sf ${short_sym}"a5a5" $wdir/short-$i
632 wait_delete_completed
634 echo "recreate the 512 symlink files with a shorter string"
635 for ((i = 0; i < 512; ++i)); do
636 # rewrite the symlink file with a shorter string
637 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
638 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
641 local mds_index=$(($($LFS getstripe -M $wdir) + 1))
642 local devname=$(mdsdevname $mds_index)
644 echo "stop and checking mds${mds_index}:"
645 # e2fsck should not return error
647 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
650 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
651 error "start mds${mds_index} failed"
652 df $MOUNT > /dev/null 2>&1
654 error "e2fsck detected error for short/long symlink: rc=$rc"
657 run_test 17m "run e2fsck against MDT which contains short/long symlink"
659 check_fs_consistency_17n() {
663 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
664 # so it only check MDT1/MDT2 instead of all of MDTs.
665 for mdt_index in 1 2; do
666 local devname=$(mdsdevname $mdt_index)
667 # e2fsck should not return error
669 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
672 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
673 error "mount mds$mdt_index failed"
674 df $MOUNT > /dev/null 2>&1
682 remote_mds_nodsh && skip "remote MDS with nodsh" && return
683 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
684 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
685 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
687 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
688 skip "ldiskfs only test" && return 0
690 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
694 test_mkdir $DIR/$tdir
695 for ((i=0; i<10; i++)); do
696 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
697 error "create remote dir error $i"
698 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
699 error "create files under remote dir failed $i"
702 check_fs_consistency_17n ||
703 error "e2fsck report error after create files under remote dir"
705 for ((i = 0; i < 10; i++)); do
706 rm -rf $DIR/$tdir/remote_dir_${i} ||
707 error "destroy remote dir error $i"
710 check_fs_consistency_17n ||
711 error "e2fsck report error after unlink files under remote dir"
713 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
714 skip "lustre < 2.4.50 does not support migrate mv " && return
716 for ((i = 0; i < 10; i++)); do
717 mkdir -p $DIR/$tdir/remote_dir_${i}
718 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
719 error "create files under remote dir failed $i"
720 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
721 error "migrate remote dir error $i"
723 check_fs_consistency_17n || error "e2fsck report error after migration"
725 for ((i = 0; i < 10; i++)); do
726 rm -rf $DIR/$tdir/remote_dir_${i} ||
727 error "destroy remote dir error $i"
730 check_fs_consistency_17n || error "e2fsck report error after unlink"
732 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
735 remote_mds_nodsh && skip "remote MDS with nodsh" && return
736 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
737 skip "Need MDS version at least 2.3.64" && return
739 local wdir=$DIR/${tdir}o
745 mdt_index=$($LFS getstripe -M $wdir/$tfile)
746 mdt_index=$((mdt_index + 1))
749 #fail mds will wait the failover finish then set
750 #following fail_loc to avoid interfer the recovery process.
753 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
754 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
755 ls -l $wdir/$tfile && rc=1
756 do_facet mds${mdt_index} lctl set_param fail_loc=0
757 [[ $rc -eq 0 ]] || error "stat file should fail"
759 run_test 17o "stat file with incompat LMA feature"
762 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
763 ls $DIR || error "Failed to ls $DIR: $?"
765 run_test 18 "touch .../f ; ls ... =============================="
771 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
773 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
776 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
778 run_test 19b "ls -l .../f19 (should return error) =============="
781 [ $RUNAS_ID -eq $UID ] &&
782 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
783 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
785 run_test 19c "$RUNAS touch .../f19 (should return error) =="
788 cat $DIR/f19 && error || true
790 run_test 19d "cat .../f19 (should return error) =============="
799 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
801 run_test 20 "touch .../f ; ls -l ..."
804 test_mkdir $DIR/$tdir
805 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
806 ln -s dangle $DIR/$tdir/link
807 echo foo >> $DIR/$tdir/link
808 cat $DIR/$tdir/dangle
809 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
810 $CHECKSTAT -f -t file $DIR/$tdir/link ||
811 error "$tdir/link not linked to a file"
813 run_test 21 "write to dangling link"
816 local wdir=$DIR/$tdir
818 chown $RUNAS_ID:$RUNAS_GID $wdir
819 (cd $wdir || error "cd $wdir failed";
820 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
822 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
823 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
824 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
825 error "checkstat -u failed"
827 run_test 22 "unpack tar archive as non-root user"
831 test_mkdir $DIR/$tdir
832 local file=$DIR/$tdir/$tfile
834 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
835 openfile -f O_CREAT:O_EXCL $file &&
836 error "$file recreate succeeded" || true
838 run_test 23a "O_CREAT|O_EXCL in subdir"
840 test_23b() { # bug 18988
841 test_mkdir $DIR/$tdir
842 local file=$DIR/$tdir/$tfile
845 echo foo > $file || error "write filed"
846 echo bar >> $file || error "append filed"
847 $CHECKSTAT -s 8 $file || error "wrong size"
850 run_test 23b "O_APPEND check"
852 # LU-9409, size with O_APPEND and tiny writes
854 local file=$DIR/$tfile
857 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
858 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
862 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
863 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
865 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
868 #racing tiny & normal writes
869 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
870 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
872 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
875 #racing tiny & normal writes 2, ugly numbers
876 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
877 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
879 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
882 run_test 23c "O_APPEND size checks for tiny writes"
886 echo '-- same directory rename'
887 test_mkdir $DIR/$tdir
888 touch $DIR/$tdir/$tfile.1
889 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
890 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
892 run_test 24a "rename file to non-existent target"
895 test_mkdir $DIR/$tdir
896 touch $DIR/$tdir/$tfile.{1,2}
897 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
898 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
899 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
901 run_test 24b "rename file to existing target"
904 test_mkdir $DIR/$tdir
905 test_mkdir $DIR/$tdir/d$testnum.1
906 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
907 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
908 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
910 run_test 24c "rename directory to non-existent target"
913 test_mkdir -c1 $DIR/$tdir
914 test_mkdir -c1 $DIR/$tdir/d$testnum.1
915 test_mkdir -c1 $DIR/$tdir/d$testnum.2
916 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
917 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
918 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
920 run_test 24d "rename directory to existing target"
923 echo '-- cross directory renames --'
927 mv $DIR/R5a/f $DIR/R5b/g
928 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
929 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
931 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
936 touch $DIR/R6a/f $DIR/R6b/g
937 mv $DIR/R6a/f $DIR/R6b/g
938 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
939 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
941 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
946 test_mkdir $DIR/R7a/d
947 mv $DIR/R7a/d $DIR/R7b/e
948 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
949 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
951 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
954 test_mkdir -c1 $DIR/R8a
955 test_mkdir -c1 $DIR/R8b
956 test_mkdir -c1 $DIR/R8a/d
957 test_mkdir -c1 $DIR/R8b/e
958 mrename $DIR/R8a/d $DIR/R8b/e
959 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
960 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
962 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
965 echo "-- rename error cases"
969 mrename $DIR/R9/f $DIR/R9/a
970 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
971 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
972 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
974 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
978 mrename $DIR/R10/f $DIR/R10/g
979 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
980 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
981 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
983 run_test 24j "source does not exist ============================"
987 test_mkdir $DIR/R11a/d
989 mv $DIR/R11a/f $DIR/R11a/d
990 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
991 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
993 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
995 # bug 2429 - rename foo foo foo creates invalid file
998 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1000 run_test 24l "Renaming a file to itself ========================"
1004 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1005 # on ext3 this does not remove either the source or target files
1006 # though the "expected" operation would be to remove the source
1007 $CHECKSTAT -t file ${f} || error "${f} missing"
1008 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1010 run_test 24m "Renaming a file to a hard link to itself ========="
1014 # this stats the old file after it was renamed, so it should fail
1016 $CHECKSTAT ${f} || error "${f} missing"
1018 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1019 $CHECKSTAT -a ${f} || error "${f} exists"
1021 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1024 test_mkdir $DIR/$tdir
1025 rename_many -s random -v -n 10 $DIR/$tdir
1027 run_test 24o "rename of files during htree split"
1030 test_mkdir $DIR/R12a
1031 test_mkdir $DIR/R12b
1032 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1033 mrename $DIR/R12a $DIR/R12b
1034 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1035 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1036 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1037 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1039 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1041 cleanup_multiop_pause() {
1043 kill -USR1 $MULTIPID
1047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1048 test_mkdir $DIR/R13a
1049 test_mkdir $DIR/R13b
1050 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1051 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1054 trap cleanup_multiop_pause EXIT
1055 mrename $DIR/R13a $DIR/R13b
1056 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1057 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1058 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1059 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1060 cleanup_multiop_pause
1061 wait $MULTIPID || error "multiop close failed"
1063 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1065 test_24r() { #bug 3789
1066 test_mkdir $DIR/R14a
1067 test_mkdir $DIR/R14a/b
1068 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1069 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1070 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1072 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1075 test_mkdir $DIR/R15a
1076 test_mkdir $DIR/R15a/b
1077 test_mkdir $DIR/R15a/b/c
1078 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1079 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1080 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1082 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1084 test_mkdir $DIR/R16a
1085 test_mkdir $DIR/R16a/b
1086 test_mkdir $DIR/R16a/b/c
1087 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1088 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1089 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1091 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1093 test_24u() { # bug12192
1094 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1095 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1097 run_test 24u "create stripe file"
1101 size=$(getconf PAGE_SIZE 2>/dev/null)
1102 echo -n ${size:-4096}
1105 simple_cleanup_common() {
1108 [ -z "$DIR" -o -z "$tdir" ] && return 0
1110 local start=$SECONDS
1113 wait_delete_completed
1114 echo "cleanup time $((SECONDS - start))"
1118 max_pages_per_rpc() {
1119 local mdtname="$(printf "MDT%04x" ${1:-0})"
1120 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1125 local nrfiles=${COUNT:-100000}
1126 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1127 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1129 local fname="$DIR/$tdir/$tfile"
1130 test_mkdir "$(dirname $fname)"
1131 # assume MDT0000 has the fewest inodes
1132 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1133 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1134 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1136 trap simple_cleanup_common EXIT
1138 createmany -m "$fname" $nrfiles
1140 cancel_lru_locks mdc
1141 lctl set_param mdc.*.stats clear
1143 # was previously test_24D: LU-6101
1144 # readdir() returns correct number of entries after cursor reload
1145 local num_ls=$(ls $DIR/$tdir | wc -l)
1146 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1147 local num_all=$(ls -a $DIR/$tdir | wc -l)
1148 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1149 $num_all -ne $((nrfiles + 2)) ]; then
1150 error "Expected $nrfiles files, got $num_ls " \
1151 "($num_uniq unique $num_all .&..)"
1153 # LU-5 large readdir
1154 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1155 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1156 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1157 # take into account of overhead in lu_dirpage header and end mark in
1158 # each page, plus one in rpc_num calculation.
1159 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1160 local page_entries=$((($(page_size) - 24) / dirent_size))
1161 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1162 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1163 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1164 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1165 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1166 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1167 error "large readdir doesn't take effect: " \
1168 "$mds_readpage should be about $rpc_max"
1170 simple_cleanup_common
1172 run_test 24v "list large directory (test hash collision, b=17560)"
1174 test_24w() { # bug21506
1176 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1177 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1178 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1179 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1180 [[ "$SZ1" -eq "$SZ2" ]] ||
1181 error "Error reading at the end of the file $tfile"
1183 run_test 24w "Reading a file larger than 4Gb"
1186 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1188 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1189 skip "Need MDS version at least 2.7.56" && return
1191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1193 local remote_dir=$DIR/$tdir/remote_dir
1195 test_mkdir $DIR/$tdir
1196 $LFS mkdir -i $MDTIDX $remote_dir ||
1197 error "create remote directory failed"
1199 test_mkdir $DIR/$tdir/src_dir
1200 touch $DIR/$tdir/src_file
1201 test_mkdir $remote_dir/tgt_dir
1202 touch $remote_dir/tgt_file
1204 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1205 error "rename dir cross MDT failed!"
1207 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1208 error "rename file cross MDT failed!"
1210 touch $DIR/$tdir/ln_file
1211 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1212 error "ln file cross MDT failed"
1214 rm -rf $DIR/$tdir || error "Can not delete directories"
1216 run_test 24x "cross MDT rename/link"
1219 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1221 local remote_dir=$DIR/$tdir/remote_dir
1224 test_mkdir $DIR/$tdir
1225 $LFS mkdir -i $mdtidx $remote_dir ||
1226 error "create remote directory failed"
1228 test_mkdir $remote_dir/src_dir
1229 touch $remote_dir/src_file
1230 test_mkdir $remote_dir/tgt_dir
1231 touch $remote_dir/tgt_file
1233 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1234 error "rename subdir in the same remote dir failed!"
1236 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1237 error "rename files in the same remote dir failed!"
1239 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1240 error "link files in the same remote dir failed!"
1242 rm -rf $DIR/$tdir || error "Can not delete directories"
1244 run_test 24y "rename/link on the same dir should succeed"
1246 test_24A() { # LU-3182
1250 test_mkdir $DIR/$tdir
1251 trap simple_cleanup_common EXIT
1252 createmany -m $DIR/$tdir/$tfile $NFILES
1253 local t=$(ls $DIR/$tdir | wc -l)
1254 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1255 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1256 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1257 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1260 simple_cleanup_common || error "Can not delete directories"
1262 run_test 24A "readdir() returns correct number of entries."
1264 test_24B() { # LU-4805
1265 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1268 test_mkdir $DIR/$tdir
1269 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1270 error "create striped dir failed"
1272 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1273 [ $count -eq 2 ] || error "Expected 2, got $count"
1275 touch $DIR/$tdir/striped_dir/a
1277 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1278 [ $count -eq 3 ] || error "Expected 3, got $count"
1280 touch $DIR/$tdir/striped_dir/.f
1282 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1283 [ $count -eq 4 ] || error "Expected 4, got $count"
1285 rm -rf $DIR/$tdir || error "Can not delete directories"
1287 run_test 24B "readdir for striped dir return correct number of entries"
1290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1296 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1297 error "create striped dir failed"
1299 cd $DIR/$tdir/d0/striped_dir
1301 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1302 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1303 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1305 [ "$d0_ino" = "$parent_ino" ] ||
1306 error ".. wrong, expect $d0_ino, get $parent_ino"
1308 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1309 error "mv striped dir failed"
1311 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1313 [ "$d1_ino" = "$parent_ino" ] ||
1314 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1316 run_test 24C "check .. in striped dir"
1319 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1323 mkdir $DIR/$tdir/src_dir
1324 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1325 error "create remote source failed"
1327 touch $DIR/$tdir/src_dir/src_child/a
1329 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1330 error "create remote target dir failed"
1332 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1333 error "create remote target child failed"
1335 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1336 error "rename dir cross MDT failed!"
1340 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1341 error "src_child still exists after rename"
1343 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1344 error "missing file(a) after rename"
1346 rm -rf $DIR/$tdir || error "Can not delete directories"
1348 run_test 24E "cross MDT rename/link"
1351 echo '== symlink sanity ============================================='
1355 touch $DIR/s25/foo ||
1356 error "File creation in symlinked directory failed"
1358 run_test 25a "create file in symlinked directory ==============="
1361 [ ! -d $DIR/d25 ] && test_25a
1362 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1364 run_test 25b "lookup file in symlinked directory ==============="
1368 test_mkdir $DIR/d26/d26-2
1369 ln -s d26/d26-2 $DIR/s26
1370 touch $DIR/s26/foo || error "File creation failed"
1372 run_test 26a "multiple component symlink ======================="
1375 test_mkdir -p $DIR/$tdir/d26-2
1376 ln -s $tdir/d26-2/foo $DIR/s26-2
1377 touch $DIR/s26-2 || error "File creation failed"
1379 run_test 26b "multiple component symlink at end of lookup ======"
1382 test_mkdir $DIR/d26.2
1383 touch $DIR/d26.2/foo
1384 ln -s d26.2 $DIR/s26.2-1
1385 ln -s s26.2-1 $DIR/s26.2-2
1386 ln -s s26.2-2 $DIR/s26.2-3
1387 chmod 0666 $DIR/s26.2-3/foo
1389 run_test 26c "chain of symlinks"
1391 # recursive symlinks (bug 439)
1393 ln -s d26-3/foo $DIR/d26-3
1395 run_test 26d "create multiple component recursive symlink"
1398 [ ! -h $DIR/d26-3 ] && test_26d
1401 run_test 26e "unlink multiple component recursive symlink"
1403 # recursive symlinks (bug 7022)
1405 test_mkdir $DIR/$tdir
1406 test_mkdir $DIR/$tdir/$tfile
1407 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1408 test_mkdir -p lndir/bar1
1409 test_mkdir $DIR/$tdir/$tfile/$tfile
1410 cd $tfile || error "cd $tfile failed"
1411 ln -s .. dotdot || error "ln dotdot failed"
1412 ln -s dotdot/lndir lndir || error "ln lndir failed"
1413 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1414 output=`ls $tfile/$tfile/lndir/bar1`
1415 [ "$output" = bar1 ] && error "unexpected output"
1416 rm -r $tfile || error "rm $tfile failed"
1417 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1419 run_test 26f "rm -r of a directory which has recursive symlink"
1422 test_mkdir $DIR/$tdir
1423 $LFS getstripe $DIR/$tdir
1424 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1425 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1426 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1428 run_test 27a "one stripe file"
1431 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1432 test_mkdir $DIR/$tdir
1433 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1434 $LFS getstripe -c $DIR/$tdir/$tfile
1435 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1436 error "two-stripe file doesn't have two stripes"
1438 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1440 run_test 27b "create and write to two stripe file"
1443 test_mkdir $DIR/$tdir
1444 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1445 error "setstripe failed"
1446 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1447 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1449 run_test 27d "create file with default settings"
1452 # LU-5839 adds check for existed layout before setting it
1453 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1454 skip "Need MDS version at least 2.7.56" && return
1455 test_mkdir $DIR/$tdir
1456 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1457 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1458 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1460 run_test 27e "setstripe existing file (should return error)"
1463 test_mkdir $DIR/$tdir
1464 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1465 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1466 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1467 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1468 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1469 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1471 run_test 27f "setstripe with bad stripe size (should return error)"
1474 test_mkdir $DIR/$tdir
1475 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1476 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1477 error "$DIR/$tdir/$tfile has object"
1479 run_test 27g "$LFS getstripe with no objects"
1482 test_mkdir $DIR/$tdir
1483 touch $DIR/$tdir/$tfile || error "touch failed"
1484 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1485 error "missing objects"
1487 run_test 27i "$LFS getstripe with some objects"
1490 test_mkdir $DIR/$tdir
1491 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1492 error "setstripe failed" || true
1494 run_test 27j "setstripe with bad stripe offset (should return error)"
1496 test_27k() { # bug 2844
1497 test_mkdir $DIR/$tdir
1498 local file=$DIR/$tdir/$tfile
1499 local ll_max_blksize=$((4 * 1024 * 1024))
1500 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1501 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1502 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1503 dd if=/dev/zero of=$file bs=4k count=1
1504 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1505 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1507 run_test 27k "limit i_blksize for broken user apps"
1510 mcreate $DIR/$tfile || error "creating file"
1511 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1512 error "setstripe should have failed" || true
1514 run_test 27l "check setstripe permissions (should return error)"
1517 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1519 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1521 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1522 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1525 trap simple_cleanup_common EXIT
1526 test_mkdir $DIR/$tdir
1527 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1528 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1529 error "dd should fill OST0"
1531 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1533 [ $i -gt 256 ] && break
1536 touch $DIR/$tdir/$tfile.$i
1537 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1538 awk '{print $1}'| grep -w "0") ] &&
1539 error "OST0 was full but new created file still use it"
1541 touch $DIR/$tdir/$tfile.$i
1542 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1543 awk '{print $1}'| grep -w "0") ] &&
1544 error "OST0 was full but new created file still use it"
1545 simple_cleanup_common
1547 run_test 27m "create file while OST0 was full"
1550 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1551 awk '{ print $1 * 2; exit; }')
1555 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1556 # if the OST isn't full anymore.
1558 local OSTIDX=${1:-""}
1560 local list=$(comma_list $(osts_nodes))
1561 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1563 do_nodes $list lctl set_param fail_loc=0
1564 sync # initiate all OST_DESTROYs from MDS to OST
1568 exhaust_precreations() {
1571 local FAILIDX=${3:-$OSTIDX}
1572 local ofacet=ost$((OSTIDX + 1))
1574 test_mkdir -p -c1 $DIR/$tdir
1575 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1576 local mfacet=mds$((mdtidx + 1))
1577 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1579 local OST=$(ostname_from_index $OSTIDX)
1582 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1583 local last_id=$(do_facet $mfacet lctl get_param -n \
1584 osc.$mdtosc_proc1.prealloc_last_id)
1585 local next_id=$(do_facet $mfacet lctl get_param -n \
1586 osc.$mdtosc_proc1.prealloc_next_id)
1588 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1589 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1591 test_mkdir -p $DIR/$tdir/${OST}
1592 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1593 #define OBD_FAIL_OST_ENOSPC 0x215
1594 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1595 echo "Creating to objid $last_id on ost $OST..."
1596 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1597 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1598 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1602 exhaust_all_precreations() {
1604 for (( i=0; i < OSTCOUNT; i++ )) ; do
1605 exhaust_precreations $i $1 -1
1610 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1612 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1613 remote_ost_nodsh && skip "remote OST with nodsh" && return
1616 rm -f $DIR/$tdir/$tfile
1617 exhaust_precreations 0 0x80000215
1618 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1619 touch $DIR/$tdir/$tfile || error "touch failed"
1620 $LFS getstripe $DIR/$tdir/$tfile
1623 run_test 27n "create file with some full OSTs"
1626 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1628 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1629 remote_ost_nodsh && skip "remote OST with nodsh" && return
1632 rm -f $DIR/$tdir/$tfile
1633 exhaust_all_precreations 0x215
1635 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1640 run_test 27o "create file with all full OSTs (should error)"
1643 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1645 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1646 remote_ost_nodsh && skip "remote OST with nodsh" && return
1649 rm -f $DIR/$tdir/$tfile
1650 test_mkdir $DIR/$tdir
1652 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1653 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1654 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1656 exhaust_precreations 0 0x80000215
1657 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1658 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1659 $LFS getstripe $DIR/$tdir/$tfile
1663 run_test 27p "append to a truncated file with some full OSTs"
1666 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1668 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1669 remote_ost_nodsh && skip "remote OST with nodsh" && return
1672 rm -f $DIR/$tdir/$tfile
1674 test_mkdir $DIR/$tdir
1675 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1676 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1677 error "truncate $DIR/$tdir/$tfile failed"
1678 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1680 exhaust_all_precreations 0x215
1682 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1683 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1687 run_test 27q "append to truncated file with all OSTs full (should error)"
1690 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1692 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1693 remote_ost_nodsh && skip "remote OST with nodsh" && return
1696 rm -f $DIR/$tdir/$tfile
1697 exhaust_precreations 0 0x80000215
1699 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1703 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1705 test_27s() { # bug 10725
1706 test_mkdir $DIR/$tdir
1707 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1708 local stripe_count=0
1709 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1710 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1711 error "stripe width >= 2^32 succeeded" || true
1714 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1716 test_27t() { # bug 10864
1721 $WLFS getstripe $tfile
1724 run_test 27t "check that utils parse path correctly"
1726 test_27u() { # bug 4900
1727 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1728 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1730 local list=$(comma_list $(mdts_nodes))
1732 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1733 do_nodes $list $LCTL set_param fail_loc=0x139
1734 test_mkdir -p $DIR/$tdir
1735 trap simple_cleanup_common EXIT
1736 createmany -o $DIR/$tdir/t- 1000
1737 do_nodes $list $LCTL set_param fail_loc=0
1739 TLOG=$TMP/$tfile.getstripe
1740 $LFS getstripe $DIR/$tdir > $TLOG
1741 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1742 unlinkmany $DIR/$tdir/t- 1000
1744 [[ $OBJS -gt 0 ]] &&
1745 error "$OBJS objects created on OST-0. See $TLOG" ||
1748 run_test 27u "skip object creation on OSC w/o objects"
1750 test_27v() { # bug 4900
1751 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1754 remote_ost_nodsh && skip "remote OST with nodsh" && return
1756 exhaust_all_precreations 0x215
1759 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1761 touch $DIR/$tdir/$tfile
1762 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1764 for (( i=1; i < OSTCOUNT; i++ )); do
1765 do_facet ost$i lctl set_param fail_loc=0x705
1767 local START=`date +%s`
1768 createmany -o $DIR/$tdir/$tfile 32
1770 local FINISH=`date +%s`
1771 local TIMEOUT=`lctl get_param -n timeout`
1772 local PROCESS=$((FINISH - START))
1773 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1774 error "$FINISH - $START >= $TIMEOUT / 2"
1775 sleep $((TIMEOUT / 2 - PROCESS))
1778 run_test 27v "skip object creation on slow OST"
1780 test_27w() { # bug 10997
1781 test_mkdir $DIR/$tdir
1782 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1783 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1784 error "stripe size $size != 65536" || true
1785 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1786 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1788 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1791 [[ $OSTCOUNT -lt 2 ]] &&
1792 skip_env "skipping multiple stripe count/offset test" && return
1794 test_mkdir $DIR/$tdir
1795 for i in $(seq 1 $OSTCOUNT); do
1797 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1798 error "setstripe -c $i -i $offset failed"
1799 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1800 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1801 [ $count -ne $i ] && error "stripe count $count != $i" || true
1802 [ $index -ne $offset ] &&
1803 error "stripe offset $index != $offset" || true
1806 run_test 27wa "check $LFS setstripe -c -i options"
1809 remote_ost_nodsh && skip "remote OST with nodsh" && return
1810 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1812 OFFSET=$(($OSTCOUNT - 1))
1814 local OST=$(ostname_from_index $OSTIDX)
1816 test_mkdir $DIR/$tdir
1817 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1818 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1820 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1821 for i in $(seq 0 $OFFSET); do
1822 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1823 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1824 error "OST0 was degraded but new created file still use it"
1826 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1828 run_test 27x "create files while OST0 is degraded"
1831 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1832 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1833 remote_ost_nodsh && skip "remote OST with nodsh" && return
1834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1836 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1837 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1838 osc.$mdtosc.prealloc_last_id)
1839 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1840 osc.$mdtosc.prealloc_next_id)
1841 local fcount=$((last_id - next_id))
1842 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1843 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1845 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1846 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1847 local OST_DEACTIVE_IDX=-1
1852 for OSC in $MDS_OSCS; do
1853 OST=$(osc_to_ost $OSC)
1854 OSTIDX=$(index_from_ostuuid $OST)
1855 if [ $OST_DEACTIVE_IDX == -1 ]; then
1856 OST_DEACTIVE_IDX=$OSTIDX
1858 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1859 echo $OSC "is Deactivated:"
1860 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1864 OSTIDX=$(index_from_ostuuid $OST)
1865 test_mkdir $DIR/$tdir
1866 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1868 for OSC in $MDS_OSCS; do
1869 OST=$(osc_to_ost $OSC)
1870 OSTIDX=$(index_from_ostuuid $OST)
1871 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1872 echo $OST "is degraded:"
1873 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1874 obdfilter.$OST.degraded=1
1879 createmany -o $DIR/$tdir/$tfile $fcount
1881 for OSC in $MDS_OSCS; do
1882 OST=$(osc_to_ost $OSC)
1883 OSTIDX=$(index_from_ostuuid $OST)
1884 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1885 echo $OST "is recovered from degraded:"
1886 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1887 obdfilter.$OST.degraded=0
1889 do_facet $SINGLEMDS lctl --device %$OSC activate
1893 # all osp devices get activated, hence -1 stripe count restored
1894 local stripe_count=0
1896 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1897 # devices get activated.
1899 $LFS setstripe -c -1 $DIR/$tfile
1900 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1902 [ $stripe_count -ne $OSTCOUNT ] &&
1903 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1906 run_test 27y "create files while OST0 is degraded and the rest inactive"
1912 lmm_count=$($GETSTRIPE -c $1)
1913 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1914 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1916 local old_ifs="$IFS"
1918 fid=($($LFS path2fid $1))
1921 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1922 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1924 # compare lmm_seq and lu_fid->f_seq
1925 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1926 # compare lmm_object_id and lu_fid->oid
1927 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1929 # check the trusted.fid attribute of the OST objects of the file
1930 local have_obdidx=false
1932 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1933 # skip lines up to and including "obdidx"
1934 [ -z "$obdidx" ] && break
1935 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1936 $have_obdidx || continue
1938 local ost=$((obdidx + 1))
1939 local dev=$(ostdevname $ost)
1942 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1944 seq=$(echo $seq | sed -e "s/^0x//g")
1945 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1946 oid_hex=$(echo $oid)
1948 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1950 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1954 # Don't unmount/remount the OSTs if we don't need to do that.
1955 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1956 # update too, until that use mount/ll_decode_filter_fid/mount.
1957 # Re-enable when debugfs will understand new filter_fid.
1959 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1960 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1961 $dev 2>/dev/null" | grep "parent=")
1963 if [ -z "$ff" ]; then
1965 mount_fstype ost$ost
1966 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1967 $(facet_mntpt ost$ost)/$obj_file)
1968 unmount_fstype ost$ost
1969 start ost$ost $dev $OST_MOUNT_OPTS
1973 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1975 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1977 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1978 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1980 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1981 # stripe_size=1048576 component_id=1 component_start=0 \
1982 # component_end=33554432
1983 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1984 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1985 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1987 if grep -q 'stripe=' <<<$ff; then
1988 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1990 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1991 # into f_ver in this case. See comment on ff_parent.
1992 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1995 # compare lmm_seq and filter_fid->ff_parent.f_seq
1996 [ $ff_pseq = $lmm_seq ] ||
1997 error "FF parent SEQ $ff_pseq != $lmm_seq"
1998 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1999 [ $ff_poid = $lmm_oid ] ||
2000 error "FF parent OID $ff_poid != $lmm_oid"
2001 (($ff_pstripe == $stripe_nr)) ||
2002 error "FF stripe $ff_pstripe != $stripe_nr"
2004 stripe_nr=$((stripe_nr + 1))
2005 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2007 if grep -q 'stripe_count=' <<<$ff; then
2008 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2009 -e 's/ .*//' <<<$ff)
2010 [ $lmm_count = $ff_scnt ] ||
2011 error "FF stripe count $lmm_count != $ff_scnt"
2017 remote_ost_nodsh && skip "remote OST with nodsh" && return
2018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2019 test_mkdir $DIR/$tdir
2021 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2022 { error "setstripe -c -1 failed"; return 1; }
2023 # We need to send a write to every object to get parent FID info set.
2024 # This _should_ also work for setattr, but does not currently.
2025 # touch $DIR/$tdir/$tfile-1 ||
2026 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2027 { error "dd $tfile-1 failed"; return 2; }
2028 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2029 { error "setstripe -c -1 failed"; return 3; }
2030 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2031 { error "dd $tfile-2 failed"; return 4; }
2033 # make sure write RPCs have been sent to OSTs
2036 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2037 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2039 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2041 test_27A() { # b=19102
2042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2044 save_layout_restore_at_exit $MOUNT
2046 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
2047 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2048 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2049 local default_size=$($GETSTRIPE -S $MOUNT)
2050 local default_offset=$($GETSTRIPE -i $MOUNT)
2051 local dsize=$(do_facet $SINGLEMDS \
2052 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2053 [ $default_size -eq $dsize ] ||
2054 error "stripe size $default_size != $dsize"
2055 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
2057 run_test 27A "check filesystem-wide default LOV EA values"
2059 test_27B() { # LU-2523
2060 test_mkdir $DIR/$tdir
2061 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2063 # open f1 with O_LOV_DELAY_CREATE
2065 # call setstripe ioctl on open file descriptor for f1
2067 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2071 # open f1 with O_LOV_DELAY_CREATE
2073 # call setstripe ioctl on open file descriptor for f1
2075 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2077 # Allow multiop to fail in imitation of NFS's busted semantics.
2080 run_test 27B "call setstripe on open unlinked file/rename victim"
2082 test_27C() { #LU-2871
2083 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2091 test_mkdir $DIR/$tdir
2093 for i in $(seq 0 $((OSTCOUNT - 1))); do
2094 # set stripe across all OSTs starting from OST$i
2095 $SETSTRIPE -i $i -c -1 $tfile$i
2096 # get striping information
2097 ost_idx=($($GETSTRIPE $tfile$i |
2098 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2102 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2103 error "${#ost_idx[@]} != $OSTCOUNT"
2105 for index in $(seq 0 $((OSTCOUNT - 1))); do
2107 for j in $(echo ${ost_idx[@]}); do
2108 if [ $index -eq $j ]; then
2114 error "Can not find $index in ${ost_idx[@]}"
2118 run_test 27C "check full striping across all OSTs"
2121 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2122 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2123 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2124 local POOL=${POOL:-testpool}
2126 local last_ost=$(($OSTCOUNT - 1))
2128 local ost_list=$(seq $first_ost $ost_step $last_ost)
2129 local ost_range="$first_ost $last_ost $ost_step"
2131 if ! combined_mgs_mds ; then
2135 test_mkdir $DIR/$tdir
2136 pool_add $POOL || error "pool_add failed"
2137 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2140 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2142 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2143 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2144 skip27D+=" -s 30,31"
2145 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2146 error "llapi_layout_test failed"
2148 destroy_test_pools || error "destroy test pools failed"
2150 if ! combined_mgs_mds ; then
2154 run_test 27D "validate llapi_layout API"
2156 # Verify that default_easize is increased from its initial value after
2157 # accessing a widely striped file.
2159 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2160 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2161 skip "client does not have LU-3338 fix" && return
2163 # 72 bytes is the minimum space required to store striping
2164 # information for a file striped across one OST:
2165 # (sizeof(struct lov_user_md_v3) +
2166 # sizeof(struct lov_user_ost_data_v1))
2168 $LCTL set_param -n llite.*.default_easize $min_easize ||
2169 error "lctl set_param failed"
2170 local easize=$($LCTL get_param -n llite.*.default_easize)
2172 [ $easize -eq $min_easize ] ||
2173 error "failed to set default_easize"
2175 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2176 error "setstripe failed"
2180 easize=$($LCTL get_param -n llite.*.default_easize)
2182 [ $easize -gt $min_easize ] ||
2183 error "default_easize not updated"
2185 run_test 27E "check that default extended attribute size properly increases"
2187 test_27F() { # LU-5346/LU-7975
2188 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2190 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2191 skip "Need MDS version at least 2.8.51" && return
2192 remote_ost_nodsh && skip "remote OST with nodsh" && return
2194 test_mkdir $DIR/$tdir
2196 $SETSTRIPE -c 2 $DIR/$tdir
2198 # stop all OSTs to reproduce situation for LU-7975 ticket
2199 for num in $(seq $OSTCOUNT); do
2203 # open/create f0 with O_LOV_DELAY_CREATE
2204 # truncate f0 to a non-0 size
2206 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2208 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2209 # open/write it again to force delayed layout creation
2210 cat /etc/hosts > $DIR/$tdir/f0 &
2214 for num in $(seq $OSTCOUNT); do
2215 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2216 error "ost$num failed to start"
2219 wait $catpid || error "cat failed"
2221 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2222 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2225 run_test 27F "Client resend delayed layout creation with non-zero size"
2227 # createtest also checks that device nodes are created and
2228 # then visible correctly (#2091)
2229 test_28() { # bug 2091
2231 $CREATETEST $DIR/d28/ct || error "createtest failed"
2233 run_test 28 "create/mknod/mkdir with bad file types ============"
2236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2237 sync; sleep 1; sync # flush out any dirty pages from previous tests
2244 declare -i LOCKCOUNTORIG=0
2245 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2246 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2248 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2250 declare -i LOCKUNUSEDCOUNTORIG=0
2251 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2252 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2259 declare -i LOCKCOUNTCURRENT=0
2260 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2261 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2264 declare -i LOCKUNUSEDCOUNTCURRENT=0
2265 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2266 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2269 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2270 $LCTL set_param -n ldlm.dump_namespaces ""
2271 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2272 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2273 log "dumped log to $TMP/test_29.dk (bug 5793)"
2276 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2277 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2278 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2279 log "dumped log to $TMP/test_29.dk (bug 5793)"
2283 run_test 29 "IT_GETATTR regression ============================"
2285 test_30a() { # was test_30
2286 cp $(which ls) $DIR || cp /bin/ls $DIR
2287 $DIR/ls / || error "Can't execute binary from lustre"
2290 run_test 30a "execute binary from Lustre (execve) =============="
2293 cp `which ls` $DIR || cp /bin/ls $DIR
2295 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2298 run_test 30b "execute binary from Lustre as non-root ==========="
2300 test_30c() { # b=22376
2301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2302 cp `which ls` $DIR || cp /bin/ls $DIR
2304 cancel_lru_locks mdc
2305 cancel_lru_locks osc
2306 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2309 run_test 30c "execute binary from Lustre without read perms ===="
2312 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2313 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2315 run_test 31a "open-unlink file =================================="
2318 touch $DIR/f31 || error "touch $DIR/f31 failed"
2319 ln $DIR/f31 $DIR/f31b || error "ln failed"
2320 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2321 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2323 run_test 31b "unlink file with multiple links while open ======="
2326 touch $DIR/f31 || error "touch $DIR/f31 failed"
2327 ln $DIR/f31 $DIR/f31c || error "ln failed"
2328 multiop_bg_pause $DIR/f31 O_uc ||
2329 error "multiop_bg_pause for $DIR/f31 failed"
2331 $MULTIOP $DIR/f31c Ouc
2332 kill -USR1 $MULTIPID
2335 run_test 31c "open-unlink file with multiple links ============="
2338 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2339 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2341 run_test 31d "remove of open directory ========================="
2343 test_31e() { # bug 2904
2344 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2346 run_test 31e "remove of open non-empty directory ==============="
2348 test_31f() { # bug 4554
2349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2351 test_mkdir $DIR/d31f
2352 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2353 cp /etc/hosts $DIR/d31f
2355 $GETSTRIPE $DIR/d31f/hosts
2356 multiop_bg_pause $DIR/d31f D_c || return 1
2359 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2360 test_mkdir $DIR/d31f
2361 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2362 cp /etc/hosts $DIR/d31f
2364 $GETSTRIPE $DIR/d31f/hosts
2365 multiop_bg_pause $DIR/d31f D_c || return 1
2368 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2369 wait $MULTIPID || error "first opendir $MULTIPID failed"
2373 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2374 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2377 run_test 31f "remove of open directory with open-unlink file ==="
2380 echo "-- cross directory link --"
2381 test_mkdir -c1 $DIR/${tdir}ga
2382 test_mkdir -c1 $DIR/${tdir}gb
2383 touch $DIR/${tdir}ga/f
2384 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2385 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2386 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2387 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2388 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2390 run_test 31g "cross directory link==============="
2393 echo "-- cross directory link --"
2394 test_mkdir -c1 $DIR/${tdir}
2395 test_mkdir -c1 $DIR/${tdir}/dir
2396 touch $DIR/${tdir}/f
2397 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2398 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2399 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2400 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2401 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2403 run_test 31h "cross directory link under child==============="
2406 echo "-- cross directory link --"
2407 test_mkdir -c1 $DIR/$tdir
2408 test_mkdir -c1 $DIR/$tdir/dir
2409 touch $DIR/$tdir/dir/f
2410 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2411 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2412 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2413 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2414 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2416 run_test 31i "cross directory link under parent==============="
2419 test_mkdir -c1 -p $DIR/$tdir
2420 test_mkdir -c1 -p $DIR/$tdir/dir1
2421 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2422 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2423 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2424 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2427 run_test 31j "link for directory==============="
2430 test_mkdir -c1 -p $DIR/$tdir
2432 touch $DIR/$tdir/exist
2433 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2434 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2435 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2436 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2437 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2438 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2439 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2442 run_test 31k "link to file: the same, non-existing, dir==============="
2448 touch $DIR/d31m2/exist
2449 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2450 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2451 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2452 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2453 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2454 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2457 run_test 31m "link to file: the same, non-existing, dir==============="
2460 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2461 nlink=$(stat --format=%h $DIR/$tfile)
2462 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2464 local cmd="exec $fd<$DIR/$tfile"
2467 trap "eval $cmd" EXIT
2468 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2469 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2470 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2471 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2472 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2475 run_test 31n "check link count of unlinked file"
2478 local TEMPNAME=$(mktemp $1_XXXXXX)
2479 mlink $TEMPNAME $1 2> /dev/null &&
2480 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2484 test_31o() { # LU-2901
2485 test_mkdir $DIR/$tdir
2486 for LOOP in $(seq 100); do
2487 rm -f $DIR/$tdir/$tfile*
2488 for THREAD in $(seq 8); do
2489 link_one $DIR/$tdir/$tfile.$LOOP &
2492 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2493 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2494 error "$LINKS duplicate links to $tfile.$LOOP" &&
2498 run_test 31o "duplicate hard links with same filename"
2501 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2503 test_mkdir $DIR/$tdir
2504 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2505 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2507 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2508 error "open unlink test1 failed"
2509 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2510 error "open unlink test2 failed"
2512 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2513 error "test1 still exists"
2514 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2515 error "test2 still exists"
2517 run_test 31p "remove of open striped directory"
2519 cleanup_test32_mount() {
2522 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2523 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2524 losetup -d $loopdev || true
2530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2531 echo "== more mountpoints and symlinks ================="
2532 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2533 trap cleanup_test32_mount EXIT
2534 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2535 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2536 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2537 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2538 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2539 cleanup_test32_mount
2541 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2545 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2546 trap cleanup_test32_mount EXIT
2547 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2548 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2549 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2550 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2551 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2552 cleanup_test32_mount
2554 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2558 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2559 trap cleanup_test32_mount EXIT
2560 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2561 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2562 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2563 test_mkdir -p $DIR/$tdir/d2/test_dir
2564 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2565 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2566 cleanup_test32_mount
2568 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2572 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2573 trap cleanup_test32_mount EXIT
2574 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2575 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2576 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2577 test_mkdir -p $DIR/$tdir/d2/test_dir
2578 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2579 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2580 cleanup_test32_mount
2582 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2586 test_mkdir -p $DIR/$tdir/tmp
2587 local tmp_dir=$DIR/$tdir/tmp
2588 ln -s $DIR/$tdir $tmp_dir/symlink11
2589 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2590 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2591 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2593 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2597 test_mkdir -p $DIR/$tdir/tmp
2598 local tmp_dir=$DIR/$tdir/tmp
2599 ln -s $DIR/$tdir $tmp_dir/symlink11
2600 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2601 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2602 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2604 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2607 local tmp_dir=$DIR/$tdir/tmp
2608 test_mkdir -p $tmp_dir
2609 test_mkdir $DIR/${tdir}2
2610 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2611 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2612 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2613 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2614 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2615 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2617 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2620 rm -fr $DIR/$tdir $DIR/${tdir}2
2621 tmp_dir=$DIR/$tdir/tmp
2622 test_mkdir -p $tmp_dir
2623 test_mkdir $DIR/${tdir}2
2624 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2625 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2626 ls $tmp_dir/symlink12 || error "listing symlink12"
2627 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2629 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2633 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2634 trap cleanup_test32_mount EXIT
2635 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2636 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2637 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2638 touch $DIR/$tdir/test_file
2639 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2640 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2641 cleanup_test32_mount
2643 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2647 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2648 trap cleanup_test32_mount EXIT
2649 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2650 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2651 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2652 touch $DIR/$tdir/test_file
2653 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2654 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2655 cleanup_test32_mount
2657 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2662 trap cleanup_test32_mount EXIT
2663 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2664 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2665 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2666 test_mkdir -p $DIR/$tdir/d2
2667 touch $DIR/$tdir/d2/test_file || error "touch failed"
2668 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2669 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2670 cleanup_test32_mount
2672 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2677 trap cleanup_test32_mount EXIT
2678 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2679 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2680 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2681 test_mkdir -p $DIR/$tdir/d2
2682 touch $DIR/$tdir/d2/test_file || error "touch failed"
2683 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2684 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2685 cleanup_test32_mount
2687 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2691 test_mkdir -p $DIR/d32m/tmp
2692 TMP_DIR=$DIR/d32m/tmp
2693 ln -s $DIR $TMP_DIR/symlink11
2694 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2695 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2696 error "symlink11 not a link"
2697 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2698 error "symlink01 not a link"
2700 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2704 test_mkdir -p $DIR/d32n/tmp
2705 TMP_DIR=$DIR/d32n/tmp
2706 ln -s $DIR $TMP_DIR/symlink11
2707 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2708 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2709 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2711 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2715 test_mkdir -p $DIR/d32o/tmp
2716 TMP_DIR=$DIR/d32o/tmp
2717 ln -s $DIR/$tfile $TMP_DIR/symlink12
2718 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2719 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2720 error "symlink12 not a link"
2721 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2722 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2723 error "$DIR/d32o/tmp/symlink12 not file type"
2724 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2725 error "$DIR/d32o/symlink02 not file type"
2727 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2737 test_mkdir -p $DIR/d32p/tmp
2739 TMP_DIR=$DIR/d32p/tmp
2741 ln -s $DIR/$tfile $TMP_DIR/symlink12
2743 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2745 cat $DIR/d32p/tmp/symlink12 ||
2746 error "Can't open $DIR/d32p/tmp/symlink12"
2748 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2751 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2755 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2756 trap cleanup_test32_mount EXIT
2757 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2758 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2759 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2760 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2761 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2762 cleanup_test32_mount
2764 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2768 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2769 trap cleanup_test32_mount EXIT
2770 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2771 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2772 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2773 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2774 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2775 cleanup_test32_mount
2777 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2782 chmod 444 $DIR/$tfile
2783 chown $RUNAS_ID $DIR/$tfile
2785 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2788 run_test 33aa "write file with mode 444 (should return error)"
2792 test_mkdir $DIR/$tdir
2793 chown $RUNAS_ID $DIR/$tdir
2794 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2795 error "$RUNAS create $tdir/$tfile failed"
2796 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2797 error "open RDWR" || true
2799 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2803 test_mkdir $DIR/$tdir
2804 chown $RUNAS_ID $DIR/$tdir
2805 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2807 run_test 33b "test open file with malformed flags (No panic)"
2810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2816 remote_ost_nodsh && skip "remote OST with nodsh" && return
2819 test_mkdir $DIR/$tdir
2820 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2823 for ostnum in $(seq $OSTCOUNT); do
2824 # test-framework's OST numbering is one-based, while Lustre's
2826 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2827 # Parsing llobdstat's output sucks; we could grep the /proc
2828 # path, but that's likely to not be as portable as using the
2829 # llobdstat utility. So we parse lctl output instead.
2830 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2831 obdfilter/$ostname/stats |
2832 awk '/^write_bytes/ {print $7}' )
2833 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2834 if (( ${write_bytes:-0} > 0 ))
2841 $all_zeros || return 0
2844 echo foo > $DIR/$tdir/bar
2848 # Total up write_bytes after writing. We'd better find non-zeros.
2849 for ostnum in $(seq $OSTCOUNT); do
2850 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2851 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2852 obdfilter/$ostname/stats |
2853 awk '/^write_bytes/ {print $7}' )
2854 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2855 if (( ${write_bytes:-0} > 0 ))
2864 for ostnum in $(seq $OSTCOUNT); do
2865 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2866 echo "Check that write_bytes is present in obdfilter/*/stats:"
2867 do_facet ost$ostnum lctl get_param -n \
2868 obdfilter/$ostname/stats
2870 error "OST not keeping write_bytes stats (b22312)"
2873 run_test 33c "test llobdstat and write_bytes"
2876 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2879 local remote_dir=$DIR/$tdir/remote_dir
2881 test_mkdir $DIR/$tdir
2882 $LFS mkdir -i $MDTIDX $remote_dir ||
2883 error "create remote directory failed"
2885 touch $remote_dir/$tfile
2886 chmod 444 $remote_dir/$tfile
2887 chown $RUNAS_ID $remote_dir/$tfile
2889 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2891 chown $RUNAS_ID $remote_dir
2892 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2893 error "create" || true
2894 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2895 error "open RDWR" || true
2896 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2898 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2901 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2905 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2906 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2907 mkdir $DIR/$tdir/local_dir
2909 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2910 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2911 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2913 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2914 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2916 rmdir $DIR/$tdir/* || error "rmdir failed"
2919 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2920 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2921 mkdir $DIR/$tdir/local_dir
2923 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2924 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2925 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2927 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2928 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2930 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2933 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2934 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2935 mkdir $DIR/$tdir/local_dir
2937 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2938 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2939 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2941 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2942 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2944 run_test 33e "mkdir and striped directory should have same mode"
2948 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2952 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2953 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2956 chmod go+rwx $DIR/$tdir
2957 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2958 trap cleanup_33f EXIT
2960 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2961 error "cannot create striped directory"
2963 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2964 error "cannot create files in striped directory"
2966 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2967 error "cannot remove files in striped directory"
2969 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2970 error "cannot remove striped directory"
2974 run_test 33f "nonroot user can create, access, and remove a striped directory"
2977 mkdir -p $DIR/$tdir/dir2
2979 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2981 [[ $err =~ "exists" ]] || error "Not exists error"
2983 run_test 33g "nonroot user create already existing root created file"
2985 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2988 $MCREATE $DIR/f34 || error "mcreate failed"
2989 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
2990 error "getstripe failed"
2991 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
2992 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
2993 error "getstripe failed"
2994 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
2995 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
2997 run_test 34a "truncate file that has not been opened ==========="
3000 [ ! -f $DIR/f34 ] && test_34a
3001 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3002 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3003 $OPENFILE -f O_RDONLY $DIR/f34
3004 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3005 error "getstripe failed"
3006 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3007 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3009 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3012 [ ! -f $DIR/f34 ] && test_34a
3013 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3014 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3015 $OPENFILE -f O_RDWR $DIR/f34
3016 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3017 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3018 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3020 run_test 34c "O_RDWR opening file-with-size works =============="
3023 [ ! -f $DIR/f34 ] && test_34a
3024 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3026 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3027 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3030 run_test 34d "write to sparse file ============================="
3034 $MCREATE $DIR/f34e || error "mcreate failed"
3035 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3036 $CHECKSTAT -s 1000 $DIR/f34e ||
3037 error "Size of $DIR/f34e not equal to 1000 bytes"
3038 $OPENFILE -f O_RDWR $DIR/f34e
3039 $CHECKSTAT -s 1000 $DIR/f34e ||
3040 error "Size of $DIR/f34e not equal to 1000 bytes"
3042 run_test 34e "create objects, some with size and some without =="
3044 test_34f() { # bug 6242, 6243
3045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3048 $MCREATE $DIR/f34f || error "mcreate failed"
3049 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3050 dd if=$DIR/f34f of=$TMP/f34f
3051 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3052 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3053 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3054 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3055 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3057 run_test 34f "read from a file with no objects until EOF ======="
3060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3061 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3063 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3064 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3065 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3066 cancel_lru_locks osc
3067 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3068 error "wrong size after lock cancel"
3070 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3071 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3072 error "expanding truncate failed"
3073 cancel_lru_locks osc
3074 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3075 error "wrong expanded size after lock cancel"
3077 run_test 34g "truncate long file ==============================="
3080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3085 sync # Flush the cache so that multiop below does not block on cache
3086 # flush when getting the group lock
3087 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3090 # Since just timed wait is not good enough, let's do a sync write
3091 # that way we are sure enough time for a roundtrip + processing
3092 # passed + 2 seconds of extra margin.
3093 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3097 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3098 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3102 local nsz=`stat -c %s $DIR/$tfile`
3103 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3105 run_test 34h "ftruncate file under grouplock should not block"
3108 cp /bin/sh $DIR/f35a
3110 chown $RUNAS_ID $DIR/f35a
3111 $RUNAS $DIR/f35a && error || true
3114 run_test 35a "exec file with mode 444 (should return and not leak)"
3118 utime $DIR/f36 || error "utime failed for MDS"
3120 run_test 36a "MDS utime check (mknod, utime)"
3124 utime $DIR/f36 || error "utime failed for OST"
3126 run_test 36b "OST utime check (open, utime)"
3131 chown $RUNAS_ID $DIR/d36
3132 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3134 run_test 36c "non-root MDS utime check (mknod, utime)"
3137 [ ! -d $DIR/d36 ] && test_36c
3138 echo "" > $DIR/d36/f36
3139 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3141 run_test 36d "non-root OST utime check (open, utime)"
3144 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3145 test_mkdir $DIR/$tdir
3146 touch $DIR/$tdir/$tfile
3147 $RUNAS utime $DIR/$tdir/$tfile &&
3148 error "utime worked, expected failure" || true
3150 run_test 36e "utime on non-owned file (should return error)"
3154 local LANG_SAVE=$LANG
3155 local LC_LANG_SAVE=$LC_LANG
3156 export LANG=C LC_LANG=C # for date language
3158 DATESTR="Dec 20 2000"
3159 test_mkdir $DIR/$tdir
3160 lctl set_param fail_loc=$fl
3162 cp /etc/hosts $DIR/$tdir/$tfile
3163 sync & # write RPC generated with "current" inode timestamp, but delayed
3165 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3166 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3167 cancel_lru_locks osc
3168 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3170 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3171 echo "BEFORE: $LS_BEFORE" && \
3172 echo "AFTER : $LS_AFTER" && \
3173 echo "WANT : $DATESTR" && \
3174 error "$DIR/$tdir/$tfile timestamps changed" || true
3176 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3181 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3182 subr_36fh "0x80000214"
3184 run_test 36f "utime on file racing with OST BRW write =========="
3187 remote_ost_nodsh && skip "remote OST with nodsh" && return
3188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3193 test_mkdir $DIR/$tdir
3194 fmd_max_age=$(do_facet ost1 \
3195 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3198 fmd_before=$(do_facet ost1 \
3199 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3200 touch $DIR/$tdir/$tfile
3201 sleep $((fmd_max_age + 12))
3202 fmd_after=$(do_facet ost1 \
3203 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3205 echo "fmd_before: $fmd_before"
3206 echo "fmd_after: $fmd_after"
3207 [[ $fmd_after -gt $fmd_before ]] &&
3208 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3209 error "fmd didn't expire after ping" || true
3211 run_test 36g "filter mod data cache expiry ====================="
3214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3215 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3216 subr_36fh "0x80000227"
3218 run_test 36h "utime on file racing with OST BRW write =========="
3221 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3223 test_mkdir $DIR/$tdir
3224 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3226 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3227 local new_mtime=$((mtime + 200))
3229 #change Modify time of striped dir
3230 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3231 error "change mtime failed"
3233 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3235 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3237 run_test 36i "change mtime on striped directory"
3239 # test_37 - duplicate with tests 32q 32r
3242 local file=$DIR/$tfile
3244 openfile -f O_DIRECTORY $file
3247 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3248 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3250 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3252 test_39a() { # was test_39
3254 touch $DIR/${tfile}2
3255 # ls -l $DIR/$tfile $DIR/${tfile}2
3256 # ls -lu $DIR/$tfile $DIR/${tfile}2
3257 # ls -lc $DIR/$tfile $DIR/${tfile}2
3259 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3260 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3262 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3264 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3266 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3267 error "O_TRUNC didn't change timestamps"
3270 run_test 39a "mtime changed on create"
3273 test_mkdir -c1 $DIR/$tdir
3274 cp -p /etc/passwd $DIR/$tdir/fopen
3275 cp -p /etc/passwd $DIR/$tdir/flink
3276 cp -p /etc/passwd $DIR/$tdir/funlink
3277 cp -p /etc/passwd $DIR/$tdir/frename
3278 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3281 echo "aaaaaa" >> $DIR/$tdir/fopen
3282 echo "aaaaaa" >> $DIR/$tdir/flink
3283 echo "aaaaaa" >> $DIR/$tdir/funlink
3284 echo "aaaaaa" >> $DIR/$tdir/frename
3286 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3287 local link_new=`stat -c %Y $DIR/$tdir/flink`
3288 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3289 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3291 cat $DIR/$tdir/fopen > /dev/null
3292 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3293 rm -f $DIR/$tdir/funlink2
3294 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3296 for (( i=0; i < 2; i++ )) ; do
3297 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3298 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3299 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3300 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3302 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3303 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3304 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3305 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3307 cancel_lru_locks osc
3308 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3311 run_test 39b "mtime change on open, link, unlink, rename ======"
3313 # this should be set to past
3314 TEST_39_MTIME=`date -d "1 year ago" +%s`
3320 local mtime0=`stat -c %Y $DIR1/$tfile`
3322 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3323 local mtime1=`stat -c %Y $DIR1/$tfile`
3324 [ "$mtime1" = $TEST_39_MTIME ] || \
3325 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3328 echo hello >> $DIR1/$tfile
3330 local mtime2=`stat -c %Y $DIR1/$tfile`
3331 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3332 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3334 mv $DIR1/$tfile $DIR1/$tfile-1
3336 for (( i=0; i < 2; i++ )) ; do
3337 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3338 [ "$mtime2" = "$mtime3" ] || \
3339 error "mtime ($mtime2) changed (to $mtime3) on rename"
3341 cancel_lru_locks osc
3342 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3345 run_test 39c "mtime change on rename ==========================="
3349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3352 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3354 for (( i=0; i < 2; i++ )) ; do
3355 local mtime=`stat -c %Y $DIR1/$tfile`
3356 [ $mtime = $TEST_39_MTIME ] || \
3357 error "mtime($mtime) is not set to $TEST_39_MTIME"
3359 cancel_lru_locks osc
3360 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3363 run_test 39d "create, utime, stat =============================="
3367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3369 local mtime1=`stat -c %Y $DIR1/$tfile`
3371 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3373 for (( i=0; i < 2; i++ )) ; do
3374 local mtime2=`stat -c %Y $DIR1/$tfile`
3375 [ $mtime2 = $TEST_39_MTIME ] || \
3376 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3378 cancel_lru_locks osc
3379 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3382 run_test 39e "create, stat, utime, stat ========================"
3386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3388 mtime1=`stat -c %Y $DIR1/$tfile`
3391 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3393 for (( i=0; i < 2; i++ )) ; do
3394 local mtime2=`stat -c %Y $DIR1/$tfile`
3395 [ $mtime2 = $TEST_39_MTIME ] || \
3396 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3398 cancel_lru_locks osc
3399 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3402 run_test 39f "create, stat, sleep, utime, stat ================="
3406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3407 echo hello >> $DIR1/$tfile
3408 local mtime1=`stat -c %Y $DIR1/$tfile`
3411 chmod o+r $DIR1/$tfile
3413 for (( i=0; i < 2; i++ )) ; do
3414 local mtime2=`stat -c %Y $DIR1/$tfile`
3415 [ "$mtime1" = "$mtime2" ] || \
3416 error "lost mtime: $mtime2, should be $mtime1"
3418 cancel_lru_locks osc
3419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3422 run_test 39g "write, chmod, stat ==============================="
3426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3431 echo hello >> $DIR1/$tfile
3432 local mtime1=`stat -c %Y $DIR1/$tfile`
3434 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3436 if [ "$d1" != "$d2" ]; then
3437 echo "write and touch not within one second"
3439 for (( i=0; i < 2; i++ )) ; do
3440 local mtime2=`stat -c %Y $DIR1/$tfile`
3441 [ "$mtime2" = $TEST_39_MTIME ] || \
3442 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3444 cancel_lru_locks osc
3445 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3449 run_test 39h "write, utime within one second, stat ============="
3452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3456 echo hello >> $DIR1/$tfile
3457 local mtime1=`stat -c %Y $DIR1/$tfile`
3459 mv $DIR1/$tfile $DIR1/$tfile-1
3461 for (( i=0; i < 2; i++ )) ; do
3462 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3464 [ "$mtime1" = "$mtime2" ] || \
3465 error "lost mtime: $mtime2, should be $mtime1"
3467 cancel_lru_locks osc
3468 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3471 run_test 39i "write, rename, stat =============================="
3474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3475 start_full_debug_logging
3479 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3480 lctl set_param fail_loc=0x80000412
3481 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3482 error "multiop failed"
3484 local mtime1=`stat -c %Y $DIR1/$tfile`
3486 mv $DIR1/$tfile $DIR1/$tfile-1
3488 kill -USR1 $multipid
3489 wait $multipid || error "multiop close failed"
3491 for (( i=0; i < 2; i++ )) ; do
3492 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3493 [ "$mtime1" = "$mtime2" ] ||
3494 error "mtime is lost on close: $mtime2, " \
3497 cancel_lru_locks osc
3498 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3500 lctl set_param fail_loc=0
3501 stop_full_debug_logging
3503 run_test 39j "write, rename, close, stat ======================="
3506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3510 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3512 local mtime1=`stat -c %Y $DIR1/$tfile`
3514 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3516 kill -USR1 $multipid
3517 wait $multipid || error "multiop close failed"
3519 for (( i=0; i < 2; i++ )) ; do
3520 local mtime2=`stat -c %Y $DIR1/$tfile`
3522 [ "$mtime2" = $TEST_39_MTIME ] || \
3523 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3525 cancel_lru_locks osc
3526 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3529 run_test 39k "write, utime, close, stat ========================"
3531 # this should be set to future
3532 TEST_39_ATIME=`date -d "1 year" +%s`
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3537 local atime_diff=$(do_facet $SINGLEMDS \
3538 lctl get_param -n mdd.*MDT0000*.atime_diff)
3542 # test setting directory atime to future
3543 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3544 local atime=$(stat -c %X $DIR/$tdir)
3545 [ "$atime" = $TEST_39_ATIME ] ||
3546 error "atime is not set to future: $atime, $TEST_39_ATIME"
3548 # test setting directory atime from future to now
3549 local now=$(date +%s)
3550 touch -a -d @$now $DIR/$tdir
3552 atime=$(stat -c %X $DIR/$tdir)
3553 [ "$atime" -eq "$now" ] ||
3554 error "atime is not updated from future: $atime, $now"
3556 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3559 # test setting directory atime when now > dir atime + atime_diff
3560 local d1=$(date +%s)
3562 local d2=$(date +%s)
3563 cancel_lru_locks mdc
3564 atime=$(stat -c %X $DIR/$tdir)
3565 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3566 error "atime is not updated : $atime, should be $d2"
3568 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3571 # test not setting directory atime when now < dir atime + atime_diff
3573 cancel_lru_locks mdc
3574 atime=$(stat -c %X $DIR/$tdir)
3575 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3576 error "atime is updated to $atime, should remain $d1<atime<$d2"
3578 do_facet $SINGLEMDS \
3579 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3581 run_test 39l "directory atime update ==========================="
3584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3587 local far_past_mtime=$(date -d "May 29 1953" +%s)
3588 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3590 touch -m -d @$far_past_mtime $DIR1/$tfile
3591 touch -a -d @$far_past_atime $DIR1/$tfile
3593 for (( i=0; i < 2; i++ )) ; do
3594 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3595 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3596 error "atime or mtime set incorrectly"
3598 cancel_lru_locks osc
3599 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3602 run_test 39m "test atime and mtime before 1970"
3604 test_39n() { # LU-3832
3605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3606 local atime_diff=$(do_facet $SINGLEMDS \
3607 lctl get_param -n mdd.*MDT0000*.atime_diff)
3612 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3615 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3616 atime0=$(stat -c %X $DIR/$tfile)
3619 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3620 atime1=$(stat -c %X $DIR/$tfile)
3623 cancel_lru_locks mdc
3624 cancel_lru_locks osc
3625 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3626 atime2=$(stat -c %X $DIR/$tfile)
3628 do_facet $SINGLEMDS \
3629 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3631 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3632 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3634 run_test 39n "check that O_NOATIME is honored"
3637 TESTDIR=$DIR/$tdir/$tfile
3638 [ -e $TESTDIR ] && rm -rf $TESTDIR
3645 links2=$(stat -c %h .)
3646 [ $(($links1 + 2)) != $links2 ] &&
3647 error "wrong links count $(($links1 + 2)) != $links2"
3649 links3=$(stat -c %h .)
3650 [ $(($links1 + 1)) != $links3 ] &&
3651 error "wrong links count $links1 != $links3"
3654 run_test 39o "directory cached attributes updated after create"
3657 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3659 TESTDIR=$DIR/$tdir/$tdir
3660 [ -e $TESTDIR ] && rm -rf $TESTDIR
3661 test_mkdir -p $TESTDIR
3665 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3666 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3668 links2=$(stat -c %h .)
3669 [ $(($links1 + 2)) != $links2 ] &&
3670 error "wrong links count $(($links1 + 2)) != $links2"
3672 links3=$(stat -c %h .)
3673 [ $(($links1 + 1)) != $links3 ] &&
3674 error "wrong links count $links1 != $links3"
3677 run_test 39p "remote directory cached attributes updated after create ========"
3680 test_39q() { # LU-8041
3681 local testdir=$DIR/$tdir
3683 multiop_bg_pause $testdir D_c || error "multiop failed"
3685 cancel_lru_locks mdc
3686 kill -USR1 $multipid
3687 local atime=$(stat -c %X $testdir)
3688 [ "$atime" -ne 0 ] || error "atime is zero"
3690 run_test 39q "close won't zero out atime"
3693 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3694 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3695 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3696 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3697 error "$tfile is not 4096 bytes in size"
3699 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3703 small_write $DIR/f41 18
3705 run_test 41 "test small file write + fstat ====================="
3707 count_ost_writes() {
3708 lctl get_param -n ${OSC}.*.stats |
3709 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3710 END { printf("%0.0f", writes) }'
3717 BG_DIRTY_RATIO_SAVE=10
3718 MAX_BG_DIRTY_RATIO=25
3722 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3723 # dirty_ratio, dirty_background_ratio
3724 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3725 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3726 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3727 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3729 # if file not here, we are a 2.4 kernel
3730 kill -CONT `pidof kupdated`
3735 # setup the trap first, so someone cannot exit the test at the
3736 # exact wrong time and mess up a machine
3737 trap start_writeback EXIT
3738 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3739 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3740 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3741 sysctl -w vm.dirty_writeback_centisecs=0
3742 sysctl -w vm.dirty_writeback_centisecs=0
3743 # save and increase /proc/sys/vm/dirty_ratio
3744 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3745 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3746 # save and increase /proc/sys/vm/dirty_background_ratio
3747 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3748 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3750 # if file not here, we are a 2.4 kernel
3751 kill -STOP `pidof kupdated`
3755 # ensure that all stripes have some grant before we test client-side cache
3757 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3758 dd if=/dev/zero of=$i bs=4k count=1
3763 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3764 # file truncation, and file removal.
3766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3768 cancel_lru_locks $OSC
3770 sync; sleep 1; sync # just to be safe
3771 BEFOREWRITES=`count_ost_writes`
3772 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3773 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3774 AFTERWRITES=`count_ost_writes`
3775 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3776 error "$BEFOREWRITES < $AFTERWRITES"
3779 run_test 42a "ensure that we don't flush on close"
3782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3784 cancel_lru_locks $OSC
3787 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3788 BEFOREWRITES=$(count_ost_writes)
3789 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3790 AFTERWRITES=$(count_ost_writes)
3791 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3792 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3794 BEFOREWRITES=$(count_ost_writes)
3795 sync || error "sync: $?"
3796 AFTERWRITES=$(count_ost_writes)
3797 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3798 error "$BEFOREWRITES < $AFTERWRITES on sync"
3800 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3804 run_test 42b "test destroy of file with cached dirty data ======"
3806 # if these tests just want to test the effect of truncation,
3807 # they have to be very careful. consider:
3808 # - the first open gets a {0,EOF}PR lock
3809 # - the first write conflicts and gets a {0, count-1}PW
3810 # - the rest of the writes are under {count,EOF}PW
3811 # - the open for truncate tries to match a {0,EOF}PR
3812 # for the filesize and cancels the PWs.
3813 # any number of fixes (don't get {0,EOF} on open, match
3814 # composite locks, do smarter file size management) fix
3815 # this, but for now we want these tests to verify that
3816 # the cancellation with truncate intent works, so we
3817 # start the file with a full-file pw lock to match against
3818 # until the truncate.
3823 cancel_lru_locks $OSC
3825 # prime the file with 0,EOF PW to match
3829 # now the real test..
3830 dd if=/dev/zero of=$file bs=1024 count=100
3831 BEFOREWRITES=`count_ost_writes`
3832 $TRUNCATE $file $offset
3833 cancel_lru_locks $OSC
3834 AFTERWRITES=`count_ost_writes`
3839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3841 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3842 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3845 run_test 42c "test partial truncate of file with cached dirty data"
3848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3850 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3851 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3854 run_test 42d "test complete truncate of file with cached dirty data"
3856 test_42e() { # bug22074
3857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3858 local TDIR=$DIR/${tdir}e
3859 local pagesz=$(page_size)
3860 local pages=16 # hardcoded 16 pages, don't change it.
3861 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3862 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3866 test_mkdir $DIR/${tdir}e
3867 $SETSTRIPE -c 1 $TDIR
3868 createmany -o $TDIR/f $files
3870 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3872 # we assume that with $OSTCOUNT files, at least one of them will
3873 # be allocated on OST0.
3874 warmup_files=$((OSTCOUNT * max_dirty_mb))
3875 createmany -o $TDIR/w $warmup_files
3877 # write a large amount of data into one file and sync, to get good
3878 # avail_grant number from OST.
3879 for ((i=0; i<$warmup_files; i++)); do
3880 idx=$($GETSTRIPE -i $TDIR/w$i)
3881 [ $idx -ne 0 ] && continue
3882 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3885 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3887 $LCTL get_param $proc_osc0/cur_dirty_bytes
3888 $LCTL get_param $proc_osc0/cur_grant_bytes
3890 # create as much dirty pages as we can while not to trigger the actual
3891 # RPCs directly. but depends on the env, VFS may trigger flush during this
3892 # period, hopefully we are good.
3893 for ((i=0; i<$warmup_files; i++)); do
3894 idx=$($GETSTRIPE -i $TDIR/w$i)
3895 [ $idx -ne 0 ] && continue
3896 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3898 $LCTL get_param $proc_osc0/cur_dirty_bytes
3899 $LCTL get_param $proc_osc0/cur_grant_bytes
3901 # perform the real test
3902 $LCTL set_param $proc_osc0/rpc_stats 0
3903 for ((;i<$files; i++)); do
3904 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3905 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3908 $LCTL get_param $proc_osc0/rpc_stats
3911 local have_ppr=false
3912 $LCTL get_param $proc_osc0/rpc_stats |
3913 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3914 # skip lines until we are at the RPC histogram data
3915 [ "$PPR" == "pages" ] && have_ppr=true && continue
3916 $have_ppr || continue
3918 # we only want the percent stat for < 16 pages
3919 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3921 percent=$((percent + WPCT))
3922 if [[ $percent -gt 15 ]]; then
3923 error "less than 16-pages write RPCs" \
3930 run_test 42e "verify sub-RPC writes are not done synchronously"
3932 test_43A() { # was test_43
3933 test_mkdir $DIR/$tdir
3934 cp -p /bin/ls $DIR/$tdir/$tfile
3935 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3937 # give multiop a chance to open
3940 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3943 run_test 43A "execution of file opened for write should return -ETXTBSY"
3946 test_mkdir $DIR/$tdir
3947 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3948 cp -p multiop $DIR/$tdir/multiop
3949 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3950 error "multiop open $TMP/$tfile.junk failed"
3951 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3953 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3954 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3955 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3957 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3961 test_mkdir $DIR/$tdir
3962 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3963 cp -p multiop $DIR/$tdir/multiop
3964 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3965 error "multiop open $TMP/$tfile.junk failed"
3966 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3968 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3969 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3970 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3972 run_test 43b "truncate of file being executed should return -ETXTBSY"
3975 local testdir="$DIR/$tdir"
3978 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3979 ( cd $testdir && md5sum -c )
3981 run_test 43c "md5sum of copy into lustre"
3983 test_44A() { # was test_44
3984 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3985 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3986 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3988 run_test 44A "zero length read from a sparse stripe"
3991 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3993 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3994 [[ $nstripe -gt $OSTCOUNT ]] &&
3995 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3997 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3999 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4000 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4004 OFFSETS="0 $((stride/2)) $((stride-1))"
4005 for offset in $OFFSETS; do
4006 for i in $(seq 0 $((nstripe-1))); do
4007 local GLOBALOFFSETS=""
4009 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4010 local myfn=$DIR/d44a-$size
4011 echo "--------writing $myfn at $size"
4012 ll_sparseness_write $myfn $size ||
4013 error "ll_sparseness_write"
4014 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4015 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4016 error "ll_sparseness_verify $GLOBALOFFSETS"
4018 for j in $(seq 0 $((nstripe-1))); do
4020 size=$((((j + $nstripe )*$stride + $offset)))
4021 ll_sparseness_write $myfn $size ||
4022 error "ll_sparseness_write"
4023 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4025 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4026 error "ll_sparseness_verify $GLOBALOFFSETS"
4031 run_test 44a "test sparse pwrite ==============================="
4035 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4041 before=`dirty_osc_total`
4042 echo executing "\"$*\""
4044 after=`dirty_osc_total`
4045 echo before $before, after $after
4048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4050 # Obtain grants from OST if it supports it
4051 echo blah > ${f}_grant
4054 do_dirty_record "echo blah > $f"
4055 [[ $before -eq $after ]] && error "write wasn't cached"
4056 do_dirty_record "> $f"
4057 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4058 do_dirty_record "echo blah > $f"
4059 [[ $before -eq $after ]] && error "write wasn't cached"
4060 do_dirty_record "sync"
4061 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4062 do_dirty_record "echo blah > $f"
4063 [[ $before -eq $after ]] && error "write wasn't cached"
4064 do_dirty_record "cancel_lru_locks osc"
4065 [[ $before -gt $after ]] ||
4066 error "lock cancellation didn't lower dirty count"
4069 run_test 45 "osc io page accounting ============================"
4071 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4072 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4073 # objects offset and an assert hit when an rpc was built with 1023's mapped
4074 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4080 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4082 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4083 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4087 run_test 46 "dirtying a previously written page ================"
4089 # test_47 is removed "Device nodes check" is moved to test_28
4091 test_48a() { # bug 2399
4092 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4093 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4094 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
4096 test_mkdir $DIR/$tdir
4098 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4099 test_mkdir $DIR/$tdir
4100 touch foo || error "'touch foo' failed after recreating cwd"
4102 touch .foo || error "'touch .foo' failed after recreating cwd"
4104 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4105 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4106 cd . || error "'cd .' failed after recreating cwd"
4107 mkdir . && error "'mkdir .' worked after recreating cwd"
4108 rmdir . && error "'rmdir .' worked after recreating cwd"
4109 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4110 cd .. || error "'cd ..' failed after recreating cwd"
4112 run_test 48a "Access renamed working dir (should return errors)="
4114 test_48b() { # bug 2399
4116 test_mkdir $DIR/$tdir
4118 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4119 touch foo && error "'touch foo' worked after removing cwd"
4120 mkdir foo && error "'mkdir foo' worked after removing cwd"
4121 touch .foo && error "'touch .foo' worked after removing cwd"
4122 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4123 ls . > /dev/null && error "'ls .' worked after removing cwd"
4124 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4125 mkdir . && error "'mkdir .' worked after removing cwd"
4126 rmdir . && error "'rmdir .' worked after removing cwd"
4127 ln -s . foo && error "'ln -s .' worked after removing cwd"
4128 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4130 run_test 48b "Access removed working dir (should return errors)="
4132 test_48c() { # bug 2350
4133 #lctl set_param debug=-1
4136 test_mkdir -p $DIR/$tdir/dir
4138 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4139 $TRACE touch foo && error "touch foo worked after removing cwd"
4140 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4141 touch .foo && error "touch .foo worked after removing cwd"
4142 mkdir .foo && error "mkdir .foo worked after removing cwd"
4143 $TRACE ls . && error "'ls .' worked after removing cwd"
4144 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4145 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4146 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4147 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4148 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4150 run_test 48c "Access removed working subdir (should return errors)"
4152 test_48d() { # bug 2350
4153 #lctl set_param debug=-1
4156 test_mkdir -p $DIR/$tdir/dir
4158 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4159 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4160 $TRACE touch foo && error "'touch foo' worked after removing parent"
4161 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4162 touch .foo && error "'touch .foo' worked after removing parent"
4163 mkdir .foo && error "mkdir .foo worked after removing parent"
4164 $TRACE ls . && error "'ls .' worked after removing parent"
4165 $TRACE ls .. && error "'ls ..' worked after removing parent"
4166 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4167 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4168 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4171 run_test 48d "Access removed parent subdir (should return errors)"
4173 test_48e() { # bug 4134
4174 #lctl set_param debug=-1
4177 test_mkdir -p $DIR/$tdir/dir
4179 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4180 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4181 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4182 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4183 # On a buggy kernel addition of "touch foo" after cd .. will
4184 # produce kernel oops in lookup_hash_it
4185 touch ../foo && error "'cd ..' worked after recreate parent"
4187 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4189 run_test 48e "Access to recreated parent subdir (should return errors)"
4191 test_49() { # LU-1030
4192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4193 remote_ost_nodsh && skip "remote OST with nodsh" && return
4194 # get ost1 size - lustre-OST0000
4195 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4197 # write 800M at maximum
4198 [[ $ost1_size -lt 2 ]] && ost1_size=2
4199 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4201 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4202 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4205 # change max_pages_per_rpc while writing the file
4206 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4207 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4208 # loop until dd process exits
4209 while ps ax -opid | grep -wq $dd_pid; do
4210 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4211 sleep $((RANDOM % 5 + 1))
4213 # restore original max_pages_per_rpc
4214 $LCTL set_param $osc1_mppc=$orig_mppc
4215 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4217 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4221 test_mkdir $DIR/$tdir
4223 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4225 run_test 50 "special situations: /proc symlinks ==============="
4227 test_51a() { # was test_51
4228 # bug 1516 - create an empty entry right after ".." then split dir
4229 test_mkdir -c1 $DIR/$tdir
4230 touch $DIR/$tdir/foo
4231 $MCREATE $DIR/$tdir/bar
4233 createmany -m $DIR/$tdir/longfile 201
4235 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4236 $MCREATE $DIR/$tdir/longfile$FNUM
4241 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4243 run_test 51a "special situations: split htree with empty entry =="
4245 cleanup_print_lfs_df () {
4252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4253 local dir=$DIR/$tdir
4255 local nrdirs=$((65536 + 100))
4257 # cleanup the directory
4264 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4265 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4266 [[ $numfree -lt $nrdirs ]] &&
4267 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4270 # need to check free space for the directories as well
4271 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4272 numfree=$(( blkfree / $(fs_inode_ksize) ))
4273 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4276 trap cleanup_print_lfs_df EXIT
4279 createmany -d $dir/d $nrdirs || {
4280 unlinkmany $dir/d $nrdirs
4281 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4285 nrdirs=$(ls -U $dir | wc -l)
4287 # unlink all but 100 subdirectories, then check it still works
4289 local delete=$((nrdirs - left))
4294 # for ldiskfs the nlink count should be 1, but this is OSD specific
4295 # and so this is listed for informational purposes only
4296 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4297 unlinkmany -d $dir/d $delete ||
4298 error "unlink of first $delete subdirs failed"
4300 echo "nlink between: $(stat -c %h $dir)"
4301 local found=$(ls -U $dir | wc -l)
4302 [ $found -ne $left ] &&
4303 error "can't find subdirs: found only $found, expected $left"
4305 unlinkmany -d $dir/d $delete $left ||
4306 error "unlink of second $left subdirs failed"
4307 # regardless of whether the backing filesystem tracks nlink accurately
4308 # or not, the nlink count shouldn't be more than "." and ".." here
4309 local after=$(stat -c %h $dir)
4310 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4311 echo "nlink after: $after"
4313 cleanup_print_lfs_df
4315 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4319 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4320 test_mkdir $DIR/$tdir
4321 createmany -o $DIR/$tdir/t- 1000
4322 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4323 for N in $(seq 0 $((OSTCOUNT - 1))); do
4324 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4325 END { printf("%0.0f", objs) }' $TMP/$tfile)
4326 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4327 '($1 == '$N') { objs += 1 } \
4328 END { printf("%0.0f", objs) }')
4329 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4331 unlinkmany $DIR/$tdir/t- 1000
4334 for N in $(seq 1 $((OSTCOUNT - 1))); do
4335 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4336 error "OST $N has less objects vs OST $NLAST" \
4337 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4338 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4339 error "OST $N has less objects vs OST $NLAST" \
4340 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4342 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4343 error "OST $N has less #0 objects vs OST $NLAST" \
4344 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4345 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4346 error "OST $N has less #0 objects vs OST $NLAST" \
4347 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4352 run_test 51d "check object distribution"
4355 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4356 skip "ldiskfs only test"
4360 test_mkdir -c1 $DIR/$tdir
4361 test_mkdir -c1 $DIR/$tdir/d0
4363 touch $DIR/$tdir/d0/foo
4364 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4365 error "file exceed 65000 nlink limit!"
4366 unlinkmany $DIR/$tdir/d0/f- 65001
4369 run_test 51e "check file nlink limit"
4372 test_mkdir $DIR/$tdir
4375 local ulimit_old=$(ulimit -n)
4376 local spare=20 # number of spare fd's for scripts/libraries, etc.
4377 local mdt=$(lfs getstripe -M $DIR/$tdir)
4378 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4380 echo "MDT$mdt numfree=$numfree, max=$max"
4381 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4382 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4383 while ! ulimit -n $((numfree + spare)); do
4384 numfree=$((numfree * 3 / 4))
4386 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4388 echo "left ulimit at $ulimit_old"
4391 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4392 unlinkmany $DIR/$tdir/f $numfree
4393 error "create+open $numfree files in $DIR/$tdir failed"
4395 ulimit -n $ulimit_old
4397 # if createmany exits at 120s there will be fewer than $numfree files
4398 unlinkmany $DIR/$tdir/f $numfree || true
4400 run_test 51f "check many open files limit"
4403 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4404 test_mkdir $DIR/$tdir
4405 touch $DIR/$tdir/foo
4406 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4407 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4408 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4409 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4410 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4412 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4413 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4414 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4416 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4417 cp -r $DIR/$tdir $TMP/
4418 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4420 run_test 52a "append-only flag test (should return errors)"
4423 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4424 test_mkdir $DIR/$tdir
4425 touch $DIR/$tdir/foo
4426 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4427 cat test > $DIR/$tdir/foo && error "cat test worked"
4428 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4429 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4430 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4432 echo foo >> $DIR/$tdir/foo && error "echo worked"
4433 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4434 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4435 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4436 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4438 chattr -i $DIR/$tdir/foo || error "chattr failed"
4440 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4442 run_test 52b "immutable flag test (should return errors) ======="
4445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4446 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4447 remote_ost_nodsh && skip "remote OST with nodsh" && return
4460 local support_last_seq=true
4462 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4463 support_last_seq=false
4466 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4468 for value in $(do_facet $SINGLEMDS \
4469 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4470 param=$(echo ${value[0]} | cut -d "=" -f1)
4471 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4473 if $support_last_seq; then
4474 param_seq=$(echo $param |
4475 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4476 mds_last_seq=$(do_facet $SINGLEMDS \
4477 $LCTL get_param -n $param_seq)
4479 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4481 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4482 node=$(facet_active_host ost$((ostnum+1)))
4483 param="obdfilter.$ostname.last_id"
4484 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4485 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4486 ost_last_id=$ost_last
4488 if $support_last_seq; then
4489 ost_last_id=$(echo $ost_last |
4490 awk -F':' '{print $2}' |
4492 ost_last_seq=$(echo $ost_last |
4493 awk -F':' '{print $1}')
4494 [[ $ost_last_seq = $mds_last_seq ]] || continue
4497 if [[ $ost_last_id != $mds_last ]]; then
4498 error "$ost_last_id != $mds_last"
4505 $found || error "can not match last_seq/last_id for $mdtosc"
4508 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4511 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4513 $SOCKETSERVER $DIR/socket ||
4514 error "$SOCKETSERVER $DIR/socket failed: $?"
4515 $SOCKETCLIENT $DIR/socket ||
4516 error "$SOCKETCLIENT $DIR/socket failed: $?"
4517 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4519 run_test 54a "unix domain socket test =========================="
4525 dd if=/dev/zero of=$f bs=$(page_size) count=1
4527 run_test 54b "char device works in lustre ======================"
4530 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4531 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4532 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4534 for i in $(seq 3 7); do
4535 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4544 loopdev="$DIR/loop54c"
4547 $UMOUNT $DIR/$tdir || rc=$?
4548 losetup -d $loopdev || true
4549 losetup -d $LOOPDEV || true
4550 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4556 loopdev="$DIR/loop54c"
4559 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4560 trap cleanup_54c EXIT
4561 mknod $loopdev b 7 $LOOPNUM
4562 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4563 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4564 losetup $loopdev $DIR/$tfile ||
4565 error "can't set up $loopdev for $DIR/$tfile"
4566 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4567 test_mkdir $DIR/$tdir
4568 mount -t ext2 $loopdev $DIR/$tdir ||
4569 error "error mounting $loopdev on $DIR/$tdir"
4570 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4573 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4577 run_test 54c "block device works in lustre ====================="
4583 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4585 run_test 54d "fifo device works in lustre ======================"
4590 cp -aL /dev/console $f
4591 echo $string > $f || error "echo $string to $f failed"
4593 run_test 54e "console/tty device works in lustre ======================"
4597 local dir=$DIR/$tdir
4600 test_mkdir -p $dir/dir
4601 for i in $(seq $numfiles); do
4603 touch $dir/dir/file$i
4606 local numcomp=$($LFS getstripe --component-count $dir)
4608 [[ $numcomp == 0 ]] && numcomp=1
4610 # test lfs getstripe with --recursive
4611 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4613 [[ $filenum -eq $((numfiles * 2)) ]] ||
4614 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4615 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4616 [[ $filenum -eq $numfiles ]] ||
4617 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4618 echo "$LFS getstripe showed obdidx or l_ost_idx"
4620 # test lfs getstripe with file instead of dir
4621 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4622 [[ $filenum -eq 1 ]] ||
4623 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4624 echo "$LFS getstripe file1 passed"
4626 #test lfs getstripe with --verbose
4627 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4628 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4629 error "$LFS getstripe --verbose $dir: "\
4630 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4631 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4632 error "$LFS getstripe $dir: showed lmm_magic"
4634 #test lfs getstripe with -v prints lmm_fid
4635 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4636 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4637 error "$LFS getstripe -v $dir: "\
4638 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4639 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4640 error "$LFS getstripe $dir: showed lmm_fid by default"
4641 echo "$LFS getstripe --verbose passed"
4643 #check for FID information
4644 local fid1=$($LFS getstripe --fid $dir/file1)
4645 local fid2=$($LFS getstripe --verbose $dir/file1 |
4646 awk '/lmm_fid: / { print $2; exit; }')
4647 local fid3=$($LFS path2fid $dir/file1)
4649 [ "$fid1" != "$fid2" ] &&
4650 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4651 [ "$fid1" != "$fid3" ] &&
4652 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4653 echo "$LFS getstripe --fid passed"
4655 #test lfs getstripe with --obd
4656 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4657 error "$LFS getstripe --obd wrong_uuid: should return error"
4659 [[ $OSTCOUNT -lt 2 ]] &&
4660 skip_env "skip '$LFS getstripe --obd' tests: $OSTCOUNT < 2" &&
4664 local obduuid=$(ostuuid_from_index $ostidx)
4665 local found=$($LFS getstripe -r --obd $obduuid $dir |
4666 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
4668 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
4669 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
4671 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
4674 [[ $found -eq $filenum ]] ||
4675 error "$LFS getstripe --obd: found $found expect $filenum"
4676 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4677 sed '/^[ ]*'${ostidx}'[ ]/d' |
4678 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4679 error "$LFS getstripe --obd: should not show file on other obd"
4680 echo "$LFS getstripe --obd passed"
4682 run_test 56a "check $LFS getstripe"
4685 local dir=$DIR/$tdir
4689 for i in $(seq $numdirs); do
4690 test_mkdir $dir/dir$i
4693 # test lfs getdirstripe default mode is non-recursion, which is
4694 # different from lfs getstripe
4695 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4697 [[ $dircnt -eq 1 ]] ||
4698 error "$LFS getdirstripe: found $dircnt, not 1"
4699 dircnt=$($LFS getdirstripe --recursive $dir |
4700 grep -c lmv_stripe_count)
4701 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4702 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4704 run_test 56b "check $LFS getdirstripe"
4707 remote_ost_nodsh && skip "remote OST with nodsh" && return
4710 local ost_name=$(ostname_from_index $ost_idx)
4711 local old_status=$(ost_dev_status $ost_idx)
4713 [[ -z "$old_status" ]] ||
4714 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4716 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4719 local new_status=$(ost_dev_status $ost_idx)
4721 [[ "$new_status" = "D" ]] ||
4722 error "OST $ost_name is in status of '$new_status', not 'D'"
4724 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4727 new_status=$(ost_dev_status $ost_idx)
4728 [[ -z "$new_status" ]] ||
4729 error "OST $ost_name is in status of '$new_status', not ''"
4731 run_test 56c "check 'lfs df' showing device status"
4736 local local_tdir="$1"
4737 local local_numfiles="$2"
4738 local local_numdirs="$3"
4739 local dir_params="$4"
4740 local dir_stripe_params="$5"
4742 if [ ! -d "$local_tdir" ] ; then
4743 test_mkdir -p $dir_stripe_params $local_tdir
4744 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4745 for i in $(seq $local_numfiles) ; do
4746 touch $local_tdir/file$i
4748 for i in $(seq $local_numdirs) ; do
4749 test_mkdir $dir_stripe_params $local_tdir/dir$i
4750 for j in $(seq $local_numfiles) ; do
4751 touch $local_tdir/dir$i/file$j
4757 setup_56_special() {
4759 local local_numfiles=$2
4760 local local_numdirs=$3
4762 setup_56 $local_tdir $local_numfiles $local_numdirs
4764 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4765 for i in $(seq $local_numfiles) ; do
4766 mknod $local_tdir/loop${i}b b 7 $i
4767 mknod $local_tdir/null${i}c c 1 3
4768 ln -s $local_tdir/file1 $local_tdir/link${i}
4770 for i in $(seq $local_numdirs) ; do
4771 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4772 mknod $local_tdir/dir$i/null${i}c c 1 3
4773 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4779 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4780 local expected=$(($NUMDIRS + 2))
4782 setup_56 $dir $NUMFILES $NUMDIRS
4784 # test lfs find with -name
4785 for i in $(seq $NUMFILES) ; do
4786 local nums=$($LFS find -name "*$i" $dir | wc -l)
4788 [ $nums -eq $expected ] ||
4789 error "lfs find -name '*$i' $dir wrong: "\
4790 "found $nums, expected $expected"
4793 run_test 56g "check lfs find -name"
4796 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4797 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4799 setup_56 $dir $NUMFILES $NUMDIRS
4801 # test lfs find with ! -name
4802 for i in $(seq $NUMFILES) ; do
4803 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
4805 [ $nums -eq $expected ] ||
4806 error "lfs find ! -name '*$i' $dir wrong: "\
4807 "found $nums, expected $expected"
4810 run_test 56h "check lfs find ! -name"
4813 local dir=$DIR/$tdir
4817 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
4820 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
4822 run_test 56i "check 'lfs find -ost UUID' skips directories"
4825 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4827 setup_56_special $dir $NUMFILES $NUMDIRS
4829 local expected=$((NUMDIRS + 1))
4830 local cmd="$LFS find -type d $dir"
4831 local nums=$($cmd | wc -l)
4833 [ $nums -eq $expected ] ||
4834 error "'$cmd' wrong: found $nums, expected $expected"
4836 run_test 56j "check lfs find -type d"
4839 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4841 setup_56_special $dir $NUMFILES $NUMDIRS
4843 local expected=$(((NUMDIRS + 1) * NUMFILES))
4844 local cmd="$LFS find -type f $dir"
4845 local nums=$($cmd | wc -l)
4847 [ $nums -eq $expected ] ||
4848 error "'$cmd' wrong: found $nums, expected $expected"
4850 run_test 56k "check lfs find -type f"
4853 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4855 setup_56_special $dir $NUMFILES $NUMDIRS
4857 local expected=$((NUMDIRS + NUMFILES))
4858 local cmd="$LFS find -type b $dir"
4859 local nums=$($cmd | wc -l)
4861 [ $nums -eq $expected ] ||
4862 error "'$cmd' wrong: found $nums, expected $expected"
4864 run_test 56l "check lfs find -type b"
4867 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4869 setup_56_special $dir $NUMFILES $NUMDIRS
4871 local expected=$((NUMDIRS + NUMFILES))
4872 local cmd="$LFS find -type c $dir"
4873 local nums=$($cmd | wc -l)
4874 [ $nums -eq $expected ] ||
4875 error "'$cmd' wrong: found $nums, expected $expected"
4877 run_test 56m "check lfs find -type c"
4880 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4881 setup_56_special $dir $NUMFILES $NUMDIRS
4883 local expected=$((NUMDIRS + NUMFILES))
4884 local cmd="$LFS find -type l $dir"
4885 local nums=$($cmd | wc -l)
4887 [ $nums -eq $expected ] ||
4888 error "'$cmd' wrong: found $nums, expected $expected"
4890 run_test 56n "check lfs find -type l"
4893 local dir=$DIR/$tdir
4895 setup_56 $dir $NUMFILES $NUMDIRS
4896 utime $dir/file1 > /dev/null || error "utime (1)"
4897 utime $dir/file2 > /dev/null || error "utime (2)"
4898 utime $dir/dir1 > /dev/null || error "utime (3)"
4899 utime $dir/dir2 > /dev/null || error "utime (4)"
4900 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
4901 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
4904 local nums=$($LFS find -mtime +0 $dir | wc -l)
4906 [ $nums -eq $expected ] ||
4907 error "lfs find -mtime +0 $dir: found $nums expect $expected"
4910 cmd="$LFS find -mtime 0 $dir"
4911 nums=$($cmd | wc -l)
4912 [ $nums -eq $expected ] ||
4913 error "'$cmd' wrong: found $nums, expected $expected"
4915 run_test 56o "check lfs find -mtime for old files"
4918 [ $RUNAS_ID -eq $UID ] &&
4919 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4921 local dir=$DIR/$tdir
4923 setup_56 $dir $NUMFILES $NUMDIRS
4924 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
4926 local expected=$NUMFILES
4927 local cmd="$LFS find -uid $RUNAS_ID $dir"
4928 local nums=$($cmd | wc -l)
4930 [ $nums -eq $expected ] ||
4931 error "'$cmd' wrong: found $nums, expected $expected"
4933 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
4934 cmd="$LFS find ! -uid $RUNAS_ID $dir"
4935 nums=$($cmd | wc -l)
4936 [ $nums -eq $expected ] ||
4937 error "'$cmd' wrong: found $nums, expected $expected"
4939 run_test 56p "check lfs find -uid and ! -uid"
4942 [ $RUNAS_ID -eq $UID ] &&
4943 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4945 local dir=$DIR/$tdir
4947 setup_56 $dir $NUMFILES $NUMDIRS
4948 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
4950 local expected=$NUMFILES
4951 local cmd="$LFS find -gid $RUNAS_GID $dir"
4952 local nums=$($cmd | wc -l)
4954 [ $nums -eq $expected ] ||
4955 error "'$cmd' wrong: found $nums, expected $expected"
4957 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4958 cmd="$LFS find ! -gid $RUNAS_GID $dir"
4959 nums=$($cmd | wc -l)
4960 [ $nums -eq $expected ] ||
4961 error "'$cmd' wrong: found $nums, expected $expected"
4963 run_test 56q "check lfs find -gid and ! -gid"
4966 local dir=$DIR/$tdir
4968 setup_56 $dir $NUMFILES $NUMDIRS
4971 local cmd="$LFS find -size 0 -type f $dir"
4972 local nums=$($cmd | wc -l)
4974 [ $nums -eq $expected ] ||
4975 error "'$cmd' wrong: found $nums, expected $expected"
4977 cmd="$LFS find ! -size 0 -type f $dir"
4978 nums=$($cmd | wc -l)
4979 [ $nums -eq $expected ] ||
4980 error "'$cmd' wrong: found $nums, expected $expected"
4981 echo "test" > $dir/$tfile
4982 echo "test2" > $dir/$tfile.2 && sync
4984 cmd="$LFS find -size 5 -type f $dir"
4985 nums=$($cmd | wc -l)
4986 [ $nums -eq $expected ] ||
4987 error "'$cmd' wrong: found $nums, expected $expected"
4989 cmd="$LFS find -size +5 -type f $dir"
4990 nums=$($cmd | wc -l)
4991 [ $nums -eq $expected ] ||
4992 error "'$cmd' wrong: found $nums, expected $expected"
4994 cmd="$LFS find -size +0 -type f $dir"
4995 nums=$($cmd | wc -l)
4996 [ $nums -eq $expected ] ||
4997 error "'$cmd' wrong: found $nums, expected $expected"
4999 cmd="$LFS find ! -size -5 -type f $dir"
5000 nums=$($cmd | wc -l)
5001 [ $nums -eq $expected ] ||
5002 error "'$cmd' wrong: found $nums, expected $expected"
5004 cmd="$LFS find -size -5 -type f $dir"
5005 nums=$($cmd | wc -l)
5006 [ $nums -eq $expected ] ||
5007 error "'$cmd' wrong: found $nums, expected $expected"
5009 run_test 56r "check lfs find -size works"
5011 test_56s() { # LU-611 #LU-9369
5012 [[ $OSTCOUNT -lt 2 ]] && skip "need at least 2 OSTs" && return 0
5014 local dir=$DIR/$tdir
5015 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5017 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5018 for i in $(seq $NUMDIRS); do
5019 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5022 local expected=$NUMDIRS
5023 local cmd="$LFS find -c $OSTCOUNT $dir"
5024 local nums=$($cmd | wc -l)
5026 [ $nums -eq $expected ] || {
5027 $LFS getstripe -R $dir
5028 error "'$cmd' wrong: found $nums, expected $expected"
5031 expected=$((NUMDIRS + onestripe))
5032 cmd="$LFS find -stripe-count +0 -type f $dir"
5033 nums=$($cmd | wc -l)
5034 [ $nums -eq $expected ] || {
5035 $LFS getstripe -R $dir
5036 error "'$cmd' wrong: found $nums, expected $expected"
5040 cmd="$LFS find -stripe-count 1 -type f $dir"
5041 nums=$($cmd | wc -l)
5042 [ $nums -eq $expected ] || {
5043 $LFS getstripe -R $dir
5044 error "'$cmd' wrong: found $nums, expected $expected"
5047 cmd="$LFS find -stripe-count -2 -type f $dir"
5048 nums=$($cmd | wc -l)
5049 [ $nums -eq $expected ] || {
5050 $LFS getstripe -R $dir
5051 error "'$cmd' wrong: found $nums, expected $expected"
5055 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5056 nums=$($cmd | wc -l)
5057 [ $nums -eq $expected ] || {
5058 $LFS getstripe -R $dir
5059 error "'$cmd' wrong: found $nums, expected $expected"
5062 run_test 56s "check lfs find -stripe-count works"
5064 test_56t() { # LU-611 #LU-9369
5065 local dir=$DIR/$tdir
5067 setup_56 $dir 0 $NUMDIRS
5068 for i in $(seq $NUMDIRS); do
5069 $LFS setstripe -S 8M $dir/dir$i/$tfile
5072 local expected=$NUMDIRS
5073 local cmd="$LFS find -S 8M $dir"
5074 local nums=$($cmd | wc -l)
5076 [ $nums -eq $expected ] || {
5077 $LFS getstripe -R $dir
5078 error "'$cmd' wrong: found $nums, expected $expected"
5082 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5084 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5086 expected=$(((NUMDIRS + 1) * NUMFILES))
5087 cmd="$LFS find -stripe-size 512k -type f $dir"
5088 nums=$($cmd | wc -l)
5089 [ $nums -eq $expected ] ||
5090 error "'$cmd' wrong: found $nums, expected $expected"
5092 cmd="$LFS find -stripe-size +320k -type f $dir"
5093 nums=$($cmd | wc -l)
5094 [ $nums -eq $expected ] ||
5095 error "'$cmd' wrong: found $nums, expected $expected"
5097 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5098 cmd="$LFS find -stripe-size +200k -type f $dir"
5099 nums=$($cmd | wc -l)
5100 [ $nums -eq $expected ] ||
5101 error "'$cmd' wrong: found $nums, expected $expected"
5103 cmd="$LFS find -stripe-size -640k -type f $dir"
5104 nums=$($cmd | wc -l)
5105 [ $nums -eq $expected ] ||
5106 error "'$cmd' wrong: found $nums, expected $expected"
5109 cmd="$LFS find -stripe-size 256k -type f $dir"
5110 nums=$($cmd | wc -l)
5111 [ $nums -eq $expected ] ||
5112 error "'$cmd' wrong: found $nums, expected $expected"
5114 cmd="$LFS find -stripe-size -320k -type f $dir"
5115 nums=$($cmd | wc -l)
5116 [ $nums -eq $expected ] ||
5117 error "'$cmd' wrong: found $nums, expected $expected"
5120 cmd="$LFS find -stripe-size 1024k -type f $dir"
5121 nums=$($cmd | wc -l)
5122 [ $nums -eq $expected ] ||
5123 error "'$cmd' wrong: found $nums, expected $expected"
5125 run_test 56t "check lfs find -stripe-size works"
5127 test_56u() { # LU-611
5128 local dir=$DIR/$tdir
5130 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5132 if [[ $OSTCOUNT -gt 1 ]]; then
5133 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5139 local expected=$(((NUMDIRS + 1) * NUMFILES))
5140 local cmd="$LFS find -stripe-index 0 -type f $dir"
5141 local nums=$($cmd | wc -l)
5143 [ $nums -eq $expected ] ||
5144 error "'$cmd' wrong: found $nums, expected $expected"
5147 cmd="$LFS find -stripe-index 1 -type f $dir"
5148 nums=$($cmd | wc -l)
5149 [ $nums -eq $expected ] ||
5150 error "'$cmd' wrong: found $nums, expected $expected"
5152 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5153 nums=$($cmd | wc -l)
5154 [ $nums -eq $expected ] ||
5155 error "'$cmd' wrong: found $nums, expected $expected"
5158 # This should produce an error and not return any files
5159 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5160 nums=$($cmd 2>/dev/null | wc -l)
5161 [ $nums -eq $expected ] ||
5162 error "'$cmd' wrong: found $nums, expected $expected"
5164 if [[ $OSTCOUNT -gt 1 ]]; then
5165 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5166 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5167 nums=$($cmd | wc -l)
5168 [ $nums -eq $expected ] ||
5169 error "'$cmd' wrong: found $nums, expected $expected"
5172 run_test 56u "check lfs find -stripe-index works"
5176 local dir=$DIR/$tdir
5178 setup_56 $dir $NUMFILES $NUMDIRS
5180 UUID=$(mdtuuid_from_index $MDT_IDX $dir)
5181 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $MDT_IDX"
5183 for file in $($LFS find -mdt $UUID $dir); do
5184 file_mdt_idx=$($LFS getstripe -M $file)
5185 [ $file_mdt_idx -eq $MDT_IDX ] ||
5186 error "lfind -mdt $UUID != getstripe -M $file_mdt_idx"
5189 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5192 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5194 local dir=$DIR/$tdir
5196 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5198 local stripe_size=$($LFS getstripe -S -d $dir) ||
5199 error "$LFS getstripe -S -d $dir failed"
5200 stripe_size=${stripe_size%% *}
5202 local file_size=$((stripe_size * OSTCOUNT))
5203 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5204 local required_space=$((file_num * file_size))
5205 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5207 [[ $free_space -le $((required_space / 1024)) ]] &&
5208 skip_env "need $required_space, have $free_space kbytes" &&
5212 local dd_count=$((file_size / dd_bs))
5214 # write data into the files
5219 for i in $(seq $NUMFILES); do
5221 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5222 error "write data into $file failed"
5224 for i in $(seq $NUMDIRS); do
5225 for j in $(seq $NUMFILES); do
5226 file=$dir/dir$i/file$j
5227 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5228 error "write data into $file failed"
5232 # $LFS_MIGRATE will fail if hard link migration is unsupported
5233 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5234 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5235 error "creating links to $dir/dir1/file1 failed"
5240 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5243 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5246 eval $cmd || error "$cmd failed"
5248 check_stripe_count $dir/file1 $expected
5250 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5252 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5253 # OST 1 if it is on OST 0. This file is small enough to
5254 # be on only one stripe.
5255 file=$dir/migr_1_ost
5256 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5257 error "write data into $file failed"
5258 local obdidx=$($LFS getstripe -i $file)
5259 local oldmd5=$(md5sum $file)
5262 [[ $obdidx -eq 0 ]] && newobdidx=1
5263 cmd="$LFS migrate -i $newobdidx $file"
5265 eval $cmd || error "$cmd failed"
5267 local realobdix=$($LFS getstripe -i $file)
5268 local newmd5=$(md5sum $file)
5270 [[ $newobdidx -ne $realobdix ]] &&
5271 error "new OST is different (was=$obdidx, "\
5272 "wanted=$newobdidx, got=$realobdix)"
5273 [[ "$oldmd5" != "$newmd5" ]] &&
5274 error "md5sum differ: $oldmd5, $newmd5"
5278 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5280 eval $cmd || error "$cmd failed"
5282 for j in $(seq $NUMFILES); do
5283 check_stripe_count $dir/dir1/file$j $expected
5286 # lfs_migrate works with lfs find
5287 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5288 $LFS_MIGRATE -y -c $expected"
5290 eval $cmd || error "$cmd failed"
5292 for i in $(seq 2 $NUMFILES); do
5293 check_stripe_count $dir/file$i $expected
5295 for i in $(seq 2 $NUMDIRS); do
5296 for j in $(seq $NUMFILES); do
5297 check_stripe_count $dir/dir$i/file$j $expected
5301 run_test 56w "check lfs_migrate -c stripe_count works"
5304 local file1=$DIR/$tdir/file1
5305 local create_pool=false
5306 local initial_pool=$($LFS getstripe -p $DIR)
5310 echo -n "Creating test dir..."
5311 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5314 echo -n "Creating test file..."
5315 touch $file1 || error "cannot create file"
5318 echo -n "Detecting existing pools..."
5319 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5321 if [ ${#pool_list[@]} -gt 0 ]; then
5322 echo "${pool_list[@]}"
5323 for thispool in "${pool_list[@]}"; do
5324 if [[ -z "$initial_pool" ||
5325 "$initial_pool" != "$thispool" ]]; then
5327 echo "Using existing pool '$pool'"
5332 echo "none detected."
5334 if [ -z "$pool" ]; then
5335 pool=${POOL:-testpool}
5336 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5337 echo -n "Creating pool '$pool'..."
5339 pool_add $pool &> /dev/null ||
5340 error "pool_add failed"
5343 echo -n "Adding target to pool..."
5344 pool_add_targets $pool 0 0 1 &> /dev/null ||
5345 error "pool_add_targets failed"
5349 echo -n "Setting pool using -p option..."
5350 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5351 error "migrate failed rc = $?"
5354 echo -n "Verifying test file is in pool after migrating..."
5355 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5356 error "file was not migrated to pool $pool"
5359 echo -n "Removing test file from pool '$pool'..."
5360 $LFS migrate $file1 &> /dev/null ||
5361 error "cannot remove from pool"
5362 [ "$($LFS getstripe -p $file1)" ] &&
5363 error "pool still set"
5366 echo -n "Setting pool using --pool option..."
5367 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5368 error "migrate failed rc = $?"
5373 if $create_pool; then
5374 destroy_test_pools 2> /dev/null ||
5375 error "destroy test pools failed"
5378 run_test 56wb "check lfs_migrate pool support"
5381 local file1="$DIR/$tdir/file 1"
5383 echo -n "Creating test dir..."
5384 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5385 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5386 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5387 error "cannot set stripe"
5390 echo -n "Setting initial stripe for test file..."
5391 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5392 error "cannot set stripe"
5393 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5394 error "stripe size not set"
5397 # File currently set to -S 512K -c 1
5399 # Ensure -c and -S options are rejected when -R is set
5400 echo -n "Verifying incompatible options are detected..."
5401 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5402 error "incompatible -c and -R options not detected"
5403 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5404 error "incompatible -S and -R options not detected"
5407 # Ensure unrecognized options are passed through to 'lfs migrate'
5408 echo -n "Verifying -S option is passed through to lfs migrate..."
5409 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5410 error "migration failed"
5411 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5412 error "file was not restriped"
5415 # File currently set to -S 1M -c 1
5417 # Ensure long options are supported
5418 echo -n "Verifying long options supported..."
5419 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5420 error "long option without argument not supported"
5421 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5422 error "long option with argument not supported"
5423 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5424 error "file not restriped with --stripe-size option"
5427 # File currently set to -S 512K -c 1
5429 if [ "$OSTCOUNT" -gt 1 ]; then
5430 echo -n "Verifying explicit stripe count can be set..."
5431 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5432 error "migrate failed"
5433 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5434 error "file not restriped to explicit count"
5438 # File currently set to -S 512K -c 1 or -S 512K -c 2
5440 # Ensure parent striping is used if -R is set, and no stripe
5441 # count or size is specified
5442 echo -n "Setting stripe for parent directory..."
5443 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5444 error "cannot set stripe"
5447 echo -n "Verifying restripe option uses parent stripe settings..."
5448 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5449 error "migrate failed"
5450 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
5451 error "file not restriped to parent settings"
5452 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5453 error "file not restriped to parent settings"
5456 # File currently set to -S 1M -c 1
5458 # Ensure striping is preserved if -R is not set, and no stripe
5459 # count or size is specified
5460 echo -n "Verifying striping size preserved when not specified..."
5461 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
5462 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5463 error "cannot set stripe on parent directory"
5464 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5465 error "migrate failed"
5466 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
5467 error "file was restriped"
5470 # Ensure file name properly detected when final option has no argument
5471 echo -n "Verifying file name properly detected..."
5472 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5473 error "file name interpreted as option argument"
5479 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5482 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5483 local file1=$DIR/$tdir/file1
5485 echo -n "Creating test dir..."
5486 test_mkdir $DIR/$tdir || error "cannot create dir"
5489 echo -n "Creating test file..."
5493 # Ensure 'lfs migrate' will fail by using a non-existent option,
5494 # and make sure rsync is not called to recover
5495 echo -n "Make sure --no-rsync option works..."
5496 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5497 grep -q 'refusing to fall back to rsync' ||
5498 error "rsync was called with --no-rsync set"
5501 # Ensure rsync is called without trying 'lfs migrate' first
5502 echo -n "Make sure --rsync option works..."
5503 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5504 grep -q 'falling back to rsync' &&
5505 error "lfs migrate was called with --rsync set"
5508 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5509 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5510 grep -q 'at the same time' ||
5511 error "--rsync and --no-rsync accepted concurrently"
5517 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5520 check_swap_layouts_support && return 0
5521 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5523 local dir=$DIR/$tdir
5524 local ref1=/etc/passwd
5525 local file1=$dir/file1
5527 test_mkdir $dir || error "creating dir $dir"
5528 $LFS setstripe -c 2 $file1
5530 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5531 stripe=$($LFS getstripe -c $file1)
5532 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5533 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5538 run_test 56x "lfs migration support"
5541 check_swap_layouts_support && return 0
5542 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5544 local dir=$DIR/$tdir/$testnum
5548 local ref1=/etc/passwd
5549 local file1=$dir/file1
5551 $LFS setstripe -c 2 $file1
5553 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5555 local stripe=$($LFS getstripe -c $file1)
5557 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5558 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5563 run_test 56xa "lfs migration --block support"
5565 check_migrate_links() {
5567 local file1="$dir/file1"
5570 local total_count=$(($begin + $count - 1))
5571 local symlink_count=10
5574 if [ ! -f "$file1" ]; then
5575 echo -n "creating initial file..."
5576 $LFS setstripe -c 1 -S "512k" "$file1" ||
5577 error "cannot setstripe initial file"
5580 echo -n "creating symlinks..."
5581 for s in $(seq 1 $symlink_count); do
5582 ln -s "$file1" "$dir/slink$s" ||
5583 error "cannot create symlinks"
5587 echo -n "creating nonlinked files..."
5588 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5589 error "cannot create nonlinked files"
5594 if [ ! -f "$dir/file$total_count" ]; then
5595 echo -n "creating hard links $begin:$total_count..."
5596 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5597 /dev/null || error "cannot create hard links"
5601 echo -n "checking number of hard links listed in xattrs..."
5602 local fid=$($LFS getstripe -F "$file1")
5603 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5606 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5607 echo "hard link list has unexpected size, skipping test"
5610 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5611 error "link names should exceed xattrs size"
5614 echo -n "migrating files..."
5615 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5617 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5620 # make sure all links have been properly migrated
5621 echo -n "verifying files..."
5622 fid=$($LFS getstripe -F "$file1") ||
5623 error "cannot get fid for file $file1"
5624 for i in $(seq 2 $total_count); do
5625 local fid2=$($LFS getstripe -F $dir/file$i)
5627 [ "$fid2" == "$fid" ] ||
5628 error "migrated hard link has mismatched FID"
5631 # make sure hard links were properly detected, and migration was
5632 # performed only once for the entire link set; nonlinked files should
5634 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5635 local expected=$(($uniq_count + 1))
5637 [ "$actual" -eq "$expected" ] ||
5638 error "hard links individually migrated ($actual != $expected)"
5640 # make sure the correct number of hard links are present
5641 local hardlinks=$(stat -c '%h' "$file1")
5643 [ $hardlinks -eq $total_count ] ||
5644 error "num hard links $hardlinks != $total_count"
5651 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
5652 skip "Need MDS version at least 2.10.55" && return
5654 local dir="$DIR/$tdir"
5656 test_mkdir "$dir" || error "cannot create dir $dir"
5658 echo "testing lfs migrate mode when all links fit within xattrs"
5659 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
5661 echo "testing rsync mode when all links fit within xattrs"
5662 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
5664 echo "testing lfs migrate mode when all links do not fit within xattrs"
5665 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
5667 echo "testing rsync mode when all links do not fit within xattrs"
5668 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
5673 run_test 56xb "lfs migration hard link support"
5676 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5677 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5681 local dir=$DIR/$tdir
5685 test_mkdir -p $dir || error "creating dir $dir"
5686 touch $f1 || error "creating std file $f1"
5687 $MULTIOP $f2 H2c || error "creating released file $f2"
5689 # a directory can be raid0, so ask only for files
5690 res=$($LFS find $dir -L raid0 -type f | wc -l)
5691 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5693 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5694 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5696 # only files can be released, so no need to force file search
5697 res=$($LFS find $dir -L released)
5698 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5700 res=$($LFS find $dir -type f \! -L released)
5701 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5703 run_test 56y "lfs find -L raid0|released"
5705 test_56z() { # LU-4824
5706 # This checks to make sure 'lfs find' continues after errors
5707 # There are two classes of errors that should be caught:
5708 # - If multiple paths are provided, all should be searched even if one
5710 # - If errors are encountered during the search, it should not terminate
5712 local dir=$DIR/$tdir
5716 for i in d{0..9}; do
5719 touch $dir/d{0..9}/$tfile
5720 $LFS find $DIR/non_existent_dir $dir &&
5721 error "$LFS find did not return an error"
5722 # Make a directory unsearchable. This should NOT be the last entry in
5723 # directory order. Arbitrarily pick the 6th entry
5724 chmod 700 $($LFS find $dir -type d | sed '6!d')
5726 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5728 # The user should be able to see 10 directories and 9 files
5729 [ $count == 19 ] || error "$LFS find did not continue after error"
5731 run_test 56z "lfs find should continue after an error"
5733 test_56aa() { # LU-5937
5734 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5736 local dir=$DIR/$tdir
5739 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5741 createmany -o $dir/striped_dir/${tfile}- 1024
5742 local dirs=$($LFS find --size +8k $dir/)
5744 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5746 run_test 56aa "lfs find --size under striped dir"
5748 test_56ab() { # LU-10705
5749 test_mkdir $DIR/$tdir
5750 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
5751 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
5752 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
5753 # Flush writes to ensure valid blocks. Need to be more thorough for
5754 # ZFS, since blocks are not allocated/returned to client immediately.
5756 wait_zfs_commit ost1 2
5757 cancel_lru_locks osc
5760 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
5762 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
5764 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
5765 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
5767 rm -f $DIR/$tdir/$tfile.[123]
5769 run_test 56ab "lfs find --blocks"
5772 # Create composite files with one component
5773 local dir=$DIR/$tdir
5775 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
5776 # Create composite files with three components
5777 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
5778 # Create non-composite files
5779 createmany -o $dir/${tfile}- 10
5781 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
5783 [[ $nfiles == 10 ]] ||
5784 error "lfs find -E 1M found $nfiles != 10 files"
5786 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
5787 [[ $nfiles == 25 ]] ||
5788 error "lfs find ! -E 1M found $nfiles != 25 files"
5790 # All files have a component that starts at 0
5791 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
5792 [[ $nfiles == 35 ]] ||
5793 error "lfs find --component-start 0 - $nfiles != 35 files"
5795 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
5796 [[ $nfiles == 15 ]] ||
5797 error "lfs find --component-start 2M - $nfiles != 15 files"
5799 # All files created here have a componenet that does not starts at 2M
5800 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
5801 [[ $nfiles == 35 ]] ||
5802 error "lfs find ! --component-start 2M - $nfiles != 35 files"
5804 # Find files with a specified number of components
5805 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
5806 [[ $nfiles == 15 ]] ||
5807 error "lfs find --component-count 3 - $nfiles != 15 files"
5809 # Remember non-composite files have a component count of zero
5810 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
5811 [[ $nfiles == 10 ]] ||
5812 error "lfs find --component-count 0 - $nfiles != 10 files"
5814 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
5815 [[ $nfiles == 20 ]] ||
5816 error "lfs find ! --component-count 3 - $nfiles != 20 files"
5818 # All files have a flag called "init"
5819 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
5820 [[ $nfiles == 35 ]] ||
5821 error "lfs find --component-flags init - $nfiles != 35 files"
5823 # Multi-component files will have a component not initialized
5824 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
5825 [[ $nfiles == 15 ]] ||
5826 error "lfs find !--component-flags init - $nfiles != 15 files"
5831 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
5834 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
5835 { skip "Need MDS version at least 2.10.57"; return 0; }
5845 # create mirrored directories and mirrored files
5846 mkdir $td || error "mkdir $td failed"
5847 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
5848 createmany -o $tf- 10 || error "create $tf- failed"
5850 for i in $(seq 2); do
5852 mkdir $dir || error "mkdir $dir failed"
5853 $LFS mirror create -N$((3 + i)) $dir ||
5854 error "create mirrored dir $dir failed"
5855 createmany -o $dir/$tfile- 10 ||
5856 error "create $dir/$tfile- failed"
5859 # change the states of some mirrored files
5861 for i in $(seq 2); do
5863 for j in $(seq 4 9); do
5864 echo foo > $dir/$tfile-$j
5868 # find mirrored files with specific mirror count
5869 cmd="$LFS find --mirror-count 3 --type f $td"
5870 nfiles=$($cmd | wc -l)
5871 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
5873 cmd="$LFS find ! --mirror-count 3 --type f $td"
5874 nfiles=$($cmd | wc -l)
5875 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
5877 cmd="$LFS find --mirror-count +2 --type f $td"
5878 nfiles=$($cmd | wc -l)
5879 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5881 cmd="$LFS find --mirror-count -6 --type f $td"
5882 nfiles=$($cmd | wc -l)
5883 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5885 # find mirrored files with specific file state
5886 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
5887 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
5889 cmd="$LFS find --mirror-state=ro --type f $td"
5890 nfiles=$($cmd | wc -l)
5891 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
5893 cmd="$LFS find ! --mirror-state=ro --type f $td"
5894 nfiles=$($cmd | wc -l)
5895 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
5897 cmd="$LFS find --mirror-state=wp --type f $td"
5898 nfiles=$($cmd | wc -l)
5899 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
5901 cmd="$LFS find ! --mirror-state=sp --type f $td"
5902 nfiles=$($cmd | wc -l)
5903 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5905 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
5908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5909 # note test will not do anything if MDS is not local
5910 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5911 skip "ldiskfs only test"
5915 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5916 local MNTDEV="osd*.*MDT*.mntdev"
5917 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5918 [ -z "$DEV" ] && error "can't access $MNTDEV"
5919 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5920 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5921 error "can't access $DEV"
5922 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5923 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5927 run_test 57a "verify MDS filesystem created with large inodes =="
5930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5931 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5932 skip "ldiskfs only test"
5936 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5937 local dir=$DIR/$tdir
5941 local FILEN=$dir/f$FILECOUNT
5943 rm -rf $dir || error "removing $dir"
5945 local mdtidx=$($LFS getstripe -M $dir)
5946 local mdtname=MDT$(printf %04x $mdtidx)
5947 local facet=mds$((mdtidx + 1))
5949 echo "mcreating $FILECOUNT files"
5950 createmany -m $dir/f 1 $FILECOUNT || \
5951 error "creating files in $dir"
5953 # verify that files do not have EAs yet
5954 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5955 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5959 df $dir #make sure we get new statfs data
5960 local MDSFREE=$(do_facet $facet \
5961 lctl get_param -n osd*.*$mdtname.kbytesfree)
5962 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5963 echo "opening files to create objects/EAs"
5965 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5966 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5969 # verify that files have EAs now
5970 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5971 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5973 sleep 1 #make sure we get new statfs data
5975 local MDSFREE2=$(do_facet $facet \
5976 lctl get_param -n osd*.*$mdtname.kbytesfree)
5977 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5978 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5979 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5980 error "MDC before $MDCFREE != after $MDCFREE2"
5982 echo "MDC before $MDCFREE != after $MDCFREE2"
5983 echo "unable to confirm if MDS has large inodes"
5988 run_test 57b "default LOV EAs are stored inside large inodes ==="
5991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5992 [ -z "$(which wiretest 2>/dev/null)" ] &&
5993 skip_env "could not find wiretest" && return
5996 run_test 58 "verify cross-platform wire constants =============="
5999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6000 echo "touch 130 files"
6001 createmany -o $DIR/f59- 130
6003 unlinkmany $DIR/f59- 130
6005 # wait for commitment of removal
6006 wait_delete_completed
6008 run_test 59 "verify cancellation of llog records async ========="
6010 TEST60_HEAD="test_60 run $RANDOM"
6012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6013 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6014 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6015 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6016 skip_env "missing subtest run-llog.sh" && return
6018 log "$TEST60_HEAD - from kernel mode"
6019 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
6020 do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
6021 do_facet mgs $LCTL dk > $TMP/$tfile
6023 # LU-6388: test llog_reader
6024 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6025 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6026 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6027 skip_env "missing llog_reader" && return
6028 local fstype=$(facet_fstype mgs)
6029 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6030 skip_env "Only for ldiskfs or zfs type mgs" && return
6032 local mntpt=$(facet_mntpt mgs)
6033 local mgsdev=$(mgsdevname 1)
6045 #get fid and record list
6046 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6048 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6050 #remount mgs as ldiskfs or zfs type
6051 stop mgs || error "stop mgs failed"
6052 mount_fstype mgs || error "remount mgs failed"
6053 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6056 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6057 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6062 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6064 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6066 echo "obj_file is $obj_file"
6067 do_facet mgs $llog_reader $obj_file
6069 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6070 awk '{ print $3 }' | sed -e "s/^type=//g")
6071 if [ $rec_type != $rec ]; then
6072 echo "FAILED test_60a wrong record type $rec_type," \
6078 #check obj path if record type is LLOG_LOGID_MAGIC
6079 if [ "$rec" == "1064553b" ]; then
6080 path=$(do_facet mgs $llog_reader $obj_file |
6081 grep "path=" | awk '{ print $NF }' |
6082 sed -e "s/^path=//g")
6083 if [ $obj_file != $mntpt/$path ]; then
6084 echo "FAILED test_60a wrong obj path" \
6085 "$montpt/$path, should be $obj_file"
6092 #restart mgs before "error", otherwise it will block the next test
6093 stop mgs || error "stop mgs failed"
6094 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6095 $pass || error "test failed, see FAILED test_60a messages for specifics"
6097 run_test 60a "llog_test run from kernel module and test llog_reader"
6100 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6102 # test old logid format
6103 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
6104 do_facet mgs $LCTL dl | grep MGS
6105 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
6106 error "old llog_print failed"
6109 # test new logid format
6110 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
6111 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
6112 error "new llog_print failed"
6115 run_test 60aa "llog_print works with FIDs and simple names"
6117 test_60b() { # bug 6411
6118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6120 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6132 [[ $LLOG_COUNT -gt 100 ]] &&
6133 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6135 run_test 60b "limit repeated messages from CERROR/CWARN ========"
6138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6139 echo "create 5000 files"
6140 createmany -o $DIR/f60c- 5000
6141 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6142 lctl set_param fail_loc=0x80000137
6143 unlinkmany $DIR/f60c- 5000
6144 lctl set_param fail_loc=0
6146 run_test 60c "unlink file when mds full"
6149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6150 SAVEPRINTK=$(lctl get_param -n printk)
6152 # verify "lctl mark" is even working"
6153 MESSAGE="test message ID $RANDOM $$"
6154 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6155 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6157 lctl set_param printk=0 || error "set lnet.printk failed"
6158 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6159 MESSAGE="new test message ID $RANDOM $$"
6160 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6161 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6162 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6164 lctl set_param -n printk="$SAVEPRINTK"
6166 run_test 60d "test printk console message masking"
6169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6170 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6172 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6173 do_facet mds1 lctl set_param fail_loc=0x15b
6176 run_test 60e "no space while new llog is being created"
6179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6181 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
6182 cancel_lru_locks osc
6183 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6186 run_test 61 "mmap() writes don't make sync hang ================"
6188 # bug 2330 - insufficient obd_match error checking causes LBUG
6190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6193 cancel_lru_locks osc
6194 lctl set_param fail_loc=0x405
6195 cat $f && error "cat succeeded, expect -EIO"
6196 lctl set_param fail_loc=0
6198 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6199 # match every page all of the time.
6200 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6202 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6203 # Though this test is irrelevant anymore, it helped to reveal some
6204 # other grant bugs (LU-4482), let's keep it.
6205 test_63a() { # was test_63
6206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6207 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
6208 for i in `seq 10` ; do
6209 dd if=/dev/zero of=$DIR/f63 bs=8k &
6215 rm -f $DIR/f63 || true
6217 run_test 63a "Verify oig_wait interruption does not crash ======="
6219 # bug 2248 - async write errors didn't return to application on sync
6220 # bug 3677 - async write errors left page locked
6222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6224 lctl set_param debug=-1
6226 # ensure we have a grant to do async writes
6227 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6230 sync # sync lest earlier test intercept the fail_loc
6232 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6233 lctl set_param fail_loc=0x80000406
6234 $MULTIOP $DIR/$tfile Owy && \
6235 error "sync didn't return ENOMEM"
6236 sync; sleep 2; sync # do a real sync this time to flush page
6237 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6238 error "locked page left in cache after async error" || true
6241 run_test 63b "async write errors should be returned to fsync ==="
6244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6246 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6248 run_test 64a "verify filter grant calculations (in kernel) ====="
6251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6252 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6254 run_test 64b "check out-of-space detection on client"
6257 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6259 run_test 64c "verify grant shrink"
6261 # this does exactly what osc_request.c:osc_announce_cached() does in
6262 # order to calculate max amount of grants to ask from server
6266 local page_size=$(get_page_size client)
6268 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6269 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6271 ((rpc_in_flight ++));
6272 nrpages=$((nrpages * rpc_in_flight))
6274 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6276 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
6278 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6279 local undirty=$((nrpages * page_size))
6281 local max_extent_pages
6282 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6283 grep grant_max_extent_size | awk '{print $2}')
6284 max_extent_pages=$((max_extent_pages / page_size))
6285 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6286 local grant_extent_tax
6287 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6288 grep grant_extent_tax | awk '{print $2}')
6290 undirty=$((undirty + nrextents * grant_extent_tax))
6295 # this is size of unit for grant allocation. It should be equal to
6296 # what tgt_grant.c:tgt_grant_chunk() calculates
6300 local grant_extent_tax
6302 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6303 grep max_brw_size | awk '{print $2}')
6305 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6306 grep grant_extent_tax | awk '{print $2}')
6308 echo $(((max_brw_size + grant_extent_tax) * 2))
6312 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
6313 skip "OST < 2.10.55 doesn't limit grants enough" && return 0
6315 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6316 local file=$DIR/$tfile
6318 [[ $($LCTL get_param osc.${tgt}.import |
6319 grep "connect_flags:.*grant_param") ]] || \
6320 { skip "no grant_param connect flag"; return; }
6322 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6324 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6326 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6327 stack_trap "rm -f $file" EXIT
6329 $SETSTRIPE $file -i 0 -c 1
6330 dd if=/dev/zero of=$file bs=1M count=1000 &
6335 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6336 if [[ $cur_grant -gt $max_cur_granted ]]
6339 error "cur_grant $cur_grant > $max_cur_granted"
6342 [[ $? -ne 0 ]] && break;
6347 wait_delete_completed
6348 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6350 run_test 64d "check grant limit exceed"
6352 # bug 1414 - set/get directories' stripe info
6354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6355 test_mkdir $DIR/$tdir
6357 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6359 run_test 65a "directory with no stripe info"
6362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6363 test_mkdir $DIR/$tdir
6364 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6366 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6369 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6371 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6375 [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
6376 test_mkdir $DIR/$tdir
6377 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
6379 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6380 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6382 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6384 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6388 test_mkdir $DIR/$tdir
6389 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
6390 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6392 if [[ $STRIPECOUNT -le 0 ]]; then
6394 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6395 #LOV_MAX_STRIPE_COUNT is 2000
6396 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6398 sc=$(($STRIPECOUNT - 1))
6400 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6401 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6402 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6403 error "lverify failed"
6405 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6409 test_mkdir $DIR/$tdir
6411 $SETSTRIPE $DIR/$tdir || error "setstripe"
6412 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
6413 error "no stripe info failed"
6415 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6417 run_test 65e "directory setstripe defaults"
6420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6421 test_mkdir $DIR/${tdir}f
6422 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
6424 run_test 65f "dir setstripe permission (should return error) ==="
6427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6428 test_mkdir $DIR/$tdir
6429 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6431 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6432 error "setstripe -S failed"
6433 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6434 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6435 error "delete default stripe failed"
6437 run_test 65g "directory setstripe -d"
6440 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6441 test_mkdir $DIR/$tdir
6442 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6444 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6445 error "setstripe -S failed"
6446 test_mkdir $DIR/$tdir/dd1
6447 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
6448 error "stripe info inherit failed"
6450 run_test 65h "directory stripe info inherit ===================="
6453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6455 save_layout_restore_at_exit $MOUNT
6457 # bug6367: set non-default striping on root directory
6458 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
6460 # bug12836: getstripe on -1 default directory striping
6461 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
6463 # bug12836: getstripe -v on -1 default directory striping
6464 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
6466 # bug12836: new find on -1 default directory striping
6467 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6469 run_test 65i "various tests to set root directory striping"
6471 test_65j() { # bug6367
6472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6476 # if we aren't already remounting for each test, do so for this test
6477 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6478 cleanup || error "failed to unmount"
6482 save_layout_restore_at_exit $MOUNT
6484 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6486 run_test 65j "set default striping on root directory (bug 6367)="
6490 wait_delete_completed
6491 do_facet $SINGLEMDS "lctl set_param -n \
6492 osp.$ost*MDT0000.max_create_count=$max_count"
6493 do_facet $SINGLEMDS "lctl set_param -n \
6494 osp.$ost*MDT0000.create_count=$count"
6495 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6496 echo $INACTIVE_OSC "is Activate"
6498 wait_osc_import_state mds ost$ostnum FULL
6501 test_65k() { # bug11679
6502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6503 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6504 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6506 local disable_precreate=true
6507 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6508 disable_precreate=false
6510 echo "Check OST status: "
6511 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6512 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6514 for OSC in $MDS_OSCS; do
6515 echo $OSC "is active"
6516 do_facet $SINGLEMDS lctl --device %$OSC activate
6519 for INACTIVE_OSC in $MDS_OSCS; do
6520 local ost=$(osc_to_ost $INACTIVE_OSC)
6521 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6522 lov.*md*.target_obd |
6523 awk -F: /$ost/'{ print $1 }' | head -n 1)
6526 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6527 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6529 echo "Deactivate: " $INACTIVE_OSC
6530 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6532 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6533 osp.$ost*MDT0000.create_count")
6534 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6535 osp.$ost*MDT0000.max_create_count")
6536 $disable_precreate &&
6537 do_facet $SINGLEMDS "lctl set_param -n \
6538 osp.$ost*MDT0000.max_create_count=0"
6540 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6541 [ -f $DIR/$tdir/$idx ] && continue
6542 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6543 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6545 error "setstripe $idx should succeed"; }
6546 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6548 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6551 do_facet $SINGLEMDS "lctl set_param -n \
6552 osp.$ost*MDT0000.max_create_count=$max_count"
6553 do_facet $SINGLEMDS "lctl set_param -n \
6554 osp.$ost*MDT0000.create_count=$count"
6555 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6556 echo $INACTIVE_OSC "is Activate"
6558 wait_osc_import_state mds ost$ostnum FULL
6561 run_test 65k "validate manual striping works properly with deactivated OSCs"
6563 test_65l() { # bug 12836
6564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6565 test_mkdir -p $DIR/$tdir/test_dir
6566 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6567 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6569 run_test 65l "lfs find on -1 stripe dir ========================"
6572 local layout=$(save_layout $MOUNT)
6573 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
6574 restore_layout $MOUNT $layout
6575 error "setstripe should fail by non-root users"
6579 run_test 65m "normal user can't set filesystem default stripe"
6581 # bug 2543 - update blocks count on client
6583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6585 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6586 sync; sync_all_data; sync; sync_all_data
6587 cancel_lru_locks osc
6588 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6589 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6591 run_test 66 "update inode blocks count on client ==============="
6594 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6598 swapon -s | awk '($1 == "'$1'") { print $4 }'
6601 # bug5265, obdfilter oa2dentry return -ENOENT
6602 # #define OBD_FAIL_SRV_ENOENT 0x217
6604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6605 remote_ost_nodsh && skip "remote OST with nodsh" && return
6608 $SETSTRIPE -c 1 -i 0 $f
6610 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6612 do_facet ost1 lctl set_param fail_loc=0x217
6613 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6614 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6616 do_facet ost1 lctl set_param fail_loc=0
6617 $DIRECTIO write $f 0 2 || error "write error"
6619 cancel_lru_locks osc
6620 $DIRECTIO read $f 0 1 || error "read error"
6622 do_facet ost1 lctl set_param fail_loc=0x217
6623 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6625 do_facet ost1 lctl set_param fail_loc=0
6628 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6631 test_mkdir $DIR/$tdir
6632 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6633 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6635 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6637 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6639 [ "$RUNAS_ID" = "$UID" ] &&
6640 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6642 # Check that testing environment is properly set up. Skip if not
6643 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6644 skip_env "User $RUNAS_ID does not exist - skipping"
6648 chmod 777 $DIR/$tfile
6649 chmod ug+s $DIR/$tfile
6650 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6651 error "$RUNAS dd $DIR/$tfile failed"
6652 # See if we are still setuid/sgid
6653 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6654 error "S/gid is not dropped on write"
6655 # Now test that MDS is updated too
6656 cancel_lru_locks mdc
6657 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6658 error "S/gid is not dropped on MDS"
6661 run_test 72a "Test that remove suid works properly (bug5695) ===="
6663 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6666 [ "$RUNAS_ID" = "$UID" ] && \
6667 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6668 [ "$RUNAS_ID" -eq 0 ] && \
6669 skip_env "RUNAS_ID = 0 -- skipping" && return
6671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6672 # Check that testing environment is properly set up. Skip if not
6673 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6674 skip_env "User $RUNAS_ID does not exist - skipping"
6677 touch $DIR/${tfile}-f{g,u}
6678 test_mkdir $DIR/${tfile}-dg
6679 test_mkdir $DIR/${tfile}-du
6680 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6681 chmod g+s $DIR/${tfile}-{f,d}g
6682 chmod u+s $DIR/${tfile}-{f,d}u
6683 for perm in 777 2777 4777; do
6684 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6685 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6686 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6687 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6691 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6693 # bug 3462 - multiple simultaneous MDC requests
6695 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6696 test_mkdir $DIR/d73-1
6697 test_mkdir $DIR/d73-2
6698 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6701 lctl set_param fail_loc=0x80000129
6702 $MULTIOP $DIR/d73-1/f73-2 Oc &
6704 lctl set_param fail_loc=0
6706 $MULTIOP $DIR/d73-2/f73-3 Oc &
6710 wait $pid1 || return 1
6714 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6715 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6716 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6720 run_test 73 "multiple MDC requests (should not deadlock)"
6722 test_74a() { # bug 6149, 6184
6723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6724 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6726 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6727 # will spin in a tight reconnection loop
6729 $LCTL set_param fail_loc=0x8000030e
6730 # get any lock that won't be difficult - lookup works.
6732 $LCTL set_param fail_loc=0
6736 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6738 test_74b() { # bug 13310
6739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6740 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6742 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6743 # will spin in a tight reconnection loop
6744 $LCTL set_param fail_loc=0x8000030e
6745 # get a "difficult" lock
6747 $LCTL set_param fail_loc=0
6751 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6755 #define OBD_FAIL_LDLM_NEW_LOCK
6756 $LCTL set_param fail_loc=0x319
6757 touch $DIR/$tfile && error "touch successful"
6758 $LCTL set_param fail_loc=0
6761 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6764 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6767 test_76() { # Now for bug 20433, added originally in bug 1443
6768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6769 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6770 cancel_lru_locks osc
6771 BEFORE_INODES=$(num_inodes)
6772 echo "before inodes: $BEFORE_INODES"
6774 [ "$SLOW" = "no" ] && COUNT=100
6775 for i in $(seq $COUNT); do
6779 cancel_lru_locks osc
6780 AFTER_INODES=$(num_inodes)
6781 echo "after inodes: $AFTER_INODES"
6783 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6785 AFTER_INODES=$(num_inodes)
6787 echo "wait $wait seconds inodes: $AFTER_INODES"
6788 if [ $wait -gt 30 ]; then
6789 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6793 run_test 76 "confirm clients recycle inodes properly ===="
6799 # Note: in sptlrpc modes which enable its own bulk checksum, the
6800 # original crc32_le bulk checksum will be automatically disabled,
6801 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6802 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6803 # In this case set_checksums() will not be no-op, because sptlrpc
6804 # bulk checksum will be enabled all through the test.
6806 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6807 lctl set_param -n osc.*.checksums $1
6811 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6812 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6813 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6814 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6817 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6818 log "set checksum type to $1"
6821 F77_TMP=$TMP/f77-temp
6824 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6825 error "error writing to $F77_TMP"
6828 test_77a() { # bug 10889
6829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6830 $GSS && skip "could not run with gss" && return
6831 [ ! -f $F77_TMP ] && setup_f77
6833 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6837 run_test 77a "normal checksum read/write operation"
6839 test_77b() { # bug 10889
6840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6841 $GSS && skip "could not run with gss" && return
6842 [ ! -f $F77_TMP ] && setup_f77
6843 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6844 $LCTL set_param fail_loc=0x80000409
6847 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6848 error "dd error: $?"
6849 $LCTL set_param fail_loc=0
6851 for algo in $CKSUM_TYPES; do
6852 cancel_lru_locks osc
6853 set_checksum_type $algo
6854 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6855 $LCTL set_param fail_loc=0x80000408
6856 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6857 $LCTL set_param fail_loc=0
6860 set_checksum_type $ORIG_CSUM_TYPE
6863 run_test 77b "checksum error on client write, read"
6868 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6870 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6871 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6872 $check_ost && [ -n $ost_file_prefix ] &&
6873 do_facet ost1 rm -f ${ost_file_prefix}\*
6877 remote_ost_nodsh && skip "remote OST with nodsh" && return
6879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6880 $GSS && skip "could not run with gss" && return
6883 local osc_file_prefix
6885 local check_ost=false
6886 local ost_file_prefix
6892 # ensure corruption will occur on first OSS/OST
6893 $LFS setstripe -i 0 $DIR/$tfile
6895 [ ! -f $F77_TMP ] && setup_f77
6896 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6897 error "dd write error: $?"
6898 fid=$($LFS path2fid $DIR/$tfile)
6900 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6903 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6904 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6906 echo "OSS do not support bulk pages dump upon error"
6909 osc_file_prefix=$($LCTL get_param -n debug_path)
6910 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6912 trap cleanup_77c EXIT
6915 # enable bulk pages dump upon error on Client
6916 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6917 # enable bulk pages dump upon error on OSS
6919 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6921 # flush Client cache to allow next read to reach OSS
6922 cancel_lru_locks osc
6924 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6925 $LCTL set_param fail_loc=0x80000408
6926 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6927 $LCTL set_param fail_loc=0
6931 # check cksum dump on Client
6932 osc_file=$(ls ${osc_file_prefix}*)
6933 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6934 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6935 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6936 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6937 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6939 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6940 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6941 error "dump content does not match on Client"
6943 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6945 # check cksum dump on OSS
6946 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6947 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6948 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6949 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6950 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6951 error "dump content does not match on OSS"
6955 run_test 77c "checksum error on client read with debug"
6957 test_77d() { # bug 10889
6958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6959 $GSS && skip "could not run with gss" && return
6960 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6961 $LCTL set_param fail_loc=0x80000409
6963 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6964 error "direct write: rc=$?"
6965 $LCTL set_param fail_loc=0
6968 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6969 $LCTL set_param fail_loc=0x80000408
6971 cancel_lru_locks osc
6972 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6973 error "direct read: rc=$?"
6974 $LCTL set_param fail_loc=0
6977 run_test 77d "checksum error on OST direct write, read"
6979 test_77f() { # bug 10889
6980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6981 $GSS && skip "could not run with gss" && return
6983 for algo in $CKSUM_TYPES; do
6984 cancel_lru_locks osc
6985 set_checksum_type $algo
6986 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6987 $LCTL set_param fail_loc=0x409
6988 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6989 error "direct write succeeded"
6990 $LCTL set_param fail_loc=0
6992 set_checksum_type $ORIG_CSUM_TYPE
6995 run_test 77f "repeat checksum error on write (expect error)"
6997 test_77g() { # bug 10889
6998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6999 $GSS && skip "could not run with gss" && return
7000 remote_ost_nodsh && skip "remote OST with nodsh" && return
7002 [ ! -f $F77_TMP ] && setup_f77
7004 local file=$DIR/$tfile
7005 stack_trap "rm -f $file" EXIT
7007 $SETSTRIPE -c 1 -i 0 $file
7008 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7009 do_facet ost1 lctl set_param fail_loc=0x8000021a
7011 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7012 error "write error: rc=$?"
7013 do_facet ost1 lctl set_param fail_loc=0
7016 cancel_lru_locks osc
7017 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7018 do_facet ost1 lctl set_param fail_loc=0x8000021b
7020 cmp $F77_TMP $file || error "file compare failed"
7021 do_facet ost1 lctl set_param fail_loc=0
7024 run_test 77g "checksum error on OST write, read"
7026 test_77j() { # bug 13805
7027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7028 $GSS && skip "could not run with gss" && return
7029 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
7030 lctl set_param fail_loc=0x40c
7031 remount_client $MOUNT
7032 lctl set_param fail_loc=0
7033 # wait async osc connect to finish and reflect updated state value
7035 for (( i=0; i < OSTCOUNT; i++ )) ; do
7036 wait_osc_import_state client ost$((i+1)) FULL
7039 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
7040 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7041 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
7042 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
7044 remount_client $MOUNT
7046 run_test 77j "client only supporting ADLER32"
7048 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7057 test_78() { # bug 10901
7058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7059 remote_ost || { skip_env "local OST" && return; }
7062 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7063 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7064 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7065 echo "MemTotal: $MEMTOTAL"
7067 # reserve 256MB of memory for the kernel and other running processes,
7068 # and then take 1/2 of the remaining memory for the read/write buffers.
7069 if [ $MEMTOTAL -gt 512 ] ;then
7070 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7072 # for those poor memory-starved high-end clusters...
7073 MEMTOTAL=$((MEMTOTAL / 2))
7075 echo "Mem to use for directio: $MEMTOTAL"
7077 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7078 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7079 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7080 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7082 echo "Smallest OST: $SMALLESTOST"
7083 [[ $SMALLESTOST -lt 10240 ]] &&
7084 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
7086 trap cleanup_test_78 EXIT
7088 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7089 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7091 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7092 echo "File size: $F78SIZE"
7093 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7094 for i in $(seq 1 $NSEQ); do
7095 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7096 echo directIO rdwr round $i of $NSEQ
7097 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7102 run_test 78 "handle large O_DIRECT writes correctly ============"
7104 test_79() { # bug 12743
7105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7106 wait_delete_completed
7108 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7109 BKFREE=$(calc_osc_kbytes kbytesfree)
7110 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7112 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7113 DFTOTAL=`echo $STRING | cut -d, -f1`
7114 DFUSED=`echo $STRING | cut -d, -f2`
7115 DFAVAIL=`echo $STRING | cut -d, -f3`
7116 DFFREE=$(($DFTOTAL - $DFUSED))
7118 ALLOWANCE=$((64 * $OSTCOUNT))
7120 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7121 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7122 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7124 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7125 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7126 error "df free($DFFREE) mismatch OST free($BKFREE)"
7128 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7129 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7130 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7133 run_test 79 "df report consistency check ======================="
7135 test_80() { # bug 10718
7136 remote_ost_nodsh && skip "remote OST with nodsh" && return
7137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7138 # relax strong synchronous semantics for slow backends like ZFS
7139 local soc="obdfilter.*.sync_on_lock_cancel"
7140 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7142 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
7143 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7144 facet_active_host $host; done | sort -u)
7145 do_nodes $hosts lctl set_param $soc=never
7148 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7150 local BEFORE=`date +%s`
7151 cancel_lru_locks osc
7152 local AFTER=`date +%s`
7153 local DIFF=$((AFTER-BEFORE))
7154 if [ $DIFF -gt 1 ] ; then
7155 error "elapsed for 1M@1T = $DIFF"
7158 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7162 run_test 80 "Page eviction is equally fast at high offsets too ===="
7164 test_81a() { # LU-456
7165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7166 remote_ost_nodsh && skip "remote OST with nodsh" && return
7167 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7168 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7169 do_facet ost1 lctl set_param fail_loc=0x80000228
7171 # write should trigger a retry and success
7172 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7173 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7175 if [ $RC -ne 0 ] ; then
7176 error "write should success, but failed for $RC"
7179 run_test 81a "OST should retry write when get -ENOSPC ==============="
7181 test_81b() { # LU-456
7182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7183 remote_ost_nodsh && skip "remote OST with nodsh" && return
7184 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7185 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7186 do_facet ost1 lctl set_param fail_loc=0x228
7188 # write should retry several times and return -ENOSPC finally
7189 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7190 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7193 if [ $RC -ne $ENOSPC ] ; then
7194 error "dd should fail for -ENOSPC, but succeed."
7197 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7199 test_82() { # LU-1031
7200 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7204 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7206 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7208 kill -USR1 $MULTIPID2
7210 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7211 error "First grouplock does not block second one"
7213 echo "Second grouplock blocks first one"
7215 kill -USR1 $MULTIPID1
7219 run_test 82 "Basic grouplock test"
7222 local sfile="/boot/System.map-$(uname -r)"
7223 [ ! -f $sfile ] && skip "No $sfile found" && return
7224 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
7225 $LCTL set_param fail_loc=0x140d
7226 cp $sfile $DIR/$tfile || error "write failed"
7227 diff -c $sfile $DIR/$tfile || error "files are different"
7228 $LCTL set_param fail_loc=0
7231 run_test 83 "Short write in ptask ==============================="
7234 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
7236 test_mkdir $DIR/$tdir.cvsroot
7237 chown $RUNAS_ID $DIR/$tdir.cvsroot
7240 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7243 # some versions of cvs import exit(1) when asked to import links or
7244 # files they can't read. ignore those files.
7245 local toignore=$(find . -type l -printf '-I %f\n' -o \
7246 ! -perm /4 -printf '-I %f\n')
7247 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7248 $tdir.reposname vtag rtag
7251 test_mkdir $DIR/$tdir.reposname
7252 chown $RUNAS_ID $DIR/$tdir.reposname
7253 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7255 cd $DIR/$tdir.reposname
7257 $RUNAS cvs add -m 'addmsg' foo99
7259 $RUNAS cvs commit -m 'nomsg' foo99
7260 rm -fr $DIR/$tdir.cvsroot
7262 run_test 99 "cvs strange file/directory operations"
7265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7266 [[ "$NETTYPE" =~ tcp ]] ||
7267 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
7270 remote_ost_nodsh && skip "remote OST with nodsh" && return
7271 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7273 { skip "useless for local single node setup" && return; }
7275 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7276 [ "$PROT" != "tcp" ] && continue
7277 RPORT=$(echo $REMOTE | cut -d: -f2)
7278 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7281 LPORT=`echo $LOCAL | cut -d: -f2`
7282 if [ $LPORT -ge 1024 ]; then
7283 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7285 error_exit "local: $LPORT > 1024, remote: $RPORT"
7288 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7290 run_test 100 "check local port using privileged port ==========="
7292 function get_named_value()
7301 echo $line | sed "s/^$tag[ ]*//"
7308 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7309 awk '/^max_cached_mb/ { print $2 }')
7312 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7318 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
7322 local cache_limit=32
7324 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7325 trap cleanup_101a EXIT
7326 $LCTL set_param -n llite.*.read_ahead_stats 0
7327 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7330 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7332 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7333 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7336 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7337 get_named_value 'read but discarded' | cut -d" " -f1); do
7338 discard=$(($discard + $s))
7342 if [[ $(($discard * 10)) -gt $nreads ]]; then
7343 $LCTL get_param osc.*-osc*.rpc_stats
7344 $LCTL get_param llite.*.read_ahead_stats
7345 error "too many ($discard) discarded pages"
7347 rm -f $DIR/$tfile || true
7349 run_test 101a "check read-ahead for random reads"
7352 test_mkdir $DIR/$tdir
7353 local STRIPE_SIZE=$1
7354 local FILE_LENGTH=$2
7357 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
7359 local list=$(comma_list $(osts_nodes))
7360 set_osd_param $list '' read_cache_enable 0
7361 set_osd_param $list '' writethrough_cache_enable 0
7363 trap cleanup_test101bc EXIT
7364 # prepare the read-ahead file
7365 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7367 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
7368 count=$FILE_SIZE_MB 2> /dev/null
7372 cleanup_test101bc() {
7377 local list=$(comma_list $(osts_nodes))
7378 set_osd_param $list '' read_cache_enable 1
7379 set_osd_param $list '' writethrough_cache_enable 1
7383 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7388 local STRIPE_SIZE=$2
7389 local FILE_LENGTH=$3
7390 local RA_INC=1048576
7391 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7392 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7393 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7394 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7395 get_named_value 'read but discarded' |
7396 cut -d" " -f1 | calc_total)
7397 if [[ $DISCARD -gt $discard_limit ]]; then
7398 $LCTL get_param llite.*.read_ahead_stats
7399 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7401 echo "Read-ahead success for size ${READ_SIZE}"
7406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7407 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7408 local STRIPE_SIZE=1048576
7409 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7410 if [ $SLOW == "yes" ]; then
7411 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7413 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7416 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7418 # prepare the read-ahead file
7419 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7420 cancel_lru_locks osc
7421 for BIDX in 2 4 8 16 32 64 128 256
7423 local BSIZE=$((BIDX*4096))
7424 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7425 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7426 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7427 $LCTL set_param -n llite.*.read_ahead_stats 0
7428 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7429 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7430 cancel_lru_locks osc
7431 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7436 run_test 101b "check stride-io mode read-ahead ================="
7439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7440 local STRIPE_SIZE=1048576
7441 local FILE_LENGTH=$((STRIPE_SIZE*100))
7445 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7447 cancel_lru_locks osc
7448 $LCTL set_param osc.*.rpc_stats 0
7449 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7450 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7451 local stats=$($LCTL get_param -n $osc_rpc_stats)
7452 local lines=$(echo "$stats" | awk 'END {print NR;}')
7455 if [ $lines -le 20 ]; then
7458 for size in 1 2 4 8; do
7459 local rpc=$(echo "$stats" |
7460 awk '($1 == "'$size':") {print $2; exit; }')
7462 error "Small $((size*4))k read IO $rpc !"
7464 echo "$osc_rpc_stats check passed!"
7469 run_test 101c "check stripe_size aligned read-ahead ================="
7472 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7473 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7478 local file=$DIR/$tfile
7479 local sz_MB=${FILESIZE_101d:-500}
7480 local ra_MB=${READAHEAD_MB:-40}
7482 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7483 [ $free_MB -lt $sz_MB ] &&
7484 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
7486 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7487 $SETSTRIPE -c -1 $file || error "setstripe failed"
7489 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7490 echo Cancel LRU locks on lustre client to flush the client cache
7491 cancel_lru_locks osc
7493 echo Disable read-ahead
7494 local old_READAHEAD=$(set_read_ahead 0)
7496 echo Reading the test file $file with read-ahead disabled
7497 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7499 echo Cancel LRU locks on lustre client to flush the client cache
7500 cancel_lru_locks osc
7501 echo Enable read-ahead with ${ra_MB}MB
7502 set_read_ahead $ra_MB
7504 echo Reading the test file $file with read-ahead enabled
7505 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7507 echo "read-ahead disabled time read $raOFF"
7508 echo "read-ahead enabled time read $raON"
7510 set_read_ahead $old_READAHEAD
7512 wait_delete_completed
7514 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7515 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7517 run_test 101d "file read with and without read-ahead enabled"
7520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7521 local file=$DIR/$tfile
7522 local size_KB=500 #KB
7526 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7527 local need_KB=$((count * size_KB))
7528 [[ $free_KB -le $need_KB ]] &&
7529 skip_env "Need free space $need_KB, have $free_KB" && return
7531 echo "Creating $count ${size_KB}K test files"
7532 for ((i = 0; i < $count; i++)); do
7533 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7536 echo "Cancel LRU locks on lustre client to flush the client cache"
7537 cancel_lru_locks $OSC
7539 echo "Reset readahead stats"
7540 $LCTL set_param -n llite.*.read_ahead_stats 0
7542 for ((i = 0; i < $count; i++)); do
7543 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7546 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7547 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7549 for ((i = 0; i < $count; i++)); do
7550 rm -rf $file.$i 2>/dev/null
7553 #10000 means 20% reads are missing in readahead
7554 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7556 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7559 which iozone || { skip "no iozone installed" && return; }
7561 local old_debug=$($LCTL get_param debug)
7562 old_debug=${old_debug#*=}
7563 $LCTL set_param debug="reada mmap"
7565 # create a test file
7566 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7568 echo Cancel LRU locks on lustre client to flush the client cache
7569 cancel_lru_locks osc
7571 echo Reset readahead stats
7572 $LCTL set_param -n llite.*.read_ahead_stats 0
7574 echo mmap read the file with small block size
7575 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7578 echo checking missing pages
7579 $LCTL get_param llite.*.read_ahead_stats
7580 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7581 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7583 $LCTL set_param debug="$old_debug"
7584 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7587 run_test 101f "check mmap read performance"
7589 test_101g_brw_size_test() {
7591 local pages=$((mb * 1048576 / $(page_size)))
7592 local file=$DIR/$tfile
7594 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7595 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7596 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7597 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7601 stack_trap "rm -f $file" EXIT
7602 $LCTL set_param -n osc.*.rpc_stats=0
7604 # 10 RPCs should be enough for the test
7606 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
7607 { error "dd write ${mb} MB blocks failed"; return 3; }
7608 cancel_lru_locks osc
7609 dd of=/dev/null if=$file bs=${mb}M count=$count ||
7610 { error "dd write ${mb} MB blocks failed"; return 4; }
7612 # calculate number of full-sized read and write RPCs
7613 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7614 sed -n '/pages per rpc/,/^$/p' |
7615 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7616 END { print reads,writes }'))
7617 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7619 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7626 remote_ost_nodsh && skip "remote OST with nodsh" && return
7629 local osts=$(get_facets OST)
7630 local list=$(comma_list $(osts_nodes))
7631 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7632 local brw_size="obdfilter.*.brw_size"
7633 local ostver=$(lustre_version_code ost1)
7634 local cliver=$(lustre_version_code client)
7636 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7638 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7639 if [ $ostver -ge $(version_code 2.8.52) -o \
7640 \( $ostver -ge $(version_code 2.7.17) -a \
7641 $ostver -lt $(version_code 2.7.50) \) ] &&
7642 [ $cliver -ge $(version_code 2.8.52) -o \
7643 \( $cliver -ge $(version_code 2.7.17) -a \
7644 $cliver -lt $(version_code 2.7.50) \) ]; then
7645 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7646 if [[ $orig_mb -lt 16 ]]; then
7647 save_lustre_params $osts "$brw_size" > $p
7648 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7649 error "set 16MB RPC size failed"
7651 echo "remount client to enable new RPC size"
7652 remount_client $MOUNT || error "remount_client failed"
7655 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7656 # should be able to set brw_size=12, but no rpc_stats for that
7657 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7660 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7662 if [[ $orig_mb -lt 16 ]]; then
7663 restore_lustre_params < $p
7664 remount_client $MOUNT || error "remount_client restore failed"
7667 rm -f $p $DIR/$tfile
7669 run_test 101g "Big bulk(4/16 MiB) readahead"
7672 test_mkdir $DIR/$tdir
7673 chown $RUNAS_ID $DIR/$tdir
7676 STRIPE_COUNT=$OSTCOUNT
7677 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7679 trap cleanup_test102 EXIT
7681 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7683 for num in 1 2 3 4; do
7684 for count in $(seq 1 $STRIPE_COUNT); do
7685 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7686 local size=`expr $STRIPE_SIZE \* $num`
7687 local file=file"$num-$idx-$count"
7688 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7694 $1 tar cf $TMP/f102.tar $tdir --xattrs
7700 rm -rf $DIR/d0.sanity/d102
7704 local testfile=$DIR/$tfile
7708 [ "$UID" != 0 ] && skip_env "must run as root" && return
7709 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7710 skip_env "must have user_xattr" && return
7712 [ -z "$(which setfattr 2>/dev/null)" ] &&
7713 skip_env "could not find setfattr" && return
7715 echo "set/get xattr..."
7716 setfattr -n trusted.name1 -v value1 $testfile ||
7717 error "setfattr -n trusted.name1=value1 $testfile failed"
7718 getfattr -n trusted.name1 $testfile 2> /dev/null |
7719 grep "trusted.name1=.value1" ||
7720 error "$testfile missing trusted.name1=value1"
7722 setfattr -n user.author1 -v author1 $testfile ||
7723 error "setfattr -n user.author1=author1 $testfile failed"
7724 getfattr -n user.author1 $testfile 2> /dev/null |
7725 grep "user.author1=.author1" ||
7726 error "$testfile missing trusted.author1=author1"
7729 setfattr -n trusted.name2 -v value2 $testfile ||
7730 error "$testfile unable to set trusted.name2"
7731 setfattr -n trusted.name3 -v value3 $testfile ||
7732 error "$testfile unable to set trusted.name3"
7733 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7734 grep "trusted.name" | wc -l) -eq 3 ] ||
7735 error "$testfile missing 3 trusted.name xattrs"
7737 setfattr -n user.author2 -v author2 $testfile ||
7738 error "$testfile unable to set user.author2"
7739 setfattr -n user.author3 -v author3 $testfile ||
7740 error "$testfile unable to set user.author3"
7741 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7742 grep "user.author" | wc -l) -eq 3 ] ||
7743 error "$testfile missing 3 user.author xattrs"
7745 echo "remove xattr..."
7746 setfattr -x trusted.name1 $testfile ||
7747 error "$testfile error deleting trusted.name1"
7748 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7749 error "$testfile did not delete trusted.name1 xattr"
7751 setfattr -x user.author1 $testfile ||
7752 error "$testfile error deleting user.author1"
7753 echo "set lustre special xattr ..."
7754 $LFS setstripe -c1 $testfile
7755 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7756 awk -F "=" '/trusted.lov/ { print $2 }' )
7757 setfattr -n "trusted.lov" -v $lovea $testfile ||
7758 error "$testfile doesn't ignore setting trusted.lov again"
7759 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7760 error "$testfile allow setting invalid trusted.lov"
7763 run_test 102a "user xattr test =================================="
7766 [ -z "$(which setfattr 2>/dev/null)" ] &&
7767 skip_env "could not find setfattr" && return
7769 # b10930: get/set/list trusted.lov xattr
7770 echo "get/set/list trusted.lov xattr ..."
7771 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7772 local testfile=$DIR/$tfile
7773 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7774 error "setstripe failed"
7775 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7776 error "getstripe failed"
7777 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7778 error "can't get trusted.lov from $testfile"
7780 local testfile2=${testfile}2
7781 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7782 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7785 setfattr -n trusted.lov -v $value $testfile2
7786 local stripe_size=$($GETSTRIPE -S $testfile2)
7787 local stripe_count=$($GETSTRIPE -c $testfile2)
7788 [[ $stripe_size -eq 65536 ]] ||
7789 error "stripe size $stripe_size != 65536"
7790 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7791 error "stripe count $stripe_count != $STRIPECOUNT"
7794 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7797 [ -z "$(which setfattr 2>/dev/null)" ] &&
7798 skip_env "could not find setfattr" && return
7800 # b10930: get/set/list lustre.lov xattr
7801 echo "get/set/list lustre.lov xattr ..."
7802 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7803 test_mkdir $DIR/$tdir
7804 chown $RUNAS_ID $DIR/$tdir
7805 local testfile=$DIR/$tdir/$tfile
7806 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7807 error "setstripe failed"
7808 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7809 error "getstripe failed"
7810 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7811 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7813 local testfile2=${testfile}2
7814 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7815 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7817 $RUNAS $MCREATE $testfile2
7818 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7819 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7820 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7821 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7822 [ $stripe_count -eq $STRIPECOUNT ] ||
7823 error "stripe count $stripe_count != $STRIPECOUNT"
7825 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7827 compare_stripe_info1() {
7828 local stripe_index_all_zero=true
7830 for num in 1 2 3 4; do
7831 for count in $(seq 1 $STRIPE_COUNT); do
7832 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7833 local size=$((STRIPE_SIZE * num))
7834 local file=file"$num-$offset-$count"
7835 stripe_size=$($LFS getstripe -S $PWD/$file)
7836 [[ $stripe_size -ne $size ]] &&
7837 error "$file: size $stripe_size != $size"
7838 stripe_count=$($LFS getstripe -c $PWD/$file)
7839 # allow fewer stripes to be created, ORI-601
7840 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7841 error "$file: count $stripe_count != $count"
7842 stripe_index=$($LFS getstripe -i $PWD/$file)
7843 [[ $stripe_index -ne 0 ]] &&
7844 stripe_index_all_zero=false
7848 $stripe_index_all_zero &&
7849 error "all files are being extracted starting from OST index 0"
7853 have_xattrs_include() {
7854 tar --help | grep -q xattrs-include &&
7855 echo --xattrs-include="lustre.*"
7859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7860 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7861 XINC=$(have_xattrs_include)
7863 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7865 compare_stripe_info1
7867 run_test 102d "tar restore stripe info from tarfile,not keep osts"
7870 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7871 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7872 XINC=$(have_xattrs_include)
7874 test_mkdir $DIR/$tdir.restore
7876 tar cf - --xattrs $tdir | tar xf - \
7877 -C $DIR/$tdir.restore --xattrs $XINC
7878 cd $DIR/$tdir.restore/$tdir
7879 compare_stripe_info1
7881 run_test 102f "tar copy files, not keep osts"
7884 local xsize=${1:-1024} # in bytes
7885 local file=$DIR/$tfile
7887 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7888 skip "must have user_xattr" && return 0
7889 [ -z "$(which setfattr 2>/dev/null)" ] &&
7890 skip_env "could not find setfattr" && return 0
7891 [ -z "$(which getfattr 2>/dev/null)" ] &&
7892 skip_env "could not find getfattr" && return 0
7896 local value="$(generate_string $xsize)"
7898 local xbig=trusted.big
7899 log "save $xbig on $file"
7900 setfattr -n $xbig -v $value $file ||
7901 error "saving $xbig on $file failed"
7903 local orig=$(get_xattr_value $xbig $file)
7904 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7906 local xsml=trusted.sml
7907 log "save $xsml on $file"
7908 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7910 local new=$(get_xattr_value $xbig $file)
7911 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7913 log "grow $xsml on $file"
7914 setfattr -n $xsml -v "$value" $file ||
7915 error "growing $xsml on $file failed"
7917 new=$(get_xattr_value $xbig $file)
7918 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7919 log "$xbig still valid after growing $xsml"
7924 test_102h() { # bug 15777
7927 run_test 102h "grow xattr from inside inode to external block"
7930 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7931 grow_xattr $(max_xattr_size)
7933 run_test 102ha "grow xattr from inside inode to external inode"
7935 test_102i() { # bug 17038
7936 [ -z "$(which getfattr 2>/dev/null)" ] &&
7937 skip "could not find getfattr" && return
7939 ln -s $DIR/$tfile $DIR/${tfile}link
7940 getfattr -n trusted.lov $DIR/$tfile ||
7941 error "lgetxattr on $DIR/$tfile failed"
7942 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7943 grep -i "no such attr" ||
7944 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7945 rm -f $DIR/$tfile $DIR/${tfile}link
7947 run_test 102i "lgetxattr test on symbolic link ============"
7950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7951 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7952 XINC=$(have_xattrs_include)
7953 setup_test102 "$RUNAS"
7954 chown $RUNAS_ID $DIR/$tdir
7955 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7957 compare_stripe_info1 "$RUNAS"
7959 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7962 [ -z "$(which setfattr 2>/dev/null)" ] &&
7963 skip "could not find setfattr" && return
7965 # b22187 just check that does not crash for regular file.
7966 setfattr -n trusted.lov $DIR/$tfile
7967 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
7968 local test_kdir=$DIR/$tdir
7969 test_mkdir $test_kdir
7970 local default_size=$($LFS getstripe -S $test_kdir)
7971 local default_count=$($LFS getstripe -c $test_kdir)
7972 local default_offset=$($LFS getstripe -i $test_kdir)
7973 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7974 error 'dir setstripe failed'
7975 setfattr -n trusted.lov $test_kdir
7976 local stripe_size=$($LFS getstripe -S $test_kdir)
7977 local stripe_count=$($LFS getstripe -c $test_kdir)
7978 local stripe_offset=$($LFS getstripe -i $test_kdir)
7979 [ $stripe_size -eq $default_size ] ||
7980 error "stripe size $stripe_size != $default_size"
7981 [ $stripe_count -eq $default_count ] ||
7982 error "stripe count $stripe_count != $default_count"
7983 [ $stripe_offset -eq $default_offset ] ||
7984 error "stripe offset $stripe_offset != $default_offset"
7985 rm -rf $DIR/$tfile $test_kdir
7987 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7990 [ -z "$(which getfattr 2>/dev/null)" ] &&
7991 skip "could not find getfattr" && return
7993 # LU-532 trusted. xattr is invisible to non-root
7994 local testfile=$DIR/$tfile
7998 echo "listxattr as user..."
7999 chown $RUNAS_ID $testfile
8000 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8001 grep -q "trusted" &&
8002 error "$testfile trusted xattrs are user visible"
8006 run_test 102l "listxattr size test =================================="
8008 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8009 local path=$DIR/$tfile
8012 listxattr_size_check $path || error "listattr_size_check $path failed"
8014 run_test 102m "Ensure listxattr fails on small bufffer ========"
8018 getxattr() { # getxattr path name
8019 # Return the base64 encoding of the value of xattr name on path.
8023 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8025 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8027 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8029 getfattr --absolute-names --encoding=base64 --name=$name $path |
8030 awk -F= -v name=$name '$1 == name {
8031 print substr($0, index($0, "=") + 1);
8035 test_102n() { # LU-4101 mdt: protect internal xattrs
8036 [ -z "$(which setfattr 2>/dev/null)" ] &&
8037 skip "could not find setfattr" && return
8038 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
8040 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8044 local file0=$DIR/$tfile.0
8045 local file1=$DIR/$tfile.1
8046 local xattr0=$TMP/$tfile.0
8047 local xattr1=$TMP/$tfile.1
8048 local namelist="lov lma lmv link fid version som hsm"
8052 rm -rf $file0 $file1 $xattr0 $xattr1
8055 # Get 'before' xattrs of $file1.
8056 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8058 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
8059 namelist+=" lfsck_namespace"
8060 for name in $namelist; do
8061 # Try to copy xattr from $file0 to $file1.
8062 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8064 setfattr --name=trusted.$name --value="$value" $file1 ||
8065 error "setxattr 'trusted.$name' failed"
8067 # Try to set a garbage xattr.
8068 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8070 if [[ x$name == "xlov" ]]; then
8071 setfattr --name=trusted.lov --value="$value" $file1 &&
8072 error "setxattr invalid 'trusted.lov' success"
8074 setfattr --name=trusted.$name --value="$value" $file1 ||
8075 error "setxattr invalid 'trusted.$name' failed"
8078 # Try to remove the xattr from $file1. We don't care if this
8079 # appears to succeed or fail, we just don't want there to be
8080 # any changes or crashes.
8081 setfattr --remove=$trusted.$name $file1 2> /dev/null
8084 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
8087 # Try to copy xattr from $file0 to $file1.
8088 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8090 setfattr --name=trusted.$name --value="$value" $file1 ||
8091 error "setxattr 'trusted.$name' failed"
8093 # Try to set a garbage xattr.
8094 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8096 setfattr --name=trusted.$name --value="$value" $file1 ||
8097 error "setxattr 'trusted.$name' failed"
8099 # Try to remove the xattr from $file1. We don't care if this
8100 # appears to succeed or fail, we just don't want there to be
8101 # any changes or crashes.
8102 setfattr --remove=$trusted.$name $file1 2> /dev/null
8105 # Get 'after' xattrs of file1.
8106 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8108 if ! diff $xattr0 $xattr1; then
8109 error "before and after xattrs of '$file1' differ"
8112 rm -rf $file0 $file1 $xattr0 $xattr1
8116 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8118 test_102p() { # LU-4703 setxattr did not check ownership
8119 local testfile=$DIR/$tfile
8121 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
8122 skip "MDS needs to be at least 2.5.56" && return
8126 echo "setfacl as user..."
8127 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8128 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8130 echo "setfattr as user..."
8131 setfacl -m "u:$RUNAS_ID:---" $testfile
8132 $RUNAS setfattr -x system.posix_acl_access $testfile
8133 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8135 run_test 102p "check setxattr(2) correctly fails without permission"
8138 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
8139 skip "MDS needs to be at least 2.6.92" && return
8140 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8142 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8145 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
8146 skip "MDS needs to be at least 2.6.93" && return
8147 touch $DIR/$tfile || error "touch"
8148 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8149 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8150 rm $DIR/$tfile || error "rm"
8153 mkdir -p $DIR/$tdir || error "mkdir"
8154 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8155 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8156 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8157 error "$testfile error deleting user.author1"
8158 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8159 grep "user.$(basename $tdir)" &&
8160 error "$tdir did not delete user.$(basename $tdir)"
8161 rmdir $DIR/$tdir || error "rmdir"
8164 test_mkdir $DIR/$tdir
8165 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8166 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8167 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8168 error "$testfile error deleting user.author1"
8169 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8170 grep "user.$(basename $tdir)" &&
8171 error "$tdir did not delete user.$(basename $tdir)"
8172 rmdir $DIR/$tdir || error "rm striped dir"
8174 run_test 102r "set EAs with empty values"
8178 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8183 [ "$UID" != 0 ] && skip_env "must run as root" && return
8184 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8185 skip "must have acl enabled" && return
8186 [ -z "$(which setfacl 2>/dev/null)" ] &&
8187 skip_env "could not find setfacl" && return
8188 $GSS && skip "could not run under gss" && return
8189 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8191 gpasswd -a daemon bin # LU-5641
8192 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8194 declare -a identity_old
8196 for num in $(seq $MDSCOUNT); do
8197 switch_identity $num true || identity_old[$num]=$?
8205 echo "performing cp ..."
8206 run_acl_subtest cp || error "run_acl_subtest cp failed"
8207 echo "performing getfacl-noacl..."
8208 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8209 echo "performing misc..."
8210 run_acl_subtest misc || error "misc test failed"
8211 echo "performing permissions..."
8212 run_acl_subtest permissions || error "permissions failed"
8213 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8214 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
8215 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
8216 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
8218 echo "performing permissions xattr..."
8219 run_acl_subtest permissions_xattr ||
8220 error "permissions_xattr failed"
8222 echo "performing setfacl..."
8223 run_acl_subtest setfacl || error "setfacl test failed"
8225 # inheritance test got from HP
8226 echo "performing inheritance..."
8227 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8228 chmod +x make-tree || error "chmod +x failed"
8229 run_acl_subtest inheritance || error "inheritance test failed"
8232 echo "LU-974 ignore umask when acl is enabled..."
8233 run_acl_subtest 974 || error "LU-974 umask test failed"
8234 if [ $MDSCOUNT -ge 2 ]; then
8235 run_acl_subtest 974_remote ||
8236 error "LU-974 umask test failed under remote dir"
8239 echo "LU-2561 newly created file is same size as directory..."
8240 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
8241 run_acl_subtest 2561 || error "LU-2561 test failed"
8243 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8246 run_acl_subtest 4924 || error "LU-4924 test failed"
8251 for num in $(seq $MDSCOUNT); do
8252 if [ "${identity_old[$num]}" = 1 ]; then
8253 switch_identity $num false || identity_old[$num]=$?
8257 run_test 103a "acl test ========================================="
8261 cp -rp $DIR/$tdir $DIR/$tdir.bak
8263 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8264 error "$DIR/$tdir shouldn't contain default ACL"
8265 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8266 error "$DIR/$tdir.bak shouldn't contain default ACL"
8269 run_test 103c "'cp -rp' won't set empty acl"
8272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8274 lfs df || error "lfs df failed"
8275 lfs df -ih || error "lfs df -ih failed"
8276 lfs df -h $DIR || error "lfs df -h $DIR failed"
8277 lfs df -i $DIR || error "lfs df -i $DIR failed"
8278 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8279 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8281 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8282 lctl --device %$OSC deactivate
8283 lfs df || error "lfs df with deactivated OSC failed"
8284 lctl --device %$OSC activate
8285 # wait the osc back to normal
8286 wait_osc_import_state client ost FULL
8288 lfs df || error "lfs df with reactivated OSC failed"
8291 run_test 104a "lfs df [-ih] [path] test ========================="
8294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8295 [ $RUNAS_ID -eq $UID ] &&
8296 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
8298 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8299 grep "Permission denied" | wc -l)))
8300 if [ $denied_cnt -ne 0 ]; then
8301 error "lfs check servers test failed"
8304 run_test 104b "$RUNAS lfs check servers test ===================="
8307 # doesn't work on 2.4 kernels
8309 if $(flock_is_enabled); then
8310 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8312 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8316 run_test 105a "flock when mounted without -o flock test ========"
8320 if $(flock_is_enabled); then
8321 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8323 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8327 run_test 105b "fcntl when mounted without -o flock test ========"
8331 if $(flock_is_enabled); then
8332 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8334 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8338 run_test 105c "lockf when mounted without -o flock test"
8340 test_105d() { # bug 15924
8341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8342 test_mkdir $DIR/$tdir
8343 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8344 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8345 $LCTL set_param fail_loc=0x80000315
8346 flocks_test 2 $DIR/$tdir
8348 run_test 105d "flock race (should not freeze) ========"
8350 test_105e() { # bug 22660 && 22040
8351 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8353 flocks_test 3 $DIR/$tfile
8355 run_test 105e "Two conflicting flocks from same process"
8357 test_106() { #bug 10921
8358 test_mkdir $DIR/$tdir
8359 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8360 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8362 run_test 106 "attempt exec of dir followed by chown of that dir"
8365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8372 local save_pattern=$(sysctl -n kernel.core_pattern)
8373 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8374 sysctl -w kernel.core_pattern=$file
8375 sysctl -w kernel.core_uses_pid=0
8383 kill -s 11 $SLEEPPID
8385 if [ -e $file ]; then
8386 size=`stat -c%s $file`
8387 [ $size -eq 0 ] && error "Fail to create core file $file"
8389 error "Fail to create core file $file"
8392 sysctl -w kernel.core_pattern=$save_pattern
8393 sysctl -w kernel.core_uses_pid=$save_uses_pid
8396 run_test 107 "Coredump on SIG"
8399 test_mkdir $DIR/$tdir
8400 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8401 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8402 error "mkdir with 256 char should fail, but did not"
8403 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8404 error "create with 255 char failed"
8405 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8406 error "create with 256 char should fail, but did not"
8411 run_test 110 "filename length checking"
8414 # Purpose: To verify dynamic thread (OSS) creation.
8417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8418 remote_ost_nodsh && skip "remote OST with nodsh" && return
8420 # Lustre does not stop service threads once they are started.
8421 # Reset number of running threads to default.
8426 local save_params="$TMP/sanity-$TESTNAME.parameters"
8428 # Get ll_ost_io count before I/O
8429 OSTIO_pre=$(do_facet ost1 \
8430 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8431 # Exit if lustre is not running (ll_ost_io not running).
8432 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8434 echo "Starting with $OSTIO_pre threads"
8435 local thread_max=$((OSTIO_pre * 2))
8436 local rpc_in_flight=$((thread_max * 2))
8437 # Number of I/O Process proposed to be started.
8439 local facets=$(get_facets OST)
8441 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8442 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8444 # Set in_flight to $rpc_in_flight
8445 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8446 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8447 nfiles=${rpc_in_flight}
8448 # Set ost thread_max to $thread_max
8449 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8451 # 5 Minutes should be sufficient for max number of OSS
8452 # threads(thread_max) to be created.
8456 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8457 test_mkdir $DIR/$tdir
8458 for i in $(seq $nfiles); do
8459 local file=$DIR/$tdir/${tfile}-$i
8460 $LFS setstripe -c -1 -i 0 $file
8461 ($WTL $file $timeout)&
8464 # I/O Started - Wait for thread_started to reach thread_max or report
8465 # error if thread_started is more than thread_max.
8466 echo "Waiting for thread_started to reach thread_max"
8467 local thread_started=0
8468 local end_time=$((SECONDS + timeout))
8470 while [ $SECONDS -le $end_time ] ; do
8472 # Get ost i/o thread_started count.
8473 thread_started=$(do_facet ost1 \
8475 ost.OSS.ost_io.threads_started | cut -d= -f2")
8476 # Break out if thread_started is equal/greater than thread_max
8477 if [[ $thread_started -ge $thread_max ]]; then
8478 echo ll_ost_io thread_started $thread_started, \
8479 equal/greater than thread_max $thread_max
8485 # Cleanup - We have the numbers, Kill i/o jobs if running.
8486 jobcount=($(jobs -p))
8487 for i in $(seq 0 $((${#jobcount[@]}-1)))
8489 kill -9 ${jobcount[$i]}
8490 if [ $? -ne 0 ] ; then
8492 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8496 # Cleanup files left by WTL binary.
8497 for i in $(seq $nfiles); do
8498 local file=$DIR/$tdir/${tfile}-$i
8500 if [ $? -ne 0 ] ; then
8501 echo "Warning: Failed to delete file $file"
8505 restore_lustre_params <$save_params
8506 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8508 # Error out if no new thread has started or Thread started is greater
8510 if [[ $thread_started -le $OSTIO_pre ||
8511 $thread_started -gt $thread_max ]]; then
8512 error "ll_ost_io: thread_started $thread_started" \
8513 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8514 "No new thread started or thread started greater " \
8518 run_test 115 "verify dynamic thread creation===================="
8521 wait_delete_completed
8522 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8523 echo "OST kbytes available: ${AVAIL[@]}"
8528 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8529 #echo OST $i: ${AVAIL[i]}kb
8530 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8534 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8539 echo "Min free space: OST $MINI: $MINV"
8540 echo "Max free space: OST $MAXI: $MAXV"
8543 test_116a() { # was previously test_116()
8544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8545 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8547 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8549 echo -n "Free space priority "
8550 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8555 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8556 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8558 trap simple_cleanup_common EXIT
8561 # Check if we need to generate uneven OSTs
8562 test_mkdir -p $DIR/$tdir/OST${MINI}
8563 local FILL=$((MINV / 4))
8564 local DIFF=$((MAXV - MINV))
8565 local DIFF2=$((DIFF * 100 / MINV))
8567 local threshold=$(do_facet $SINGLEMDS \
8568 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8569 threshold=${threshold%%%}
8570 echo -n "Check for uneven OSTs: "
8571 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8573 if [[ $DIFF2 -gt $threshold ]]; then
8575 echo "Don't need to fill OST$MINI"
8577 # generate uneven OSTs. Write 2% over the QOS threshold value
8579 DIFF=$((threshold - DIFF2 + 2))
8580 DIFF2=$((MINV * DIFF / 100))
8581 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8582 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8583 error "setstripe failed"
8584 DIFF=$((DIFF2 / 2048))
8586 while [ $i -lt $DIFF ]; do
8588 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8589 bs=2M count=1 2>/dev/null
8598 DIFF=$((MAXV - MINV))
8599 DIFF2=$((DIFF * 100 / MINV))
8600 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8601 if [ $DIFF2 -gt $threshold ]; then
8604 echo "failed - QOS mode won't be used"
8605 skip "QOS imbalance criteria not met"
8606 simple_cleanup_common
8615 # now fill using QOS
8616 $SETSTRIPE -c 1 $DIR/$tdir
8617 FILL=$((FILL / 200))
8618 if [ $FILL -gt 600 ]; then
8621 echo "writing $FILL files to QOS-assigned OSTs"
8623 while [ $i -lt $FILL ]; do
8625 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8629 echo "wrote $i 200k files"
8633 echo "Note: free space may not be updated, so measurements might be off"
8635 DIFF2=$((MAXV - MINV))
8636 echo "free space delta: orig $DIFF final $DIFF2"
8637 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8638 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8639 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8640 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8641 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8642 if [[ $DIFF -gt 0 ]]; then
8643 FILL=$((DIFF2 * 100 / DIFF - 100))
8644 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8647 # Figure out which files were written where
8648 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8649 awk '/'$MINI1': / {print $2; exit}')
8651 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8652 echo "$MINC files created on smaller OST $MINI1"
8653 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8654 awk '/'$MAXI1': / {print $2; exit}')
8656 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8657 echo "$MAXC files created on larger OST $MAXI1"
8658 if [[ $MINC -gt 0 ]]; then
8659 FILL=$((MAXC * 100 / MINC - 100))
8660 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8662 [[ $MAXC -gt $MINC ]] ||
8663 error_ignore LU-9 "stripe QOS didn't balance free space"
8664 simple_cleanup_common
8666 run_test 116a "stripe QOS: free space balance ==================="
8668 test_116b() { # LU-2093
8669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8670 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8672 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8673 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8674 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8675 [ -z "$old_rr" ] && skip "no QOS" && return 0
8676 do_facet $SINGLEMDS lctl set_param \
8677 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8679 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8680 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8681 do_facet $SINGLEMDS lctl set_param fail_loc=0
8683 do_facet $SINGLEMDS lctl set_param \
8684 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8686 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8688 test_117() # bug 10891
8690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8691 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8692 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8693 lctl set_param fail_loc=0x21e
8694 > $DIR/$tfile || error "truncate failed"
8695 lctl set_param fail_loc=0
8696 echo "Truncate succeeded."
8699 run_test 117 "verify osd extend =========="
8701 NO_SLOW_RESENDCOUNT=4
8702 export OLD_RESENDCOUNT=""
8703 set_resend_count () {
8704 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8705 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8706 lctl set_param -n $PROC_RESENDCOUNT $1
8707 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8710 # for reduce test_118* time (b=14842)
8711 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8713 # Reset async IO behavior after error case
8715 FILE=$DIR/reset_async
8717 # Ensure all OSCs are cleared
8718 $SETSTRIPE -c -1 $FILE
8719 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8724 test_118a() #bug 11710
8726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8729 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8730 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8731 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8733 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8734 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8739 run_test 118a "verify O_SYNC works =========="
8743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8744 remote_ost_nodsh && skip "remote OST with nodsh" && return
8748 #define OBD_FAIL_SRV_ENOENT 0x217
8749 set_nodes_failloc "$(osts_nodes)" 0x217
8750 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8752 set_nodes_failloc "$(osts_nodes)" 0
8753 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8754 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8757 if [[ $RC -eq 0 ]]; then
8758 error "Must return error due to dropped pages, rc=$RC"
8762 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8763 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8767 echo "Dirty pages not leaked on ENOENT"
8769 # Due to the above error the OSC will issue all RPCs syncronously
8770 # until a subsequent RPC completes successfully without error.
8771 $MULTIOP $DIR/$tfile Ow4096yc
8776 run_test 118b "Reclaim dirty pages on fatal error =========="
8780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8782 # for 118c, restore the original resend count, LU-1940
8783 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8784 set_resend_count $OLD_RESENDCOUNT
8785 remote_ost_nodsh && skip "remote OST with nodsh" && return
8789 #define OBD_FAIL_OST_EROFS 0x216
8790 set_nodes_failloc "$(osts_nodes)" 0x216
8792 # multiop should block due to fsync until pages are written
8793 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8797 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8798 error "Multiop failed to block on fsync, pid=$MULTIPID"
8801 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8803 if [[ $WRITEBACK -eq 0 ]]; then
8804 error "No page in writeback, writeback=$WRITEBACK"
8807 set_nodes_failloc "$(osts_nodes)" 0
8810 if [[ $RC -ne 0 ]]; then
8811 error "Multiop fsync failed, rc=$RC"
8814 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8815 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8817 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8818 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8822 echo "Dirty pages flushed via fsync on EROFS"
8825 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8827 # continue to use small resend count to reduce test_118* time (b=14842)
8828 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8833 remote_ost_nodsh && skip "remote OST with nodsh" && return
8837 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8838 set_nodes_failloc "$(osts_nodes)" 0x214
8839 # multiop should block due to fsync until pages are written
8840 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8844 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8845 error "Multiop failed to block on fsync, pid=$MULTIPID"
8848 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8850 if [[ $WRITEBACK -eq 0 ]]; then
8851 error "No page in writeback, writeback=$WRITEBACK"
8854 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8855 set_nodes_failloc "$(osts_nodes)" 0
8857 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8858 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8860 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8861 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8865 echo "Dirty pages gaurenteed flushed via fsync"
8868 run_test 118d "Fsync validation inject a delay of the bulk =========="
8871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8874 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8875 lctl set_param fail_loc=0x8000040a
8877 # Should simulate EINVAL error which is fatal
8878 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8880 if [[ $RC -eq 0 ]]; then
8881 error "Must return error due to dropped pages, rc=$RC"
8884 lctl set_param fail_loc=0x0
8886 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8887 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8888 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8890 if [[ $LOCKED -ne 0 ]]; then
8891 error "Locked pages remain in cache, locked=$LOCKED"
8894 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8895 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8899 echo "No pages locked after fsync"
8904 run_test 118f "Simulate unrecoverable OSC side error =========="
8907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8910 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8911 lctl set_param fail_loc=0x406
8913 # simulate local -ENOMEM
8914 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8917 lctl set_param fail_loc=0
8918 if [[ $RC -eq 0 ]]; then
8919 error "Must return error due to dropped pages, rc=$RC"
8922 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8923 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8924 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8926 if [[ $LOCKED -ne 0 ]]; then
8927 error "Locked pages remain in cache, locked=$LOCKED"
8930 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8931 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8935 echo "No pages locked after fsync"
8940 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8944 remote_ost_nodsh && skip "remote OST with nodsh" && return
8948 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8949 set_nodes_failloc "$(osts_nodes)" 0x20e
8950 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8951 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8954 set_nodes_failloc "$(osts_nodes)" 0
8955 if [[ $RC -eq 0 ]]; then
8956 error "Must return error due to dropped pages, rc=$RC"
8959 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8960 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8961 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8963 if [[ $LOCKED -ne 0 ]]; then
8964 error "Locked pages remain in cache, locked=$LOCKED"
8967 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8968 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8972 echo "No pages locked after fsync"
8976 run_test 118h "Verify timeout in handling recoverables errors =========="
8978 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8982 remote_ost_nodsh && skip "remote OST with nodsh" && return
8986 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8987 set_nodes_failloc "$(osts_nodes)" 0x20e
8989 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8990 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8993 set_nodes_failloc "$(osts_nodes)" 0
8997 if [[ $RC -ne 0 ]]; then
8998 error "got error, but should be not, rc=$RC"
9001 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9002 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9003 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9004 if [[ $LOCKED -ne 0 ]]; then
9005 error "Locked pages remain in cache, locked=$LOCKED"
9008 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9009 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9013 echo "No pages locked after fsync"
9017 run_test 118i "Fix error before timeout in recoverable error =========="
9019 [ "$SLOW" = "no" ] && set_resend_count 4
9022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9023 remote_ost_nodsh && skip "remote OST with nodsh" && return
9027 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9028 set_nodes_failloc "$(osts_nodes)" 0x220
9030 # return -EIO from OST
9031 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9033 set_nodes_failloc "$(osts_nodes)" 0x0
9034 if [[ $RC -eq 0 ]]; then
9035 error "Must return error due to dropped pages, rc=$RC"
9038 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9039 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9040 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9041 if [[ $LOCKED -ne 0 ]]; then
9042 error "Locked pages remain in cache, locked=$LOCKED"
9045 # in recoverable error on OST we want resend and stay until it finished
9046 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9047 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9051 echo "No pages locked after fsync"
9055 run_test 118j "Simulate unrecoverable OST side error =========="
9059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9060 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
9062 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9063 set_nodes_failloc "$(osts_nodes)" 0x20e
9064 test_mkdir $DIR/$tdir
9066 for ((i=0;i<10;i++)); do
9067 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9068 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9075 set_nodes_failloc "$(osts_nodes)" 0
9078 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9084 test_mkdir $DIR/$tdir
9085 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9088 run_test 118l "fsync dir"
9090 test_118m() # LU-3066
9092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9093 test_mkdir $DIR/$tdir
9094 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9097 run_test 118m "fdatasync dir ========="
9099 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9107 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
9109 # Sleep to avoid a cached response.
9110 #define OBD_STATFS_CACHE_SECONDS 1
9113 # Inject a 10 second delay in the OST_STATFS handler.
9114 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9115 set_nodes_failloc "$(osts_nodes)" 0x242
9118 stat --file-system $MOUNT > /dev/null
9121 set_nodes_failloc "$(osts_nodes)" 0
9123 if ((end - begin > 20)); then
9124 error "statfs took $((end - begin)) seconds, expected 10"
9127 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9129 test_119a() # bug 11737
9131 BSIZE=$((512 * 1024))
9132 directio write $DIR/$tfile 0 1 $BSIZE
9133 # We ask to read two blocks, which is more than a file size.
9134 # directio will indicate an error when requested and actual
9135 # sizes aren't equeal (a normal situation in this case) and
9136 # print actual read amount.
9137 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9138 if [ "$NOB" != "$BSIZE" ]; then
9139 error "read $NOB bytes instead of $BSIZE"
9143 run_test 119a "Short directIO read must return actual read amount"
9145 test_119b() # bug 11737
9147 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9149 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
9150 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9152 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
9153 error "direct read failed"
9156 run_test 119b "Sparse directIO read must return actual read amount"
9158 test_119c() # bug 13099
9161 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9162 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9165 run_test 119c "Testing for direct read hitting hole"
9167 test_119d() # bug 15950
9169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9170 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9171 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9173 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9174 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9175 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9176 lctl set_param fail_loc=0x40d
9177 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9180 cat $DIR/$tfile > /dev/null &
9181 lctl set_param fail_loc=0
9184 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9186 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9187 error "the read rpcs have not completed in 2s"
9189 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
9191 run_test 119d "The DIO path should try to send a new rpc once one is completed"
9194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9195 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9196 test_mkdir $DIR/$tdir
9197 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9198 { skip "no early lock cancel on server"; return 0; }
9200 lru_resize_disable mdc
9201 lru_resize_disable osc
9202 cancel_lru_locks mdc
9203 # asynchronous object destroy at MDT could cause bl ast to client
9204 cancel_lru_locks osc
9206 stat $DIR/$tdir > /dev/null
9207 can1=$(do_facet $SINGLEMDS \
9208 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9209 awk '/ldlm_cancel/ {print $2}')
9210 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9211 awk '/ldlm_bl_callback/ {print $2}')
9212 test_mkdir -c1 $DIR/$tdir/d1
9213 can2=$(do_facet $SINGLEMDS \
9214 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9215 awk '/ldlm_cancel/ {print $2}')
9216 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9217 awk '/ldlm_bl_callback/ {print $2}')
9218 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9219 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9220 lru_resize_enable mdc
9221 lru_resize_enable osc
9223 run_test 120a "Early Lock Cancel: mkdir test"
9226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9227 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9228 test_mkdir $DIR/$tdir
9229 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9230 { skip "no early lock cancel on server"; return 0; }
9231 lru_resize_disable mdc
9232 lru_resize_disable osc
9233 cancel_lru_locks mdc
9234 stat $DIR/$tdir > /dev/null
9235 can1=$(do_facet $SINGLEMDS \
9236 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9237 awk '/ldlm_cancel/ {print $2}')
9238 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9239 awk '/ldlm_bl_callback/ {print $2}')
9241 can2=$(do_facet $SINGLEMDS \
9242 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9243 awk '/ldlm_cancel/ {print $2}')
9244 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9245 awk '/ldlm_bl_callback/ {print $2}')
9246 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9247 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9248 lru_resize_enable mdc
9249 lru_resize_enable osc
9251 run_test 120b "Early Lock Cancel: create test"
9254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9255 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9256 test_mkdir -c1 $DIR/$tdir
9257 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9258 { skip "no early lock cancel on server"; return 0; }
9259 lru_resize_disable mdc
9260 lru_resize_disable osc
9261 test_mkdir -c1 $DIR/$tdir/d1
9262 test_mkdir -c1 $DIR/$tdir/d2
9263 touch $DIR/$tdir/d1/f1
9264 cancel_lru_locks mdc
9265 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9266 can1=$(do_facet $SINGLEMDS \
9267 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9268 awk '/ldlm_cancel/ {print $2}')
9269 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9270 awk '/ldlm_bl_callback/ {print $2}')
9271 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9272 can2=$(do_facet $SINGLEMDS \
9273 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9274 awk '/ldlm_cancel/ {print $2}')
9275 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9276 awk '/ldlm_bl_callback/ {print $2}')
9277 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9278 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9279 lru_resize_enable mdc
9280 lru_resize_enable osc
9282 run_test 120c "Early Lock Cancel: link test"
9285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9286 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9287 test_mkdir -c1 $DIR/$tdir
9288 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9289 { skip "no early lock cancel on server"; return 0; }
9290 lru_resize_disable mdc
9291 lru_resize_disable osc
9293 cancel_lru_locks mdc
9294 stat $DIR/$tdir > /dev/null
9295 can1=$(do_facet $SINGLEMDS \
9296 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9297 awk '/ldlm_cancel/ {print $2}')
9298 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9299 awk '/ldlm_bl_callback/ {print $2}')
9300 chmod a+x $DIR/$tdir
9301 can2=$(do_facet $SINGLEMDS \
9302 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9303 awk '/ldlm_cancel/ {print $2}')
9304 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9305 awk '/ldlm_bl_callback/ {print $2}')
9306 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9307 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9308 lru_resize_enable mdc
9309 lru_resize_enable osc
9311 run_test 120d "Early Lock Cancel: setattr test"
9314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9315 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9316 { skip "no early lock cancel on server"; return 0; }
9317 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9318 local dlmtrace_set=false
9320 test_mkdir -c1 $DIR/$tdir
9321 lru_resize_disable mdc
9322 lru_resize_disable osc
9323 ! $LCTL get_param debug | grep -q dlmtrace &&
9324 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9325 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9326 cancel_lru_locks mdc
9327 cancel_lru_locks osc
9328 dd if=$DIR/$tdir/f1 of=/dev/null
9329 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9330 # XXX client can not do early lock cancel of OST lock
9331 # during unlink (LU-4206), so cancel osc lock now.
9333 cancel_lru_locks osc
9334 can1=$(do_facet $SINGLEMDS \
9335 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9336 awk '/ldlm_cancel/ {print $2}')
9337 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9338 awk '/ldlm_bl_callback/ {print $2}')
9339 unlink $DIR/$tdir/f1
9341 can2=$(do_facet $SINGLEMDS \
9342 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9343 awk '/ldlm_cancel/ {print $2}')
9344 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9345 awk '/ldlm_bl_callback/ {print $2}')
9346 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9347 $LCTL dk $TMP/cancel.debug.txt
9348 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9349 $LCTL dk $TMP/blocking.debug.txt
9350 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9351 lru_resize_enable mdc
9352 lru_resize_enable osc
9354 run_test 120e "Early Lock Cancel: unlink test"
9357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9358 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9359 { skip "no early lock cancel on server"; return 0; }
9360 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9361 test_mkdir -c1 $DIR/$tdir
9362 lru_resize_disable mdc
9363 lru_resize_disable osc
9364 test_mkdir -c1 $DIR/$tdir/d1
9365 test_mkdir -c1 $DIR/$tdir/d2
9366 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9367 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9368 cancel_lru_locks mdc
9369 cancel_lru_locks osc
9370 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9371 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9372 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9373 # XXX client can not do early lock cancel of OST lock
9374 # during rename (LU-4206), so cancel osc lock now.
9376 cancel_lru_locks osc
9377 can1=$(do_facet $SINGLEMDS \
9378 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9379 awk '/ldlm_cancel/ {print $2}')
9380 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9381 awk '/ldlm_bl_callback/ {print $2}')
9382 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9384 can2=$(do_facet $SINGLEMDS \
9385 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9386 awk '/ldlm_cancel/ {print $2}')
9387 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9388 awk '/ldlm_bl_callback/ {print $2}')
9389 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9390 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9391 lru_resize_enable mdc
9392 lru_resize_enable osc
9394 run_test 120f "Early Lock Cancel: rename test"
9397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9398 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9399 { skip "no early lock cancel on server"; return 0; }
9400 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9401 lru_resize_disable mdc
9402 lru_resize_disable osc
9404 echo create $count files
9405 test_mkdir $DIR/$tdir
9406 cancel_lru_locks mdc
9407 cancel_lru_locks osc
9410 can0=$(do_facet $SINGLEMDS \
9411 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9412 awk '/ldlm_cancel/ {print $2}')
9413 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9414 awk '/ldlm_bl_callback/ {print $2}')
9415 createmany -o $DIR/$tdir/f $count
9417 can1=$(do_facet $SINGLEMDS \
9418 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9419 awk '/ldlm_cancel/ {print $2}')
9420 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9421 awk '/ldlm_bl_callback/ {print $2}')
9423 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9424 echo rm $count files
9427 can2=$(do_facet $SINGLEMDS \
9428 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9429 awk '/ldlm_cancel/ {print $2}')
9430 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9431 awk '/ldlm_bl_callback/ {print $2}')
9433 echo total: $count removes in $((t2-t1))
9434 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9436 # wait for commitment of removal
9437 lru_resize_enable mdc
9438 lru_resize_enable osc
9440 run_test 120g "Early Lock Cancel: performance test"
9442 test_121() { #bug #10589
9443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9445 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9446 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9447 lctl set_param fail_loc=0x310
9448 cancel_lru_locks osc > /dev/null
9449 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9450 lctl set_param fail_loc=0
9451 [[ $reads -eq $writes ]] ||
9452 error "read $reads blocks, must be $writes blocks"
9454 run_test 121 "read cancel race ========="
9456 test_123a() { # was test 123, statahead(bug 11401)
9457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9459 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9460 log "testing UP system. Performance may be lower than expected."
9465 test_mkdir $DIR/$tdir
9466 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9467 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9469 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9470 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9472 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9473 lctl set_param -n llite.*.statahead_max 0
9474 lctl get_param llite.*.statahead_max
9475 cancel_lru_locks mdc
9476 cancel_lru_locks osc
9478 time ls -l $DIR/$tdir | wc -l
9480 delta=$((etime - stime))
9481 log "ls $i files without statahead: $delta sec"
9482 lctl set_param llite.*.statahead_max=$max
9484 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9485 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9486 cancel_lru_locks mdc
9487 cancel_lru_locks osc
9489 time ls -l $DIR/$tdir | wc -l
9491 delta_sa=$((etime - stime))
9492 log "ls $i files with statahead: $delta_sa sec"
9493 lctl get_param -n llite.*.statahead_stats
9494 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9496 [[ $swrong -lt $ewrong ]] &&
9497 log "statahead was stopped, maybe too many locks held!"
9498 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9500 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9501 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9502 lctl set_param -n llite.*.statahead_max 0
9503 lctl get_param llite.*.statahead_max
9504 cancel_lru_locks mdc
9505 cancel_lru_locks osc
9507 time ls -l $DIR/$tdir | wc -l
9509 delta=$((etime - stime))
9510 log "ls $i files again without statahead: $delta sec"
9511 lctl set_param llite.*.statahead_max=$max
9512 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9513 if [ $SLOWOK -eq 0 ]; then
9514 error "ls $i files is slower with statahead!"
9516 log "ls $i files is slower with statahead!"
9522 [ $delta -gt 20 ] && break
9523 [ $delta -gt 8 ] && MULT=$((50 / delta))
9524 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9532 delta=$((etime - stime))
9533 log "rm -r $DIR/$tdir/: $delta seconds"
9535 lctl get_param -n llite.*.statahead_stats
9537 run_test 123a "verify statahead work"
9539 test_123b () { # statahead(bug 15027)
9540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9541 test_mkdir $DIR/$tdir
9542 createmany -o $DIR/$tdir/$tfile-%d 1000
9544 cancel_lru_locks mdc
9545 cancel_lru_locks osc
9547 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9548 lctl set_param fail_loc=0x80000803
9549 ls -lR $DIR/$tdir > /dev/null
9551 lctl set_param fail_loc=0x0
9552 lctl get_param -n llite.*.statahead_stats
9557 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9560 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9561 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9562 { skip "no lru resize on server"; return 0; }
9564 test_mkdir $DIR/$tdir
9566 log "create $NR files at $DIR/$tdir"
9567 createmany -o $DIR/$tdir/f $NR ||
9568 error "failed to create $NR files in $DIR/$tdir"
9570 cancel_lru_locks mdc
9571 ls -l $DIR/$tdir > /dev/null
9575 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9576 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9577 LRU_SIZE=$($LCTL get_param -n $PARAM)
9578 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9579 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9581 log "NS=$(basename $NSDIR)"
9586 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9587 skip "Not enough cached locks created!"
9594 # We know that lru resize allows one client to hold $LIMIT locks
9595 # for 10h. After that locks begin to be killed by client.
9597 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9599 if [ $LIMIT -lt $LRU_SIZE ]; then
9600 skip "Limit is too small $LIMIT"
9604 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9605 # killing locks. Some time was spent for creating locks. This means
9606 # that up to the moment of sleep finish we must have killed some of
9607 # them (10-100 locks). This depends on how fast ther were created.
9608 # Many of them were touched in almost the same moment and thus will
9609 # be killed in groups.
9610 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9612 # Use $LRU_SIZE_B here to take into account real number of locks
9613 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9614 local LRU_SIZE_B=$LRU_SIZE
9616 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9617 log "OLD_LVF=$OLD_LVF"
9618 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9620 # Let's make sure that we really have some margin. Client checks
9621 # cached locks every 10 sec.
9623 log "Sleep ${SLEEP} sec"
9625 while ((SEC<$SLEEP)); do
9629 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9633 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9634 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9636 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9637 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9638 unlinkmany $DIR/$tdir/f $NR
9642 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9643 log "unlink $NR files at $DIR/$tdir"
9644 unlinkmany $DIR/$tdir/f $NR
9646 run_test 124a "lru resize ======================================="
9648 get_max_pool_limit()
9650 local limit=$($LCTL get_param \
9651 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9654 if [[ $l -gt $max ]]; then
9662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9663 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9664 { skip "no lru resize on server"; return 0; }
9666 LIMIT=$(get_max_pool_limit)
9668 NR=$(($(default_lru_size)*20))
9669 if [[ $NR -gt $LIMIT ]]; then
9670 log "Limit lock number by $LIMIT locks"
9674 IFree=$(mdsrate_inodes_available)
9675 if [ $IFree -lt $NR ]; then
9676 log "Limit lock number by $IFree inodes"
9680 lru_resize_disable mdc
9681 test_mkdir -p $DIR/$tdir/disable_lru_resize
9683 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9684 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9685 cancel_lru_locks mdc
9688 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9691 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9694 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9698 nolruresize_delta=$((etime-stime))
9699 log "ls -la time: $nolruresize_delta seconds"
9700 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9701 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9703 lru_resize_enable mdc
9704 test_mkdir -p $DIR/$tdir/enable_lru_resize
9706 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9707 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9708 cancel_lru_locks mdc
9711 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9714 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9717 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9721 lruresize_delta=$((etime-stime))
9722 log "ls -la time: $lruresize_delta seconds"
9723 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9725 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9726 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9727 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9728 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9730 log "lru resize performs the same with no lru resize"
9732 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9734 run_test 124b "lru resize (performance test) ======================="
9737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9738 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9739 { skip "no lru resize on server"; return 0; }
9741 # cache ununsed locks on client
9743 cancel_lru_locks mdc
9744 test_mkdir $DIR/$tdir
9745 createmany -o $DIR/$tdir/f $nr ||
9746 error "failed to create $nr files in $DIR/$tdir"
9747 ls -l $DIR/$tdir > /dev/null
9749 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9750 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9751 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9752 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9753 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9755 # set lru_max_age to 1 sec
9756 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9757 echo "sleep $((recalc_p * 2)) seconds..."
9758 sleep $((recalc_p * 2))
9760 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9761 # restore lru_max_age
9762 $LCTL set_param -n $nsdir.lru_max_age $max_age
9763 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9764 unlinkmany $DIR/$tdir/f $nr
9766 run_test 124c "LRUR cancel very aged locks"
9768 test_125() { # 13358
9769 $LCTL get_param -n llite.*.client_type | grep -q local ||
9770 { skip "must run as local client"; return; }
9771 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
9772 { skip "must have acl enabled"; return; }
9773 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9774 test_mkdir $DIR/$tdir
9775 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
9776 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
9777 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
9779 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9781 test_126() { # bug 12829/13455
9782 $LCTL get_param -n llite.*.client_type | grep -q local ||
9783 { skip "must run as local client"; return; }
9784 [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
9785 $GSS && skip "must run as gss disabled" && return
9787 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9788 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9790 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9792 run_test 126 "check that the fsgid provided by the client is taken into account"
9794 test_127a() { # bug 15521
9795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9796 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9797 $LCTL set_param osc.*.stats=0
9798 FSIZE=$((2048 * 1024))
9799 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9800 cancel_lru_locks osc
9801 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9803 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9804 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9805 echo "got $COUNT $NAME"
9806 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9807 eval $NAME=$COUNT || error "Wrong proc format"
9810 read_bytes|write_bytes)
9811 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9812 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9813 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9814 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9815 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9816 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9817 error "sumsquare is too small: $SUMSQ"
9818 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9819 error "sumsquare is too big: $SUMSQ"
9823 done < $DIR/${tfile}.tmp
9825 #check that we actually got some stats
9826 [ "$read_bytes" ] || error "Missing read_bytes stats"
9827 [ "$write_bytes" ] || error "Missing write_bytes stats"
9828 [ "$read_bytes" != 0 ] || error "no read done"
9829 [ "$write_bytes" != 0 ] || error "no write done"
9831 run_test 127a "verify the client stats are sane"
9833 test_127b() { # bug LU-333
9834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9835 $LCTL set_param llite.*.stats=0
9836 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9837 # perform 2 reads and writes so MAX is different from SUM.
9838 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9839 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9840 cancel_lru_locks osc
9841 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9842 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9844 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9845 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9846 echo "got $COUNT $NAME"
9847 eval $NAME=$COUNT || error "Wrong proc format"
9851 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9852 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9853 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9854 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9857 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9858 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9859 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9860 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9864 done < $TMP/${tfile}.tmp
9866 #check that we actually got some stats
9867 [ "$read_bytes" ] || error "Missing read_bytes stats"
9868 [ "$write_bytes" ] || error "Missing write_bytes stats"
9869 [ "$read_bytes" != 0 ] || error "no read done"
9870 [ "$write_bytes" != 0 ] || error "no write done"
9872 rm -f $TMP/${tfile}.tmp
9874 run_test 127b "verify the llite client stats are sane"
9876 test_128() { # bug 15212
9878 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9883 result=$(grep error $TMP/$tfile.log)
9884 rm -f $DIR/$tfile $TMP/$tfile.log
9886 error "consecutive find's under interactive lfs failed"
9888 run_test 128 "interactive lfs for 2 consecutive find's"
9895 local ldproc=/proc/fs/ldiskfs
9896 local facets=$(get_facets MDS)
9898 for facet in ${facets//,/ }; do
9899 canondev=$(ldiskfs_canon \
9900 *.$(convert_facet2label $facet).mntdev $facet)
9901 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9902 ldproc=/sys/fs/ldiskfs
9903 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9904 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9909 local facets=$(get_facets MDS)
9910 for facet in ${facets//,/ }; do
9911 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9917 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9918 { skip "Need MDS version with at least 2.5.56"; return 0; }
9920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9921 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9922 skip "ldiskfs only test"
9925 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9928 local has_warning=false
9933 # block size of mds1
9934 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9935 set_dir_limits $maxsize $maxsize
9936 local dirsize=$(stat -c%s "$DIR/$tdir")
9938 while [[ $dirsize -le $maxsize ]]; do
9939 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9941 if ! $has_warning; then
9942 check_mds_dmesg '"is approaching"' && has_warning=true
9945 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9946 # EFBIG for previous versions included in ldiskfs series
9947 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9949 echo "return code $rc received as expected"
9951 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9952 error_exit "create failed w/o dir size limit"
9954 check_mds_dmesg '"has reached"' ||
9955 error_exit "reached message should be output"
9957 [ $has_warning = "false" ] &&
9958 error_exit "warning message should be output"
9960 dirsize=$(stat -c%s "$DIR/$tdir")
9962 [[ $dirsize -ge $maxsize ]] && return 0
9963 error_exit "current dir size $dirsize, " \
9964 "previous limit $maxsize"
9965 elif [ $rc -ne 0 ]; then
9967 error_exit "return $rc received instead of expected " \
9968 "$EFBIG or $ENOSPC, files in dir $dirsize"
9970 nfiles=$((nfiles + 1))
9971 dirsize=$(stat -c%s "$DIR/$tdir")
9975 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9977 run_test 129 "test directory size limit ========================"
9986 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9987 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9990 trap cleanup_130 EXIT RETURN
9992 local fm_file=$DIR/$tfile
9993 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9994 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9995 error "dd failed for $fm_file"
9997 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9998 filefrag -ves $fm_file
10000 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10001 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
10002 [ $RC != 0 ] && error "filefrag $fm_file failed"
10004 filefrag_op=$(filefrag -ve -k $fm_file |
10005 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10006 lun=$($GETSTRIPE -i $fm_file)
10008 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10011 for line in $filefrag_op
10013 frag_lun=`echo $line | cut -d: -f5`
10014 ext_len=`echo $line | cut -d: -f4`
10015 if (( $frag_lun != $lun )); then
10017 error "FIEMAP on 1-stripe file($fm_file) failed"
10020 (( tot_len += ext_len ))
10023 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10025 error "FIEMAP on 1-stripe file($fm_file) failed;"
10031 echo "FIEMAP on single striped file succeeded"
10033 run_test 130a "FIEMAP (1-stripe file)"
10036 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
10038 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10039 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
10042 trap cleanup_130 EXIT RETURN
10044 local fm_file=$DIR/$tfile
10045 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10046 error "setstripe on $fm_file"
10047 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10048 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
10050 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10051 error "dd failed on $fm_file"
10053 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10054 filefrag_op=$(filefrag -ve -k $fm_file |
10055 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10057 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10058 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10063 for line in $filefrag_op
10065 frag_lun=$(echo $line | cut -d: -f5 |
10066 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10067 ext_len=$(echo $line | cut -d: -f4)
10068 if (( $frag_lun != $last_lun )); then
10069 if (( tot_len != 1024 )); then
10071 error "FIEMAP on $fm_file failed; returned " \
10072 "len $tot_len for OST $last_lun instead of 1024"
10075 (( num_luns += 1 ))
10079 (( tot_len += ext_len ))
10082 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10084 error "FIEMAP on $fm_file failed; returned wrong number of " \
10085 "luns or wrong len for OST $last_lun"
10091 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10093 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10096 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
10098 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10099 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
10102 trap cleanup_130 EXIT RETURN
10104 local fm_file=$DIR/$tfile
10105 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10106 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10107 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
10109 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10110 error "dd failed on $fm_file"
10112 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10113 filefrag_op=$(filefrag -ve -k $fm_file |
10114 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10116 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10117 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10122 for line in $filefrag_op
10124 frag_lun=$(echo $line | cut -d: -f5 |
10125 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10126 ext_len=$(echo $line | cut -d: -f4)
10127 if (( $frag_lun != $last_lun )); then
10128 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10129 if (( logical != 512 )); then
10131 error "FIEMAP on $fm_file failed; returned " \
10132 "logical start for lun $logical instead of 512"
10135 if (( tot_len != 512 )); then
10137 error "FIEMAP on $fm_file failed; returned " \
10138 "len $tot_len for OST $last_lun instead of 1024"
10141 (( num_luns += 1 ))
10145 (( tot_len += ext_len ))
10148 if (( num_luns != 2 || tot_len != 512 )); then
10150 error "FIEMAP on $fm_file failed; returned wrong number of " \
10151 "luns or wrong len for OST $last_lun"
10157 echo "FIEMAP on 2-stripe file with hole succeeded"
10159 run_test 130c "FIEMAP (2-stripe file with hole)"
10162 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
10164 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10165 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
10168 trap cleanup_130 EXIT RETURN
10170 local fm_file=$DIR/$tfile
10171 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10172 error "setstripe on $fm_file"
10173 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10174 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
10176 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
10177 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
10178 error "dd failed on $fm_file"
10180 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10181 filefrag_op=$(filefrag -ve -k $fm_file |
10182 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10184 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10185 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10190 for line in $filefrag_op
10192 frag_lun=$(echo $line | cut -d: -f5 |
10193 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10194 ext_len=$(echo $line | cut -d: -f4)
10195 if (( $frag_lun != $last_lun )); then
10196 if (( tot_len != 1024 )); then
10198 error "FIEMAP on $fm_file failed; returned " \
10199 "len $tot_len for OST $last_lun instead of 1024"
10202 (( num_luns += 1 ))
10206 (( tot_len += ext_len ))
10209 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
10211 error "FIEMAP on $fm_file failed; returned wrong number of " \
10212 "luns or wrong len for OST $last_lun"
10218 echo "FIEMAP on N-stripe file succeeded"
10220 run_test 130d "FIEMAP (N-stripe file)"
10223 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
10225 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10226 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
10228 trap cleanup_130 EXIT RETURN
10230 local fm_file=$DIR/$tfile
10231 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
10232 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10233 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
10236 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
10237 for ((i = 0; i < $NUM_BLKS; i++))
10239 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
10242 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10243 filefrag_op=$(filefrag -ve -k $fm_file |
10244 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10246 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10247 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10252 for line in $filefrag_op
10254 frag_lun=$(echo $line | cut -d: -f5 |
10255 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10256 ext_len=$(echo $line | cut -d: -f4)
10257 if (( $frag_lun != $last_lun )); then
10258 if (( tot_len != $EXPECTED_LEN )); then
10260 error "FIEMAP on $fm_file failed; returned " \
10261 "len $tot_len for OST $last_lun instead " \
10265 (( num_luns += 1 ))
10269 (( tot_len += ext_len ))
10272 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10274 error "FIEMAP on $fm_file failed; returned wrong number " \
10275 "of luns or wrong len for OST $last_lun"
10281 echo "FIEMAP with continuation calls succeeded"
10283 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10286 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10287 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
10290 local fm_file=$DIR/$tfile
10291 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
10292 error "multiop create with lov_delay_create on $fm_file"
10294 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10295 filefrag_extents=$(filefrag -vek $fm_file |
10296 awk '/extents? found/ { print $2 }')
10297 if [[ "$filefrag_extents" != "0" ]]; then
10298 error "FIEMAP on $fm_file failed; " \
10299 "returned $filefrag_extents expected 0"
10304 run_test 130f "FIEMAP (unstriped file)"
10306 # Test for writev/readv
10308 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10309 error "writev test failed"
10310 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10311 error "readv failed"
10314 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10317 local fsize=$((524288 + 1048576 + 1572864))
10318 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10319 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10320 error "append writev test failed"
10322 ((fsize += 1572864 + 1048576))
10323 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10324 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10325 error "append writev test failed"
10328 run_test 131b "test append writev"
10331 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10334 run_test 131c "test read/write on file w/o objects"
10337 rwv -f $DIR/$tfile -w -n 1 1572864
10338 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10339 if [ "$NOB" != 1572864 ]; then
10340 error "Short read filed: read $NOB bytes instead of 1572864"
10344 run_test 131d "test short read"
10347 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10348 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10349 error "read hitting hole failed"
10352 run_test 131e "test read hitting hole"
10361 mds*) res=$(do_facet $facet \
10362 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10364 ost*) res=$(do_facet $facet \
10365 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10367 *) error "Wrong facet '$facet'" ;;
10370 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10371 # if the argument $3 is zero, it means any stat increment is ok.
10372 if [[ $want -gt 0 ]]; then
10373 local count=$(echo $res | awk '{ print $2 }')
10374 [[ $count -ne $want ]] &&
10375 error "The $op counter on $facet is $count, not $want"
10380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10381 remote_ost_nodsh && skip "remote OST with nodsh" && return
10382 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10384 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10385 { skip "MDS doesn't support rename stats"; return; }
10386 local testdir=$DIR/${tdir}/stats_testdir
10387 mkdir -p $DIR/${tdir}
10390 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10391 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10393 # verify mdt stats first.
10394 mkdir ${testdir} || error "mkdir failed"
10395 check_stats $SINGLEMDS "mkdir" 1
10396 touch ${testdir}/${tfile} || error "touch failed"
10397 check_stats $SINGLEMDS "open" 1
10398 check_stats $SINGLEMDS "close" 1
10399 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10400 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10401 check_stats $SINGLEMDS "mknod" 2
10403 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10404 check_stats $SINGLEMDS "unlink" 1
10405 rm -f ${testdir}/${tfile} || error "file remove failed"
10406 check_stats $SINGLEMDS "unlink" 2
10408 # remove working dir and check mdt stats again.
10409 rmdir ${testdir} || error "rmdir failed"
10410 check_stats $SINGLEMDS "rmdir" 1
10412 local testdir1=$DIR/${tdir}/stats_testdir1
10413 mkdir -p ${testdir}
10414 mkdir -p ${testdir1}
10415 touch ${testdir1}/test1
10416 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10417 check_stats $SINGLEMDS "crossdir_rename" 1
10419 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10420 check_stats $SINGLEMDS "samedir_rename" 1
10422 rm -rf $DIR/${tdir}
10424 run_test 133a "Verifying MDT stats ========================================"
10427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10428 remote_ost_nodsh && skip "remote OST with nodsh" && return
10429 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10430 local testdir=$DIR/${tdir}/stats_testdir
10431 mkdir -p ${testdir} || error "mkdir failed"
10432 touch ${testdir}/${tfile} || error "touch failed"
10433 cancel_lru_locks mdc
10436 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10437 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10439 # extra mdt stats verification.
10440 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10441 check_stats $SINGLEMDS "setattr" 1
10442 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10443 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10445 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10446 check_stats $SINGLEMDS "getattr" 1
10448 $LFS df || error "lfs failed"
10449 check_stats $SINGLEMDS "statfs" 1
10451 rm -rf $DIR/${tdir}
10453 run_test 133b "Verifying extra MDT stats =================================="
10456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10457 remote_ost_nodsh && skip "remote OST with nodsh" && return
10458 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10459 local testdir=$DIR/$tdir/stats_testdir
10460 test_mkdir -p $testdir
10462 # verify obdfilter stats.
10463 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10465 cancel_lru_locks osc
10466 wait_delete_completed
10469 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10470 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10472 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10475 cancel_lru_locks osc
10476 check_stats ost1 "write" 1
10478 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10479 check_stats ost1 "read" 1
10481 > $testdir/$tfile || error "truncate failed"
10482 check_stats ost1 "punch" 1
10484 rm -f $testdir/$tfile || error "file remove failed"
10485 wait_delete_completed
10486 check_stats ost1 "destroy" 1
10490 run_test 133c "Verifying OST stats ========================================"
10497 while [ $value -ge 2 ]; do
10502 if [ $orig -gt $order ]; then
10510 local size=('K' 'M' 'G' 'T');
10512 local size_string=$value
10514 while [ $value -ge 1024 ]; do
10515 if [ $i -gt 3 ]; then
10516 #T is the biggest unit we get here, if that is bigger,
10518 size_string=${value}T
10521 value=$((value >> 10))
10522 if [ $value -lt 1024 ]; then
10523 size_string=${value}${size[$i]}
10532 get_rename_size() {
10534 local context=${2:-.}
10535 local sample=$(do_facet $SINGLEMDS $LCTL \
10536 get_param mdt.$FSNAME-MDT0000.rename_stats |
10537 grep -A1 $context |
10538 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10544 remote_ost_nodsh && skip "remote OST with nodsh" && return
10545 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10546 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10547 { skip "MDS doesn't support rename stats"; return; }
10549 local testdir1=$DIR/${tdir}/stats_testdir1
10550 local testdir2=$DIR/${tdir}/stats_testdir2
10551 mkdir -p $DIR/${tdir}
10553 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10555 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
10556 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
10558 createmany -o $testdir1/test 512 || error "createmany failed"
10560 # check samedir rename size
10561 mv ${testdir1}/test0 ${testdir1}/test_0
10563 local testdir1_size=$(ls -l $DIR/${tdir} |
10564 awk '/stats_testdir1/ {print $5}')
10565 local testdir2_size=$(ls -l $DIR/${tdir} |
10566 awk '/stats_testdir2/ {print $5}')
10568 testdir1_size=$(order_2 $testdir1_size)
10569 testdir2_size=$(order_2 $testdir2_size)
10571 testdir1_size=$(size_in_KMGT $testdir1_size)
10572 testdir2_size=$(size_in_KMGT $testdir2_size)
10574 echo "source rename dir size: ${testdir1_size}"
10575 echo "target rename dir size: ${testdir2_size}"
10577 local cmd="do_facet $SINGLEMDS $LCTL "
10578 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10580 eval $cmd || error "$cmd failed"
10581 local samedir=$($cmd | grep 'same_dir')
10582 local same_sample=$(get_rename_size $testdir1_size)
10583 [ -z "$samedir" ] && error "samedir_rename_size count error"
10584 [[ $same_sample -eq 1 ]] ||
10585 error "samedir_rename_size error $same_sample"
10586 echo "Check same dir rename stats success"
10588 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10590 # check crossdir rename size
10591 mv ${testdir1}/test_0 ${testdir2}/test_0
10593 testdir1_size=$(ls -l $DIR/${tdir} |
10594 awk '/stats_testdir1/ {print $5}')
10595 testdir2_size=$(ls -l $DIR/${tdir} |
10596 awk '/stats_testdir2/ {print $5}')
10598 testdir1_size=$(order_2 $testdir1_size)
10599 testdir2_size=$(order_2 $testdir2_size)
10601 testdir1_size=$(size_in_KMGT $testdir1_size)
10602 testdir2_size=$(size_in_KMGT $testdir2_size)
10604 echo "source rename dir size: ${testdir1_size}"
10605 echo "target rename dir size: ${testdir2_size}"
10607 eval $cmd || error "$cmd failed"
10608 local crossdir=$($cmd | grep 'crossdir')
10609 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10610 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10611 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10612 [[ $src_sample -eq 1 ]] ||
10613 error "crossdir_rename_size error $src_sample"
10614 [[ $tgt_sample -eq 1 ]] ||
10615 error "crossdir_rename_size error $tgt_sample"
10616 echo "Check cross dir rename stats success"
10617 rm -rf $DIR/${tdir}
10619 run_test 133d "Verifying rename_stats ========================================"
10622 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10623 remote_ost_nodsh && skip "remote OST with nodsh" && return
10624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10625 local testdir=$DIR/${tdir}/stats_testdir
10626 local ctr f0 f1 bs=32768 count=42 sum
10628 mkdir -p ${testdir} || error "mkdir failed"
10630 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10632 for ctr in {write,read}_bytes; do
10634 cancel_lru_locks osc
10636 do_facet ost1 $LCTL set_param -n \
10637 "obdfilter.*.exports.clear=clear"
10639 if [ $ctr = write_bytes ]; then
10641 f1=${testdir}/${tfile}
10643 f0=${testdir}/${tfile}
10647 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10650 cancel_lru_locks osc
10652 sum=$(do_facet ost1 $LCTL get_param \
10653 "obdfilter.*.exports.*.stats" |
10654 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10655 $1 == ctr { sum += $7 }
10656 END { printf("%0.0f", sum) }')
10658 if ((sum != bs * count)); then
10659 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10663 rm -rf $DIR/${tdir}
10665 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10667 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10670 # First without trusting modes.
10671 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10672 echo "proc_dirs='$proc_dirs'"
10673 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10674 find $proc_dirs -exec cat '{}' \; &> /dev/null
10676 # Second verifying readability.
10677 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10679 # Verifing writability with badarea_io.
10681 -ignore_readdir_race \
10683 -not -name force_lbug \
10684 -not -name changelog_mask \
10685 -exec badarea_io '{}' \; ||
10686 error "find $proc_dirs failed"
10688 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
10691 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10692 remote_ost_nodsh && skip "remote OST with nodsh" && return
10694 # eventually, this can also be replaced with "lctl get_param -R",
10695 # but not until that option is always available on the server
10697 for facet in mds1 ost1; do
10698 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10699 skip "Too old lustre on $facet" && continue
10700 local facet_proc_dirs=$(do_facet $facet \
10701 \\\ls -d $proc_regexp 2>/dev/null)
10702 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10703 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10704 do_facet $facet find $facet_proc_dirs \
10705 ! -name req_history \
10706 -exec cat '{}' \\\; &> /dev/null
10708 do_facet $facet find $facet_proc_dirs \
10709 ! -name req_history \
10711 -exec cat '{}' \\\; &> /dev/null ||
10712 error "proc file read failed"
10714 do_facet $facet find $facet_proc_dirs \
10715 -ignore_readdir_race \
10717 -not -name force_lbug \
10718 -not -name changelog_mask \
10719 -exec badarea_io '{}' \\\; ||
10720 error "$facet find $facet_proc_dirs failed"
10723 # remount the FS in case writes/reads /proc break the FS
10724 cleanup || error "failed to unmount"
10725 setup || error "failed to setup"
10728 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
10731 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10732 remote_ost_nodsh && skip "remote OST with nodsh" && return
10733 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10734 skip "Need MDS version at least 2.9.54" && return
10737 for facet in client mds1 ost1; do
10738 local facet_proc_dirs=$(do_facet $facet \
10739 \\\ls -d $proc_regexp 2> /dev/null)
10740 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10741 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10742 # Get the list of files that are missing the terminating newline
10743 local missing=($(do_facet $facet \
10744 find ${facet_proc_dirs} -type f \| \
10745 while read F\; do \
10746 awk -v FS='\v' -v RS='\v\v' \
10747 "'END { if(NR>0 && \
10748 \\\$NF !~ /.*\\\n\$/) \
10749 print FILENAME}'" \
10752 [ ${#missing[*]} -eq 0 ] ||
10753 error "files do not end with newline: ${missing[*]}"
10756 run_test 133h "Proc files should end with newlines"
10759 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10760 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10761 skip "Need MDS version at least 2.7.54" && return
10763 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10764 cancel_lru_locks mdc
10766 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10767 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10768 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10771 createmany -o $DIR/$tdir/f $nr ||
10772 error "failed to create $nr files in $DIR/$tdir"
10773 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10775 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10776 do_facet mds1 $LCTL set_param fail_loc=0x327
10777 do_facet mds1 $LCTL set_param fail_val=500
10780 echo "sleep 10 seconds ..."
10782 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10784 do_facet mds1 $LCTL set_param fail_loc=0
10785 do_facet mds1 $LCTL set_param fail_val=0
10786 [ $lck_cnt -lt $unused ] ||
10787 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10790 unlinkmany $DIR/$tdir/f $nr
10792 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10795 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10796 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10797 skip "Need MDS version at least 2.7.54" && return
10799 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10800 cancel_lru_locks mdc
10802 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10803 ldlm.lock_reclaim_threshold_mb)
10804 # disable reclaim temporarily
10805 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10807 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10808 do_facet mds1 $LCTL set_param fail_loc=0x328
10809 do_facet mds1 $LCTL set_param fail_val=500
10811 $LCTL set_param debug=+trace
10814 createmany -o $DIR/$tdir/f $nr &
10815 local create_pid=$!
10817 echo "Sleep $TIMEOUT seconds ..."
10819 if ! ps -p $create_pid > /dev/null 2>&1; then
10820 do_facet mds1 $LCTL set_param fail_loc=0
10821 do_facet mds1 $LCTL set_param fail_val=0
10822 do_facet mds1 $LCTL set_param \
10823 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10824 error "createmany finished incorrectly!"
10826 do_facet mds1 $LCTL set_param fail_loc=0
10827 do_facet mds1 $LCTL set_param fail_val=0
10828 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10829 wait $create_pid || return 1
10831 unlinkmany $DIR/$tdir/f $nr
10833 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10835 test_140() { #bug-17379
10836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10837 test_mkdir $DIR/$tdir
10838 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10839 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10841 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10842 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10844 while i=$((i + 1)); do
10846 cd $i || error "Changing to $i"
10847 ln -s ../stat stat || error "Creating stat symlink"
10848 # Read the symlink until ELOOP present,
10849 # not LBUGing the system is considered success,
10850 # we didn't overrun the stack.
10851 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10852 if [ $ret -ne 0 ]; then
10853 if [ $ret -eq 40 ]; then
10856 error "Open stat symlink"
10862 echo "The symlink depth = $i"
10863 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10864 error "Invalid symlink depth"
10866 # Test recursive symlink
10867 ln -s symlink_self symlink_self
10868 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10869 echo "open symlink_self returns $ret"
10870 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10872 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10876 local TF="$TMP/$tfile"
10878 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10880 cancel_lru_locks $OSC
10881 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10882 remount_client $MOUNT
10884 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10887 $TRUNCATE $DIR/$tfile 6000
10888 cancel_lru_locks $OSC
10889 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10892 echo "12345" >>$DIR/$tfile
10893 cancel_lru_locks $OSC
10894 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10897 echo "12345" >>$DIR/$tfile
10898 cancel_lru_locks $OSC
10899 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10904 run_test 150 "truncate/append tests"
10906 #LU-2902 roc_hit was not able to read all values from lproc
10907 function roc_hit_init() {
10908 local list=$(comma_list $(osts_nodes))
10909 local dir=$DIR/$tdir-check
10910 local file=$dir/$tfile
10916 #use setstripe to do a write to every ost
10917 for i in $(seq 0 $((OSTCOUNT-1))); do
10918 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10919 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10920 idx=$(printf %04x $i)
10921 BEFORE=$(get_osd_param $list *OST*$idx stats |
10922 awk '$1 == "cache_access" {sum += $7}
10923 END { printf("%0.0f", sum) }')
10925 cancel_lru_locks osc
10926 cat $file >/dev/null
10928 AFTER=$(get_osd_param $list *OST*$idx stats |
10929 awk '$1 == "cache_access" {sum += $7}
10930 END { printf("%0.0f", sum) }')
10932 echo BEFORE:$BEFORE AFTER:$AFTER
10933 if ! let "AFTER - BEFORE == 4"; then
10935 error "roc_hit is not safe to use"
10943 function roc_hit() {
10944 local list=$(comma_list $(osts_nodes))
10945 echo $(get_osd_param $list '' stats |
10946 awk '$1 == "cache_hit" {sum += $7}
10947 END { printf("%0.0f", sum) }')
10950 function set_cache() {
10953 if [ "$2" == "off" ]; then
10956 local list=$(comma_list $(osts_nodes))
10957 set_osd_param $list '' $1_cache_enable $on
10959 cancel_lru_locks osc
10963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10964 remote_ost_nodsh && skip "remote OST with nodsh" && return
10967 local list=$(comma_list $(osts_nodes))
10969 # check whether obdfilter is cache capable at all
10970 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10971 echo "not cache-capable obdfilter"
10975 # check cache is enabled on all obdfilters
10976 if get_osd_param $list '' read_cache_enable | grep 0; then
10977 echo "oss cache is disabled"
10981 set_osd_param $list '' writethrough_cache_enable 1
10983 # check write cache is enabled on all obdfilters
10984 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10985 echo "oss write cache is NOT enabled"
10991 #define OBD_FAIL_OBD_NO_LRU 0x609
10992 do_nodes $list $LCTL set_param fail_loc=0x609
10994 # pages should be in the case right after write
10995 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10998 local BEFORE=$(roc_hit)
10999 cancel_lru_locks osc
11000 cat $DIR/$tfile >/dev/null
11001 local AFTER=$(roc_hit)
11003 do_nodes $list $LCTL set_param fail_loc=0
11005 if ! let "AFTER - BEFORE == CPAGES"; then
11006 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11009 # the following read invalidates the cache
11010 cancel_lru_locks osc
11011 set_osd_param $list '' read_cache_enable 0
11012 cat $DIR/$tfile >/dev/null
11014 # now data shouldn't be found in the cache
11016 cancel_lru_locks osc
11017 cat $DIR/$tfile >/dev/null
11019 if let "AFTER - BEFORE != 0"; then
11020 error "IN CACHE: before: $BEFORE, after: $AFTER"
11023 set_osd_param $list '' read_cache_enable 1
11026 run_test 151 "test cache on oss and controls ==============================="
11029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11030 local TF="$TMP/$tfile"
11032 # simulate ENOMEM during write
11033 #define OBD_FAIL_OST_NOMEM 0x226
11034 lctl set_param fail_loc=0x80000226
11035 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11037 sync || error "sync failed"
11038 lctl set_param fail_loc=0
11040 # discard client's cache
11041 cancel_lru_locks osc
11043 # simulate ENOMEM during read
11044 lctl set_param fail_loc=0x80000226
11045 cmp $TF $DIR/$tfile || error "cmp failed"
11046 lctl set_param fail_loc=0
11050 run_test 152 "test read/write with enomem ============================"
11053 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11055 run_test 153 "test if fdatasync does not crash ======================="
11057 dot_lustre_fid_permission_check() {
11059 local ffid=$MOUNT/.lustre/fid/$fid
11062 echo "stat fid $fid"
11063 stat $ffid > /dev/null || error "stat $ffid failed."
11064 echo "touch fid $fid"
11065 touch $ffid || error "touch $ffid failed."
11066 echo "write to fid $fid"
11067 cat /etc/hosts > $ffid || error "write $ffid failed."
11068 echo "read fid $fid"
11069 diff /etc/hosts $ffid || error "read $ffid failed."
11070 echo "append write to fid $fid"
11071 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11072 echo "rename fid $fid"
11073 mv $ffid $test_dir/$tfile.1 &&
11074 error "rename $ffid to $tfile.1 should fail."
11075 touch $test_dir/$tfile.1
11076 mv $test_dir/$tfile.1 $ffid &&
11077 error "rename $tfile.1 to $ffid should fail."
11078 rm -f $test_dir/$tfile.1
11079 echo "truncate fid $fid"
11080 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11081 echo "link fid $fid"
11082 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11083 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11084 echo "setfacl fid $fid"
11085 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11086 echo "getfacl fid $fid"
11087 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11089 echo "unlink fid $fid"
11090 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11091 echo "mknod fid $fid"
11092 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11094 fid=[0xf00000400:0x1:0x0]
11095 ffid=$MOUNT/.lustre/fid/$fid
11097 echo "stat non-exist fid $fid"
11098 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11099 echo "write to non-exist fid $fid"
11100 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11101 echo "link new fid $fid"
11102 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11104 mkdir -p $test_dir/$tdir
11105 touch $test_dir/$tdir/$tfile
11106 fid=$($LFS path2fid $test_dir/$tdir)
11109 error "error: could not get fid for $test_dir/$dir/$tfile."
11111 ffid=$MOUNT/.lustre/fid/$fid
11114 ls $ffid > /dev/null || error "ls $ffid failed."
11115 echo "touch $fid/$tfile.1"
11116 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11118 echo "touch $MOUNT/.lustre/fid/$tfile"
11119 touch $MOUNT/.lustre/fid/$tfile && \
11120 error "touch $MOUNT/.lustre/fid/$tfile should fail."
11122 echo "setxattr to $MOUNT/.lustre/fid"
11123 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
11125 echo "listxattr for $MOUNT/.lustre/fid"
11126 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
11128 echo "delxattr from $MOUNT/.lustre/fid"
11129 setfattr -x trusted.name1 $MOUNT/.lustre/fid
11131 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
11132 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
11133 error "touch invalid fid should fail."
11135 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
11136 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
11137 error "touch non-normal fid should fail."
11139 echo "rename $tdir to $MOUNT/.lustre/fid"
11140 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
11141 error "rename to $MOUNT/.lustre/fid should fail."
11143 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
11145 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
11146 local new_obf_mode=777
11148 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
11149 chmod $new_obf_mode $DIR/.lustre/fid ||
11150 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
11152 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
11153 [ $obf_mode -eq $new_obf_mode ] ||
11154 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
11156 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
11157 chmod $old_obf_mode $DIR/.lustre/fid ||
11158 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
11161 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
11162 fid=$($LFS path2fid $test_dir/$tfile-2)
11164 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
11166 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
11167 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
11168 error "create lov data thru .lustre failed"
11170 echo "cp /etc/passwd $test_dir/$tfile-2"
11171 cp /etc/passwd $test_dir/$tfile-2 ||
11172 error "copy to $test_dir/$tfile-2 failed."
11173 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
11174 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
11175 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
11177 rm -rf $test_dir/tfile.lnk
11178 rm -rf $test_dir/$tfile-2
11182 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11183 skip "Need MDS version at least 2.4.1" && return
11185 local tf=$DIR/$tfile
11188 local fid=$($LFS path2fid $tf)
11189 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
11191 # check that we get the same pathname back
11192 local found=$($LFS fid2path $MOUNT "$fid")
11193 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
11194 [ "$found" == "$tf" ] ||
11195 error "fid2path($fid=path2fid($tf)) = $found != $tf"
11197 run_test 154A "lfs path2fid and fid2path basic checks"
11200 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11201 skip "Need MDS version at least 2.4.1" && return
11203 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11204 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11205 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
11206 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
11208 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
11209 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
11211 # check that we get the same pathname
11212 echo "PFID: $PFID, name: $name"
11213 local FOUND=$($LFS fid2path $MOUNT "$PFID")
11214 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
11215 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
11216 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
11218 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
11220 run_test 154B "verify the ll_decode_linkea tool"
11223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11224 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11225 { skip "Need MDS version at least 2.2.51"; return 0; }
11226 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
11227 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11229 cp /etc/hosts $DIR/$tfile
11231 fid=$($LFS path2fid $DIR/$tfile)
11233 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
11235 dot_lustre_fid_permission_check "$fid" $DIR ||
11236 error "dot lustre permission check $fid failed"
11238 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
11240 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
11242 touch $MOUNT/.lustre/file &&
11243 error "creation is not allowed under .lustre"
11245 mkdir $MOUNT/.lustre/dir &&
11246 error "mkdir is not allowed under .lustre"
11250 run_test 154a "Open-by-FID"
11253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11254 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11255 { skip "Need MDS version at least 2.2.51"; return 0; }
11256 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11258 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11260 local remote_dir=$DIR/$tdir/remote_dir
11264 mkdir -p $DIR/$tdir
11265 $LFS mkdir -i $MDTIDX $remote_dir ||
11266 error "create remote directory failed"
11268 cp /etc/hosts $remote_dir/$tfile
11270 fid=$($LFS path2fid $remote_dir/$tfile)
11272 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11274 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11275 error "dot lustre permission check $fid failed"
11278 run_test 154b "Open-by-FID for remote directory"
11281 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11282 skip "Need MDS version at least 2.4.1" && return
11284 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11285 local FID1=$($LFS path2fid $DIR/$tfile.1)
11286 local FID2=$($LFS path2fid $DIR/$tfile.2)
11287 local FID3=$($LFS path2fid $DIR/$tfile.3)
11290 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11291 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11292 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11294 [ "$FID" = "${!want}" ] ||
11295 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11299 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11301 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11302 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11306 run_test 154c "lfs path2fid and fid2path multiple arguments"
11309 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11310 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
11311 skip "Need MDS version at least 2.5.53" && return
11313 if remote_mds; then
11314 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11318 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11325 local fid=$($LFS path2fid $DIR/$tfile)
11328 cmd="exec $fd<$DIR/$tfile"
11330 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11331 echo "$fid_list" | grep "$fid"
11334 cmd="exec $fd>/dev/null"
11336 if [ $rc -ne 0 ]; then
11337 error "FID $fid not found in open files list $fid_list"
11340 run_test 154d "Verify open file fid"
11344 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
11345 skip "Need MDS version at least 2.6.50" && return
11347 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11348 error ".lustre returned by readdir"
11351 run_test 154e ".lustre is not returned by readdir"
11354 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11355 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11356 test_mkdir -p -c1 $DIR/$tdir/d
11357 # test dirs inherit from its stripe
11358 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11359 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11360 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11361 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11364 # get fid of parents
11365 local FID0=$($LFS path2fid $DIR/$tdir/d)
11366 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11367 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11368 local FID3=$($LFS path2fid $DIR)
11370 # check that path2fid --parents returns expected <parent_fid>/name
11371 # 1) test for a directory (single parent)
11372 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11373 [ "$parent" == "$FID0/foo1" ] ||
11374 error "expected parent: $FID0/foo1, got: $parent"
11376 # 2) test for a file with nlink > 1 (multiple parents)
11377 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11378 echo "$parent" | grep -F "$FID1/$tfile" ||
11379 error "$FID1/$tfile not returned in parent list"
11380 echo "$parent" | grep -F "$FID2/link" ||
11381 error "$FID2/link not returned in parent list"
11383 # 3) get parent by fid
11384 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11385 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11386 echo "$parent" | grep -F "$FID1/$tfile" ||
11387 error "$FID1/$tfile not returned in parent list (by fid)"
11388 echo "$parent" | grep -F "$FID2/link" ||
11389 error "$FID2/link not returned in parent list (by fid)"
11391 # 4) test for entry in root directory
11392 parent=$($LFS path2fid --parents $DIR/f)
11393 echo "$parent" | grep -F "$FID3/f" ||
11394 error "$FID3/f not returned in parent list"
11396 # 5) test it on root directory
11397 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11398 error "$MOUNT should not have parents"
11400 # enable xattr caching and check that linkea is correctly updated
11401 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11402 save_lustre_params client "llite.*.xattr_cache" > $save
11403 lctl set_param llite.*.xattr_cache 1
11405 # 6.1) linkea update on rename
11406 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11408 # get parents by fid
11409 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11410 # foo1 should no longer be returned in parent list
11411 echo "$parent" | grep -F "$FID1" &&
11412 error "$FID1 should no longer be in parent list"
11413 # the new path should appear
11414 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11415 error "$FID2/$tfile.moved is not in parent list"
11417 # 6.2) linkea update on unlink
11418 rm -f $DIR/$tdir/d/foo2/link
11419 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11420 # foo2/link should no longer be returned in parent list
11421 echo "$parent" | grep -F "$FID2/link" &&
11422 error "$FID2/link should no longer be in parent list"
11426 restore_lustre_params < $save
11429 run_test 154f "get parent fids by reading link ea"
11433 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11434 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11435 { skip "Need MDS version at least 2.6.92"; return 0; }
11436 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11438 mkdir -p $DIR/$tdir
11439 llapi_fid_test -d $DIR/$tdir
11441 run_test 154g "various llapi FID tests"
11443 test_155_small_load() {
11444 local temp=$TMP/$tfile
11445 local file=$DIR/$tfile
11447 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11448 error "dd of=$temp bs=6096 count=1 failed"
11450 cancel_lru_locks $OSC
11451 cmp $temp $file || error "$temp $file differ"
11453 $TRUNCATE $temp 6000
11454 $TRUNCATE $file 6000
11455 cmp $temp $file || error "$temp $file differ (truncate1)"
11457 echo "12345" >>$temp
11458 echo "12345" >>$file
11459 cmp $temp $file || error "$temp $file differ (append1)"
11461 echo "12345" >>$temp
11462 echo "12345" >>$file
11463 cmp $temp $file || error "$temp $file differ (append2)"
11469 test_155_big_load() {
11470 remote_ost_nodsh && skip "remote OST with nodsh" && return
11471 local temp=$TMP/$tfile
11472 local file=$DIR/$tfile
11475 local cache_size=$(do_facet ost$((MAXI+1)) \
11476 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11477 local large_file_size=$((cache_size * 2))
11479 echo "OSS cache size: $cache_size KB"
11480 echo "Large file size: $large_file_size KB"
11482 [ $MAXV -le $large_file_size ] && \
11483 skip_env "max available OST size needs > $large_file_size KB" && \
11486 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11488 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
11489 error "dd of=$temp bs=$large_file_size count=1k failed"
11492 cancel_lru_locks osc
11493 cmp $temp $file || error "$temp $file differ"
11499 save_writethrough() {
11500 local facets=$(get_facets OST)
11502 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11503 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11508 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11509 save_writethrough $p
11512 set_cache writethrough on
11513 test_155_small_load
11514 restore_lustre_params < $p
11517 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11521 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11522 save_writethrough $p
11525 set_cache writethrough off
11526 test_155_small_load
11527 restore_lustre_params < $p
11530 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11534 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11535 save_writethrough $p
11538 set_cache writethrough on
11539 test_155_small_load
11540 restore_lustre_params < $p
11543 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11547 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11548 save_writethrough $p
11551 set_cache writethrough off
11552 test_155_small_load
11553 restore_lustre_params < $p
11556 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11560 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11561 save_writethrough $p
11564 set_cache writethrough on
11566 restore_lustre_params < $p
11569 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11573 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11574 save_writethrough $p
11577 set_cache writethrough off
11579 restore_lustre_params < $p
11582 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11586 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11587 save_writethrough $p
11590 set_cache writethrough on
11592 restore_lustre_params < $p
11595 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11599 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11600 save_writethrough $p
11603 set_cache writethrough off
11605 restore_lustre_params < $p
11608 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11611 remote_ost_nodsh && skip "remote OST with nodsh" && return
11612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11616 local file="$DIR/$tfile"
11617 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11619 [ "$(facet_fstype ost1)" = "zfs" -a \
11620 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11621 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11624 save_writethrough $p
11627 log "Turn on read and write cache"
11629 set_cache writethrough on
11631 log "Write data and read it back."
11632 log "Read should be satisfied from the cache."
11633 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11635 cancel_lru_locks osc
11636 cat $file >/dev/null
11638 if ! let "AFTER - BEFORE == CPAGES"; then
11639 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11641 log "cache hits:: before: $BEFORE, after: $AFTER"
11644 log "Read again; it should be satisfied from the cache."
11646 cancel_lru_locks osc
11647 cat $file >/dev/null
11649 if ! let "AFTER - BEFORE == CPAGES"; then
11650 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11652 log "cache hits:: before: $BEFORE, after: $AFTER"
11655 log "Turn off the read cache and turn on the write cache"
11657 set_cache writethrough on
11659 log "Read again; it should be satisfied from the cache."
11661 cancel_lru_locks osc
11662 cat $file >/dev/null
11664 if ! let "AFTER - BEFORE == CPAGES"; then
11665 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11667 log "cache hits:: before: $BEFORE, after: $AFTER"
11670 log "Read again; it should not be satisfied from the cache."
11672 cancel_lru_locks osc
11673 cat $file >/dev/null
11675 if ! let "AFTER - BEFORE == 0"; then
11676 error "IN CACHE: before: $BEFORE, after: $AFTER"
11678 log "cache hits:: before: $BEFORE, after: $AFTER"
11681 log "Write data and read it back."
11682 log "Read should be satisfied from the cache."
11683 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11685 cancel_lru_locks osc
11686 cat $file >/dev/null
11688 if ! let "AFTER - BEFORE == CPAGES"; then
11689 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11691 log "cache hits:: before: $BEFORE, after: $AFTER"
11694 log "Read again; it should not be satisfied from the cache."
11696 cancel_lru_locks osc
11697 cat $file >/dev/null
11699 if ! let "AFTER - BEFORE == 0"; then
11700 error "IN CACHE: before: $BEFORE, after: $AFTER"
11702 log "cache hits:: before: $BEFORE, after: $AFTER"
11705 log "Turn off read and write cache"
11707 set_cache writethrough off
11709 log "Write data and read it back"
11710 log "It should not be satisfied from the cache."
11712 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11713 cancel_lru_locks osc
11715 cat $file >/dev/null
11717 if ! let "AFTER - BEFORE == 0"; then
11718 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11720 log "cache hits:: before: $BEFORE, after: $AFTER"
11723 log "Turn on the read cache and turn off the write cache"
11725 set_cache writethrough off
11727 log "Write data and read it back"
11728 log "It should not be satisfied from the cache."
11730 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11732 cancel_lru_locks osc
11733 cat $file >/dev/null
11735 if ! let "AFTER - BEFORE == 0"; then
11736 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11738 log "cache hits:: before: $BEFORE, after: $AFTER"
11741 log "Read again; it should be satisfied from the cache."
11743 cancel_lru_locks osc
11744 cat $file >/dev/null
11746 if ! let "AFTER - BEFORE == CPAGES"; then
11747 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11749 log "cache hits:: before: $BEFORE, after: $AFTER"
11752 restore_lustre_params < $p
11755 run_test 156 "Verification of tunables"
11758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11759 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11760 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11761 { skip "Need MDS version at least 2.2.0"; return; }
11763 changelog_register || error "changelog_register failed"
11764 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
11765 changelog_users $SINGLEMDS | grep -q $cl_user ||
11766 error "User $cl_user not found in changelog_users"
11769 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11770 changelog_clear 0 || error "changelog_clear failed"
11771 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
11772 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
11773 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11774 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11775 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11776 rm $DIR/$tdir/pics/desktop.jpg
11778 changelog_dump | tail -10
11780 echo "verifying changelog mask"
11781 changelog_chmask "-MKDIR"
11782 changelog_chmask "-CLOSE"
11784 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
11785 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
11787 changelog_chmask "+MKDIR"
11788 changelog_chmask "+CLOSE"
11790 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
11791 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
11793 changelog_dump | tail -10
11794 MKDIRS=$(changelog_dump | grep -c "MKDIR")
11795 CLOSES=$(changelog_dump | grep -c "CLOSE")
11796 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
11797 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
11800 echo "verifying target fid"
11801 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
11802 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
11803 [ "$fidc" == "$fidf" ] ||
11804 error "changelog '$tfile' fid $fidc != file fid $fidf"
11805 echo "verifying parent fid"
11806 # The FID returned from the Changelog may be the directory shard on
11807 # a different MDT, and not the FID returned by path2fid on the parent.
11808 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
11809 # since this is what will matter when recreating this file in the tree.
11810 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
11811 local pathp=$($LFS fid2path $MOUNT "$fidp")
11812 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
11813 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
11815 echo "getting records for $cl_user"
11816 changelog_users $SINGLEMDS
11817 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
11819 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
11820 error "changelog_clear failed"
11821 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
11822 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
11823 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
11824 error "user index expect $user_rec1 + $nclr != $user_rec2"
11826 local min0_rec=$(changelog_users $SINGLEMDS |
11827 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
11828 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
11829 awk '{ print $1; exit; }')
11831 changelog_dump | tail -n 5
11832 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
11833 [ $first_rec == $((min0_rec + 1)) ] ||
11834 error "first index should be $min0_rec + 1 not $first_rec"
11836 # LU-3446 changelog index reset on MDT restart
11837 local cur_rec1=$(changelog_users $SINGLEMDS |
11838 awk '/^current.index:/ { print $NF }')
11839 changelog_clear 0 ||
11840 error "clear all changelog records for $cl_user failed"
11841 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
11842 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
11843 error "Fail to start $SINGLEMDS"
11844 local cur_rec2=$(changelog_users $SINGLEMDS |
11845 awk '/^current.index:/ { print $NF }')
11846 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
11847 [ $cur_rec1 == $cur_rec2 ] ||
11848 error "current index should be $cur_rec1 not $cur_rec2"
11850 echo "verifying users from this test are deregistered"
11851 changelog_deregister || error "changelog_deregister failed"
11852 changelog_users $SINGLEMDS | grep -q $cl_user &&
11853 error "User '$cl_user' still in changelog_users"
11855 # lctl get_param -n mdd.*.changelog_users
11856 # current index: 144
11857 # ID index (idle seconds)
11859 if ! changelog_users $SINGLEMDS | grep "^cl"; then
11860 # this is the normal case where all users were deregistered
11861 # make sure no new records are added when no users are present
11862 local last_rec1=$(changelog_users $SINGLEMDS |
11863 awk '/^current.index:/ { print $NF }')
11864 touch $DIR/$tdir/chloe
11865 local last_rec2=$(changelog_users $SINGLEMDS |
11866 awk '/^current.index:/ { print $NF }')
11867 echo "verify changelogs are off: $last_rec1 == $last_rec2"
11868 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
11870 # any changelog users must be leftovers from a previous test
11871 changelog_users $SINGLEMDS
11872 echo "other changelog users; can't verify off"
11875 run_test 160a "changelog sanity"
11877 test_160b() { # LU-3587
11878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11879 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11880 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11881 { skip "Need MDS version at least 2.2.0"; return; }
11883 changelog_register || error "changelog_register failed"
11884 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
11885 changelog_users $SINGLEMDS | grep -q $cl_user ||
11886 error "User '$cl_user' not found in changelog_users"
11888 local longname1=$(str_repeat a 255)
11889 local longname2=$(str_repeat b 255)
11892 echo "creating very long named file"
11893 touch $longname1 || error "create of '$longname1' failed"
11894 echo "renaming very long named file"
11895 mv $longname1 $longname2
11897 changelog_dump | grep RENME | tail -n 5
11900 run_test 160b "Verify that very long rename doesn't crash in changelog"
11903 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11906 local server_version=$(lustre_version_code $SINGLEMDS)
11908 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11909 [[ $server_version -gt $(version_code 2.5.1) &&
11910 $server_version -lt $(version_code 2.5.50) ]] ||
11911 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11914 # Registration step
11915 changelog_register || error "changelog_register failed"
11918 mkdir -p $DIR/$tdir
11919 $MCREATE $DIR/$tdir/foo_160c
11920 changelog_chmask "-TRUNC"
11921 $TRUNCATE $DIR/$tdir/foo_160c 200
11922 changelog_chmask "+TRUNC"
11923 $TRUNCATE $DIR/$tdir/foo_160c 199
11924 changelog_dump | tail -n 5
11925 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
11926 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
11928 run_test 160c "verify that changelog log catch the truncate event"
11931 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11934 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]] ||
11935 { skip "Need MDS version at least 2.7.60+"; return; }
11936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11938 # Registration step
11939 changelog_register || error "changelog_register failed"
11941 mkdir -p $DIR/$tdir/migrate_dir
11942 changelog_clear 0 || error "changelog_clear failed"
11944 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11945 changelog_dump | tail -n 5
11946 local migrates=$(changelog_dump | grep -c "MIGRT")
11947 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
11949 run_test 160d "verify that changelog log catch the migrate event"
11952 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11955 changelog_register || error "changelog_register failed"
11957 # Delete a future user (expect fail)
11958 local MDT0=$(facet_svc $SINGLEMDS)
11959 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
11962 if [ $rc -eq 0 ]; then
11963 error "Deleted non-existant user cl77"
11964 elif [ $rc -ne 2 ]; then
11965 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
11968 # Clear to a bad index (1 billion should be safe)
11969 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
11972 if [ $rc -eq 0 ]; then
11973 error "Successfully cleared to invalid CL index"
11974 elif [ $rc -ne 22 ]; then
11975 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11978 run_test 160e "changelog negative testing (should return errors)"
11981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11982 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
11983 { skip "Need MDS version at least 2.10.56"; return 0; }
11985 local mdts=$(comma_list $(mdts_nodes))
11988 changelog_register || error "first changelog_register failed"
11989 changelog_register || error "second changelog_register failed"
11990 local cl_users=(${CL_USERS[$SINGLEMDS]})
11991 local cl_user1="${cl_users[0]}"
11992 local cl_user2="${cl_users[1]}"
11994 # generate some changelog records to accumulate on each MDT
11995 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
11996 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
11997 error "create $DIR/$tdir/$tfile failed"
11999 # check changelogs have been generated
12000 nbcl=$(changelog_dump | wc -l)
12001 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12003 # changelog_gc=1 should be set by default
12004 for param in "changelog_max_idle_time=10" \
12005 "changelog_min_gc_interval=2" \
12006 "changelog_min_free_cat_entries=3"; do
12007 local MDT0=$(facet_svc $SINGLEMDS)
12008 local var="${param%=*}"
12009 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12011 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12012 do_nodes $mdts $LCTL set_param mdd.*.$param
12015 # simulate changelog catalog almost full
12016 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12017 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12020 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user1)
12021 [ -n "$user_rec1" ] ||
12022 error "User $cl_user1 not found in changelog_users"
12023 __changelog_clear $SINGLEMDS $cl_user1 +2
12024 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user1)
12025 [ -n "$user_rec2" ] ||
12026 error "User $cl_user1 not found in changelog_users"
12027 echo "verifying user clear: $user_rec1 + 2 == $user_rec2"
12028 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12029 error "user index expected $user_rec1 + 2, but is $user_rec2"
12032 # generate one more changelog to trigger fail_loc
12033 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
12035 # ensure gc thread is done
12036 wait_update_facet $SINGLEMDS \
12037 "ps -e -o comm= | grep chlg_gc_thread" "" 20
12039 # check user still registered
12040 changelog_users $SINGLEMDS | grep -q "$cl_user1" ||
12041 error "User $cl_user1 not found in changelog_users"
12042 # check user2 unregistered
12043 changelog_users $SINGLEMDS | grep -q "$cl_user2" &&
12044 error "User $cl_user2 still found in changelog_users"
12046 # check changelogs are present and starting at $user_rec2 + 1
12047 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12048 awk '{ print $1; exit; }')
12050 echo "verifying min purge: $user_rec2 + 1 == $first_rec"
12051 [ $((user_rec2 + 1)) == $first_rec ] ||
12052 error "first index should be $user_rec2 + 1, but is $first_rec"
12054 run_test 160f "changelog garbage collect (timestamped users)"
12057 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12058 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12059 { skip "Need MDS version at least 2.10.56"; return 0; }
12061 local mdts=$(comma_list $(mdts_nodes))
12063 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12064 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12067 changelog_register || error "first changelog_register failed"
12068 changelog_register || error "second changelog_register failed"
12069 local cl_users=(${CL_USERS[$SINGLEMDS]})
12070 local cl_user1="${cl_users[0]}"
12071 local cl_user2="${cl_users[1]}"
12073 # generate some changelog records to accumulate on each MDT
12074 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12075 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12076 error "create $DIR/$tdir/$tfile failed"
12078 # check changelogs have been generated
12079 nbcl=$(changelog_dump | wc -l)
12080 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12082 # changelog_gc=1 should be set by default
12083 for param in "changelog_max_idle_indexes=$((nbcl / 2))" \
12084 "changelog_min_gc_interval=2" \
12085 "changelog_min_free_cat_entries=3"; do
12086 local MDT0=$(facet_svc $SINGLEMDS)
12087 local var="${param%=*}"
12088 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12090 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12091 do_nodes $mdts $LCTL set_param mdd.*.$param ||
12092 error "unable to set mdd.*.$param"
12095 # simulate changelog catalog almost full
12096 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12097 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12099 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user1)
12101 __changelog_clear $SINGLEMDS $cl_user1 +3
12103 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user1)
12105 echo "verifying user clear: $user_rec1 + 3 == $user_rec2"
12106 [ $((user_rec1 + 3)) == $user_rec2 ] ||
12107 error "user index expected $user_rec1 + 3, but is $user_rec2"
12109 # generate one more changelog to trigger fail_loc
12110 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
12112 # ensure gc thread is done
12113 wait_update_facet $SINGLEMDS \
12114 "ps -e -o comm= | grep chlg_gc_thread" "" 20
12116 # check user still registered
12117 [ -n "$(changelog_user_rec $SINGLEMDS $cl_user1)" ] ||
12118 error "User $cl_user1 not found in changelog_users"
12119 # check user2 unregistered
12120 [ -z "$(changelog_user_rec $SINGLEMDS $cl_user2)" ] ||
12121 error "User $cl_user2 still found in changelog_users"
12123 # check changelogs are present and starting at $user_rec2 + 1
12124 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12125 awk '{ print $1; exit; }')
12127 echo "verifying min purge: $user_rec2 + 1 == $first_rec"
12128 [ $((user_rec2 + 1)) == $first_rec ] ||
12129 error "first index should be $user_rec2 + 1, but is $first_rec"
12131 run_test 160g "changelog garbage collect (old users)"
12134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12135 test_mkdir -c1 $DIR/$tdir
12136 cp /etc/hosts $DIR/$tdir/$tfile
12137 test_mkdir -c1 $DIR/$tdir/foo1
12138 test_mkdir -c1 $DIR/$tdir/foo2
12139 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
12140 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
12141 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
12142 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
12143 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
12144 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12145 $LFS fid2path $DIR $FID
12146 error "bad link ea"
12149 rm $DIR/$tdir/foo2/zachary
12151 rm $DIR/$tdir/foo2/thor
12153 rm $DIR/$tdir/$tfile
12155 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
12156 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
12157 { $LFS fid2path $DIR $FID; error "bad link rename"; }
12158 rm $DIR/$tdir/foo2/maggie
12161 local longname=$tfile.avg_len_is_thirty_two_
12162 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
12163 error_noexit 'failed to unlink many hardlinks'" EXIT
12164 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
12165 error "failed to hardlink many files"
12166 links=$($LFS fid2path $DIR $FID | wc -l)
12167 echo -n "${links}/1000 links in link EA"
12168 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
12170 run_test 161a "link ea sanity"
12173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12174 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
12176 local remote_dir=$DIR/$tdir/remote_dir
12178 mkdir -p $DIR/$tdir
12179 $LFS mkdir -i $MDTIDX $remote_dir ||
12180 error "create remote directory failed"
12182 cp /etc/hosts $remote_dir/$tfile
12183 mkdir -p $remote_dir/foo1
12184 mkdir -p $remote_dir/foo2
12185 ln $remote_dir/$tfile $remote_dir/foo1/sofia
12186 ln $remote_dir/$tfile $remote_dir/foo2/zachary
12187 ln $remote_dir/$tfile $remote_dir/foo1/luna
12188 ln $remote_dir/$tfile $remote_dir/foo2/thor
12190 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
12192 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12193 $LFS fid2path $DIR $FID
12194 error "bad link ea"
12197 rm $remote_dir/foo2/zachary
12199 rm $remote_dir/foo2/thor
12201 rm $remote_dir/$tfile
12203 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
12204 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
12205 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
12206 $LFS fid2path $DIR $FID
12207 error "bad link rename"
12209 rm $remote_dir/foo2/maggie
12212 local longname=filename_avg_len_is_thirty_two_
12213 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
12214 error "failed to hardlink many files"
12215 links=$($LFS fid2path $DIR $FID | wc -l)
12216 echo -n "${links}/1000 links in link EA"
12217 [[ ${links} -gt 60 ]] ||
12218 error "expected at least 60 links in link EA"
12219 unlinkmany $remote_dir/foo2/$longname 1000 ||
12220 error "failed to unlink many hardlinks"
12222 run_test 161b "link ea sanity under remote directory"
12225 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12227 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
12228 skip "Need MDS version at least 2.1.5" && return
12230 # define CLF_RENAME_LAST 0x0001
12231 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
12232 changelog_register || error "changelog_register failed"
12235 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
12236 touch $DIR/$tdir/foo_161c
12237 touch $DIR/$tdir/bar_161c
12238 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12239 changelog_dump | grep RENME | tail -n 5
12240 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
12241 changelog_clear 0 || error "changelog_clear failed"
12242 if [ x$flags != "x0x1" ]; then
12243 error "flag $flags is not 0x1"
12246 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
12247 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
12248 touch $DIR/$tdir/foo_161c
12249 touch $DIR/$tdir/bar_161c
12250 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12251 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12252 changelog_dump | grep RENME | tail -n 5
12253 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
12254 changelog_clear 0 || error "changelog_clear failed"
12255 if [ x$flags != "x0x0" ]; then
12256 error "flag $flags is not 0x0"
12258 echo "rename overwrite a target having nlink > 1," \
12259 "changelog record has flags of $flags"
12261 # rename doesn't overwrite a target (changelog flag 0x0)
12262 touch $DIR/$tdir/foo_161c
12263 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
12264 changelog_dump | grep RENME | tail -n 5
12265 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
12266 changelog_clear 0 || error "changelog_clear failed"
12267 if [ x$flags != "x0x0" ]; then
12268 error "flag $flags is not 0x0"
12270 echo "rename doesn't overwrite a target," \
12271 "changelog record has flags of $flags"
12273 # define CLF_UNLINK_LAST 0x0001
12274 # unlink a file having nlink = 1 (changelog flag 0x1)
12275 rm -f $DIR/$tdir/foo2_161c
12276 changelog_dump | grep UNLNK | tail -n 5
12277 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
12278 changelog_clear 0 || error "changelog_clear failed"
12279 if [ x$flags != "x0x1" ]; then
12280 error "flag $flags is not 0x1"
12282 echo "unlink a file having nlink = 1," \
12283 "changelog record has flags of $flags"
12285 # unlink a file having nlink > 1 (changelog flag 0x0)
12286 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12287 rm -f $DIR/$tdir/foobar_161c
12288 changelog_dump | grep UNLNK | tail -n 5
12289 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
12290 changelog_clear 0 || error "changelog_clear failed"
12291 if [ x$flags != "x0x0" ]; then
12292 error "flag $flags is not 0x0"
12294 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
12296 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
12299 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12304 changelog_register || error "changelog_register failed"
12306 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
12307 # interfer with $MOUNT/.lustre/fid/ access
12309 [[ $? -eq 0 ]] || error "mkdir failed"
12311 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
12312 $LCTL set_param fail_loc=0x8000140c
12314 $LCTL set_param fail_val=5
12317 echo foofoo > $DIR/$tdir/$tfile &
12320 # wait for create to be delayed
12324 [[ $? -eq 0 ]] || error "create should be blocked"
12326 local tempfile=$(mktemp)
12327 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
12328 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
12329 # some delay may occur during ChangeLog publishing and file read just
12330 # above, that could allow file write to happen finally
12331 [[ -s $tempfile ]] && echo "file should be empty"
12333 $LCTL set_param fail_loc=0
12336 [[ $? -eq 0 ]] || error "create failed"
12338 run_test 161d "create with concurrent .lustre/fid access"
12341 local expected="$1"
12346 path=$($LFS fid2path "$@")
12349 if [ $rc -ne 0 ]; then
12350 error "path looked up of '$expected' failed: rc=$rc"
12351 elif [ "$path" != "$expected" ]; then
12352 error "path looked up '$path' instead of '$expected'"
12354 echo "FID '$fid' resolves to path '$path' as expected"
12358 test_162a() { # was test_162
12359 test_mkdir -p -c1 $DIR/$tdir/d2
12360 touch $DIR/$tdir/d2/$tfile
12361 touch $DIR/$tdir/d2/x1
12362 touch $DIR/$tdir/d2/x2
12363 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
12364 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
12366 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
12367 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
12370 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
12371 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
12372 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
12374 # softlink to wrong file
12375 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
12376 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
12377 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
12380 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
12381 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
12382 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
12383 # fid2path dir/fsname should both work
12384 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
12385 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
12387 # hardlink count: check that there are 2 links
12388 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
12389 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
12391 # hardlink indexing: remove the first link
12392 rm $DIR/$tdir/d2/p/q/r/hlink
12393 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
12395 run_test 162a "path lookup sanity"
12398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12399 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12402 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
12403 error "create striped dir failed"
12405 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
12406 tail -n 1 | awk '{print $2}')
12407 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
12409 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
12410 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
12413 for ((i=0;i<5;i++)); do
12414 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
12415 error "get fid for f$i failed"
12416 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
12418 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
12419 error "get fid for d$i failed"
12420 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
12425 run_test 162b "striped directory path lookup sanity"
12427 # LU-4239: Verify fid2path works with paths 100 or more directories deep
12429 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
12430 skip "Need MDS version at least 2.7.51" && return
12431 test_mkdir $DIR/$tdir.local
12432 test_mkdir $DIR/$tdir.remote
12433 local lpath=$tdir.local
12434 local rpath=$tdir.remote
12436 for ((i = 0; i <= 101; i++)); do
12439 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
12440 error "get fid for local directory $DIR/$lpath failed"
12441 check_path "$DIR/$lpath" $MOUNT $FID --link 0
12444 test_mkdir $DIR/$rpath
12445 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
12446 error "get fid for remote directory $DIR/$rpath failed"
12447 check_path "$DIR/$rpath" $MOUNT $FID --link 0
12452 run_test 162c "fid2path works with paths 100 or more directories deep"
12455 # do directio so as not to populate the page cache
12456 log "creating a 10 Mb file"
12457 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12458 log "starting reads"
12459 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12460 log "truncating the file"
12461 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12463 kill %+ || true # reads might have finished
12464 echo "wait until dd is finished"
12466 log "removing the temporary file"
12467 rm -rf $DIR/$tfile || error "tmp file removal failed"
12469 run_test 169 "parallel read and truncate should not deadlock"
12472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12474 $LCTL clear # bug 18514
12475 $LCTL debug_daemon start $TMP/${tfile}_log_good
12477 $LCTL debug_daemon stop
12478 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
12479 error "sed failed to read log_good"
12481 $LCTL debug_daemon start $TMP/${tfile}_log_good
12483 $LCTL debug_daemon stop
12485 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
12486 error "lctl df log_bad failed"
12488 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12489 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12491 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
12492 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
12494 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
12495 error "bad_line good_line1 good_line2 are empty"
12497 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12498 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
12499 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12501 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
12502 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12503 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12505 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
12506 error "bad_line_new good_line_new are empty"
12508 local expected_good=$((good_line1 + good_line2*2))
12510 rm -f $TMP/${tfile}*
12511 # LU-231, short malformed line may not be counted into bad lines
12512 if [ $bad_line -ne $bad_line_new ] &&
12513 [ $bad_line -ne $((bad_line_new - 1)) ]; then
12514 error "expected $bad_line bad lines, but got $bad_line_new"
12518 if [ $expected_good -ne $good_line_new ]; then
12519 error "expected $expected_good good lines, but got $good_line_new"
12524 run_test 170 "test lctl df to handle corrupted log ====================="
12526 test_171() { # bug20592
12527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12528 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12529 $LCTL set_param fail_loc=0x50e
12530 $LCTL set_param fail_val=3000
12531 multiop_bg_pause $DIR/$tfile O_s || true
12533 kill -USR1 $MULTIPID
12537 if dmesg | grep "recursive fault"; then
12538 error "caught a recursive fault"
12540 $LCTL set_param fail_loc=0
12543 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12545 # it would be good to share it with obdfilter-survey/iokit-libecho code
12546 setup_obdecho_osc () {
12549 local obdfilter_name=$2
12550 echo "Creating new osc for $obdfilter_name on $ost_nid"
12551 # make sure we can find loopback nid
12552 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12554 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12555 ${obdfilter_name}_osc_UUID || rc=2; }
12556 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12557 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12561 cleanup_obdecho_osc () {
12562 local obdfilter_name=$1
12563 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12564 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12571 local pages=${3:-64}
12576 local obd_size=$(get_obd_size $node $OBD)
12577 local page_size=$(get_page_size $node)
12578 if [[ -n "$obd_size" ]]; then
12579 local new_count=$((obd_size / (pages * page_size / 1024)))
12580 [[ $new_count -ge $count ]] || count=$new_count
12583 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12584 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12586 if [ $rc -eq 0 ]; then
12587 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12588 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12590 echo "New object id is $id"
12591 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12593 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12594 "test_brw $count w v $pages $id" || rc=4; }
12595 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12597 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12598 "cleanup" || rc=5; }
12599 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12600 "detach" || rc=6; }
12601 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12607 remote_ost_nodsh && skip "remote OST with nodsh" && return
12609 local rmmod_local=0
12611 if ! module_loaded obdecho; then
12612 load_module obdecho/obdecho
12616 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12617 local host=$(lctl get_param -n osc.$osc.import |
12618 awk '/current_connection:/ {print $2}' )
12619 local target=$(lctl get_param -n osc.$osc.import |
12620 awk '/target:/ {print $2}' )
12621 target=${target%_UUID}
12623 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12624 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12625 [[ -n $target ]] && cleanup_obdecho_osc $target
12626 [ $rmmod_local -eq 1 ] && rmmod obdecho
12629 run_test 180a "test obdecho on osc"
12632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12633 remote_ost_nodsh && skip "remote OST with nodsh" && return
12635 local rmmod_remote=0
12637 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12638 rmmod_remote=true || error "failed to load module obdecho"
12639 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12640 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12641 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12644 run_test 180b "test obdecho directly on obdfilter"
12646 test_180c() { # LU-2598
12647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12648 remote_ost_nodsh && skip "remote OST with nodsh" && return
12649 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12650 skip "Need MDS version at least 2.4.0" && return
12653 local rmmod_remote=false
12654 local pages=16384 # 64MB bulk I/O RPC size
12657 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12658 rmmod_remote=true || error "failed to load module obdecho"
12660 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4; exit; }')
12661 if [ -n "$target" ]; then
12662 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12664 echo "there is no obdfilter target on ost1"
12667 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12670 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12672 test_181() { # bug 22177
12673 test_mkdir $DIR/$tdir
12674 # create enough files to index the directory
12675 createmany -o $DIR/$tdir/foobar 4000
12676 # print attributes for debug purpose
12679 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12681 # remove the files & current working dir
12682 unlinkmany $DIR/$tdir/foobar 4000
12684 kill -USR1 $MULTIPID
12686 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12689 run_test 181 "Test open-unlinked dir ========================"
12695 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12697 $LCTL set_param mdc.*.rpc_stats=clear
12699 for (( i = 0; i < $tcount; i++ )) ; do
12700 mkdir $DIR/$tdir/$i
12703 for (( i = 0; i < $tcount; i++ )) ; do
12704 createmany -o $DIR/$tdir/$i/f- $fcount &
12708 for (( i = 0; i < $tcount; i++ )) ; do
12709 unlinkmany $DIR/$tdir/$i/f- $fcount &
12713 $LCTL get_param mdc.*.rpc_stats
12717 run_test 182 "Test parallel modify metadata operations ================"
12719 test_183() { # LU-2275
12720 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12721 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12722 skip "Need MDS version at least 2.3.56" && return
12724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12725 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12726 echo aaa > $DIR/$tdir/$tfile
12728 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12729 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12731 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12732 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12734 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12736 # Flush negative dentry cache
12737 touch $DIR/$tdir/$tfile
12739 # We are not checking for any leaked references here, they'll
12740 # become evident next time we do cleanup with module unload.
12743 run_test 183 "No crash or request leak in case of strange dispositions ========"
12745 # test suite 184 is for LU-2016, LU-2017
12747 check_swap_layouts_support && return 0
12749 dir0=$DIR/$tdir/$testnum
12750 test_mkdir -p -c1 $dir0
12755 $SETSTRIPE -c1 $file1
12757 $SETSTRIPE -c2 $file2
12759 gen1=$($GETSTRIPE -g $file1)
12760 gen2=$($GETSTRIPE -g $file2)
12762 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12763 gen=$($GETSTRIPE -g $file1)
12764 [[ $gen1 != $gen ]] ||
12765 "Layout generation on $file1 does not change"
12766 gen=$($GETSTRIPE -g $file2)
12767 [[ $gen2 != $gen ]] ||
12768 "Layout generation on $file2 does not change"
12770 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12771 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12773 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
12775 run_test 184a "Basic layout swap"
12778 check_swap_layouts_support && return 0
12780 dir0=$DIR/$tdir/$testnum
12781 mkdir -p $dir0 || error "creating dir $dir0"
12788 $SETSTRIPE -c1 $file1
12789 $SETSTRIPE -c2 $file2
12790 $SETSTRIPE -c1 $file3
12791 chown $RUNAS_ID $file3
12792 gen1=$($GETSTRIPE -g $file1)
12793 gen2=$($GETSTRIPE -g $file2)
12795 $LFS swap_layouts $dir1 $dir2 &&
12796 error "swap of directories layouts should fail"
12797 $LFS swap_layouts $dir1 $file1 &&
12798 error "swap of directory and file layouts should fail"
12799 $RUNAS $LFS swap_layouts $file1 $file2 &&
12800 error "swap of file we cannot write should fail"
12801 $LFS swap_layouts $file1 $file3 &&
12802 error "swap of file with different owner should fail"
12803 /bin/true # to clear error code
12805 run_test 184b "Forbidden layout swap (will generate errors)"
12808 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12809 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12810 check_swap_layouts_support && return 0
12812 local dir0=$DIR/$tdir/$testnum
12813 mkdir -p $dir0 || error "creating dir $dir0"
12815 local ref1=$dir0/ref1
12816 local ref2=$dir0/ref2
12817 local file1=$dir0/file1
12818 local file2=$dir0/file2
12819 # create a file large enough for the concurrent test
12820 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12821 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12822 echo "ref file size: ref1($(stat -c %s $ref1))," \
12823 "ref2($(stat -c %s $ref2))"
12826 dd if=$ref1 of=$file1 bs=16k &
12829 # Make sure dd starts to copy file
12830 while [ ! -f $file1 ]; do sleep 0.1; done
12832 $LFS swap_layouts $file1 $file2
12835 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12836 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12838 # how many bytes copied before swapping layout
12839 local copied=$(stat -c %s $file2)
12840 local remaining=$(stat -c %s $ref1)
12841 remaining=$((remaining - copied))
12842 echo "Copied $copied bytes before swapping layout..."
12844 cmp -n $copied $file1 $ref2 | grep differ &&
12845 error "Content mismatch [0, $copied) of ref2 and file1"
12846 cmp -n $copied $file2 $ref1 ||
12847 error "Content mismatch [0, $copied) of ref1 and file2"
12848 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12849 error "Content mismatch [$copied, EOF) of ref1 and file1"
12852 rm -f $ref1 $ref2 $file1 $file2
12854 run_test 184c "Concurrent write and layout swap"
12857 check_swap_layouts_support && return 0
12858 [ -z "$(which getfattr 2>/dev/null)" ] &&
12859 skip "no getfattr command" && return 0
12861 local file1=$DIR/$tdir/$tfile-1
12862 local file2=$DIR/$tdir/$tfile-2
12863 local file3=$DIR/$tdir/$tfile-3
12867 mkdir -p $DIR/$tdir
12868 touch $file1 || error "create $file1 failed"
12869 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12870 error "create $file2 failed"
12871 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12872 error "create $file3 failed"
12873 lovea1=$(get_layout_param $file1)
12875 $LFS swap_layouts $file2 $file3 ||
12876 error "swap $file2 $file3 layouts failed"
12877 $LFS swap_layouts $file1 $file2 ||
12878 error "swap $file1 $file2 layouts failed"
12880 lovea2=$(get_layout_param $file2)
12883 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12885 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12886 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12888 run_test 184d "allow stripeless layouts swap"
12891 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12892 { skip "Need MDS version at least 2.6.94"; return 0; }
12893 check_swap_layouts_support && return 0
12894 [ -z "$(which getfattr 2>/dev/null)" ] &&
12895 skip "no getfattr command" && return 0
12897 local file1=$DIR/$tdir/$tfile-1
12898 local file2=$DIR/$tdir/$tfile-2
12899 local file3=$DIR/$tdir/$tfile-3
12902 mkdir -p $DIR/$tdir
12903 touch $file1 || error "create $file1 failed"
12904 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12905 error "create $file2 failed"
12906 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12907 error "create $file3 failed"
12909 $LFS swap_layouts $file1 $file2 ||
12910 error "swap $file1 $file2 layouts failed"
12912 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12913 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12915 echo 123 > $file1 || error "Should be able to write into $file1"
12917 $LFS swap_layouts $file1 $file3 ||
12918 error "swap $file1 $file3 layouts failed"
12920 echo 123 > $file1 || error "Should be able to write into $file1"
12922 rm -rf $file1 $file2 $file3
12924 run_test 184e "Recreate layout after stripeless layout swaps"
12926 test_185() { # LU-2441
12927 # LU-3553 - no volatile file support in old servers
12928 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12929 { skip "Need MDS version at least 2.3.60"; return 0; }
12931 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12932 touch $DIR/$tdir/spoo
12933 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12934 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12935 error "cannot create/write a volatile file"
12936 [ "$FILESET" == "" ] &&
12937 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12938 error "FID is still valid after close"
12940 multiop_bg_pause $DIR/$tdir vVw4096_c
12947 # assume that the next FID for this client is sequential, since stdout
12948 # is unfortunately eaten by multiop_bg_pause
12949 local n=$((${fidv[1]} + 1))
12950 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12951 if [ "$FILESET" == "" ]; then
12952 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12953 error "FID is missing before close"
12955 kill -USR1 $multi_pid
12956 # 1 second delay, so if mtime change we will see it
12958 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12959 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12961 run_test 185 "Volatile file support"
12964 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12965 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12966 skip "Need MDS version at least 2.3.0" && return
12968 local dir0=$DIR/$tdir/$testnum
12969 mkdir -p $dir0 || error "creating dir $dir0"
12971 local file=$dir0/file1
12972 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12973 local dv1=$($LFS data_version $file)
12974 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12975 local dv2=$($LFS data_version $file)
12976 [[ $dv1 != $dv2 ]] ||
12977 error "data version did not change on write $dv1 == $dv2"
12982 run_test 187a "Test data version change"
12985 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12986 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12987 skip "Need MDS version at least 2.3.0" && return
12989 local dir0=$DIR/$tdir/$testnum
12990 mkdir -p $dir0 || error "creating dir $dir0"
12992 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12993 [[ ${DV[0]} != ${DV[1]} ]] ||
12994 error "data version did not change on write"\
12995 " ${DV[0]} == ${DV[1]}"
13000 run_test 187b "Test data version change on volatile file"
13003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13004 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13005 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13007 local POOL=${POOL:-cea1}
13008 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
13009 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
13012 local last_ost=$(($OSTCOUNT - 1))
13014 local ost_list=$(seq $first_ost $ost_step $last_ost)
13015 local ost_range="$first_ost $last_ost $ost_step"
13016 local test_path=$POOL_ROOT/$POOL_DIR_NAME
13017 local file_dir=$POOL_ROOT/file_tst
13018 local subdir=$test_path/subdir
13021 if ! combined_mgs_mds ; then
13026 # former test_200a test_200b
13027 pool_add $POOL || { rc=$? ; break; }
13028 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
13029 # former test_200c test_200d
13030 mkdir -p $test_path
13031 pool_set_dir $POOL $test_path || { rc=$? ; break; }
13032 pool_check_dir $POOL $test_path || { rc=$? ; break; }
13034 pool_check_dir $POOL $subdir || { rc=$? ; break; }
13035 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
13036 || { rc=$? ; break; }
13037 # former test_200e test_200f
13038 local files=$((OSTCOUNT*3))
13039 pool_alloc_files $POOL $test_path $files "$ost_list" \
13040 || { rc=$? ; break; }
13041 pool_create_files $POOL $file_dir $files "$ost_list" \
13042 || { rc=$? ; break; }
13043 # former test_200g test_200h
13044 pool_lfs_df $POOL || { rc=$? ; break; }
13045 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
13047 # former test_201a test_201b test_201c
13048 pool_remove_first_target $POOL || { rc=$? ; break; }
13050 local f=$test_path/$tfile
13051 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
13052 pool_remove $POOL $f || { rc=$? ; break; }
13058 if ! combined_mgs_mds ; then
13063 run_test 200 "OST pools"
13065 # usage: default_attr <count | size | offset>
13067 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
13070 # usage: check_default_stripe_attr
13071 check_default_stripe_attr() {
13072 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
13075 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
13077 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
13081 error "unknown getstripe attr '$1'"
13084 [ $ACTUAL == $EXPECTED ] ||
13085 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
13089 test_mkdir $DIR/$tdir
13090 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
13092 check_default_stripe_attr --stripe-count
13093 check_default_stripe_attr --stripe-size
13094 check_default_stripe_attr --stripe-index
13096 run_test 204a "Print default stripe attributes"
13099 test_mkdir $DIR/$tdir
13100 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13102 check_default_stripe_attr --stripe-size
13103 check_default_stripe_attr --stripe-index
13105 run_test 204b "Print default stripe size and offset"
13108 test_mkdir $DIR/$tdir
13109 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13111 check_default_stripe_attr --stripe-count
13112 check_default_stripe_attr --stripe-index
13114 run_test 204c "Print default stripe count and offset"
13117 test_mkdir $DIR/$tdir
13118 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13120 check_default_stripe_attr --stripe-count
13121 check_default_stripe_attr --stripe-size
13123 run_test 204d "Print default stripe count and size"
13126 test_mkdir $DIR/$tdir
13127 $SETSTRIPE -d $DIR/$tdir
13129 check_default_stripe_attr --stripe-count --raw
13130 check_default_stripe_attr --stripe-size --raw
13131 check_default_stripe_attr --stripe-index --raw
13133 run_test 204e "Print raw stripe attributes"
13136 test_mkdir $DIR/$tdir
13137 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13139 check_default_stripe_attr --stripe-size --raw
13140 check_default_stripe_attr --stripe-index --raw
13142 run_test 204f "Print raw stripe size and offset"
13145 test_mkdir $DIR/$tdir
13146 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13148 check_default_stripe_attr --stripe-count --raw
13149 check_default_stripe_attr --stripe-index --raw
13151 run_test 204g "Print raw stripe count and offset"
13154 test_mkdir $DIR/$tdir
13155 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13157 check_default_stripe_attr --stripe-count --raw
13158 check_default_stripe_attr --stripe-size --raw
13160 run_test 204h "Print raw stripe count and size"
13162 # Figure out which job scheduler is being used, if any,
13163 # or use a fake one
13164 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
13165 JOBENV=SLURM_JOB_ID
13166 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
13168 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
13170 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
13171 JOBENV=LOADL_STEP_ID
13172 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
13175 $LCTL list_param jobid_name > /dev/null 2>&1
13176 if [ $? -eq 0 ]; then
13183 verify_jobstats() {
13188 # we don't really need to clear the stats for this test to work, since each
13189 # command has a unique jobid, but it makes debugging easier if needed.
13190 # for facet in $facets; do
13191 # local dev=$(convert_facet2label $facet)
13192 # # clear old jobstats
13193 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
13196 # use a new JobID for each test, or we might see an old one
13197 [ "$JOBENV" = "FAKE_JOBID" ] &&
13198 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13202 [ "$JOBENV" = "nodelocal" ] && {
13203 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13204 $LCTL set_param jobid_name=$FAKE_JOBID
13208 log "Test: ${cmd[*]}"
13209 log "Using JobID environment variable $JOBENV=$JOBVAL"
13211 if [ $JOBENV = "FAKE_JOBID" ]; then
13212 FAKE_JOBID=$JOBVAL ${cmd[*]}
13217 # all files are created on OST0000
13218 for facet in $facets; do
13219 local stats="*.$(convert_facet2label $facet).job_stats"
13220 if [ $(do_facet $facet lctl get_param $stats |
13221 grep -c $JOBVAL) -ne 1 ]; then
13222 do_facet $facet lctl get_param $stats
13223 error "No jobstats for $JOBVAL found on $facet::$stats"
13229 local new_jobenv=$1
13231 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$new_jobenv
13232 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $new_jobenv
13235 test_205() { # Job stats
13236 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
13237 { skip "Need MDS version with at least 2.7.1"; return 0; }
13239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13240 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13241 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13242 remote_ost_nodsh && skip "remote OST with nodsh" && return
13244 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
13245 skip "Server doesn't support jobstats" && return 0
13246 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
13248 local old_jobenv=$($LCTL get_param -n jobid_var)
13249 if [ $old_jobenv != $JOBENV ]; then
13250 jobstats_set $JOBENV
13251 stack_trap "do_facet mgs \
13252 $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
13257 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
13258 mdt.*.job_cleanup_interval | head -n 1)
13259 local new_interval=5
13260 do_facet $SINGLEMDS \
13261 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
13262 stack_trap "do_facet $SINGLEMDS \
13263 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
13264 local start=$SECONDS
13268 cmd="mkdir $DIR/$tdir"
13269 verify_jobstats "$cmd" "$SINGLEMDS"
13271 cmd="rmdir $DIR/$tdir"
13272 verify_jobstats "$cmd" "$SINGLEMDS"
13273 # mkdir on secondary MDT
13274 if [ $MDSCOUNT -gt 1 ]; then
13275 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
13276 verify_jobstats "$cmd" "mds2"
13279 cmd="mknod $DIR/$tfile c 1 3"
13280 verify_jobstats "$cmd" "$SINGLEMDS"
13282 cmd="rm -f $DIR/$tfile"
13283 verify_jobstats "$cmd" "$SINGLEMDS"
13284 # create all files on OST0000 so verify_jobstats can find OST stats
13286 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
13287 verify_jobstats "$cmd" "$SINGLEMDS"
13289 cmd="touch $DIR/$tfile"
13290 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13292 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
13293 verify_jobstats "$cmd" "ost1"
13295 cancel_lru_locks osc
13296 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
13297 verify_jobstats "$cmd" "ost1"
13299 cmd="$TRUNCATE $DIR/$tfile 0"
13300 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13302 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
13303 verify_jobstats "$cmd" "$SINGLEMDS"
13304 # jobstats expiry - sleep until old stats should be expired
13305 local left=$((new_interval + 5 - (SECONDS - start)))
13306 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
13307 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
13309 cmd="mkdir $DIR/$tdir.expire"
13310 verify_jobstats "$cmd" "$SINGLEMDS"
13311 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
13312 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
13314 # Ensure that jobid are present in changelog (if supported by MDS)
13315 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ];then
13316 changelog_dump | tail -10
13317 jobids=$(changelog_dump | tail -9 | grep -c "j=")
13318 [ $jobids -eq 9 ] ||
13319 error "Wrong changelog jobid count $jobids != 9"
13323 jobstats_set $JOBENV
13325 changelog_dump | grep $tfile
13326 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
13327 [ $jobids -eq 0 ] ||
13328 error "Unexpected jobids when jobid_var=$JOBENV"
13331 run_test 205 "Verify job stats"
13333 # LU-1480, LU-1773 and LU-1657
13335 mkdir -p $DIR/$tdir
13336 $SETSTRIPE -c -1 $DIR/$tdir
13337 #define OBD_FAIL_LOV_INIT 0x1403
13338 $LCTL set_param fail_loc=0xa0001403
13339 $LCTL set_param fail_val=1
13340 touch $DIR/$tdir/$tfile || true
13342 run_test 206 "fail lov_init_raid0() doesn't lbug"
13345 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13346 local fsz=`stat -c %s $DIR/$tfile`
13347 cancel_lru_locks mdc
13349 # do not return layout in getattr intent
13350 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
13351 $LCTL set_param fail_loc=0x170
13352 local sz=`stat -c %s $DIR/$tfile`
13354 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
13358 run_test 207a "can refresh layout at glimpse"
13361 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13362 local cksum=`md5sum $DIR/$tfile`
13363 local fsz=`stat -c %s $DIR/$tfile`
13364 cancel_lru_locks mdc
13365 cancel_lru_locks osc
13367 # do not return layout in getattr intent
13368 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
13369 $LCTL set_param fail_loc=0x171
13371 # it will refresh layout after the file is opened but before read issues
13372 echo checksum is "$cksum"
13373 echo "$cksum" |md5sum -c --quiet || error "file differs"
13377 run_test 207b "can refresh layout at open"
13380 # FIXME: in this test suite, only RD lease is used. This is okay
13381 # for now as only exclusive open is supported. After generic lease
13382 # is done, this test suite should be revised. - Jinshan
13384 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13385 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
13386 { skip "Need MDS version at least 2.4.52"; return 0; }
13388 echo "==== test 1: verify get lease work"
13389 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
13391 echo "==== test 2: verify lease can be broken by upcoming open"
13392 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13396 $MULTIOP $DIR/$tfile oO_RDONLY:c
13397 kill -USR1 $PID && wait $PID || error "break lease error"
13399 echo "==== test 3: verify lease can't be granted if an open already exists"
13400 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
13404 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
13405 kill -USR1 $PID && wait $PID || error "open file error"
13407 echo "==== test 4: lease can sustain over recovery"
13408 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
13414 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
13416 echo "==== test 5: lease broken can't be regained by replay"
13417 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13421 # open file to break lease and then recovery
13422 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
13425 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
13429 run_test 208 "Exclusive open"
13432 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
13433 skip_env "must have disp_stripe" && return
13436 sync; sleep 5; sync;
13438 echo 3 > /proc/sys/vm/drop_caches
13439 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13441 # open/close 500 times
13442 for i in $(seq 500); do
13446 echo 3 > /proc/sys/vm/drop_caches
13447 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13449 echo "before: $req_before, after: $req_after"
13450 [ $((req_after - req_before)) -ge 300 ] &&
13451 error "open/close requests are not freed"
13454 run_test 209 "read-only open/close requests should be freed promptly"
13458 size=$((size % 8192 + 1))
13459 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
13460 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
13461 rm -f $DIR/f212 $DIR/f212.xyz
13463 run_test 212 "Sendfile test ============================================"
13466 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
13467 cancel_lru_locks osc
13468 lctl set_param fail_loc=0x8000040f
13469 # generate a read lock
13470 cat $DIR/$tfile > /dev/null
13471 # write to the file, it will try to cancel the above read lock.
13472 cat /etc/hosts >> $DIR/$tfile
13474 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
13476 test_214() { # for bug 20133
13477 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
13478 for (( i=0; i < 340; i++ )) ; do
13479 touch $DIR/$tdir/d214c/a$i
13482 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
13483 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
13484 ls $DIR/d214c || error "ls $DIR/d214c failed"
13485 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
13486 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
13488 run_test 214 "hash-indexed directory test - bug 20133"
13490 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
13491 create_lnet_proc_files() {
13492 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
13495 # counterpart of create_lnet_proc_files
13496 remove_lnet_proc_files() {
13497 rm -f $TMP/lnet_$1.sys
13500 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13501 # 3rd arg as regexp for body
13502 check_lnet_proc_stats() {
13503 local l=$(cat "$TMP/lnet_$1" |wc -l)
13504 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13506 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13509 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13510 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13511 # optional and can be regexp for 2nd line (lnet.routes case)
13512 check_lnet_proc_entry() {
13513 local blp=2 # blp stands for 'position of 1st line of body'
13514 [ -z "$5" ] || blp=3 # lnet.routes case
13516 local l=$(cat "$TMP/lnet_$1" |wc -l)
13517 # subtracting one from $blp because the body can be empty
13518 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13520 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13521 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13523 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13524 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13526 # bail out if any unexpected line happened
13527 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13528 [ "$?" != 0 ] || error "$2 misformatted"
13531 test_215() { # for bugs 18102, 21079, 21517
13532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13533 local N='(0|[1-9][0-9]*)' # non-negative numeric
13534 local P='[1-9][0-9]*' # positive numeric
13535 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13536 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13537 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13538 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13540 local L1 # regexp for 1st line
13541 local L2 # regexp for 2nd line (optional)
13542 local BR # regexp for the rest (body)
13544 # lnet.stats should look as 11 space-separated non-negative numerics
13545 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13546 create_lnet_proc_files "stats"
13547 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13548 remove_lnet_proc_files "stats"
13550 # lnet.routes should look like this:
13551 # Routing disabled/enabled
13552 # net hops priority state router
13553 # where net is a string like tcp0, hops > 0, priority >= 0,
13554 # state is up/down,
13555 # router is a string like 192.168.1.1@tcp2
13556 L1="^Routing (disabled|enabled)$"
13557 L2="^net +hops +priority +state +router$"
13558 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13559 create_lnet_proc_files "routes"
13560 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13561 remove_lnet_proc_files "routes"
13563 # lnet.routers should look like this:
13564 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13565 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13566 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13567 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13568 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13569 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13570 create_lnet_proc_files "routers"
13571 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13572 remove_lnet_proc_files "routers"
13574 # lnet.peers should look like this:
13575 # nid refs state last max rtr min tx min queue
13576 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13577 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13578 # numeric (0 or >0 or <0), queue >= 0.
13579 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13580 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13581 create_lnet_proc_files "peers"
13582 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13583 remove_lnet_proc_files "peers"
13585 # lnet.buffers should look like this:
13586 # pages count credits min
13587 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13588 L1="^pages +count +credits +min$"
13589 BR="^ +$N +$N +$I +$I$"
13590 create_lnet_proc_files "buffers"
13591 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13592 remove_lnet_proc_files "buffers"
13594 # lnet.nis should look like this:
13595 # nid status alive refs peer rtr max tx min
13596 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13597 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13598 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13599 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13600 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13601 create_lnet_proc_files "nis"
13602 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13603 remove_lnet_proc_files "nis"
13605 # can we successfully write to lnet.stats?
13606 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13608 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13610 test_216() { # bug 20317
13611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13612 remote_ost_nodsh && skip "remote OST with nodsh" && return
13615 local facets=$(get_facets OST)
13616 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13618 save_lustre_params client "osc.*.contention_seconds" > $p
13619 save_lustre_params $facets \
13620 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13621 save_lustre_params $facets \
13622 "ldlm.namespaces.filter-*.contended_locks" >> $p
13623 save_lustre_params $facets \
13624 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13625 clear_stats osc.*.osc_stats
13627 # agressive lockless i/o settings
13628 do_nodes $(comma_list $(osts_nodes)) \
13629 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13630 ldlm.namespaces.filter-*.contended_locks=0 \
13631 ldlm.namespaces.filter-*.contention_seconds=60"
13632 lctl set_param -n osc.*.contention_seconds=60
13634 $DIRECTIO write $DIR/$tfile 0 10 4096
13635 $CHECKSTAT -s 40960 $DIR/$tfile
13637 # disable lockless i/o
13638 do_nodes $(comma_list $(osts_nodes)) \
13639 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13640 ldlm.namespaces.filter-*.contended_locks=32 \
13641 ldlm.namespaces.filter-*.contention_seconds=0"
13642 lctl set_param -n osc.*.contention_seconds=0
13643 clear_stats osc.*.osc_stats
13645 dd if=/dev/zero of=$DIR/$tfile count=0
13646 $CHECKSTAT -s 0 $DIR/$tfile
13648 restore_lustre_params <$p
13652 run_test 216 "check lockless direct write updates file size and kms correctly"
13654 test_217() { # bug 22430
13655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13659 for node in $(nodes_list); do
13660 nid=$(host_nids_address $node $NETTYPE)
13661 if [[ $nid = *-* ]] ; then
13662 echo "lctl ping $(h2nettype $nid)"
13663 lctl ping $(h2nettype $nid)
13665 echo "skipping $node (no hyphen detected)"
13669 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13672 # do directio so as not to populate the page cache
13673 log "creating a 10 Mb file"
13674 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13675 log "starting reads"
13676 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13677 log "truncating the file"
13678 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13680 kill %+ || true # reads might have finished
13681 echo "wait until dd is finished"
13683 log "removing the temporary file"
13684 rm -rf $DIR/$tfile || error "tmp file removal failed"
13686 run_test 218 "parallel read and truncate should not deadlock ======================="
13689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13690 # write one partial page
13691 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13692 # set no grant so vvp_io_commit_write will do sync write
13693 $LCTL set_param fail_loc=0x411
13694 # write a full page at the end of file
13695 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13697 $LCTL set_param fail_loc=0
13698 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13699 $LCTL set_param fail_loc=0x411
13700 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13703 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13704 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13706 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13708 test_220() { #LU-325
13709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13710 remote_ost_nodsh && skip "remote OST with nodsh" && return
13711 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13712 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13715 # create on MDT0000 so the last_id and next_id are correct
13717 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13721 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13722 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13723 osc.$mdtosc_proc1.prealloc_last_id)
13724 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13725 osc.$mdtosc_proc1.prealloc_next_id)
13729 if ! combined_mgs_mds ; then
13733 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13734 #define OBD_FAIL_OST_ENOINO 0x229
13735 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13736 create_pool $FSNAME.$TESTNAME || return 1
13737 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13739 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13741 MDSOBJS=$((last_id - next_id))
13742 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13744 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13745 echo "OST still has $count kbytes free"
13747 echo "create $MDSOBJS files @next_id..."
13748 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13750 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13751 osc.$mdtosc_proc1.prealloc_last_id)
13752 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13753 osc.$mdtosc_proc1.prealloc_next_id)
13755 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13760 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13761 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13763 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13764 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13765 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13766 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13767 echo "unlink $MDSOBJS files @$next_id..."
13768 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13770 if ! combined_mgs_mds ; then
13774 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13778 dd if=`which date` of=$MOUNT/date oflag=sync
13779 chmod +x $MOUNT/date
13781 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13782 $LCTL set_param fail_loc=0x80001401
13784 $MOUNT/date > /dev/null
13787 run_test 221 "make sure fault and truncate race to not cause OOM"
13790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13792 test_mkdir $DIR/$tdir
13793 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13794 createmany -o $DIR/$tdir/$tfile 10
13795 cancel_lru_locks mdc
13796 cancel_lru_locks osc
13797 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13798 $LCTL set_param fail_loc=0x31a
13799 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13800 $LCTL set_param fail_loc=0
13803 run_test 222a "AGL for ls should not trigger CLIO lock failure"
13806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13808 test_mkdir $DIR/$tdir
13809 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13810 createmany -o $DIR/$tdir/$tfile 10
13811 cancel_lru_locks mdc
13812 cancel_lru_locks osc
13813 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13814 $LCTL set_param fail_loc=0x31a
13815 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13816 $LCTL set_param fail_loc=0
13818 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
13821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13823 test_mkdir $DIR/$tdir
13824 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13825 createmany -o $DIR/$tdir/$tfile 10
13826 cancel_lru_locks mdc
13827 cancel_lru_locks osc
13828 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13829 $LCTL set_param fail_loc=0x31b
13830 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13831 $LCTL set_param fail_loc=0
13834 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13836 test_224a() { # LU-1039, MRP-303
13837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13838 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13839 $LCTL set_param fail_loc=0x508
13840 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13841 $LCTL set_param fail_loc=0
13844 run_test 224a "Don't panic on bulk IO failure"
13846 test_224b() { # LU-1039, MRP-303
13847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13848 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13849 cancel_lru_locks osc
13850 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13851 $LCTL set_param fail_loc=0x515
13852 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13853 $LCTL set_param fail_loc=0
13856 run_test 224b "Don't panic on bulk IO failure"
13858 test_224c() { # LU-6441
13859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13860 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13862 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13863 save_writethrough $p
13864 set_cache writethrough on
13866 local pages_per_rpc=$($LCTL get_param \
13867 osc.*.max_pages_per_rpc)
13868 local at_max=$($LCTL get_param -n at_max)
13869 local timeout=$($LCTL get_param -n timeout)
13870 local test_at="$LCTL get_param -n at_max"
13871 local param_at="$FSNAME.sys.at_max"
13872 local test_timeout="$LCTL get_param -n timeout"
13873 local param_timeout="$FSNAME.sys.timeout"
13875 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13877 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13878 error "conf_param at_max=0 failed"
13879 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13880 error "conf_param timeout=5 failed"
13882 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13883 do_facet ost1 $LCTL set_param fail_loc=0x520
13884 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13885 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13887 do_facet ost1 $LCTL set_param fail_loc=0
13889 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13890 error "conf_param at_max=$at_max failed"
13891 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13892 $timeout || error "conf_param timeout=$timeout failed"
13894 $LCTL set_param -n $pages_per_rpc
13895 restore_lustre_params < $p
13898 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13900 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13903 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13904 if [ -z ${MDSSURVEY} ]; then
13905 skip_env "mds-survey not found" && return
13908 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13909 { skip "Need MDS version at least 2.2.51"; return; }
13911 local mds=$(facet_host $SINGLEMDS)
13912 local target=$(do_nodes $mds 'lctl dl' |
13913 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
13915 local cmd1="file_count=1000 thrhi=4"
13916 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13917 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13918 local cmd="$cmd1 $cmd2 $cmd3"
13920 rm -f ${TMP}/mds_survey*
13922 eval $cmd || error "mds-survey with zero-stripe failed"
13923 cat ${TMP}/mds_survey*
13924 rm -f ${TMP}/mds_survey*
13926 run_test 225a "Metadata survey sanity with zero-stripe"
13929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13930 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13931 if [ -z ${MDSSURVEY} ]; then
13932 skip_env "mds-survey not found" && return
13934 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13935 { skip "Need MDS version at least 2.2.51"; return; }
13937 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13938 skip_env "Need to mount OST to test" && return
13941 local mds=$(facet_host $SINGLEMDS)
13942 local target=$(do_nodes $mds 'lctl dl' |
13943 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
13945 local cmd1="file_count=1000 thrhi=4"
13946 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13947 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13948 local cmd="$cmd1 $cmd2 $cmd3"
13950 rm -f ${TMP}/mds_survey*
13952 eval $cmd || error "mds-survey with stripe_count failed"
13953 cat ${TMP}/mds_survey*
13954 rm -f ${TMP}/mds_survey*
13956 run_test 225b "Metadata survey sanity with stripe_count = 1"
13958 mcreate_path2fid () {
13964 local path=$DIR/$tdir/$name
13969 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13970 error "cannot create $desc"
13972 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13974 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13976 fid_path=$($LFS fid2path $MOUNT $fid)
13978 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13980 [ "$path" == "$fid_path" ] ||
13981 error "fid2path returned $fid_path, expected $path"
13983 echo "pass with $path and $fid"
13988 mkdir -p $DIR/$tdir
13990 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13991 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13992 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13993 mcreate_path2fid 0040666 0 0 dir "directory"
13994 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13995 mcreate_path2fid 0100666 0 0 file "regular file"
13996 mcreate_path2fid 0120666 0 0 link "symbolic link"
13997 mcreate_path2fid 0140666 0 0 sock "socket"
13999 run_test 226a "call path2fid and fid2path on files of all type"
14002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14006 mkdir -p $DIR/$tdir
14007 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
14008 error "create remote directory failed"
14009 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
14010 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
14011 "character special file (null)"
14012 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
14013 "character special file (no device)"
14014 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
14015 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
14016 "block special file (loop)"
14017 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
14018 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
14019 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
14021 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
14023 # LU-1299 Executing or running ldd on a truncated executable does not
14024 # cause an out-of-memory condition.
14026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14027 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
14028 dd if=$(which date) of=$MOUNT/date bs=1k count=1
14029 chmod +x $MOUNT/date
14031 $MOUNT/date > /dev/null
14032 ldd $MOUNT/date > /dev/null
14035 run_test 227 "running truncated executable does not cause OOM"
14037 # LU-1512 try to reuse idle OI blocks
14039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14040 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14041 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14042 skip "ldiskfs only test" && return
14044 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14045 local myDIR=$DIR/$tdir
14048 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14049 $LCTL set_param fail_loc=0x80001002
14050 createmany -o $myDIR/t- 10000
14051 $LCTL set_param fail_loc=0
14052 # The guard is current the largest FID holder
14054 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14056 local IDX=$(($SEQ % 64))
14058 do_facet $SINGLEMDS sync
14059 # Make sure journal flushed.
14061 local blk1=$(do_facet $SINGLEMDS \
14062 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14063 grep Blockcount | awk '{print $4}')
14065 # Remove old files, some OI blocks will become idle.
14066 unlinkmany $myDIR/t- 10000
14067 # Create new files, idle OI blocks should be reused.
14068 createmany -o $myDIR/t- 2000
14069 do_facet $SINGLEMDS sync
14070 # Make sure journal flushed.
14072 local blk2=$(do_facet $SINGLEMDS \
14073 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14074 grep Blockcount | awk '{print $4}')
14076 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14078 run_test 228a "try to reuse idle OI blocks"
14081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14082 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14083 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14084 skip "ldiskfs only test" && return
14086 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14087 local myDIR=$DIR/$tdir
14090 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14091 $LCTL set_param fail_loc=0x80001002
14092 createmany -o $myDIR/t- 10000
14093 $LCTL set_param fail_loc=0
14094 # The guard is current the largest FID holder
14096 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14098 local IDX=$(($SEQ % 64))
14100 do_facet $SINGLEMDS sync
14101 # Make sure journal flushed.
14103 local blk1=$(do_facet $SINGLEMDS \
14104 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14105 grep Blockcount | awk '{print $4}')
14107 # Remove old files, some OI blocks will become idle.
14108 unlinkmany $myDIR/t- 10000
14111 stop $SINGLEMDS || error "Fail to stop MDT."
14113 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
14115 df $MOUNT || error "Fail to df."
14116 # Create new files, idle OI blocks should be reused.
14117 createmany -o $myDIR/t- 2000
14118 do_facet $SINGLEMDS sync
14119 # Make sure journal flushed.
14121 local blk2=$(do_facet $SINGLEMDS \
14122 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14123 grep Blockcount | awk '{print $4}')
14125 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14127 run_test 228b "idle OI blocks can be reused after MDT restart"
14131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14132 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14133 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14134 skip "ldiskfs only test" && return
14136 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14137 local myDIR=$DIR/$tdir
14140 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14141 $LCTL set_param fail_loc=0x80001002
14142 # 20000 files can guarantee there are index nodes in the OI file
14143 createmany -o $myDIR/t- 20000
14144 $LCTL set_param fail_loc=0
14145 # The guard is current the largest FID holder
14147 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14149 local IDX=$(($SEQ % 64))
14151 do_facet $SINGLEMDS sync
14152 # Make sure journal flushed.
14154 local blk1=$(do_facet $SINGLEMDS \
14155 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14156 grep Blockcount | awk '{print $4}')
14158 # Remove old files, some OI blocks will become idle.
14159 unlinkmany $myDIR/t- 20000
14161 # The OI file should become empty now
14163 # Create new files, idle OI blocks should be reused.
14164 createmany -o $myDIR/t- 2000
14165 do_facet $SINGLEMDS sync
14166 # Make sure journal flushed.
14168 local blk2=$(do_facet $SINGLEMDS \
14169 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14170 grep Blockcount | awk '{print $4}')
14172 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14174 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
14176 test_229() { # LU-2482, LU-3448
14177 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
14178 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
14180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14181 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
14185 # Create a file with a released layout and stripe count 2.
14186 $MULTIOP $DIR/$tfile H2c ||
14187 error "failed to create file with released layout"
14189 $GETSTRIPE -v $DIR/$tfile
14191 local pattern=$($GETSTRIPE -L $DIR/$tfile)
14192 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
14194 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
14195 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
14196 stat $DIR/$tfile || error "failed to stat released file"
14198 chown $RUNAS_ID $DIR/$tfile ||
14199 error "chown $RUNAS_ID $DIR/$tfile failed"
14201 chgrp $RUNAS_ID $DIR/$tfile ||
14202 error "chgrp $RUNAS_ID $DIR/$tfile failed"
14204 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
14205 rm $DIR/$tfile || error "failed to remove released file"
14207 run_test 229 "getstripe/stat/rm/attr changes work on released files"
14210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14211 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14214 test_mkdir $DIR/$tdir
14215 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
14216 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
14217 [ $mdt_idx -ne 0 ] &&
14218 error "create local directory on wrong MDT $mdt_idx"
14220 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
14221 error "create remote directory failed"
14222 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
14223 [ $mdt_idx -ne $MDTIDX ] &&
14224 error "create remote directory on wrong MDT $mdt_idx"
14226 createmany -o $DIR/$tdir/test_230/t- 10 ||
14227 error "create files on remote directory failed"
14228 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
14229 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
14230 rm -r $DIR/$tdir || error "unlink remote directory failed"
14232 run_test 230a "Create remote directory and files under the remote directory"
14235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14236 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14243 local migrate_dir=$DIR/$tdir/migrate_dir
14244 local other_dir=$DIR/$tdir/other_dir
14246 test_mkdir $DIR/$tdir
14247 test_mkdir -i0 -c1 $migrate_dir
14248 test_mkdir -i0 -c1 $other_dir
14249 for ((i=0; i<10; i++)); do
14250 mkdir -p $migrate_dir/dir_${i}
14251 createmany -o $migrate_dir/dir_${i}/f 10 ||
14252 error "create files under remote dir failed $i"
14255 cp /etc/passwd $migrate_dir/$tfile
14256 cp /etc/passwd $other_dir/$tfile
14257 chattr +SAD $migrate_dir
14258 chattr +SAD $migrate_dir/$tfile
14260 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14261 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14262 local old_dir_mode=$(stat -c%f $migrate_dir)
14263 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
14265 mkdir -p $migrate_dir/dir_default_stripe2
14266 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
14267 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
14269 mkdir -p $other_dir
14270 ln $migrate_dir/$tfile $other_dir/luna
14271 ln $migrate_dir/$tfile $migrate_dir/sofia
14272 ln $other_dir/$tfile $migrate_dir/david
14273 ln -s $migrate_dir/$tfile $other_dir/zachary
14274 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
14275 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
14277 $LFS migrate -m $MDTIDX $migrate_dir ||
14278 error "fails on migrating remote dir to MDT1"
14280 echo "migratate to MDT1, then checking.."
14281 for ((i = 0; i < 10; i++)); do
14282 for file in $(find $migrate_dir/dir_${i}); do
14283 mdt_index=$($LFS getstripe -M $file)
14284 [ $mdt_index == $MDTIDX ] ||
14285 error "$file is not on MDT${MDTIDX}"
14289 # the multiple link file should still in MDT0
14290 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
14291 [ $mdt_index == 0 ] ||
14292 error "$file is not on MDT${MDTIDX}"
14294 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14295 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14296 error " expect $old_dir_flag get $new_dir_flag"
14298 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14299 [ "$old_file_flag" = "$new_file_flag" ] ||
14300 error " expect $old_file_flag get $new_file_flag"
14302 local new_dir_mode=$(stat -c%f $migrate_dir)
14303 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14304 error "expect mode $old_dir_mode get $new_dir_mode"
14306 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14307 [ "$old_file_mode" = "$new_file_mode" ] ||
14308 error "expect mode $old_file_mode get $new_file_mode"
14310 diff /etc/passwd $migrate_dir/$tfile ||
14311 error "$tfile different after migration"
14313 diff /etc/passwd $other_dir/luna ||
14314 error "luna different after migration"
14316 diff /etc/passwd $migrate_dir/sofia ||
14317 error "sofia different after migration"
14319 diff /etc/passwd $migrate_dir/david ||
14320 error "david different after migration"
14322 diff /etc/passwd $other_dir/zachary ||
14323 error "zachary different after migration"
14325 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14326 error "${tfile}_ln different after migration"
14328 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14329 error "${tfile}_ln_other different after migration"
14331 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
14332 [ $stripe_count = 2 ] ||
14333 error "dir strpe_count $d != 2 after migration."
14335 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
14336 [ $stripe_count = 2 ] ||
14337 error "file strpe_count $d != 2 after migration."
14339 #migrate back to MDT0
14342 $LFS migrate -m $MDTIDX $migrate_dir ||
14343 error "fails on migrating remote dir to MDT0"
14345 echo "migrate back to MDT0, checking.."
14346 for file in $(find $migrate_dir); do
14347 mdt_index=$($LFS getstripe -M $file)
14348 [ $mdt_index == $MDTIDX ] ||
14349 error "$file is not on MDT${MDTIDX}"
14352 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14353 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14354 error " expect $old_dir_flag get $new_dir_flag"
14356 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14357 [ "$old_file_flag" = "$new_file_flag" ] ||
14358 error " expect $old_file_flag get $new_file_flag"
14360 local new_dir_mode=$(stat -c%f $migrate_dir)
14361 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14362 error "expect mode $old_dir_mode get $new_dir_mode"
14364 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14365 [ "$old_file_mode" = "$new_file_mode" ] ||
14366 error "expect mode $old_file_mode get $new_file_mode"
14368 diff /etc/passwd ${migrate_dir}/$tfile ||
14369 error "$tfile different after migration"
14371 diff /etc/passwd ${other_dir}/luna ||
14372 error "luna different after migration"
14374 diff /etc/passwd ${migrate_dir}/sofia ||
14375 error "sofia different after migration"
14377 diff /etc/passwd ${other_dir}/zachary ||
14378 error "zachary different after migration"
14380 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14381 error "${tfile}_ln different after migration"
14383 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14384 error "${tfile}_ln_other different after migration"
14386 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
14387 [ $stripe_count = 2 ] ||
14388 error "dir strpe_count $d != 2 after migration."
14390 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
14391 [ $stripe_count = 2 ] ||
14392 error "file strpe_count $d != 2 after migration."
14394 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14396 run_test 230b "migrate directory"
14399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14400 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14401 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14405 local migrate_dir=$DIR/$tdir/migrate_dir
14407 #If migrating directory fails in the middle, all entries of
14408 #the directory is still accessiable.
14409 test_mkdir $DIR/$tdir
14410 test_mkdir -i0 -c1 $migrate_dir
14412 createmany -o $migrate_dir/f 10 ||
14413 error "create files under ${migrate_dir} failed"
14415 #failed after migrating 5 entries
14416 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
14417 do_facet mds1 lctl set_param fail_loc=0x20001801
14418 do_facet mds1 lctl set_param fail_val=5
14419 local t=$(ls $migrate_dir | wc -l)
14420 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
14421 error "migrate should fail after 5 entries"
14423 mkdir $migrate_dir/dir &&
14424 error "mkdir succeeds under migrating directory"
14425 touch $migrate_dir/file &&
14426 error "touch file succeeds under migrating directory"
14428 local u=$(ls $migrate_dir | wc -l)
14429 [ "$u" == "$t" ] || error "$u != $t during migration"
14431 for file in $(find $migrate_dir); do
14432 stat $file || error "stat $file failed"
14435 do_facet mds1 lctl set_param fail_loc=0
14436 do_facet mds1 lctl set_param fail_val=0
14438 $LFS migrate -m $MDTIDX $migrate_dir ||
14439 error "migrate open files should failed with open files"
14441 echo "Finish migration, then checking.."
14442 for file in $(find $migrate_dir); do
14443 mdt_index=$($LFS getstripe -M $file)
14444 [ $mdt_index == $MDTIDX ] ||
14445 error "$file is not on MDT${MDTIDX}"
14448 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14450 run_test 230c "check directory accessiblity if migration is failed"
14453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14454 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14457 local migrate_dir=$DIR/$tdir/migrate_dir
14461 test_mkdir $DIR/$tdir
14462 test_mkdir -i0 -c1 $migrate_dir
14464 for ((i=0; i<100; i++)); do
14465 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
14466 createmany -o $migrate_dir/dir_${i}/f 100 ||
14467 error "create files under remote dir failed $i"
14470 $LFS migrate -m $MDTIDX $migrate_dir ||
14471 error "migrate remote dir error"
14473 echo "Finish migration, then checking.."
14474 for file in $(find $migrate_dir); do
14475 mdt_index=$($LFS getstripe -M $file)
14476 [ $mdt_index == $MDTIDX ] ||
14477 error "$file is not on MDT${MDTIDX}"
14480 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14482 run_test 230d "check migrate big directory"
14485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14486 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14492 mkdir -p $DIR/$tdir
14493 mkdir $DIR/$tdir/migrate_dir
14494 mkdir $DIR/$tdir/other_dir
14495 touch $DIR/$tdir/migrate_dir/a
14496 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14497 ls $DIR/$tdir/other_dir
14499 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14500 error "migrate dir fails"
14502 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14503 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14505 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14506 [ $mdt_index == 0 ] || error "a is not on MDT0"
14508 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14509 error "migrate dir fails"
14511 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14512 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14514 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14515 [ $mdt_index == 1 ] || error "a is not on MDT1"
14517 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14518 [ $mdt_index == 1 ] || error "b is not on MDT1"
14520 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14521 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14523 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14525 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14527 run_test 230e "migrate mulitple local link files"
14530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14531 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14535 mkdir -p $DIR/$tdir
14536 mkdir $DIR/$tdir/migrate_dir
14537 $LFS mkdir -i1 $DIR/$tdir/other_dir
14538 touch $DIR/$tdir/migrate_dir/a
14539 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14540 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14541 ls $DIR/$tdir/other_dir
14543 # a should be migrated to MDT1, since no other links on MDT0
14544 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14545 error "#1 migrate dir fails"
14546 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14547 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14548 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14549 [ $mdt_index == 1 ] || error "a is not on MDT1"
14551 # a should stay on MDT1, because it is a mulitple link file
14552 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14553 error "#2 migrate dir fails"
14554 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14555 [ $mdt_index == 1 ] || error "a is not on MDT1"
14557 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14558 error "#3 migrate dir fails"
14560 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14561 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14562 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14564 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14565 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14567 # a should be migrated to MDT0, since no other links on MDT1
14568 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14569 error "#4 migrate dir fails"
14570 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14571 [ $mdt_index == 0 ] || error "a is not on MDT0"
14573 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14575 run_test 230f "migrate mulitple remote link files"
14578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14581 mkdir -p $DIR/$tdir/migrate_dir
14583 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14584 error "migrating dir to non-exist MDT succeeds"
14587 run_test 230g "migrate dir to non-exist MDT"
14590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14591 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14592 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14593 skip "Need MDS version at least 2.7.64" && return
14596 mkdir -p $DIR/$tdir/migrate_dir
14598 $LFS migrate -m1 $DIR &&
14599 error "migrating mountpoint1 should fail"
14601 $LFS migrate -m1 $DIR/$tdir/.. &&
14602 error "migrating mountpoint2 should fail"
14604 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14605 error "migrating $tdir fail"
14607 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14608 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14610 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14611 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14614 run_test 230h "migrate .. and root"
14617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14618 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14620 mkdir -p $DIR/$tdir/migrate_dir
14622 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14623 error "migration fails with a tailing slash"
14625 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14626 error "migration fails with two tailing slashes"
14628 run_test 230i "lfs migrate -m tolerates trailing slashes"
14632 # For simplicity this test assumes that max_pages_per_rpc
14633 # is the same across all OSCs
14634 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14635 local bulk_size=$((max_pages * 4096))
14636 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14639 mkdir -p $DIR/$tdir
14640 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14641 error "failed to set stripe with -S ${brw_size}M option"
14643 # clear the OSC stats
14644 $LCTL set_param osc.*.stats=0 &>/dev/null
14647 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14648 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14649 oflag=direct &>/dev/null || error "dd failed"
14651 sync; sleep 1; sync # just to be safe
14652 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14653 if [ x$nrpcs != "x1" ]; then
14654 $LCTL get_param osc.*.stats
14655 error "found $nrpcs ost_write RPCs, not 1 as expected"
14659 # Drop the OSC cache, otherwise we will read from it
14660 cancel_lru_locks osc
14662 # clear the OSC stats
14663 $LCTL set_param osc.*.stats=0 &>/dev/null
14665 # Client reads $bulk_size.
14666 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14667 iflag=direct &>/dev/null || error "dd failed"
14669 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14670 if [ x$nrpcs != "x1" ]; then
14671 $LCTL get_param osc.*.stats
14672 error "found $nrpcs ost_read RPCs, not 1 as expected"
14675 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14678 mkdir -p $DIR/$tdir
14680 for i in {0..1023}; do
14681 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14682 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14683 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14687 run_test 231b "must not assert on fully utilized OST request buffer"
14690 mkdir -p $DIR/$tdir
14691 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14693 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14694 do_facet ost1 $LCTL set_param fail_loc=0x31c
14696 # ignore dd failure
14697 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14699 do_facet ost1 $LCTL set_param fail_loc=0
14700 umount_client $MOUNT || error "umount failed"
14701 mount_client $MOUNT || error "mount failed"
14702 stop ost1 || error "cannot stop ost1"
14703 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14705 run_test 232a "failed lock should not block umount"
14708 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.58) ] ||
14709 { skip "Need MDS version at least 2.10.58"; return; }
14710 mkdir -p $DIR/$tdir
14711 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14712 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
14714 cancel_lru_locks osc
14716 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14717 do_facet ost1 $LCTL set_param fail_loc=0x31c
14720 $LFS data_version $DIR/$tdir/$tfile || true
14722 do_facet ost1 $LCTL set_param fail_loc=0
14723 umount_client $MOUNT || error "umount failed"
14724 mount_client $MOUNT || error "mount failed"
14725 stop ost1 || error "cannot stop ost1"
14726 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14728 run_test 232b "failed data version lock should not block umount"
14731 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14732 { skip "Need MDS version at least 2.3.64"; return; }
14733 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14735 local fid=$($LFS path2fid $MOUNT)
14736 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14737 error "cannot access $MOUNT using its FID '$fid'"
14739 run_test 233a "checking that OBF of the FS root succeeds"
14742 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14743 { skip "Need MDS version at least 2.5.90"; return; }
14744 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14746 local fid=$($LFS path2fid $MOUNT/.lustre)
14747 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14748 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14750 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14751 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14752 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14754 run_test 233b "checking that OBF of the FS .lustre succeeds"
14757 local p="$TMP/sanityN-$TESTNAME.parameters"
14758 save_lustre_params client "llite.*.xattr_cache" > $p
14759 lctl set_param llite.*.xattr_cache 1 ||
14760 { skip "xattr cache is not supported"; return 0; }
14762 mkdir -p $DIR/$tdir || error "mkdir failed"
14763 touch $DIR/$tdir/$tfile || error "touch failed"
14764 # OBD_FAIL_LLITE_XATTR_ENOMEM
14765 $LCTL set_param fail_loc=0x1405
14766 getfattr -n user.attr $DIR/$tdir/$tfile &&
14767 error "getfattr should have failed with ENOMEM"
14768 $LCTL set_param fail_loc=0x0
14771 restore_lustre_params < $p
14774 run_test 234 "xattr cache should not crash on ENOMEM"
14777 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14778 skip "Need MDS version at least 2.4.52" && return
14779 flock_deadlock $DIR/$tfile
14784 124) error "process hangs on a deadlock"
14786 *) error "error executing flock_deadlock $DIR/$tfile"
14790 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14794 check_swap_layouts_support && return 0
14795 test_mkdir -c1 $DIR/$tdir
14797 local ref1=/etc/passwd
14798 local ref2=/etc/group
14799 local file1=$DIR/$tdir/f1
14800 local file2=$DIR/$tdir/f2
14802 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14803 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14804 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14805 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14806 local fd=$(free_fd)
14807 local cmd="exec $fd<>$file2"
14810 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14811 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14814 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14819 run_test 236 "Layout swap on open unlinked file"
14821 # test to verify file handle related system calls
14822 # (name_to_handle_at/open_by_handle_at)
14823 # The new system calls are supported in glibc >= 2.14.
14826 echo "Test file_handle syscalls" > $DIR/$tfile ||
14827 error "write failed"
14828 check_fhandle_syscalls $DIR/$tfile ||
14829 error "check_fhandle_syscalls failed"
14831 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14833 # LU-4659 linkea consistency
14835 local server_version=$(lustre_version_code $SINGLEMDS)
14837 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14838 [[ $server_version -gt $(version_code 2.5.1) &&
14839 $server_version -lt $(version_code 2.5.50) ]] ||
14840 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14843 ln $DIR/$tfile $DIR/$tfile.lnk
14844 touch $DIR/$tfile.new
14845 mv $DIR/$tfile.new $DIR/$tfile
14846 local fid1=$($LFS path2fid $DIR/$tfile)
14847 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14848 local path1=$($LFS fid2path $FSNAME "$fid1")
14849 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14850 local path2=$($LFS fid2path $FSNAME "$fid2")
14851 [ $tfile.lnk == $path2 ] ||
14852 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14855 run_test 238 "Verify linkea consistency"
14857 test_239A() { # was test_239
14858 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14859 skip "Need MDS version at least 2.5.60" && return
14860 local list=$(comma_list $(mdts_nodes))
14862 mkdir -p $DIR/$tdir
14863 createmany -o $DIR/$tdir/f- 5000
14864 unlinkmany $DIR/$tdir/f- 5000
14865 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
14866 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14867 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14868 osp.*MDT*.sync_in_flight" | calc_sum)
14869 [ "$changes" -eq 0 ] || error "$changes not synced"
14871 run_test 239A "osp_sync test"
14873 test_239a() { #LU-5297
14874 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14876 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14877 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14878 chgrp $RUNAS_GID $DIR/$tfile
14879 wait_delete_completed
14881 run_test 239a "process invalid osp sync record correctly"
14883 test_239b() { #LU-5297
14884 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14886 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14887 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14888 chgrp $RUNAS_GID $DIR/$tfile1
14889 wait_delete_completed
14890 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14892 chgrp $RUNAS_GID $DIR/$tfile2
14893 wait_delete_completed
14895 run_test 239b "process osp sync record with ENOMEM error correctly"
14898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14899 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14901 mkdir -p $DIR/$tdir
14903 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14904 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14905 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14906 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14908 umount_client $MOUNT || error "umount failed"
14909 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14910 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14911 mount_client $MOUNT || error "failed to mount client"
14913 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14914 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14916 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14919 for LOOP in $(seq $1); do
14920 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14921 cancel_lru_locks $OSC || true
14926 for LOOP in $(seq $1); do
14927 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14928 iflag=direct 2>/dev/null
14932 test_241a() { # was test_241
14933 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14935 cancel_lru_locks $OSC
14936 test_241_bio 1000 &
14941 run_test 241a "bio vs dio"
14944 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14946 test_241_dio 1000 &
14951 run_test 241b "dio vs dio"
14954 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14955 mkdir -p $DIR/$tdir
14956 touch $DIR/$tdir/$tfile
14958 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14959 do_facet mds1 lctl set_param fail_loc=0x105
14960 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14962 do_facet mds1 lctl set_param fail_loc=0
14963 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14965 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14969 test_mkdir $DIR/$tdir
14970 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14972 run_test 243 "various group lock tests"
14976 test_mkdir $DIR/$tdir
14977 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14978 sendfile_grouplock $DIR/$tdir/$tfile || \
14979 error "sendfile+grouplock failed"
14982 run_test 244 "sendfile with group lock tests"
14985 local flagname="multi_mod_rpcs"
14986 local connect_data_name="max_mod_rpcs"
14989 # check if multiple modify RPCs flag is set
14990 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14991 grep "connect_flags:")
14994 echo "$out" | grep -qw $flagname
14995 if [ $? -ne 0 ]; then
14996 echo "connect flag $flagname is not set"
15000 # check if multiple modify RPCs data is set
15001 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
15004 echo "$out" | grep -qw $connect_data_name ||
15005 error "import should have connect data $connect_data_name"
15007 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
15009 test_246() { # LU-7371
15010 remote_ost_nodsh && skip "remote OST with nodsh" && return
15011 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
15012 skip "Need OST version >= 2.7.62" && return 0
15013 do_facet ost1 $LCTL set_param fail_val=4095
15014 #define OBD_FAIL_OST_READ_SIZE 0x234
15015 do_facet ost1 $LCTL set_param fail_loc=0x234
15016 $LFS setstripe $DIR/$tfile -i 0 -c 1
15017 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
15018 cancel_lru_locks $FSNAME-OST0000
15019 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
15021 run_test 246 "Read file of size 4095 should return right length"
15027 umount_client $submount
15032 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
15034 { skip "Fileset feature is not supported"; return; }
15036 local submount=${MOUNT}_$tdir
15039 mkdir -p $submount || error "mkdir $submount failed"
15040 FILESET="$FILESET/$tdir" mount_client $submount ||
15041 error "mount $submount failed"
15042 trap "cleanup_247 $submount" EXIT
15043 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
15044 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
15045 error "read $MOUNT/$tdir/$tfile failed"
15046 cleanup_247 $submount
15048 run_test 247a "mount subdir as fileset"
15051 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15052 { skip "Fileset feature is not supported"; return; }
15054 local submount=${MOUNT}_$tdir
15056 rm -rf $MOUNT/$tdir
15057 mkdir -p $submount || error "mkdir $submount failed"
15059 FILESET="$FILESET/$tdir" mount_client $submount &&
15060 error "mount $submount should fail"
15063 run_test 247b "mount subdir that dose not exist"
15066 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15067 { skip "Fileset feature is not supported"; return; }
15069 local submount=${MOUNT}_$tdir
15071 mkdir -p $MOUNT/$tdir/dir1
15072 mkdir -p $submount || error "mkdir $submount failed"
15073 trap "cleanup_247 $submount" EXIT
15074 FILESET="$FILESET/$tdir" mount_client $submount ||
15075 error "mount $submount failed"
15076 local fid=$($LFS path2fid $MOUNT/)
15077 $LFS fid2path $submount $fid && error "fid2path should fail"
15078 cleanup_247 $submount
15080 run_test 247c "running fid2path outside root"
15083 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15084 { skip "Fileset feature is not supported"; return; }
15086 local submount=${MOUNT}_$tdir
15088 mkdir -p $MOUNT/$tdir/dir1
15089 mkdir -p $submount || error "mkdir $submount failed"
15090 FILESET="$FILESET/$tdir" mount_client $submount ||
15091 error "mount $submount failed"
15092 trap "cleanup_247 $submount" EXIT
15093 local fid=$($LFS path2fid $submount/dir1)
15094 $LFS fid2path $submount $fid || error "fid2path should succeed"
15095 cleanup_247 $submount
15097 run_test 247d "running fid2path inside root"
15101 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
15103 { skip "Fileset feature is not supported"; return; }
15105 local submount=${MOUNT}_$tdir
15108 mkdir -p $submount || error "mkdir $submount failed"
15109 FILESET="$FILESET/.." mount_client $submount &&
15110 error "mount $submount should fail"
15113 run_test 247e "mount .. as fileset"
15116 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
15117 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
15119 # create a large file for fast read verification
15120 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
15122 # make sure the file is created correctly
15123 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
15124 { rm -f $DIR/$tfile; skip "file creation error" && return; }
15126 echo "Test 1: verify that fast read is 4 times faster on cache read"
15128 # small read with fast read enabled
15129 $LCTL set_param -n llite.*.fast_read=1
15130 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15131 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15132 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15133 # small read with fast read disabled
15134 $LCTL set_param -n llite.*.fast_read=0
15135 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15136 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15137 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15139 # verify that fast read is 4 times faster for cache read
15140 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
15141 error_not_in_vm "fast read was not 4 times faster: " \
15142 "$t_fast vs $t_slow"
15144 echo "Test 2: verify the performance between big and small read"
15145 $LCTL set_param -n llite.*.fast_read=1
15147 # 1k non-cache read
15148 cancel_lru_locks osc
15149 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15150 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15151 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15153 # 1M non-cache read
15154 cancel_lru_locks osc
15155 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15156 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15157 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15159 # verify that big IO is not 4 times faster than small IO
15160 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
15161 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
15163 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
15166 run_test 248 "fast read verification"
15168 test_249() { # LU-7890
15170 $SETSTRIPE -c 1 $DIR/$tfile
15172 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
15173 skip "Need at least version 2.8.54"
15175 # Offset 2T == 4k * 512M
15176 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
15177 error "dd to 2T offset failed"
15179 run_test 249 "Write above 2T file size"
15182 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
15183 && skip "no 16TB file size limit on ZFS" && return
15185 $SETSTRIPE -c 1 $DIR/$tfile
15186 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
15187 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
15188 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
15189 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
15190 conv=notrunc,fsync && error "append succeeded"
15193 run_test 250 "Write above 16T limit"
15196 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
15198 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
15199 #Skip once - writing the first stripe will succeed
15200 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15201 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
15202 error "short write happened"
15204 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15205 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
15206 error "short read happened"
15210 run_test 251 "Handling short read and write correctly"
15220 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15221 remote_ost_nodsh && skip "remote OST with nodsh" && return
15222 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
15223 "$(facet_fstype mds1)" != "ldiskfs" ]; then
15224 skip "ldiskfs only test"
15228 # check lr_reader on OST0000
15230 dev=$(facet_device $tgt)
15231 out=$(do_facet $tgt $LR_READER $dev)
15232 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15234 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
15235 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
15236 error "Invalid uuid returned by $LR_READER on target $tgt"
15237 echo -e "uuid returned by $LR_READER is '$uuid'\n"
15239 # check lr_reader -c on MDT0000
15241 dev=$(facet_device $tgt)
15242 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
15243 echo "$LR_READER does not support additional options"
15246 out=$(do_facet $tgt $LR_READER -c $dev)
15247 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15249 num=$(echo "$out" | grep -c "mdtlov")
15250 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
15251 error "Invalid number of mdtlov clients returned by $LR_READER"
15252 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
15254 # check lr_reader -cr on MDT0000
15255 out=$(do_facet $tgt $LR_READER -cr $dev)
15256 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15258 echo "$out" | grep -q "^reply_data:$" ||
15259 error "$LR_READER should have returned 'reply_data' section"
15260 num=$(echo "$out" | grep -c "client_generation")
15261 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
15263 run_test 252 "check lr_reader tool"
15265 test_253_fill_ost() {
15266 local size_mb #how many MB should we write to pass watermark
15267 local lwm=$3 #low watermark
15268 local free_10mb #10% of free space
15270 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15271 size_mb=$((free_kb / 1024 - lwm))
15272 free_10mb=$((free_kb / 10240))
15273 #If 10% of free space cross low watermark use it
15274 if (( free_10mb > size_mb )); then
15277 #At least we need to store 1.1 of difference between
15278 #free space and low watermark
15279 size_mb=$((size_mb + size_mb / 10))
15281 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
15282 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
15283 oflag=append conv=notrunc
15288 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15289 echo "OST still has $((free_kb / 1024)) mbytes free"
15296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15297 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15298 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
15300 local ost_name=$($LFS osts |
15301 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
15303 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
15304 do_facet $SINGLEMDS $LCTL get_param -n \
15305 osp.$mdtosc_proc1.reserved_mb_high ||
15306 { skip "remote MDS does not support reserved_mb_high" &&
15311 wait_delete_completed
15314 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
15315 osp.$mdtosc_proc1.reserved_mb_high)
15316 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
15317 osp.$mdtosc_proc1.reserved_mb_low)
15318 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
15320 if ! combined_mgs_mds ; then
15323 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
15324 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
15325 error "Adding $ost_name to pool failed"
15327 # Wait for client to see a OST at pool
15328 wait_update $HOSTNAME "$LCTL get_param -n
15329 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
15330 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
15331 error "Client can not see the pool"
15332 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
15333 error "Setstripe failed"
15335 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
15336 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
15337 echo "OST still has $((blocks/1024)) mbytes free"
15339 local new_lwm=$((blocks/1024-10))
15340 do_facet $SINGLEMDS $LCTL set_param \
15341 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
15342 do_facet $SINGLEMDS $LCTL set_param \
15343 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
15345 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15347 #First enospc could execute orphan deletion so repeat.
15348 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15350 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15351 osp.$mdtosc_proc1.prealloc_status)
15352 echo "prealloc_status $oa_status"
15354 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
15355 error "File creation should fail"
15356 #object allocation was stopped, but we still able to append files
15357 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
15358 error "Append failed"
15359 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
15361 wait_delete_completed
15365 for i in $(seq 10 12); do
15366 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
15367 error "File creation failed after rm";
15370 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15371 osp.$mdtosc_proc1.prealloc_status)
15372 echo "prealloc_status $oa_status"
15374 if (( oa_status != 0 )); then
15375 error "Object allocation still disable after rm"
15377 do_facet $SINGLEMDS $LCTL set_param \
15378 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
15379 do_facet $SINGLEMDS $LCTL set_param \
15380 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
15383 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
15384 error "Remove $ost_name from pool failed"
15385 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15386 error "Pool destroy fialed"
15388 if ! combined_mgs_mds ; then
15392 run_test 253 "Check object allocation limit"
15397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15398 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15400 local MDT0=$(facet_svc $SINGLEMDS)
15402 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
15403 { skip "MDS does not support changelog_size" && return; }
15405 changelog_register || error "changelog_register failed"
15407 changelog_clear 0 || error "changelog_clear failed"
15409 local size1=$(do_facet $SINGLEMDS \
15410 $LCTL get_param -n mdd.$MDT0.changelog_size)
15411 echo "Changelog size $size1"
15414 $LFS mkdir -i 0 $DIR/$tdir
15416 mkdir -p $DIR/$tdir/pics/2008/zachy
15417 touch $DIR/$tdir/pics/2008/zachy/timestamp
15418 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
15419 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15420 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15421 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15422 rm $DIR/$tdir/pics/desktop.jpg
15424 local size2=$(do_facet $SINGLEMDS \
15425 $LCTL get_param -n mdd.$MDT0.changelog_size)
15426 echo "Changelog size after work $size2"
15428 (( $size2 > $size1 )) ||
15429 error "new Changelog size=$size2 less than old size=$size1"
15431 run_test 254 "Check changelog size"
15438 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
15439 awk -F: '{print $2}' | grep $type > /dev/null
15440 if [ $? -ne 0 ]; then
15450 lfs ladvise -a willread $file > /dev/null 2>&1
15451 if [ $? -eq 0 ]; then
15455 lfs ladvise -a willread $file 2>&1 |
15456 grep "Inappropriate ioctl for device" > /dev/null
15457 if [ $? -eq 0 ]; then
15464 bc <<<"scale=2; ($1 - $2) * 100 / $2"
15467 # run a random read IO workload
15468 # usage: random_read_iops <filename> <filesize> <iosize>
15469 random_read_iops() {
15472 local iosize=${3:-4096}
15474 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
15475 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
15478 drop_file_oss_cache() {
15482 $LFS ladvise -a dontneed $file 2>/dev/null ||
15483 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
15486 ladvise_willread_performance()
15489 local average_origin=0
15490 local average_cache=0
15491 local average_ladvise=0
15493 for ((i = 1; i <= $repeat; i++)); do
15494 echo "Iter $i/$repeat: reading without willread hint"
15495 cancel_lru_locks osc
15496 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15497 local speed_origin=$(random_read_iops $DIR/$tfile $size)
15498 echo "Iter $i/$repeat: uncached speed: $speed_origin"
15499 average_origin=$(bc <<<"$average_origin + $speed_origin")
15501 cancel_lru_locks osc
15502 local speed_cache=$(random_read_iops $DIR/$tfile $size)
15503 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
15504 average_cache=$(bc <<<"$average_cache + $speed_cache")
15506 cancel_lru_locks osc
15507 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15508 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
15509 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
15510 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
15511 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
15513 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
15514 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
15515 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
15517 speedup_cache=$(percent $average_cache $average_origin)
15518 speedup_ladvise=$(percent $average_ladvise $average_origin)
15520 echo "Average uncached read: $average_origin"
15521 echo "Average speedup with OSS cached read: " \
15522 "$average_cache = +$speedup_cache%"
15523 echo "Average speedup with ladvise willread: " \
15524 "$average_ladvise = +$speedup_ladvise%"
15526 local lowest_speedup=20
15527 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15528 echo "Speedup with OSS cached read less than $lowest_speedup%," \
15529 "got $average_cache%. Skipping ladvise willread check."
15533 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15534 # it is still good to run until then to exercise 'ladvise willread'
15535 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15536 [ "$(facet_fstype ost1)" = "zfs" ] &&
15537 echo "osd-zfs does not support dontneed or drop_caches" &&
15540 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15541 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15542 error_not_in_vm "Speedup with willread is less than " \
15543 "$lowest_speedup%, got $average_ladvise%"
15547 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15548 skip "lustre < 2.8.54 does not support ladvise " && return
15549 remote_ost_nodsh && skip "remote OST with nodsh" && return
15551 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15553 ladvise_no_type willread $DIR/$tfile &&
15554 skip "willread ladvise is not supported" && return
15556 ladvise_no_ioctl $DIR/$tfile &&
15557 skip "ladvise ioctl is not supported" && return
15560 local size=$((size_mb * 1048576))
15561 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15562 error "dd to $DIR/$tfile failed"
15564 lfs ladvise -a willread $DIR/$tfile ||
15565 error "Ladvise failed with no range argument"
15567 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15568 error "Ladvise failed with no -l or -e argument"
15570 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15571 error "Ladvise failed with only -e argument"
15573 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15574 error "Ladvise failed with only -l argument"
15576 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15577 error "End offset should not be smaller than start offset"
15579 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15580 error "End offset should not be equal to start offset"
15582 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15583 error "Ladvise failed with overflowing -s argument"
15585 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15586 error "Ladvise failed with overflowing -e argument"
15588 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15589 error "Ladvise failed with overflowing -l argument"
15591 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15592 error "Ladvise succeeded with conflicting -l and -e arguments"
15594 echo "Synchronous ladvise should wait"
15596 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15597 do_nodes $(comma_list $(osts_nodes)) \
15598 $LCTL set_param fail_val=$delay fail_loc=0x237
15600 local start_ts=$SECONDS
15601 lfs ladvise -a willread $DIR/$tfile ||
15602 error "Ladvise failed with no range argument"
15603 local end_ts=$SECONDS
15604 local inteval_ts=$((end_ts - start_ts))
15606 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15607 error "Synchronous advice didn't wait reply"
15610 echo "Asynchronous ladvise shouldn't wait"
15611 local start_ts=$SECONDS
15612 lfs ladvise -a willread -b $DIR/$tfile ||
15613 error "Ladvise failed with no range argument"
15614 local end_ts=$SECONDS
15615 local inteval_ts=$((end_ts - start_ts))
15617 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15618 error "Asynchronous advice blocked"
15621 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15622 ladvise_willread_performance
15624 run_test 255a "check 'lfs ladvise -a willread'"
15630 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15634 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15635 skip "lustre < 2.8.54 does not support ladvise " && return
15636 remote_ost_nodsh && skip "remote OST with nodsh" && return
15638 lfs setstripe -c 1 -i 0 $DIR/$tfile
15640 ladvise_no_type dontneed $DIR/$tfile &&
15641 skip "dontneed ladvise is not supported" && return
15643 ladvise_no_ioctl $DIR/$tfile &&
15644 skip "ladvise ioctl is not supported" && return
15646 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15647 skip "lustre < 2.8.54 does not support ladvise" && return
15649 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15650 [ "$(facet_fstype ost1)" = "zfs" ] &&
15651 skip "zfs-osd does not support 'ladvise dontneed'" && return
15654 local size=$((size_mb * 1048576))
15655 # In order to prevent disturbance of other processes, only check 3/4
15656 # of the memory usage
15657 local kibibytes=$((size_mb * 1024 * 3 / 4))
15659 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15660 error "dd to $DIR/$tfile failed"
15662 local total=$(facet_meminfo ost1 MemTotal)
15663 echo "Total memory: $total KiB"
15665 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15666 local before_read=$(facet_meminfo ost1 Cached)
15667 echo "Cache used before read: $before_read KiB"
15669 lfs ladvise -a willread $DIR/$tfile ||
15670 error "Ladvise willread failed"
15671 local after_read=$(facet_meminfo ost1 Cached)
15672 echo "Cache used after read: $after_read KiB"
15674 lfs ladvise -a dontneed $DIR/$tfile ||
15675 error "Ladvise dontneed again failed"
15676 local no_read=$(facet_meminfo ost1 Cached)
15677 echo "Cache used after dontneed ladvise: $no_read KiB"
15679 if [ $total -lt $((before_read + kibibytes)) ]; then
15680 echo "Memory is too small, abort checking"
15684 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15685 error "Ladvise willread should use more memory" \
15686 "than $kibibytes KiB"
15689 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15690 error "Ladvise dontneed should release more memory" \
15691 "than $kibibytes KiB"
15694 run_test 255b "check 'lfs ladvise -a dontneed'"
15703 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
15704 skip "lustre < 2.10.53 does not support lockahead" && return
15706 test_mkdir -p $DIR/$tdir
15707 $SETSTRIPE -i 0 $DIR/$tdir
15709 #test 10 returns only success/failure
15711 lockahead_test -d $DIR/$tdir -t $i -f $tfile
15713 if [ $rc -eq 255 ]; then
15714 error "Ladvise test${i} failed, ${rc}"
15717 #test 11 counts lock enqueue requests, all others count new locks
15719 count=$(do_facet ost1 \
15720 $LCTL get_param -n ost.OSS.ost.stats)
15721 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
15723 lockahead_test -d $DIR/$tdir -t $i -f $tfile
15725 if [ $rc -eq 255 ]; then
15726 error "Ladvise test${i} failed, ${rc}"
15729 new_count=$(do_facet ost1 \
15730 $LCTL get_param -n ost.OSS.ost.stats)
15731 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
15732 awk '{ print $2 }')
15734 difference="$((new_count - count))"
15735 if [ $difference -ne $rc ]; then
15736 error "Ladvise test${i}, bad enqueue count, returned " \
15737 "${rc}, actual ${difference}"
15740 for i in $(seq 12 21); do
15741 # If we do not do this, we run the risk of having too many
15742 # locks and starting lock cancellation while we are checking
15744 cancel_lru_locks osc
15746 count=$($LCTL get_param -n \
15747 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15749 lockahead_test -d $DIR/$tdir -t $i -f $tfile
15751 if [ $rc -eq 255 ]; then
15752 error "Ladvise test ${i} failed, ${rc}"
15755 new_count=$($LCTL get_param -n \
15756 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15757 difference="$((new_count - count))"
15759 # Test 15 output is divided by 100 to map down to valid return
15760 if [ $i -eq 15 ]; then
15764 if [ $difference -ne $rc ]; then
15765 error "Ladvise test ${i}, bad lock count, returned " \
15766 "${rc}, actual ${difference}"
15770 #test 22 returns only success/failure
15772 lockahead_test -d $DIR/$tdir -t $i -f $tfile
15774 if [ $rc -eq 255 ]; then
15775 error "Ladvise test${i} failed, ${rc}"
15778 run_test 255c "suite of ladvise lockahead tests"
15785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15786 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15787 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
15788 skip "ldiskfs only test" && return
15790 mdt_dev=$(mdsdevname 1)
15792 changelog_users $SINGLEMDS | grep "^cl" &&
15793 skip "active changelog user" && return
15795 changelog_register || error "changelog_register failed"
15798 mkdir -p $DIR/$tdir
15800 changelog_clear 0 || error "changelog_clear failed"
15803 touch $DIR/$tdir/{1..10}
15806 stop $SINGLEMDS || error "Fail to stop MDT"
15810 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
15812 #after mount new plainllog is used
15813 touch $DIR/$tdir/{11..19}
15814 local tmpfile=$(mktemp -u $tfile.XXXXXX)
15815 cat_sl=$(do_facet $SINGLEMDS "sync; \
15816 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
15817 llog_reader $tmpfile | grep -c type=1064553b")
15818 do_facet $SINGLEMDS llog_reader $tmpfile
15820 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
15822 changelog_clear 0 || error "changelog_clear failed"
15824 cat_sl=$(do_facet $SINGLEMDS "sync; \
15825 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
15826 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
15828 if (( cat_sl == 2 )); then
15829 error "Empty plain llog was not deleted from changelog catalog"
15830 elif (( cat_sl != 1 )); then
15831 error "Active plain llog shouldn't be deleted from catalog"
15834 run_test 256 "Check llog delete for empty and not full state"
15837 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15838 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15839 skip "Need MDS version at least 2.8.55" && return
15841 test_mkdir $DIR/$tdir
15843 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15844 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15847 #define OBD_FAIL_MDS_XATTR_REP 0x161
15848 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15849 local facet=mds$((mdtidx + 1))
15850 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15851 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15853 stop $facet || error "stop MDS failed"
15854 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15855 error "start MDS fail"
15857 run_test 257 "xattr locks are not lost"
15859 # Verify we take the i_mutex when security requires it
15861 #define OBD_FAIL_IMUTEX_SEC 0x141c
15862 $LCTL set_param fail_loc=0x141c
15864 chmod u+s $DIR/$tfile
15865 chmod a+rwx $DIR/$tfile
15866 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15868 if [ $RC -ne 0 ]; then
15869 error "error, failed to take i_mutex, rc=$?"
15875 # Verify we do NOT take the i_mutex in the normal case
15877 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15878 $LCTL set_param fail_loc=0x141d
15881 chmod a+rw $DIR/$tfile
15882 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15884 if [ $RC -ne 0 ]; then
15885 error "error, took i_mutex unnecessarily, rc=$?"
15890 run_test 258b "verify i_mutex security behavior"
15893 #define OBD_FAIL_MDC_CLOSE 0x806
15894 $LCTL set_param fail_loc=0x80000806
15898 run_test 260 "Check mdc_close fail"
15900 ### Data-on-MDT sanity tests ###
15903 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15904 skip "Need MDS version at least 2.10.55" && return
15907 local dom=$DIR/$tdir/dom_file
15908 local tmp=$DIR/$tdir/tmp_file
15910 mkdir -p $DIR/$tdir
15912 # basic checks for DoM component creation
15913 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
15914 error "Can set MDT layout to non-first entry"
15916 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
15917 error "Can define multiple entries as MDT layout"
15919 $LFS setstripe -E 1M -L mdt $dom ||
15920 error "Can't create DoM layout"
15922 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
15923 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
15924 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
15926 local mdtidx=$($GETSTRIPE -M $dom)
15927 local mdtname=MDT$(printf %04x $mdtidx)
15928 local facet=mds$((mdtidx + 1))
15929 local space_check=1
15931 # Skip free space checks with ZFS
15932 if [ "$(facet_fstype $facet)" == "zfs" ]; then
15938 local mdtfree1=$(do_facet $facet \
15939 lctl get_param -n osd*.*$mdtname.kbytesfree)
15940 dd if=/dev/urandom of=$tmp bs=1024 count=100
15941 # check also direct IO along write
15942 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
15944 cmp $tmp $dom || error "file data is different"
15945 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
15946 if [ $space_check == 1 ]; then
15947 local mdtfree2=$(do_facet $facet \
15948 lctl get_param -n osd*.*$mdtname.kbytesfree)
15949 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15950 error "MDT free space is wrong after write"
15954 $TRUNCATE $dom 10000
15955 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
15956 if [ $space_check == 1 ]; then
15957 mdtfree1=$(do_facet $facet \
15958 lctl get_param -n osd*.*$mdtname.kbytesfree)
15959 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
15960 error "MDT free space is wrong after truncate"
15966 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
15967 if [ $space_check == 1 ]; then
15968 mdtfree2=$(do_facet $facet \
15969 lctl get_param -n osd*.*$mdtname.kbytesfree)
15970 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15971 error "MDT free space is wrong after append"
15976 if [ $space_check == 1 ]; then
15977 mdtfree1=$(do_facet $facet \
15978 lctl get_param -n osd*.*$mdtname.kbytesfree)
15979 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
15980 error "MDT free space is wrong after removal"
15983 # combined striping
15984 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
15985 error "Can't create DoM + OST striping"
15987 dd if=/dev/urandom of=$tmp bs=1024 count=2000
15988 # check also direct IO along write
15989 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
15991 cmp $tmp $dom || error "file data is different"
15992 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
15998 run_test 270a "DoM: basic functionality tests"
16001 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16002 skip "Need MDS version at least 2.10.55" && return
16004 local dom=$DIR/$tdir/dom_file
16005 local max_size=1048576
16007 mkdir -p $DIR/$tdir
16008 $LFS setstripe -E $max_size -L mdt $dom
16010 # truncate over the limit
16011 $TRUNCATE $dom $(($max_size + 1)) &&
16012 error "successful truncate over the maximum size"
16013 # write over the limit
16014 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
16015 error "successful write over the maximum size"
16016 # append over the limit
16017 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
16018 echo "12345" >> $dom && error "successful append over the maximum size"
16023 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
16026 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16027 skip "Need MDS version at least 2.10.55" && return
16029 mkdir -p $DIR/$tdir
16030 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16032 # check files inherit DoM EA
16033 touch $DIR/$tdir/first
16034 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
16035 error "bad pattern"
16036 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
16037 error "bad stripe count"
16038 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
16039 error "bad stripe size"
16041 # check directory inherits DoM EA and uses it as default
16042 mkdir $DIR/$tdir/subdir
16043 touch $DIR/$tdir/subdir/second
16044 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
16045 error "bad pattern in sub-directory"
16046 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
16047 error "bad stripe count in sub-directory"
16048 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
16049 error "bad stripe size in sub-directory"
16052 run_test 270c "DoM: DoM EA inheritance tests"
16055 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16056 skip "Need MDS version at least 2.10.55" && return
16058 mkdir -p $DIR/$tdir
16059 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16061 # inherit default DoM striping
16062 mkdir $DIR/$tdir/subdir
16063 touch $DIR/$tdir/subdir/f1
16065 # change default directory striping
16066 $LFS setstripe -c 1 $DIR/$tdir/subdir
16067 touch $DIR/$tdir/subdir/f2
16068 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
16069 error "wrong default striping in file 2"
16070 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
16071 error "bad pattern in file 2"
16074 run_test 270d "DoM: change striping from DoM to RAID0"
16077 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16078 skip "Need MDS version at least 2.10.55" && return
16080 mkdir -p $DIR/$tdir/dom
16081 mkdir -p $DIR/$tdir/norm
16084 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
16085 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
16087 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
16088 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
16090 # find DoM files by layout
16091 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
16092 [ $NUM -eq $DOMFILES ] ||
16093 error "lfs find -L: found $NUM, expected $DOMFILES"
16094 echo "Test 1: lfs find 20 DOM files by layout: OK"
16096 # there should be 1 dir with default DOM striping
16097 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
16099 error "lfs find -L: found $NUM, expected 1 dir"
16100 echo "Test 2: lfs find 1 DOM dir by layout: OK"
16102 # find DoM files by stripe size
16103 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
16104 [ $NUM -eq $DOMFILES ] ||
16105 error "lfs find -S: found $NUM, expected $DOMFILES"
16106 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
16108 # find files by stripe offset except DoM files
16109 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
16110 [ $NUM -eq $NORMFILES ] ||
16111 error "lfs find -i: found $NUM, expected $NORMFILES"
16112 echo "Test 5: lfs find no DOM files by stripe index: OK"
16115 run_test 270e "DoM: lfs find with DoM files test"
16118 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16119 skip "Need MDS version at least 2.10.55" && return
16121 local mdtname=${FSNAME}-MDT0000-mdtlov
16122 local dom=$DIR/$tdir/dom_file
16123 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
16124 lod.$mdtname.dom_stripesize)
16125 local dom_limit=131072
16127 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
16128 local dom_current=$(do_facet mds1 $LCTL get_param -n \
16129 lod.$mdtname.dom_stripesize)
16130 [ ${dom_limit} -eq ${dom_current} ] ||
16131 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
16133 $LFS mkdir -i 0 -c 1 $DIR/$tdir
16134 $LFS setstripe -d $DIR/$tdir
16135 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
16136 error "Can't set directory default striping"
16138 # exceed maximum stripe size
16139 $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
16140 error "Able to create DoM component size more than LOD limit"
16142 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
16143 dom_current=$(do_facet mds1 $LCTL get_param -n \
16144 lod.$mdtname.dom_stripesize)
16145 [ 0 -eq ${dom_current} ] ||
16146 error "Can't set zero DoM stripe limit"
16148 # too low values to be aligned with smallest stripe size 64K
16149 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
16150 dom_current=$(do_facet mds1 $LCTL get_param -n \
16151 lod.$mdtname.dom_stripesize)
16152 [ 30000 -eq ${dom_current} ] &&
16153 error "Can set too small DoM stripe limit"
16155 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
16156 dom_current=$(do_facet mds1 $LCTL get_param -n \
16157 lod.$mdtname.dom_stripesize)
16159 [ 2147483648 -eq ${dom_current} ] &&
16160 error "Can set too large DoM stripe limit"
16162 do_facet mds1 $LCTL set_param -n \
16163 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
16164 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16165 error "Can't create DoM component size after limit change"
16166 do_facet mds1 $LCTL set_param -n \
16167 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
16168 $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
16169 error "Can create big DoM component after limit decrease"
16170 touch ${dom}_def ||
16171 error "Can't create file with old default layout"
16173 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
16176 run_test 270f "DoM: maximum DoM stripe size checks"
16179 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16180 skip "Need MDS version at least 2.10.55" && return
16182 local dom=$DIR/$tdir/dom
16184 mkdir -p $DIR/$tdir
16186 $LFS setstripe -E 1024K -L mdt $dom
16188 lctl set_param -n mdc.*.stats=clear
16189 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16190 cat $dom > /dev/null
16191 local reads=$(lctl get_param -n mdc.*.stats |
16192 awk '/ost_read/ {print $2}')
16193 [ -z $reads ] || error "Unexpected $reads READ RPCs"
16197 run_test 271a "DoM: data is cached for read after write"
16200 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16201 skip "Need MDS version at least 2.10.55" && return
16203 local dom=$DIR/$tdir/dom
16205 mkdir -p $DIR/$tdir
16207 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16209 lctl set_param -n mdc.*.stats=clear
16210 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16211 cancel_lru_locks mdc
16212 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
16213 # second stat to check size is cached on client
16214 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
16215 local gls=$(lctl get_param -n mdc.*.stats |
16216 awk '/ldlm_glimpse/ {print $2}')
16217 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16220 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
16223 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16224 skip "Need MDS version at least 2.10.55" && return
16226 local dom=$DIR/$tdir/dom
16228 mkdir -p $DIR/$tdir
16230 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16232 lctl set_param -n mdc.*.stats=clear
16233 lctl set_param -n osc.*.stats=clear
16234 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
16235 cancel_lru_locks mdc
16236 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16237 # second stat to check size is cached on client
16238 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16239 local gls=$(lctl get_param -n mdc.*.stats |
16240 awk '/ldlm_glimpse/ {print $2}')
16241 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16242 local gls=$(lctl get_param -n osc.*.stats |
16243 awk '/ldlm_glimpse/ {print $2}')
16244 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
16247 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
16250 # test to be enabled with lock_convert
16251 skip "skipped until lock convert will be implemented" && return
16253 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16254 skip "Need MDS version at least 2.10.55" && return
16256 local dom=$DIR/$tdir/dom
16258 mkdir -p $DIR/$tdir
16260 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16262 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
16263 local facet=mds$((mdtidx + 1))
16265 cancel_lru_locks mdc
16266 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
16267 createmany -o $dom 1000
16268 lctl set_param -n mdc.*.stats=clear
16269 smalliomany -w $dom 1000 200
16270 lctl get_param -n mdc.*.stats
16271 local enq=$(lctl get_param -n mdc.*.stats |
16272 awk '/ldlm_ibits_enqueue/ {print $2}')
16273 # Each file has 1 open, 1 IO enqueues, total 2000
16274 # but now we have also +1 getxattr for security.capability, total 3000
16275 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
16276 unlinkmany $dom 1000
16278 cancel_lru_locks mdc
16279 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
16280 createmany -o $dom 1000
16281 lctl set_param -n mdc.*.stats=clear
16282 smalliomany -w $dom 1000 200
16283 lctl get_param -n mdc.*.stats
16284 local enq_2=$(lctl get_param -n mdc.*.stats |
16285 awk '/ldlm_ibits_enqueue/ {print $2}')
16286 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
16287 # for OPEN and IO lock.
16288 [ $((enq - enq_2)) -ge 1000 ] ||
16289 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
16290 unlinkmany $dom 1000
16293 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
16296 remote_ost_nodsh && skip "remote OST with nodsh" && return
16297 [ $(lustre_version_code ost1) -lt $(version_code 2.10.57) ] &&
16298 skip "Need OST version >= 2.10.57" && return 0
16300 local file=$DIR/$tfile
16303 oss=$(comma_list $(osts_nodes))
16305 dd if=/dev/urandom of=$file bs=1M count=2 ||
16306 error "failed to create a file"
16307 cancel_lru_locks osc
16310 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
16311 error "failed to read a file"
16313 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
16314 $LCTL set_param fail_loc=0x8000031f
16316 cancel_lru_locks osc &
16319 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
16320 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
16321 #IO takes another lock, but matches the PENDING one
16322 #and places it to the IO RPC
16323 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
16324 error "failed to read a file with PENDING lock"
16326 run_test 275 "Read on a canceled duplicate lock"
16329 remote_ost_nodsh && skip "remote OST with nodsh" && return
16332 do_facet ost1 "(while true; do \
16333 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
16334 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
16337 for LOOP in $(seq 20); do
16339 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
16342 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
16343 rm $TMP/sanity_276_pid"
16345 run_test 276 "Race between mount and obd_statfs"
16347 cleanup_test_300() {
16351 test_striped_dir() {
16356 mkdir -p $DIR/$tdir
16358 SAVE_UMASK=$(umask)
16359 trap cleanup_test_300 RETURN EXIT
16361 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
16362 $DIR/$tdir/striped_dir ||
16363 error "set striped dir error"
16365 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
16366 [ "$mode" = "755" ] || error "expect 755 got $mode"
16368 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
16369 error "getdirstripe failed"
16370 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
16371 if [ "$stripe_count" != "2" ]; then
16372 error "1:stripe_count is $stripe_count, expect 2"
16374 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
16375 if [ "$stripe_count" != "2" ]; then
16376 error "2:stripe_count is $stripe_count, expect 2"
16379 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
16380 if [ "$stripe_index" != "$mdt_index" ]; then
16381 error "stripe_index is $stripe_index, expect $mdt_index"
16384 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16385 error "nlink error after create striped dir"
16387 mkdir $DIR/$tdir/striped_dir/a
16388 mkdir $DIR/$tdir/striped_dir/b
16390 stat $DIR/$tdir/striped_dir/a ||
16391 error "create dir under striped dir failed"
16392 stat $DIR/$tdir/striped_dir/b ||
16393 error "create dir under striped dir failed"
16395 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
16396 error "nlink error after mkdir"
16398 rmdir $DIR/$tdir/striped_dir/a
16399 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
16400 error "nlink error after rmdir"
16402 rmdir $DIR/$tdir/striped_dir/b
16403 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16404 error "nlink error after rmdir"
16406 chattr +i $DIR/$tdir/striped_dir
16407 createmany -o $DIR/$tdir/striped_dir/f 10 &&
16408 error "immutable flags not working under striped dir!"
16409 chattr -i $DIR/$tdir/striped_dir
16411 rmdir $DIR/$tdir/striped_dir ||
16412 error "rmdir striped dir error"
16420 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16421 skip "skipped for lustre < 2.7.0" && return
16422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16423 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16425 test_striped_dir 0 || error "failed on striped dir on MDT0"
16426 test_striped_dir 1 || error "failed on striped dir on MDT0"
16428 run_test 300a "basic striped dir sanity test"
16431 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16432 skip "skipped for lustre < 2.7.0" && return
16433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16434 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16440 test_mkdir $DIR/$tdir || error "mkdir fail"
16441 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
16442 error "set striped dir error"
16443 for i in {0..9}; do
16444 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
16446 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
16447 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
16448 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
16450 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
16451 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
16452 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
16456 run_test 300b "check ctime/mtime for striped dir"
16459 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16460 skip "skipped for lustre < 2.7.0" && return
16461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16465 mkdir -p $DIR/$tdir
16466 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
16467 error "set striped dir error"
16469 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
16470 error "chown striped dir failed"
16472 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
16473 error "create 5k files failed"
16475 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
16477 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
16481 run_test 300c "chown && check ls under striped directory"
16484 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16485 skip "skipped for lustre < 2.7.0" && return
16486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16487 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16491 mkdir -p $DIR/$tdir
16492 $SETSTRIPE -c 2 $DIR/$tdir
16494 #local striped directory
16495 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
16496 error "set striped dir error"
16497 createmany -o $DIR/$tdir/striped_dir/f 10 ||
16498 error "create 10 files failed"
16500 #remote striped directory
16501 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
16502 error "set striped dir error"
16503 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
16504 error "create 10 files failed"
16506 for file in $(find $DIR/$tdir); do
16507 stripe_count=$($GETSTRIPE -c $file)
16508 [ $stripe_count -eq 2 ] ||
16509 error "wrong stripe $stripe_count for $file"
16514 run_test 300d "check default stripe under striped directory"
16517 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16518 skip "Need MDS version at least 2.7.55" && return
16519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16520 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16524 mkdir -p $DIR/$tdir
16526 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
16527 error "set striped dir error"
16529 touch $DIR/$tdir/striped_dir/a
16530 touch $DIR/$tdir/striped_dir/b
16531 touch $DIR/$tdir/striped_dir/c
16533 mkdir $DIR/$tdir/striped_dir/dir_a
16534 mkdir $DIR/$tdir/striped_dir/dir_b
16535 mkdir $DIR/$tdir/striped_dir/dir_c
16537 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
16538 error "set striped adir under striped dir error"
16540 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
16541 error "set striped bdir under striped dir error"
16543 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
16544 error "set striped cdir under striped dir error"
16546 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
16547 error "rename dir under striped dir fails"
16549 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
16550 error "rename dir under different stripes fails"
16552 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
16553 error "rename file under striped dir should succeed"
16555 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
16556 error "rename dir under striped dir should succeed"
16560 run_test 300e "check rename under striped directory"
16563 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16564 skip "Need MDS version at least 2.7.55" && return
16565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16566 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16571 mkdir -p $DIR/$tdir
16573 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
16574 error "set striped dir error"
16576 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
16577 error "set striped dir error"
16579 touch $DIR/$tdir/striped_dir/a
16580 mkdir $DIR/$tdir/striped_dir/dir_a
16581 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
16582 error "create striped dir under striped dir fails"
16584 touch $DIR/$tdir/striped_dir1/b
16585 mkdir $DIR/$tdir/striped_dir1/dir_b
16586 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
16587 error "create striped dir under striped dir fails"
16589 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
16590 error "rename dir under different striped dir should fail"
16592 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
16593 error "rename striped dir under diff striped dir should fail"
16595 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
16596 error "rename file under diff striped dirs fails"
16600 run_test 300f "check rename cross striped directory"
16602 test_300_check_default_striped_dir()
16605 local default_count=$2
16606 local default_index=$3
16609 local dir_stripe_index
16612 echo "checking $dirname $default_count $default_index"
16613 $LFS setdirstripe -D -c $default_count -i $default_index \
16614 -t all_char $DIR/$tdir/$dirname ||
16615 error "set default stripe on striped dir error"
16616 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
16617 [ $stripe_count -eq $default_count ] ||
16618 error "expect $default_count get $stripe_count for $dirname"
16620 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
16621 [ $stripe_index -eq $default_index ] ||
16622 error "expect $default_index get $stripe_index for $dirname"
16624 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
16625 error "create dirs failed"
16627 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
16628 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
16629 for dir in $(find $DIR/$tdir/$dirname/*); do
16630 stripe_count=$($LFS getdirstripe -c $dir)
16631 [ $stripe_count -eq $default_count ] ||
16632 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
16633 error "stripe count $default_count != $stripe_count for $dir"
16635 stripe_index=$($LFS getdirstripe -i $dir)
16636 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
16637 error "$stripe_index != $default_index for $dir"
16639 #check default stripe
16640 stripe_count=$($LFS getdirstripe -D -c $dir)
16641 [ $stripe_count -eq $default_count ] ||
16642 error "default count $default_count != $stripe_count for $dir"
16644 stripe_index=$($LFS getdirstripe -D -i $dir)
16645 [ $stripe_index -eq $default_index ] ||
16646 error "default index $default_index != $stripe_index for $dir"
16648 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
16652 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16653 skip "Need MDS version at least 2.7.55" && return
16654 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16660 mkdir $DIR/$tdir/normal_dir
16662 #Checking when client cache stripe index
16663 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
16664 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
16665 error "create striped_dir failed"
16667 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
16668 error "create dir0 fails"
16669 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
16670 [ $stripe_index -eq 0 ] ||
16671 error "dir0 expect index 0 got $stripe_index"
16673 mkdir $DIR/$tdir/striped_dir/dir1 ||
16674 error "create dir1 fails"
16675 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
16676 [ $stripe_index -eq 1 ] ||
16677 error "dir1 expect index 1 got $stripe_index"
16679 #check default stripe count/stripe index
16680 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
16681 test_300_check_default_striped_dir normal_dir 1 0
16682 test_300_check_default_striped_dir normal_dir 2 1
16683 test_300_check_default_striped_dir normal_dir 2 -1
16685 #delete default stripe information
16686 echo "delete default stripeEA"
16687 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
16688 error "set default stripe on striped dir error"
16690 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
16691 for dir in $(find $DIR/$tdir/normal_dir/*); do
16692 stripe_count=$($LFS getdirstripe -c $dir)
16693 [ $stripe_count -eq 0 ] ||
16694 error "expect 1 get $stripe_count for $dir"
16695 stripe_index=$($LFS getdirstripe -i $dir)
16696 [ $stripe_index -eq 0 ] ||
16697 error "expect 0 get $stripe_index for $dir"
16700 run_test 300g "check default striped directory for normal directory"
16703 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16704 skip "Need MDS version at least 2.7.55" && return
16705 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16710 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
16711 error "set striped dir error"
16713 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
16714 test_300_check_default_striped_dir striped_dir 1 0
16715 test_300_check_default_striped_dir striped_dir 2 1
16716 test_300_check_default_striped_dir striped_dir 2 -1
16718 #delete default stripe information
16719 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
16720 error "set default stripe on striped dir error"
16722 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
16723 for dir in $(find $DIR/$tdir/striped_dir/*); do
16724 stripe_count=$($LFS getdirstripe -c $dir)
16725 [ $stripe_count -eq 0 ] ||
16726 error "expect 1 get $stripe_count for $dir"
16729 run_test 300h "check default striped directory for striped directory"
16732 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16733 skip "Need MDS version at least 2.7.55" && return
16734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16735 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16741 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
16742 error "set striped dir error"
16744 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16745 error "create files under striped dir failed"
16747 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
16748 error "set striped hashdir error"
16750 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
16751 error "create dir0 under hash dir failed"
16752 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
16753 error "create dir1 under hash dir failed"
16755 # unfortunately, we need to umount to clear dir layout cache for now
16756 # once we fully implement dir layout, we can drop this
16757 umount_client $MOUNT || error "umount failed"
16758 mount_client $MOUNT || error "mount failed"
16760 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
16761 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
16762 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
16764 #set the stripe to be unknown hash type
16765 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
16766 $LCTL set_param fail_loc=0x1901
16767 for ((i = 0; i < 10; i++)); do
16768 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
16769 error "stat f-$i failed"
16770 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
16773 touch $DIR/$tdir/striped_dir/f0 &&
16774 error "create under striped dir with unknown hash should fail"
16776 $LCTL set_param fail_loc=0
16778 umount_client $MOUNT || error "umount failed"
16779 mount_client $MOUNT || error "mount failed"
16783 run_test 300i "client handle unknown hash type striped directory"
16786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16787 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16788 skip "Need MDS version at least 2.7.55" && return
16789 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16795 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
16796 $LCTL set_param fail_loc=0x1702
16797 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
16798 error "set striped dir error"
16800 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16801 error "create files under striped dir failed"
16803 $LCTL set_param fail_loc=0
16805 rm -rf $DIR/$tdir || error "unlink striped dir fails"
16809 run_test 300j "test large update record"
16812 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16813 skip "Need MDS version at least 2.7.55" && return
16814 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16815 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16821 #define OBD_FAIL_LARGE_STRIPE 0x1703
16822 $LCTL set_param fail_loc=0x1703
16823 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
16824 error "set striped dir error"
16825 $LCTL set_param fail_loc=0
16827 $LFS getdirstripe $DIR/$tdir/striped_dir ||
16828 error "getstripeddir fails"
16829 rm -rf $DIR/$tdir/striped_dir ||
16830 error "unlink striped dir fails"
16834 run_test 300k "test large striped directory"
16837 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16838 skip "Need MDS version at least 2.7.55" && return
16839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16840 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16843 test_mkdir -p $DIR/$tdir/striped_dir
16844 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
16845 error "chown $RUNAS_ID failed"
16846 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
16847 error "set default striped dir failed"
16849 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
16850 $LCTL set_param fail_loc=0x80000158
16851 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
16853 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
16854 [ $stripe_index -eq 1 ] ||
16855 error "expect 1 get $stripe_index for $dir"
16857 run_test 300l "non-root user to create dir under striped dir with stale layout"
16860 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16861 skip "Need MDS version at least 2.7.55" && return
16862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16863 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
16865 mkdir -p $DIR/$tdir/striped_dir
16866 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
16867 error "set default stripes dir error"
16869 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
16871 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
16872 [ $stripe_count -eq 0 ] ||
16873 error "expect 0 get $stripe_count for a"
16875 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
16876 error "set default stripes dir error"
16878 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
16880 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
16881 [ $stripe_count -eq 0 ] ||
16882 error "expect 0 get $stripe_count for b"
16884 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
16885 error "set default stripes dir error"
16887 mkdir $DIR/$tdir/striped_dir/c &&
16888 error "default stripe_index is invalid, mkdir c should fails"
16890 rm -rf $DIR/$tdir || error "rmdir fails"
16892 run_test 300m "setstriped directory on single MDT FS"
16895 local list=$(comma_list $(mdts_nodes))
16898 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16902 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16903 skip "Need MDS version at least 2.7.55" && return
16904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16905 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16906 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16909 local list=$(comma_list $(mdts_nodes))
16911 trap cleanup_300n RETURN EXIT
16912 mkdir -p $DIR/$tdir
16913 chmod 777 $DIR/$tdir
16914 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16915 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16916 error "create striped dir succeeds with gid=0"
16918 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16919 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16920 error "create striped dir fails with gid=-1"
16922 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16923 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16924 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16925 error "set default striped dir succeeds with gid=0"
16928 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16929 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16930 error "set default striped dir fails with gid=-1"
16933 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16934 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16935 error "create test_dir fails"
16936 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16937 error "create test_dir1 fails"
16938 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16939 error "create test_dir2 fails"
16942 run_test 300n "non-root user to create dir under striped dir with default EA"
16945 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16946 skip "Need MDS version at least 2.7.55" && return
16947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16948 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16952 mkdir -p $DIR/$tdir
16954 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16955 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16956 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16957 skip "not enough free inodes $numfree1 $numfree2"
16961 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16962 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16963 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16964 skip "not enough free space $numfree1 $numfree2"
16968 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16969 error "setdirstripe fails"
16971 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16972 error "create dirs fails"
16974 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16975 ls $DIR/$tdir/striped_dir > /dev/null ||
16976 error "ls striped dir fails"
16977 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16978 error "unlink big striped dir fails"
16980 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16984 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16985 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16987 mkdir -p $DIR/$tdir
16989 #define OBD_FAIL_OUT_ENOSPC 0x1704
16990 do_facet mds2 lctl set_param fail_loc=0x80001704
16991 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
16992 && error "create striped directory should fail"
16994 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16996 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16999 run_test 300p "create striped directory without space"
17002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17005 local fd=$(free_fd)
17006 local cmd="exec $fd<$tdir"
17008 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
17011 trap "eval $cmd" EXIT
17012 cd $tdir || error "cd $tdir fails"
17013 rmdir ../$tdir || error "rmdir $tdir fails"
17014 mkdir local_dir && error "create dir succeeds"
17015 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
17019 run_test 300q "create remote directory under orphan directory"
17021 prepare_remote_file() {
17022 mkdir $DIR/$tdir/src_dir ||
17023 error "create remote source failed"
17025 cp /etc/hosts $DIR/$tdir/src_dir/a ||
17026 error "cp to remote source failed"
17027 touch $DIR/$tdir/src_dir/a
17029 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
17030 error "create remote target dir failed"
17032 touch $DIR/$tdir/tgt_dir/b
17034 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
17035 error "rename dir cross MDT failed!"
17037 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
17038 error "src_child still exists after rename"
17040 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
17041 error "missing file(a) after rename"
17043 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
17044 error "diff after rename"
17048 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
17049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17050 local remote_file=$DIR/$tdir/tgt_dir/b
17052 mkdir -p $DIR/$tdir
17054 prepare_remote_file || error "prepare remote file failed"
17057 $OPENUNLINK $remote_file $remote_file ||
17058 error "openunlink $remote_file failed"
17059 $CHECKSTAT -a $remote_file || error "$remote_file exists"
17061 run_test 310a "open unlink remote file"
17064 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
17065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17066 local remote_file=$DIR/$tdir/tgt_dir/b
17068 mkdir -p $DIR/$tdir
17070 prepare_remote_file || error "prepare remote file failed"
17072 ln $remote_file $DIR/$tfile || error "link failed for remote file"
17073 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
17074 $CHECKSTAT -t file $remote_file || error "check file failed"
17076 run_test 310b "unlink remote file with multiple links while open"
17079 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
17080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17081 local remote_file=$DIR/$tdir/tgt_dir/b
17083 mkdir -p $DIR/$tdir
17085 prepare_remote_file || error "prepare remote file failed"
17087 ln $remote_file $DIR/$tfile || error "link failed for remote file"
17088 multiop_bg_pause $remote_file O_uc ||
17089 error "mulitop failed for remote file"
17091 $MULTIOP $DIR/$tfile Ouc
17092 kill -USR1 $MULTIPID
17095 run_test 310c "open-unlink remote file with multiple links"
17099 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17100 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
17101 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
17102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17103 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17105 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
17107 mkdir -p $DIR/$tdir
17108 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
17109 createmany -o $DIR/$tdir/$tfile. 1000
17111 # statfs data is not real time, let's just calculate it
17112 old_iused=$((old_iused + 1000))
17114 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
17115 osp.*OST0000*MDT0000.create_count")
17116 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
17117 osp.*OST0000*MDT0000.max_create_count")
17118 for idx in $(seq $MDSCOUNT); do
17119 do_facet mds$idx "lctl set_param -n \
17120 osp.*OST0000*MDT000?.max_create_count=0"
17123 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
17124 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
17125 [ $index -ne 0 ] || error "$tfile stripe index is 0"
17127 unlinkmany $DIR/$tdir/$tfile. 1000
17129 for idx in $(seq $MDSCOUNT); do
17130 do_facet mds$idx "lctl set_param -n \
17131 osp.*OST0000*MDT000?.max_create_count=$max_count"
17132 do_facet mds$idx "lctl set_param -n \
17133 osp.*OST0000*MDT000?.create_count=$count"
17137 for i in $(seq 120); do
17138 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
17139 # system may be too busy to destroy all objs in time, use
17140 # a somewhat small value to not fail autotest
17141 [ $((old_iused - new_iused)) -gt 400 ] && break
17145 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
17146 [ $((old_iused - new_iused)) -gt 400 ] ||
17147 error "objs not destroyed after unlink"
17149 run_test 311 "disable OSP precreate, and unlink should destroy objs"
17156 local vdevdir=$(dirname $(facet_vdevice $ost))
17157 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
17158 local zfs_zapid=$(do_facet $ost $cmd |
17159 grep -w "/O/0/d$((objid%32))" -C 5 |
17160 awk '/Object/{getline; print $1}')
17161 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
17162 awk "/$objid = /"'{printf $3}')
17167 zfs_object_blksz() {
17171 local vdevdir=$(dirname $(facet_vdevice $ost))
17172 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
17173 local blksz=$(do_facet $ost $cmd $objid |
17174 awk '/dblk/{getline; printf $4}')
17176 case "${blksz: -1}" in
17177 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
17178 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
17185 test_312() { # LU-4856
17186 remote_ost_nodsh && skip "remote OST with nodsh" && return
17188 [ $(facet_fstype ost1) = "zfs" ] ||
17189 { skip "the test only applies to zfs" && return; }
17191 local max_blksz=$(do_facet ost1 \
17192 $ZFS get -p recordsize $(facet_device ost1) |
17193 awk '!/VALUE/{print $3}')
17194 local min_blksz=$(getconf PAGE_SIZE)
17196 # to make life a little bit easier
17197 $LFS mkdir -c 1 -i 0 $DIR/$tdir
17198 $LFS setstripe -c 1 -i 0 $DIR/$tdir
17200 local tf=$DIR/$tdir/$tfile
17202 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17204 # Get ZFS object id
17205 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17207 # block size change by sequential over write
17209 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
17210 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
17212 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17213 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
17217 # block size change by sequential append write
17218 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
17219 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17220 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17222 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
17223 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
17224 oflag=sync conv=notrunc
17226 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17227 [ $blksz -eq $((2 * count * min_blksz)) ] ||
17228 error "blksz error, actual $blksz, " \
17229 "expected: 2 * $count * $min_blksz"
17235 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17236 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17238 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
17239 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17240 [ $blksz -eq $min_blksz ] ||
17241 error "blksz error: $blksz, expected: $min_blksz"
17243 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
17244 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17245 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
17247 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
17248 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17249 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
17251 run_test 312 "make sure ZFS adjusts its block size by write pattern"
17254 remote_ost_nodsh && skip "remote OST with nodsh" && return
17256 local file=$DIR/$tfile
17258 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
17260 # define OBD_FAIL_TGT_RCVD_EIO 0x720
17261 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17262 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
17263 error "write should failed"
17264 do_facet ost1 "$LCTL set_param fail_loc=0"
17267 run_test 313 "io should fail after last_rcvd update fail"
17270 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17272 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
17273 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17275 wait_delete_completed
17276 do_facet ost1 "$LCTL set_param fail_loc=0"
17278 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
17280 test_315() { # LU-618
17281 local file=$DIR/$tfile
17284 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
17285 $MULTIOP $file oO_RDONLY:r4096000_c &
17290 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
17293 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
17296 run_test 315 "read should be accounted"
17299 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
17300 large_xattr_enabled || { skip "large_xattr disabled" && return; }
17302 rm -rf $DIR/$tdir/d
17303 mkdir -p $DIR/$tdir/d
17304 chown nobody $DIR/$tdir/d
17305 touch $DIR/$tdir/d/file
17307 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
17309 run_test 316 "lfs mv"
17312 local read_write=$1
17313 if [ "$read_write" = "write" ]; then
17314 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
17315 elif [ "$read_write" = "read" ]; then
17316 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
17318 error "argument error"
17321 # turn off debug for performance testing
17322 local saved_debug=$($LCTL get_param -n debug)
17323 $LCTL set_param debug=0
17325 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
17327 # get ost1 size - lustre-OST0000
17328 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
17329 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
17330 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
17332 if [ "$read_write" = "read" ]; then
17333 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
17336 local start_time=$(date +%s.%N)
17337 $dd_cmd bs=1M count=$blocks oflag=sync ||
17338 error "real dd $read_write error"
17339 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
17341 if [ "$read_write" = "write" ]; then
17345 # define OBD_FAIL_OST_FAKE_RW 0x238
17346 do_facet ost1 $LCTL set_param fail_loc=0x238
17348 local start_time=$(date +%s.%N)
17349 $dd_cmd bs=1M count=$blocks oflag=sync ||
17350 error "fake dd $read_write error"
17351 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
17353 if [ "$read_write" = "write" ]; then
17355 cancel_lru_locks osc
17356 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
17357 error "$tfile size not $blocks MB"
17359 do_facet ost1 $LCTL set_param fail_loc=0
17361 echo "fake $read_write $duration_fake vs. normal $read_write" \
17362 "$duration in seconds"
17363 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
17364 error_not_in_vm "fake write is slower"
17366 $LCTL set_param -n debug="$saved_debug"
17369 test_399a() { # LU-7655 for OST fake write
17370 remote_ost_nodsh && skip "remote OST with nodsh" && return
17374 run_test 399a "fake write should not be slower than normal write"
17376 test_399b() { # LU-8726 for OST fake read
17377 remote_ost_nodsh && skip "remote OST with nodsh" && return
17379 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
17380 skip "ldiskfs only test" && return 0
17384 run_test 399b "fake read should not be slower than normal read"
17386 test_400a() { # LU-1606, was conf-sanity test_74
17387 local extra_flags=''
17388 local out=$TMP/$tfile
17389 local prefix=/usr/include/lustre
17392 if ! which $CC > /dev/null 2>&1; then
17393 skip_env "$CC is not installed"
17397 if ! [[ -d $prefix ]]; then
17398 # Assume we're running in tree and fixup the include path.
17399 extra_flags+=" -I$LUSTRE/include"
17400 extra_flags+=" -L$LUSTRE/utils"
17403 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
17404 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
17405 error "client api broken"
17409 run_test 400a "Lustre client api program can compile and link"
17411 test_400b() { # LU-1606, LU-5011
17413 local out=$TMP/$tfile
17414 local prefix=/usr/include/linux/lustre
17416 # We use a hard coded prefix so that this test will not fail
17417 # when run in tree. There are headers in lustre/include/lustre/
17418 # that are not packaged (like lustre_idl.h) and have more
17419 # complicated include dependencies (like config.h and lnet/types.h).
17420 # Since this test about correct packaging we just skip them when
17421 # they don't exist (see below) rather than try to fixup cppflags.
17423 if ! which $CC > /dev/null 2>&1; then
17424 skip_env "$CC is not installed"
17428 for header in $prefix/*.h; do
17429 if ! [[ -f "$header" ]]; then
17433 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
17434 continue # lustre_ioctl.h is internal header
17437 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
17438 error "cannot compile '$header'"
17442 run_test 400b "packaged headers can be compiled"
17444 test_401a() { #LU-7437
17445 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
17446 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
17448 #count the number of parameters by "list_param -R"
17449 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
17450 #count the number of parameters by listing proc files
17451 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
17452 echo "proc_dirs='$proc_dirs'"
17453 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
17454 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
17457 [ $params -eq $procs ] ||
17458 error "found $params parameters vs. $procs proc files"
17460 # test the list_param -D option only returns directories
17461 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
17462 #count the number of parameters by listing proc directories
17463 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
17466 [ $params -eq $procs ] ||
17467 error "found $params parameters vs. $procs proc files"
17469 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
17472 local save=$($LCTL get_param -n jobid_var)
17475 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
17476 error "no error returned when setting bad parameters"
17478 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
17479 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
17481 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
17482 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
17483 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
17485 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
17488 local jobid_var_old=$($LCTL get_param -n jobid_var)
17489 local jobid_var_new
17491 $LCTL set_param jobid_var= &&
17492 error "no error returned for 'set_param a='"
17494 jobid_var_new=$($LCTL get_param -n jobid_var)
17495 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17496 error "jobid_var was changed by setting without value"
17498 $LCTL set_param jobid_var &&
17499 error "no error returned for 'set_param a'"
17501 jobid_var_new=$($LCTL get_param -n jobid_var)
17502 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17503 error "jobid_var was changed by setting without value"
17505 run_test 401c "Verify 'lctl set_param' without value fails in either format."
17508 local jobid_var_old=$($LCTL get_param -n jobid_var)
17509 local jobid_var_new
17510 local new_value="foo=bar"
17512 $LCTL set_param jobid_var=$new_value ||
17513 error "'set_param a=b' did not accept a value containing '='"
17515 jobid_var_new=$($LCTL get_param -n jobid_var)
17516 [[ "$jobid_var_new" == "$new_value" ]] ||
17517 error "'set_param a=b' failed on a value containing '='"
17519 # Reset the jobid_var to test the other format
17520 $LCTL set_param jobid_var=$jobid_var_old
17521 jobid_var_new=$($LCTL get_param -n jobid_var)
17522 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17523 error "failed to reset jobid_var"
17525 $LCTL set_param jobid_var $new_value ||
17526 error "'set_param a b' did not accept a value containing '='"
17528 jobid_var_new=$($LCTL get_param -n jobid_var)
17529 [[ "$jobid_var_new" == "$new_value" ]] ||
17530 error "'set_param a b' failed on a value containing '='"
17532 $LCTL set_param jobid_var $jobid_var_old
17533 jobid_var_new=$($LCTL get_param -n jobid_var)
17534 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17535 error "failed to reset jobid_var"
17537 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
17540 local server_version=$(lustre_version_code $SINGLEMDS)
17541 [[ $server_version -ge $(version_code 2.7.66) ]] ||
17542 [[ $server_version -ge $(version_code 2.7.18.4) &&
17543 $server_version -lt $(version_code 2.7.50) ]] ||
17544 [[ $server_version -ge $(version_code 2.7.2) &&
17545 $server_version -lt $(version_code 2.7.11) ]] ||
17546 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
17548 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17549 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
17550 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
17551 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
17552 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
17553 echo "Touch failed - OK"
17555 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
17558 local file1=$DIR/$tfile.1
17559 local file2=$DIR/$tfile.2
17560 local tfile=$TMP/$tfile
17562 rm -f $file1 $file2 $tfile
17567 # 30 sec OBD_TIMEOUT in ll_getattr()
17568 # right before populating st_nlink
17569 $LCTL set_param fail_loc=0x80001409
17570 stat -c %h $file1 > $tfile &
17572 # create an alias, drop all locks and reclaim the dentry
17574 cancel_lru_locks mdc
17575 cancel_lru_locks osc
17576 sysctl -w vm.drop_caches=2
17580 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
17582 rm -f $tfile $file1 $file2
17584 run_test 403 "i_nlink should not drop to zero due to aliasing"
17586 test_404() { # LU-6601
17587 local server_version=$(lustre_version_code $SINGLEMDS)
17588 [[ $server_version -ge $(version_code 2.8.53) ]] ||
17589 { skip "Need server version newer than 2.8.52"; return 0; }
17591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17592 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
17593 awk '/osp .*-osc-MDT/ { print $4}')
17596 for osp in $mosps; do
17597 echo "Deactivate: " $osp
17598 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
17599 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17600 awk -vp=$osp '$4 == p { print $2 }')
17601 [ $stat = IN ] || {
17602 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17603 error "deactivate error"
17605 echo "Activate: " $osp
17606 do_facet $SINGLEMDS $LCTL --device %$osp activate
17607 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17608 awk -vp=$osp '$4 == p { print $2 }')
17609 [ $stat = UP ] || {
17610 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17611 error "activate error"
17615 run_test 404 "validate manual {de}activated works properly for OSPs"
17618 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
17619 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
17620 skip "Layout swap lock is not supported" && return
17622 check_swap_layouts_support && return 0
17624 test_mkdir $DIR/$tdir
17625 swap_lock_test -d $DIR/$tdir ||
17626 error "One layout swap locked test failed"
17628 run_test 405 "Various layout swap lock tests"
17631 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17632 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17633 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
17634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17635 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
17636 skip "Need MDS version at least 2.8.50" && return
17638 local def_stripe_size=$($LFS getstripe -S $MOUNT)
17639 local test_pool=$TESTNAME
17641 if ! combined_mgs_mds ; then
17644 pool_add $test_pool || error "pool_add failed"
17645 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
17646 error "pool_add_targets failed"
17648 save_layout_restore_at_exit $MOUNT
17650 # parent set default stripe count only, child will stripe from both
17651 # parent and fs default
17652 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
17653 error "setstripe $MOUNT failed"
17654 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
17655 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
17656 for i in $(seq 10); do
17657 local f=$DIR/$tdir/$tfile.$i
17658 touch $f || error "touch failed"
17659 local count=$($LFS getstripe -c $f)
17660 [ $count -eq $OSTCOUNT ] ||
17661 error "$f stripe count $count != $OSTCOUNT"
17662 local offset=$($LFS getstripe -i $f)
17663 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
17664 local size=$($LFS getstripe -S $f)
17665 [ $size -eq $((def_stripe_size * 2)) ] ||
17666 error "$f stripe size $size != $((def_stripe_size * 2))"
17667 local pool=$($LFS getstripe -p $f)
17668 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
17671 # change fs default striping, delete parent default striping, now child
17672 # will stripe from new fs default striping only
17673 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
17674 error "change $MOUNT default stripe failed"
17675 $LFS setstripe -c 0 $DIR/$tdir ||
17676 error "delete $tdir default stripe failed"
17677 for i in $(seq 11 20); do
17678 local f=$DIR/$tdir/$tfile.$i
17679 touch $f || error "touch $f failed"
17680 local count=$($LFS getstripe -c $f)
17681 [ $count -eq 1 ] || error "$f stripe count $count != 1"
17682 local offset=$($LFS getstripe -i $f)
17683 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
17684 local size=$($LFS getstripe -S $f)
17685 [ $size -eq $def_stripe_size ] ||
17686 error "$f stripe size $size != $def_stripe_size"
17687 local pool=$($LFS getstripe -p $f)
17688 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
17691 unlinkmany $DIR/$tdir/$tfile. 1 20
17693 local f=$DIR/$tdir/$tfile
17694 pool_remove_all_targets $test_pool $f
17695 pool_remove $test_pool $f
17697 if ! combined_mgs_mds ; then
17701 run_test 406 "DNE support fs default striping"
17704 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17705 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
17706 skip "Need MDS version at least 2.8.55" && return
17707 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17709 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
17710 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
17711 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
17712 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
17713 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
17715 #define OBD_FAIL_DT_TXN_STOP 0x2019
17716 for idx in $(seq $MDSCOUNT); do
17717 do_facet mds$idx "lctl set_param fail_loc=0x2019"
17719 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
17720 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
17721 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
17724 run_test 407 "transaction fail should cause operation fail"
17727 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
17729 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
17730 lctl set_param fail_loc=0x8000040a
17731 # let ll_prepare_partial_page() fail
17732 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
17736 # create at least 100 unused inodes so that
17737 # shrink_icache_memory(0) should not return 0
17738 touch $DIR/$tfile-{0..100}
17739 rm -f $DIR/$tfile-{0..100}
17742 echo 2 > /proc/sys/vm/drop_caches
17744 run_test 408 "drop_caches should not hang due to page leaks"
17748 [ $MDSCOUNT -lt 2 ] &&
17749 skip "We need at least 2 MDTs for this test" && return
17751 check_mount_and_prep
17753 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
17754 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
17755 touch $DIR/$tdir/guard || error "(2) Fail to create"
17757 local PREFIX=$(str_repeat 'A' 128)
17758 echo "Create 1K hard links start at $(date)"
17759 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17760 error "(3) Fail to hard link"
17762 echo "Links count should be right although linkEA overflow"
17763 stat $DIR/$tdir/guard || error "(4) Fail to stat"
17764 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
17765 [ $linkcount -eq 1001 ] ||
17766 error "(5) Unexpected hard links count: $linkcount"
17768 echo "List all links start at $(date)"
17769 ls -l $DIR/$tdir/foo > /dev/null ||
17770 error "(6) Fail to list $DIR/$tdir/foo"
17772 echo "Unlink hard links start at $(date)"
17773 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17774 error "(7) Fail to unlink"
17776 run_test 409 "Large amount of cross-MDTs hard links on the same file"
17780 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
17781 skip "Need client version at least 2.9.59" && return
17783 # Create a file, and stat it from the kernel
17784 local testfile=$DIR/$tfile
17787 local run_id=$RANDOM
17788 local my_ino=$(stat --format "%i" $testfile)
17790 # Try to insert the module. This will always fail as the
17791 # module is designed to not be inserted.
17792 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
17795 # Anything but success is a test failure
17797 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
17798 error "no inode match"
17800 run_test 410 "Test inode number returned from kernel thread"
17802 cleanup_test411_cgroup() {
17808 local cg_basedir=/sys/fs/cgroup/memory
17810 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
17811 { skip "no setup for cgroup"; return; }
17813 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
17814 error "test file creation failed"
17815 cancel_lru_locks osc
17817 # Create a very small memory cgroup to force a slab allocation error
17818 local cgdir=$cg_basedir/osc_slab_alloc
17819 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
17820 trap "cleanup_test411_cgroup $cgdir" EXIT
17821 echo 2M > $cgdir/memory.kmem.limit_in_bytes
17822 echo 1M > $cgdir/memory.limit_in_bytes
17824 # Should not LBUG, just be killed by oom-killer
17825 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
17826 error "fail to trigger a memory allocation error"
17828 cleanup_test411_cgroup $cgdir
17832 run_test 411 "Slab allocation error with cgroup does not LBUG"
17835 [ $MDSCOUNT -lt 2 ] &&
17836 skip "We need at least 2 MDTs for this test" && return
17838 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
17839 skip "Need server version at least 2.10.55" && exit 0
17842 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
17843 error "mkdir failed"
17844 $LFS getdirstripe $DIR/$tdir
17845 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
17846 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
17847 error "expect $((MDSCOUT - 1)) get $stripe_index"
17848 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
17849 [ $stripe_count -eq 2 ] ||
17850 error "expect 2 get $stripe_count"
17852 run_test 412 "mkdir on specific MDTs"
17855 [ $MDSCOUNT -lt 2 ] &&
17856 skip "We need at least 2 MDTs for this test" && return
17858 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
17859 skip "Need server version at least 2.10.55" && exit 0
17862 mkdir $DIR/$tdir || error "mkdir failed"
17864 # find MDT that is the most full
17865 local max=$($LFS df | grep MDT |
17874 END { split(b, c, ":")
17879 for i in $(seq $((MDSCOUNT - 1))); do
17880 $LFS mkdir -c $i $DIR/$tdir/d$i ||
17881 error "mkdir d$i failed"
17882 $LFS getdirstripe $DIR/$tdir/d$i
17883 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
17884 [ $stripe_index -ne $max ] ||
17885 error "don't expect $max"
17888 run_test 413 "mkdir on less full MDTs"
17891 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17892 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17893 skip "Need server version at least 2.9.55" & exit 0
17894 start_full_debug_logging
17898 stop_full_debug_logging
17902 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17903 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17904 awk '/The barrier for/ { print $7 }')
17907 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
17912 barrier_expired() {
17915 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17916 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17917 awk '/will be expired/ { print $7 }')
17919 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
17928 echo "Start barrier_freeze at: $(date)"
17929 #define OBD_FAIL_BARRIER_DELAY 0x2202
17930 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17931 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
17934 local b_status=$(barrier_stat)
17935 echo "Got barrier status at: $(date)"
17936 [ "$b_status" = "'freezing_p1'" ] ||
17937 error "(1) unexpected barrier status $b_status"
17939 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17941 b_status=$(barrier_stat)
17942 [ "$b_status" = "'frozen'" ] ||
17943 error "(2) unexpected barrier status $b_status"
17945 local expired=$(barrier_expired)
17946 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
17947 sleep $((expired + 3))
17949 b_status=$(barrier_stat)
17950 [ "$b_status" = "'expired'" ] ||
17951 error "(3) unexpected barrier status $b_status"
17953 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
17954 error "(4) fail to freeze barrier"
17956 b_status=$(barrier_stat)
17957 [ "$b_status" = "'frozen'" ] ||
17958 error "(5) unexpected barrier status $b_status"
17960 echo "Start barrier_thaw at: $(date)"
17961 #define OBD_FAIL_BARRIER_DELAY 0x2202
17962 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17963 do_facet mgs $LCTL barrier_thaw $FSNAME &
17966 b_status=$(barrier_stat)
17967 echo "Got barrier status at: $(date)"
17968 [ "$b_status" = "'thawing'" ] ||
17969 error "(6) unexpected barrier status $b_status"
17971 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17973 b_status=$(barrier_stat)
17974 [ "$b_status" = "'thawed'" ] ||
17975 error "(7) unexpected barrier status $b_status"
17977 #define OBD_FAIL_BARRIER_FAILURE 0x2203
17978 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
17979 do_facet mgs $LCTL barrier_freeze $FSNAME
17981 b_status=$(barrier_stat)
17982 [ "$b_status" = "'failed'" ] ||
17983 error "(8) unexpected barrier status $b_status"
17985 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17986 do_facet mgs $LCTL barrier_thaw $FSNAME
17990 run_test 801a "write barrier user interfaces and stat machine"
17995 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17996 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17997 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17998 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17999 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
18001 cancel_lru_locks mdc
18003 # 180 seconds should be long enough
18004 do_facet mgs $LCTL barrier_freeze $FSNAME 180
18006 local b_status=$(barrier_stat)
18007 [ "$b_status" = "'frozen'" ] ||
18008 error "(6) unexpected barrier status $b_status"
18010 mkdir $DIR/$tdir/d0/d10 &
18013 touch $DIR/$tdir/d1/f13 &
18016 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
18019 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
18022 rm -f $DIR/$tdir/d4/f12 &
18025 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
18027 # To guarantee taht the 'stat' is not blocked
18028 b_status=$(barrier_stat)
18029 [ "$b_status" = "'frozen'" ] ||
18030 error "(8) unexpected barrier status $b_status"
18032 # let above commands to run at background
18035 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
18036 ps -p $touch_pid || error "(10) touch should be blocked"
18037 ps -p $ln_pid || error "(11) link should be blocked"
18038 ps -p $mv_pid || error "(12) rename should be blocked"
18039 ps -p $rm_pid || error "(13) unlink should be blocked"
18041 b_status=$(barrier_stat)
18042 [ "$b_status" = "'frozen'" ] ||
18043 error "(14) unexpected barrier status $b_status"
18045 do_facet mgs $LCTL barrier_thaw $FSNAME
18046 b_status=$(barrier_stat)
18047 [ "$b_status" = "'thawed'" ] ||
18048 error "(15) unexpected barrier status $b_status"
18050 wait $mkdir_pid || error "(16) mkdir should succeed"
18051 wait $touch_pid || error "(17) touch should succeed"
18052 wait $ln_pid || error "(18) link should succeed"
18053 wait $mv_pid || error "(19) rename should succeed"
18054 wait $rm_pid || error "(20) unlink should succeed"
18058 run_test 801b "modification will be blocked by write barrier"
18061 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
18065 stop mds2 || error "(1) Fail to stop mds2"
18067 do_facet mgs $LCTL barrier_freeze $FSNAME 30
18069 local b_status=$(barrier_stat)
18070 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
18071 do_facet mgs $LCTL barrier_thaw $FSNAME
18072 error "(2) unexpected barrier status $b_status"
18075 do_facet mgs $LCTL barrier_rescan $FSNAME ||
18076 error "(3) Fail to rescan barrier bitmap"
18078 do_facet mgs $LCTL barrier_freeze $FSNAME 10
18080 b_status=$(barrier_stat)
18081 [ "$b_status" = "'frozen'" ] ||
18082 error "(4) unexpected barrier status $b_status"
18084 do_facet mgs $LCTL barrier_thaw $FSNAME
18085 b_status=$(barrier_stat)
18086 [ "$b_status" = "'thawed'" ] ||
18087 error "(5) unexpected barrier status $b_status"
18089 local devname=$(mdsdevname 2)
18091 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
18093 do_facet mgs $LCTL barrier_rescan $FSNAME ||
18094 error "(7) Fail to rescan barrier bitmap"
18098 run_test 801c "rescan barrier bitmap"
18100 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
18101 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
18102 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
18108 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
18109 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
18110 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
18116 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
18117 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
18118 skip "Need server version at least 2.9.55" & exit 0
18120 mkdir $DIR/$tdir || error "(1) fail to mkdir"
18122 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
18123 error "(2) Fail to copy"
18125 trap cleanup_802 EXIT
18127 # sync by force before remount as readonly
18128 sync; sync_all_data; sleep 3; sync_all_data
18132 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
18133 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
18134 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
18136 echo "Mount the server as read only"
18137 setupall server_only || error "(3) Fail to start servers"
18139 echo "Mount client without ro should fail"
18140 mount_client $MOUNT &&
18141 error "(4) Mount client without 'ro' should fail"
18143 echo "Mount client with ro should succeed"
18144 mount_client $MOUNT ro ||
18145 error "(5) Mount client with 'ro' should succeed"
18147 echo "Modify should be refused"
18148 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
18150 echo "Read should be allowed"
18151 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
18152 error "(7) Read should succeed under ro mode"
18156 run_test 802 "simulate readonly device"
18159 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
18160 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18161 skip "MDS needs to be newer than 2.10.54" && return
18163 mkdir -p $DIR/$tdir
18164 # Create some objects on all MDTs to trigger related logs objects
18165 for idx in $(seq $MDSCOUNT); do
18166 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
18167 $DIR/$tdir/dir${idx} ||
18168 error "Fail to create $DIR/$tdir/dir${idx}"
18172 echo "before create:"
18174 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18176 for ((i=0; i<10; i++)); do
18177 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
18178 error "Fail to create $DIR/$tdir/foo$i"
18182 echo "after create:"
18184 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18186 [ $after_used -ge $((before_used + 10)) ] ||
18187 error "before ($before_used) + 10 > after ($after_used)"
18189 for ((i=0; i<10; i++)); do
18190 rm -rf $DIR/$tdir/foo$i ||
18191 error "Fail to remove $DIR/$tdir/foo$i"
18194 sleep 3 # avoid MDT return cached statfs
18195 wait_delete_completed
18196 echo "after unlink:"
18198 before_used=$after_used
18199 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18201 [ $after_used -le $((before_used - 8)) ] ||
18202 error "before ($before_used) - 8 < after ($after_used)"
18204 run_test 803 "verify agent object for remote object"
18207 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
18208 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18209 skip "MDS needs to be newer than 2.10.54" && return
18211 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
18212 skip "ldiskfs only test" && return 0
18214 mkdir -p $DIR/$tdir
18215 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
18216 error "Fail to create $DIR/$tdir/dir0"
18218 local fid=$($LFS path2fid $DIR/$tdir/dir0)
18219 local dev=$(mdsdevname 2)
18221 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18222 grep ${fid} || error "NOT found agent entry for dir0"
18224 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
18225 error "Fail to create $DIR/$tdir/dir1"
18227 touch $DIR/$tdir/dir1/foo0 ||
18228 error "Fail to create $DIR/$tdir/dir1/foo0"
18229 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
18232 for idx in $(seq $MDSCOUNT); do
18233 dev=$(mdsdevname $idx)
18234 do_facet mds${idx} \
18235 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18236 grep ${fid} && rc=$idx
18239 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
18240 error "Fail to rename foo0 to foo1"
18241 if [ $rc -eq 0 ]; then
18242 for idx in $(seq $MDSCOUNT); do
18243 dev=$(mdsdevname $idx)
18244 do_facet mds${idx} \
18245 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18246 grep ${fid} && rc=$idx
18250 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
18251 error "Fail to rename foo1 to foo2"
18252 if [ $rc -eq 0 ]; then
18253 for idx in $(seq $MDSCOUNT); do
18254 dev=$(mdsdevname $idx)
18255 do_facet mds${idx} \
18256 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18257 grep ${fid} && rc=$idx
18261 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
18263 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
18264 error "Fail to link to $DIR/$tdir/dir1/foo2"
18265 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
18266 error "Fail to rename foo2 to foo0"
18267 unlink $DIR/$tdir/dir1/foo0 ||
18268 error "Fail to unlink $DIR/$tdir/dir1/foo0"
18269 rm -rf $DIR/$tdir/dir0 ||
18270 error "Fail to rm $DIR/$tdir/dir0"
18272 for idx in $(seq $MDSCOUNT); do
18273 dev=$(mdsdevname $idx)
18277 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
18279 start mds${idx} $dev $MDS_MOUNT_OPTS ||
18280 error "mount mds$idx failed"
18281 df $MOUNT > /dev/null 2>&1
18283 # e2fsck should not return error
18285 error "e2fsck detected error on MDT${idx}: rc=$rc"
18288 run_test 804 "verify agent entry for remote entry"
18291 do_facet $SINGLEMDS zfs set quota=$old $fsset
18292 unlinkmany $DIR/$tdir/f- 1000000
18297 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
18298 [ "$(facet_fstype mds1)" != "zfs" ] &&
18299 skip "ZFS specific test" && return
18300 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
18301 skip "netfree not implemented before 0.7" && return
18302 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
18303 { skip "Need MDS version at least 2.10.57" && return 0; }
18310 local pref="osd-zfs.lustre-MDT0000."
18312 # limit available space on MDS dataset to meet nospace issue
18313 # quickly. then ZFS 0.7.2 can use reserved space if asked
18314 # properly (using netfree flag in osd_declare_destroy()
18315 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
18316 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
18318 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
18319 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
18320 let "usedkb=usedkb-freekb"
18321 let "freekb=freekb/2"
18322 if let "freekb > 5000"; then
18325 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
18326 trap cleanup_805 EXIT
18328 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
18329 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
18330 rm -rf $DIR/$tdir || error "not able to remove"
18331 do_facet $SINGLEMDS zfs set quota=$old $fsset
18334 run_test 805 "ZFS can remove from full fs"
18337 # tests that do cleanup/setup should be run at the end
18341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18343 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
18344 $LCTL set_param fail_loc=0x903
18346 cancel_lru_locks MGC
18348 FAIL_ON_ERROR=true cleanup
18349 FAIL_ON_ERROR=true setup
18351 run_test 900 "umount should not race with any mgc requeue thread"
18354 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
18355 check_and_cleanup_lustre
18356 if [ "$I_MOUNTED" != "yes" ]; then
18357 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true