3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
33 LUSTRE=${LUSTRE:-$(dirname $0)/..}
34 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
35 . $LUSTRE/tests/test-framework.sh
40 ALWAYS_EXCEPT="$SANITY_EXCEPT "
41 always_except LU-9693 42a 42c
42 always_except LU-6493 42b
43 always_except LU-14541 277
44 always_except LU-9054 312
45 always_except LU-8411 407
48 always_except LU-14181 64e 64f
51 # skip the grant tests for ARM until they are fixed
52 if [[ $(uname -m) = aarch64 ]]; then
53 always_except LU-11671 45
56 # skip nfs tests on kernels >= 4.12.0 until they are fixed
57 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
58 always_except LU-12661 817
60 # skip cgroup tests on RHEL8.1 kernels until they are fixed
61 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
62 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
63 always_except LU-13063 411
67 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 230d 300o"
69 if [ "$mds1_FSTYPE" = "zfs" ]; then
71 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
74 if [ "$ost1_FSTYPE" = "zfs" ]; then
75 always_except LU-1941 130b 130c 130d 130e 130f 130g
78 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
80 # Get the SLES distro version
82 # Returns a version string that should only be used in comparing
83 # strings returned by version_code()
86 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
88 # All SuSE Linux versions have one decimal. version_code expects two
89 local sles_version=$version.0
90 version_code $sles_version
93 # Check if we are running on Ubuntu or SLES so we can make decisions on
95 if [ -r /etc/SuSE-release ]; then
96 sles_version=$(sles_version_code)
97 [ $sles_version -lt $(version_code 11.4.0) ] &&
98 always_except LU-4341 170
100 [ $sles_version -lt $(version_code 12.0.0) ] &&
101 always_except LU-3703 234
102 elif [ -r /etc/os-release ]; then
103 if grep -qi ubuntu /etc/os-release; then
104 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
105 -e 's/^VERSION=//p' \
109 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
110 always_except LU-10366 410
120 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
121 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
130 check_swap_layouts_support()
132 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
133 skip "Does not support layout lock."
136 check_swap_layout_no_dom()
139 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
140 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
143 check_and_setup_lustre
147 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
149 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
150 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
151 rm -rf $DIR/[Rdfs][0-9]*
153 # $RUNAS_ID may get set incorrectly somewhere else
154 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
155 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
157 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
159 if [ "${ONLY}" = "MOUNT" ] ; then
160 echo "Lustre is up, please go on"
164 echo "preparing for tests involving mounts"
165 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
167 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
168 echo # add a newline after mke2fs.
172 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
173 lctl set_param debug=-1 2> /dev/null || true
176 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
178 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
180 run_test 0a "touch; rm ====================="
183 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
184 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
186 run_test 0b "chmod 0755 $DIR ============================="
189 $LCTL get_param mdc.*.import | grep "state: FULL" ||
190 error "import not FULL"
191 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
194 run_test 0c "check import proc"
196 test_0d() { # LU-3397
197 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
198 skip "proc exports not supported before 2.10.57"
200 local mgs_exp="mgs.MGS.exports"
201 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
203 local exp_client_version
206 local temp_imp=$DIR/$tfile.import
207 local temp_exp=$DIR/$tfile.export
209 # save mgc import file to $temp_imp
210 $LCTL get_param mgc.*.import | tee $temp_imp
211 # Check if client uuid is found in MGS export
212 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
213 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
217 # save mgs export file to $temp_exp
218 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
220 # Compare the value of field "connect_flags"
221 imp_val=$(grep "connect_flags" $temp_imp)
222 exp_val=$(grep "connect_flags" $temp_exp)
223 [ "$exp_val" == "$imp_val" ] ||
224 error "export flags '$exp_val' != import flags '$imp_val'"
226 # Compare client versions. Only compare top-3 fields for compatibility
227 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
228 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
229 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
230 [ "$exp_val" == "$imp_val" ] ||
231 error "exp version '$exp_client_version'($exp_val) != " \
232 "'$(lustre_build_version client)'($imp_val)"
234 run_test 0d "check export proc ============================="
236 test_0e() { # LU-13417
237 (( $MDSCOUNT > 1 )) ||
238 skip "We need at least 2 MDTs for this test"
240 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
241 skip "Need server version at least 2.14.51"
243 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
244 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
246 [ $default_lmv_count -eq 1 ] ||
247 error "$MOUNT default stripe count $default_lmv_count"
249 [ $default_lmv_index -eq -1 ] ||
250 error "$MOUNT default stripe index $default_lmv_index"
252 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
253 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
255 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
256 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
258 [ $mdt_index1 -eq $mdt_index2 ] &&
259 error "directories are on the same MDT $mdt_index1=$mdt_index2"
261 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
263 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
266 test_mkdir $DIR/$tdir
267 test_mkdir $DIR/$tdir/d2
268 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
269 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
272 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
274 run_test 1 "mkdir; remkdir; rmdir"
277 test_mkdir $DIR/$tdir
278 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
279 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
281 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
283 run_test 2 "mkdir; touch; rmdir; check file"
286 test_mkdir $DIR/$tdir
287 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
288 touch $DIR/$tdir/$tfile
289 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
291 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
293 run_test 3 "mkdir; touch; rmdir; check dir"
295 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
297 test_mkdir -i 1 $DIR/$tdir
299 touch $DIR/$tdir/$tfile ||
300 error "Create file under remote directory failed"
303 error "Expect error removing in-use dir $DIR/$tdir"
305 test -d $DIR/$tdir || error "Remote directory disappeared"
307 rm -rf $DIR/$tdir || error "remove remote dir error"
309 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
315 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
316 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
318 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
321 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
322 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
323 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
324 error "$tfile does not have perm 0666 or UID $UID"
325 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
326 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
327 error "$tfile should be 0666 and owned by UID $UID"
329 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
335 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
336 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
337 error "$tfile should be owned by UID $RUNAS_ID"
338 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
339 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
340 error "$tfile should be owned by UID $RUNAS_ID"
342 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
345 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
348 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
349 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
350 error "$tfile should be owned by GID $UID"
351 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
352 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
353 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
355 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
358 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
360 test_mkdir $DIR/$tdir
361 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
362 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
363 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
364 test_mkdir $DIR/$tdir/d/subdir
365 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
366 error "$tdir/d/subdir should be GID $RUNAS_GID"
367 if [[ $MDSCOUNT -gt 1 ]]; then
368 # check remote dir sgid inherite
369 $LFS mkdir -i 0 $DIR/$tdir.local ||
370 error "mkdir $tdir.local failed"
371 chmod g+s $DIR/$tdir.local ||
372 error "chmod $tdir.local failed"
373 chgrp $RUNAS_GID $DIR/$tdir.local ||
374 error "chgrp $tdir.local failed"
375 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
376 error "mkdir $tdir.remote failed"
377 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
378 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
379 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
380 error "$tdir.remote should be mode 02755"
383 run_test 6g "verify new dir in sgid dir inherits group"
385 test_6h() { # bug 7331
386 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
388 touch $DIR/$tfile || error "touch failed"
389 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
390 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
391 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
392 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
393 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
395 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
398 test_mkdir $DIR/$tdir
399 $MCREATE $DIR/$tdir/$tfile
400 chmod 0666 $DIR/$tdir/$tfile
401 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
402 error "$tdir/$tfile should be mode 0666"
404 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
407 if [ ! -d $DIR/$tdir ]; then
408 test_mkdir $DIR/$tdir
410 $MCREATE $DIR/$tdir/$tfile
411 echo -n foo > $DIR/$tdir/$tfile
412 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
413 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
415 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
418 test_mkdir $DIR/$tdir
419 touch $DIR/$tdir/$tfile
420 chmod 0666 $DIR/$tdir/$tfile
421 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
422 error "$tfile mode not 0666"
424 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
427 test_mkdir $DIR/$tdir
428 test_mkdir $DIR/$tdir/d2
429 test_mkdir $DIR/$tdir/d2/d3
430 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
432 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
435 test_mkdir $DIR/$tdir
436 test_mkdir $DIR/$tdir/d2
437 touch $DIR/$tdir/d2/$tfile
438 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
439 error "$tdir/d2/$tfile not a file"
441 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
444 test_mkdir $DIR/$tdir
445 test_mkdir $DIR/$tdir/d2
446 chmod 0666 $DIR/$tdir/d2
447 chmod 0705 $DIR/$tdir/d2
448 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
449 error "$tdir/d2 mode not 0705"
451 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
454 test_mkdir $DIR/$tdir
455 touch $DIR/$tdir/$tfile
456 chmod 0666 $DIR/$tdir/$tfile
457 chmod 0654 $DIR/$tdir/$tfile
458 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
459 error "$tdir/d2 mode not 0654"
461 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
464 test_mkdir $DIR/$tdir
465 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
467 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
468 error "$tdir/$tfile size not 0 after truncate"
470 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
476 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
478 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
481 test_mkdir $DIR/$tdir
482 touch $DIR/$tdir/$tfile
483 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
484 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
485 error "$tdir/${tfile_2} not a file after rename"
486 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
488 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
491 test_mkdir $DIR/$tdir
492 touch $DIR/$tdir/$tfile
493 rm -rf $DIR/$tdir/$tfile
494 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
496 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
499 test_mkdir $DIR/$tdir
500 touch $DIR/$tdir/$tfile
501 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
503 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
504 error "$tdir/l-exist not a symlink"
505 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
506 error "$tdir/l-exist not referencing a file"
507 rm -f $DIR/$tdir/l-exist
508 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
510 run_test 17a "symlinks: create, remove (real)"
513 test_mkdir $DIR/$tdir
514 ln -s no-such-file $DIR/$tdir/l-dangle
516 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
517 error "$tdir/l-dangle not referencing no-such-file"
518 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
519 error "$tdir/l-dangle not referencing non-existent file"
520 rm -f $DIR/$tdir/l-dangle
521 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
523 run_test 17b "symlinks: create, remove (dangling)"
525 test_17c() { # bug 3440 - don't save failed open RPC for replay
526 test_mkdir $DIR/$tdir
527 ln -s foo $DIR/$tdir/$tfile
528 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
530 run_test 17c "symlinks: open dangling (should return error)"
533 test_mkdir $DIR/$tdir
534 ln -s foo $DIR/$tdir/$tfile
535 touch $DIR/$tdir/$tfile || error "creating to new symlink"
537 run_test 17d "symlinks: create dangling"
540 test_mkdir $DIR/$tdir
541 local foo=$DIR/$tdir/$tfile
542 ln -s $foo $foo || error "create symlink failed"
543 ls -l $foo || error "ls -l failed"
544 ls $foo && error "ls not failed" || true
546 run_test 17e "symlinks: create recursive symlink (should return error)"
549 test_mkdir $DIR/$tdir
550 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
551 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
552 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
553 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
554 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
555 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
558 run_test 17f "symlinks: long and very long symlink name"
560 # str_repeat(S, N) generate a string that is string S repeated N times
565 while [ $((n -= 1)) -ge 0 ]; do
571 # Long symlinks and LU-2241
573 test_mkdir $DIR/$tdir
574 local TESTS="59 60 61 4094 4095"
576 # Fix for inode size boundary in 2.1.4
577 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
580 # Patch not applied to 2.2 or 2.3 branches
581 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
582 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
586 local SYMNAME=$(str_repeat 'x' $i)
587 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
588 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
591 run_test 17g "symlinks: really long symlink name and inode boundaries"
593 test_17h() { #bug 17378
594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
595 remote_mds_nodsh && skip "remote MDS with nodsh"
599 test_mkdir $DIR/$tdir
600 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
601 $LFS setstripe -c -1 $DIR/$tdir
602 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
603 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
604 touch $DIR/$tdir/$tfile || true
606 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
608 test_17i() { #bug 20018
609 [ $PARALLEL == "yes" ] && skip "skip parallel run"
610 remote_mds_nodsh && skip "remote MDS with nodsh"
612 local foo=$DIR/$tdir/$tfile
615 test_mkdir -c1 $DIR/$tdir
616 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
617 ln -s $foo $foo || error "create symlink failed"
618 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
619 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
620 ls -l $foo && error "error not detected"
623 run_test 17i "don't panic on short symlink (should return error)"
625 test_17k() { #bug 22301
626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
627 [[ -z "$(which rsync 2>/dev/null)" ]] &&
628 skip "no rsync command"
629 rsync --help | grep -q xattr ||
630 skip_env "$(rsync --version | head -n1) does not support xattrs"
631 test_mkdir $DIR/$tdir
632 test_mkdir $DIR/$tdir.new
633 touch $DIR/$tdir/$tfile
634 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
635 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
636 error "rsync failed with xattrs enabled"
638 run_test 17k "symlinks: rsync with xattrs enabled"
640 test_17l() { # LU-279
641 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
642 skip "no getfattr command"
644 test_mkdir $DIR/$tdir
645 touch $DIR/$tdir/$tfile
646 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
647 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
648 # -h to not follow symlinks. -m '' to list all the xattrs.
649 # grep to remove first line: '# file: $path'.
650 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
652 lgetxattr_size_check $path $xattr ||
653 error "lgetxattr_size_check $path $xattr failed"
657 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
662 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
663 remote_mds_nodsh && skip "remote MDS with nodsh"
664 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
665 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
666 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
668 local short_sym="0123456789"
669 local wdir=$DIR/$tdir
674 # create a long symlink file
675 for ((i = 0; i < 4; ++i)); do
676 long_sym=${long_sym}${long_sym}
679 echo "create 512 short and long symlink files under $wdir"
680 for ((i = 0; i < 256; ++i)); do
681 ln -sf ${long_sym}"a5a5" $wdir/long-$i
682 ln -sf ${short_sym}"a5a5" $wdir/short-$i
688 wait_delete_completed
690 echo "recreate the 512 symlink files with a shorter string"
691 for ((i = 0; i < 512; ++i)); do
692 # rewrite the symlink file with a shorter string
693 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
694 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
697 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
699 echo "stop and checking mds${mds_index}:"
700 # e2fsck should not return error
702 local devname=$(mdsdevname $mds_index)
703 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
706 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
707 error "start mds${mds_index} failed"
708 df $MOUNT > /dev/null 2>&1
710 error "e2fsck detected error for short/long symlink: rc=$rc"
713 run_test 17m "run e2fsck against MDT which contains short/long symlink"
715 check_fs_consistency_17n() {
719 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
720 # so it only check MDT1/MDT2 instead of all of MDTs.
721 for mdt_index in 1 2; do
722 # e2fsck should not return error
724 local devname=$(mdsdevname $mdt_index)
725 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
728 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
729 error "mount mds$mdt_index failed"
730 df $MOUNT > /dev/null 2>&1
736 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
738 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
739 remote_mds_nodsh && skip "remote MDS with nodsh"
740 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
741 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
742 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
746 test_mkdir $DIR/$tdir
747 for ((i=0; i<10; i++)); do
748 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
749 error "create remote dir error $i"
750 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
751 error "create files under remote dir failed $i"
754 check_fs_consistency_17n ||
755 error "e2fsck report error after create files under remote dir"
757 for ((i = 0; i < 10; i++)); do
758 rm -rf $DIR/$tdir/remote_dir_${i} ||
759 error "destroy remote dir error $i"
762 check_fs_consistency_17n ||
763 error "e2fsck report error after unlink files under remote dir"
765 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
766 skip "lustre < 2.4.50 does not support migrate mv"
768 for ((i = 0; i < 10; i++)); do
769 mkdir -p $DIR/$tdir/remote_dir_${i}
770 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
771 error "create files under remote dir failed $i"
772 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
773 error "migrate remote dir error $i"
775 check_fs_consistency_17n || error "e2fsck report error after migration"
777 for ((i = 0; i < 10; i++)); do
778 rm -rf $DIR/$tdir/remote_dir_${i} ||
779 error "destroy remote dir error $i"
782 check_fs_consistency_17n || error "e2fsck report error after unlink"
784 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
787 remote_mds_nodsh && skip "remote MDS with nodsh"
788 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
789 skip "Need MDS version at least 2.3.64"
791 local wdir=$DIR/${tdir}o
797 mdt_index=$($LFS getstripe -m $wdir/$tfile)
798 mdt_index=$((mdt_index + 1))
801 #fail mds will wait the failover finish then set
802 #following fail_loc to avoid interfer the recovery process.
805 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
806 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
807 ls -l $wdir/$tfile && rc=1
808 do_facet mds${mdt_index} lctl set_param fail_loc=0
809 [[ $rc -eq 0 ]] || error "stat file should fail"
811 run_test 17o "stat file with incompat LMA feature"
814 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
815 ls $DIR || error "Failed to ls $DIR: $?"
817 run_test 18 "touch .../f ; ls ... =============================="
823 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
825 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
828 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
830 run_test 19b "ls -l .../f19 (should return error) =============="
833 [ $RUNAS_ID -eq $UID ] &&
834 skip_env "RUNAS_ID = UID = $UID -- skipping"
836 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
838 run_test 19c "$RUNAS touch .../f19 (should return error) =="
841 cat $DIR/f19 && error || true
843 run_test 19d "cat .../f19 (should return error) =============="
852 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
854 run_test 20 "touch .../f ; ls -l ..."
857 test_mkdir $DIR/$tdir
858 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
859 ln -s dangle $DIR/$tdir/link
860 echo foo >> $DIR/$tdir/link
861 cat $DIR/$tdir/dangle
862 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
863 $CHECKSTAT -f -t file $DIR/$tdir/link ||
864 error "$tdir/link not linked to a file"
866 run_test 21 "write to dangling link"
869 local wdir=$DIR/$tdir
871 chown $RUNAS_ID:$RUNAS_GID $wdir
872 (cd $wdir || error "cd $wdir failed";
873 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
875 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
876 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
877 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
878 error "checkstat -u failed"
880 run_test 22 "unpack tar archive as non-root user"
884 test_mkdir $DIR/$tdir
885 local file=$DIR/$tdir/$tfile
887 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
888 openfile -f O_CREAT:O_EXCL $file &&
889 error "$file recreate succeeded" || true
891 run_test 23a "O_CREAT|O_EXCL in subdir"
893 test_23b() { # bug 18988
894 test_mkdir $DIR/$tdir
895 local file=$DIR/$tdir/$tfile
898 echo foo > $file || error "write filed"
899 echo bar >> $file || error "append filed"
900 $CHECKSTAT -s 8 $file || error "wrong size"
903 run_test 23b "O_APPEND check"
905 # LU-9409, size with O_APPEND and tiny writes
907 local file=$DIR/$tfile
910 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
911 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
915 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
916 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
918 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
921 #racing tiny & normal writes
922 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
923 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
925 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
928 #racing tiny & normal writes 2, ugly numbers
929 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
930 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
932 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
935 run_test 23c "O_APPEND size checks for tiny writes"
937 # LU-11069 file offset is correct after appending writes
939 local file=$DIR/$tfile
942 echo CentaurHauls > $file
943 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
944 if ((offset != 26)); then
945 error "wrong offset, expected 26, got '$offset'"
948 run_test 23d "file offset is correct after appending writes"
952 echo '-- same directory rename'
953 test_mkdir $DIR/$tdir
954 touch $DIR/$tdir/$tfile.1
955 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
956 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
958 run_test 24a "rename file to non-existent target"
961 test_mkdir $DIR/$tdir
962 touch $DIR/$tdir/$tfile.{1,2}
963 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
964 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
965 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
967 run_test 24b "rename file to existing target"
970 test_mkdir $DIR/$tdir
971 test_mkdir $DIR/$tdir/d$testnum.1
972 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
973 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
974 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
976 run_test 24c "rename directory to non-existent target"
979 test_mkdir -c1 $DIR/$tdir
980 test_mkdir -c1 $DIR/$tdir/d$testnum.1
981 test_mkdir -c1 $DIR/$tdir/d$testnum.2
982 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
983 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
984 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
986 run_test 24d "rename directory to existing target"
989 echo '-- cross directory renames --'
993 mv $DIR/R5a/f $DIR/R5b/g
994 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
995 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
997 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1002 touch $DIR/R6a/f $DIR/R6b/g
1003 mv $DIR/R6a/f $DIR/R6b/g
1004 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1005 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1007 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1012 test_mkdir $DIR/R7a/d
1013 mv $DIR/R7a/d $DIR/R7b/e
1014 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1015 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1017 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1020 test_mkdir -c1 $DIR/R8a
1021 test_mkdir -c1 $DIR/R8b
1022 test_mkdir -c1 $DIR/R8a/d
1023 test_mkdir -c1 $DIR/R8b/e
1024 mrename $DIR/R8a/d $DIR/R8b/e
1025 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1026 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1028 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1031 echo "-- rename error cases"
1033 test_mkdir $DIR/R9/a
1035 mrename $DIR/R9/f $DIR/R9/a
1036 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1037 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1038 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1040 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1044 mrename $DIR/R10/f $DIR/R10/g
1045 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1046 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1047 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1049 run_test 24j "source does not exist ============================"
1052 test_mkdir $DIR/R11a
1053 test_mkdir $DIR/R11a/d
1055 mv $DIR/R11a/f $DIR/R11a/d
1056 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1057 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1059 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1061 # bug 2429 - rename foo foo foo creates invalid file
1064 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1066 run_test 24l "Renaming a file to itself ========================"
1070 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1071 # on ext3 this does not remove either the source or target files
1072 # though the "expected" operation would be to remove the source
1073 $CHECKSTAT -t file ${f} || error "${f} missing"
1074 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1076 run_test 24m "Renaming a file to a hard link to itself ========="
1080 # this stats the old file after it was renamed, so it should fail
1082 $CHECKSTAT ${f} || error "${f} missing"
1084 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1085 $CHECKSTAT -a ${f} || error "${f} exists"
1087 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1090 test_mkdir $DIR/$tdir
1091 rename_many -s random -v -n 10 $DIR/$tdir
1093 run_test 24o "rename of files during htree split"
1096 test_mkdir $DIR/R12a
1097 test_mkdir $DIR/R12b
1098 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1099 mrename $DIR/R12a $DIR/R12b
1100 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1101 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1102 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1103 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1105 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1107 cleanup_multiop_pause() {
1109 kill -USR1 $MULTIPID
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1115 test_mkdir $DIR/R13a
1116 test_mkdir $DIR/R13b
1117 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1118 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1121 trap cleanup_multiop_pause EXIT
1122 mrename $DIR/R13a $DIR/R13b
1123 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1124 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1125 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1126 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1127 cleanup_multiop_pause
1128 wait $MULTIPID || error "multiop close failed"
1130 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1132 test_24r() { #bug 3789
1133 test_mkdir $DIR/R14a
1134 test_mkdir $DIR/R14a/b
1135 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1136 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1137 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1139 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1142 test_mkdir $DIR/R15a
1143 test_mkdir $DIR/R15a/b
1144 test_mkdir $DIR/R15a/b/c
1145 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1146 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1147 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1149 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1151 test_mkdir $DIR/R16a
1152 test_mkdir $DIR/R16a/b
1153 test_mkdir $DIR/R16a/b/c
1154 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1155 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1156 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1158 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1160 test_24u() { # bug12192
1161 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1162 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1164 run_test 24u "create stripe file"
1166 simple_cleanup_common() {
1170 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1172 local start=$SECONDS
1174 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1175 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1177 wait_delete_completed
1178 echo "cleanup time $((SECONDS - start))"
1182 max_pages_per_rpc() {
1183 local mdtname="$(printf "MDT%04x" ${1:-0})"
1184 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1190 local nrfiles=${COUNT:-100000}
1191 local fname="$DIR/$tdir/$tfile"
1193 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1194 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1196 test_mkdir "$(dirname $fname)"
1197 # assume MDT0000 has the fewest inodes
1198 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1199 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1200 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1202 stack_trap "simple_cleanup_common $nrfiles"
1204 createmany -m "$fname" $nrfiles
1206 cancel_lru_locks mdc
1207 lctl set_param mdc.*.stats clear
1209 # was previously test_24D: LU-6101
1210 # readdir() returns correct number of entries after cursor reload
1211 local num_ls=$(ls $DIR/$tdir | wc -l)
1212 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1213 local num_all=$(ls -a $DIR/$tdir | wc -l)
1214 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1215 [ $num_all -ne $((nrfiles + 2)) ]; then
1216 error "Expected $nrfiles files, got $num_ls " \
1217 "($num_uniq unique $num_all .&..)"
1219 # LU-5 large readdir
1220 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1221 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1222 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1223 # take into account of overhead in lu_dirpage header and end mark in
1224 # each page, plus one in rpc_num calculation.
1225 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1226 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1227 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1228 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1229 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1230 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1231 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1232 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1233 error "large readdir doesn't take effect: " \
1234 "$mds_readpage should be about $rpc_max"
1236 run_test 24v "list large directory (test hash collision, b=17560)"
1238 test_24w() { # bug21506
1240 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1241 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1242 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1243 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1244 [[ "$SZ1" -eq "$SZ2" ]] ||
1245 error "Error reading at the end of the file $tfile"
1247 run_test 24w "Reading a file larger than 4Gb"
1250 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1252 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1253 skip "Need MDS version at least 2.7.56"
1256 local remote_dir=$DIR/$tdir/remote_dir
1258 test_mkdir $DIR/$tdir
1259 $LFS mkdir -i $MDTIDX $remote_dir ||
1260 error "create remote directory failed"
1262 test_mkdir $DIR/$tdir/src_dir
1263 touch $DIR/$tdir/src_file
1264 test_mkdir $remote_dir/tgt_dir
1265 touch $remote_dir/tgt_file
1267 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1268 error "rename dir cross MDT failed!"
1270 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1271 error "rename file cross MDT failed!"
1273 touch $DIR/$tdir/ln_file
1274 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1275 error "ln file cross MDT failed"
1277 rm -rf $DIR/$tdir || error "Can not delete directories"
1279 run_test 24x "cross MDT rename/link"
1282 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1285 local remote_dir=$DIR/$tdir/remote_dir
1288 test_mkdir $DIR/$tdir
1289 $LFS mkdir -i $mdtidx $remote_dir ||
1290 error "create remote directory failed"
1292 test_mkdir $remote_dir/src_dir
1293 touch $remote_dir/src_file
1294 test_mkdir $remote_dir/tgt_dir
1295 touch $remote_dir/tgt_file
1297 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1298 error "rename subdir in the same remote dir failed!"
1300 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1301 error "rename files in the same remote dir failed!"
1303 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1304 error "link files in the same remote dir failed!"
1306 rm -rf $DIR/$tdir || error "Can not delete directories"
1308 run_test 24y "rename/link on the same dir should succeed"
1311 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1312 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1313 skip "Need MDS version at least 2.12.51"
1317 for index in 0 1; do
1318 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1319 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1322 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1324 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1325 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1327 local mdts=$(comma_list $(mdts_nodes))
1329 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1330 stack_trap "do_nodes $mdts $LCTL \
1331 set_param mdt.*.enable_remote_rename=1" EXIT
1333 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1335 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1336 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1338 run_test 24z "cross-MDT rename is done as cp"
1340 test_24A() { # LU-3182
1343 test_mkdir $DIR/$tdir
1344 stack_trap "simple_cleanup_common $NFILES"
1345 createmany -m $DIR/$tdir/$tfile $NFILES
1346 local t=$(ls $DIR/$tdir | wc -l)
1347 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1348 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1350 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1351 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1353 run_test 24A "readdir() returns correct number of entries."
1355 test_24B() { # LU-4805
1356 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1360 test_mkdir $DIR/$tdir
1361 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1362 error "create striped dir failed"
1364 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1365 [ $count -eq 2 ] || error "Expected 2, got $count"
1367 touch $DIR/$tdir/striped_dir/a
1369 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1370 [ $count -eq 3 ] || error "Expected 3, got $count"
1372 touch $DIR/$tdir/striped_dir/.f
1374 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1375 [ $count -eq 4 ] || error "Expected 4, got $count"
1377 rm -rf $DIR/$tdir || error "Can not delete directories"
1379 run_test 24B "readdir for striped dir return correct number of entries"
1382 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1388 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1389 error "create striped dir failed"
1391 cd $DIR/$tdir/d0/striped_dir
1393 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1394 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1395 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1397 [ "$d0_ino" = "$parent_ino" ] ||
1398 error ".. wrong, expect $d0_ino, get $parent_ino"
1400 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1401 error "mv striped dir failed"
1403 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1405 [ "$d1_ino" = "$parent_ino" ] ||
1406 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1408 run_test 24C "check .. in striped dir"
1411 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1415 mkdir $DIR/$tdir/src_dir
1416 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1417 error "create remote source failed"
1419 touch $DIR/$tdir/src_dir/src_child/a
1421 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1422 error "create remote target dir failed"
1424 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1425 error "create remote target child failed"
1427 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1428 error "rename dir cross MDT failed!"
1432 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1433 error "src_child still exists after rename"
1435 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1436 error "missing file(a) after rename"
1438 rm -rf $DIR/$tdir || error "Can not delete directories"
1440 run_test 24E "cross MDT rename/link"
1443 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1446 [ "$SLOW" = "no" ] && repeats=100
1450 echo "$repeats repeats"
1451 for ((i = 0; i < repeats; i++)); do
1452 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1453 touch $DIR/$tdir/test/a || error "touch fails"
1454 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1455 rm -rf $DIR/$tdir/test || error "rmdir fails"
1460 run_test 24F "hash order vs readdir (LU-11330)"
1463 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1468 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1469 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1470 touch $DIR/$tdir-0/f1 || error "touch f1"
1471 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1472 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1473 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1474 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1475 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1477 run_test 24G "migrate symlink in rename"
1480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1481 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1482 skip "MDT1 should be on another node"
1484 test_mkdir -i 1 -c 1 $DIR/$tdir
1485 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1486 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1487 touch $DIR/$tdir/$tfile || error "touch failed"
1489 run_test 24H "repeat FLD_QUERY rpc"
1492 echo '== symlink sanity ============================================='
1496 touch $DIR/s25/foo ||
1497 error "File creation in symlinked directory failed"
1499 run_test 25a "create file in symlinked directory ==============="
1502 [ ! -d $DIR/d25 ] && test_25a
1503 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1505 run_test 25b "lookup file in symlinked directory ==============="
1509 test_mkdir $DIR/d26/d26-2
1510 ln -s d26/d26-2 $DIR/s26
1511 touch $DIR/s26/foo || error "File creation failed"
1513 run_test 26a "multiple component symlink ======================="
1516 test_mkdir -p $DIR/$tdir/d26-2
1517 ln -s $tdir/d26-2/foo $DIR/s26-2
1518 touch $DIR/s26-2 || error "File creation failed"
1520 run_test 26b "multiple component symlink at end of lookup ======"
1523 test_mkdir $DIR/d26.2
1524 touch $DIR/d26.2/foo
1525 ln -s d26.2 $DIR/s26.2-1
1526 ln -s s26.2-1 $DIR/s26.2-2
1527 ln -s s26.2-2 $DIR/s26.2-3
1528 chmod 0666 $DIR/s26.2-3/foo
1530 run_test 26c "chain of symlinks"
1532 # recursive symlinks (bug 439)
1534 ln -s d26-3/foo $DIR/d26-3
1536 run_test 26d "create multiple component recursive symlink"
1539 [ ! -h $DIR/d26-3 ] && test_26d
1542 run_test 26e "unlink multiple component recursive symlink"
1544 # recursive symlinks (bug 7022)
1546 test_mkdir $DIR/$tdir
1547 test_mkdir $DIR/$tdir/$tfile
1548 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1549 test_mkdir -p lndir/bar1
1550 test_mkdir $DIR/$tdir/$tfile/$tfile
1551 cd $tfile || error "cd $tfile failed"
1552 ln -s .. dotdot || error "ln dotdot failed"
1553 ln -s dotdot/lndir lndir || error "ln lndir failed"
1554 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1555 output=`ls $tfile/$tfile/lndir/bar1`
1556 [ "$output" = bar1 ] && error "unexpected output"
1557 rm -r $tfile || error "rm $tfile failed"
1558 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1560 run_test 26f "rm -r of a directory which has recursive symlink"
1563 test_mkdir $DIR/$tdir
1564 $LFS getstripe $DIR/$tdir
1565 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1566 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1567 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1569 run_test 27a "one stripe file"
1572 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1574 test_mkdir $DIR/$tdir
1575 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1576 $LFS getstripe -c $DIR/$tdir/$tfile
1577 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1578 error "two-stripe file doesn't have two stripes"
1580 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1582 run_test 27b "create and write to two stripe file"
1584 # 27c family tests specific striping, setstripe -o
1586 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1587 test_mkdir -p $DIR/$tdir
1590 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1591 $LFS getstripe -i $DIR/$tdir/$tfile
1592 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1593 error "stripe not on specified OST"
1595 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1597 run_test 27ca "one stripe on specified OST"
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1601 test_mkdir -p $DIR/$tdir
1603 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1604 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1607 # Strip getstripe output to a space separated list of OSTs
1608 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1609 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1610 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1611 error "stripes not on specified OSTs"
1613 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1615 run_test 27cb "two stripes on specified OSTs"
1618 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1619 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1620 skip "server does not support overstriping"
1622 test_mkdir -p $DIR/$tdir
1624 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1625 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1628 # Strip getstripe output to a space separated list of OSTs
1629 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1630 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1631 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1632 error "stripes not on specified OSTs"
1634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1636 run_test 27cc "two stripes on the same OST"
1639 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1640 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1641 skip "server does not support overstriping"
1642 test_mkdir -p $DIR/$tdir
1643 local osts="0,1,1,0"
1644 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1645 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1648 # Strip getstripe output to a space separated list of OSTs
1649 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1650 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1651 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1652 error "stripes not on specified OSTs"
1654 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1656 run_test 27cd "four stripes on two OSTs"
1659 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1660 skip_env "too many osts, skipping"
1661 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1662 skip "server does not support overstriping"
1663 # We do one more stripe than we have OSTs
1664 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1665 skip_env "ea_inode feature disabled"
1667 test_mkdir -p $DIR/$tdir
1669 for i in $(seq 0 $OSTCOUNT);
1672 if [ $i -ne $OSTCOUNT ]; then
1676 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1677 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1680 # Strip getstripe output to a space separated list of OSTs
1681 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1682 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1683 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1684 error "stripes not on specified OSTs"
1686 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1688 run_test 27ce "more stripes than OSTs with -o"
1691 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1694 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1695 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1696 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1697 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1698 error "failed to set $osp_proc=0"
1700 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1703 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1704 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1705 error "failed to set $osp_proc=1"
1708 error "should return error due to $osp_proc=0"
1710 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1713 test_mkdir $DIR/$tdir
1714 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1715 error "setstripe failed"
1716 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1717 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1719 run_test 27d "create file with default settings"
1722 # LU-5839 adds check for existed layout before setting it
1723 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1724 skip "Need MDS version at least 2.7.56"
1726 test_mkdir $DIR/$tdir
1727 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1728 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1729 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1731 run_test 27e "setstripe existing file (should return error)"
1734 test_mkdir $DIR/$tdir
1735 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1736 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1737 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1738 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1739 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1740 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1742 run_test 27f "setstripe with bad stripe size (should return error)"
1745 test_mkdir $DIR/$tdir
1746 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1747 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1748 error "$DIR/$tdir/$tfile has object"
1750 run_test 27g "$LFS getstripe with no objects"
1753 test_mkdir $DIR/$tdir
1754 touch $DIR/$tdir/$tfile || error "touch failed"
1755 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1756 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1758 (( rc == 2 )) || error "getstripe did not return ENOENT"
1760 run_test 27ga "$LFS getstripe with missing file (should return error)"
1763 test_mkdir $DIR/$tdir
1764 touch $DIR/$tdir/$tfile || error "touch failed"
1765 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1766 error "missing objects"
1768 run_test 27i "$LFS getstripe with some objects"
1771 test_mkdir $DIR/$tdir
1772 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1773 error "setstripe failed" || true
1775 run_test 27j "setstripe with bad stripe offset (should return error)"
1777 test_27k() { # bug 2844
1778 test_mkdir $DIR/$tdir
1779 local file=$DIR/$tdir/$tfile
1780 local ll_max_blksize=$((4 * 1024 * 1024))
1781 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1782 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1783 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1784 dd if=/dev/zero of=$file bs=4k count=1
1785 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1786 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1788 run_test 27k "limit i_blksize for broken user apps"
1791 mcreate $DIR/$tfile || error "creating file"
1792 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1793 error "setstripe should have failed" || true
1795 run_test 27l "check setstripe permissions (should return error)"
1798 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1800 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1801 skip_env "multiple clients -- skipping"
1803 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1805 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1806 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1808 stack_trap simple_cleanup_common
1809 test_mkdir $DIR/$tdir
1810 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1811 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1812 error "dd should fill OST0"
1814 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1816 [ $i -gt 256 ] && break
1819 touch $DIR/$tdir/$tfile.$i
1820 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1821 awk '{print $1}'| grep -w "0") ] &&
1822 error "OST0 was full but new created file still use it"
1824 touch $DIR/$tdir/$tfile.$i
1825 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1826 awk '{print $1}'| grep -w "0") ] &&
1827 error "OST0 was full but new created file still use it" || true
1829 run_test 27m "create file while OST0 was full"
1831 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1832 # if the OST isn't full anymore.
1834 local ostidx=${1:-""}
1839 local list=$(comma_list $(osts_nodes))
1840 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1842 do_nodes $list lctl set_param fail_loc=0
1843 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1844 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1845 awk '{print $1 * 2;exit;}')
1846 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1848 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1852 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1854 remote_mds_nodsh && skip "remote MDS with nodsh"
1855 remote_ost_nodsh && skip "remote OST with nodsh"
1858 rm -f $DIR/$tdir/$tfile
1859 exhaust_precreations 0 0x80000215
1860 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1861 touch $DIR/$tdir/$tfile || error "touch failed"
1862 $LFS getstripe $DIR/$tdir/$tfile
1865 run_test 27n "create file with some full OSTs"
1868 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1870 remote_mds_nodsh && skip "remote MDS with nodsh"
1871 remote_ost_nodsh && skip "remote OST with nodsh"
1874 rm -f $DIR/$tdir/$tfile
1875 exhaust_all_precreations 0x215
1877 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1882 run_test 27o "create file with all full OSTs (should error)"
1884 function create_and_checktime() {
1889 for ((i=0; i < $loops; i++)); do
1890 local start=$SECONDS
1891 multiop $fname-$i Oc
1892 ((SECONDS-start < TIMEOUT)) ||
1893 error "creation took " $((SECONDS-$start)) && return 1
1898 local mdts=$(comma_list $(mdts_nodes))
1900 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1901 skip "Need MDS version at least 2.13.57"
1903 local f0=$DIR/${tfile}-0
1904 local f1=$DIR/${tfile}-1
1906 wait_delete_completed
1908 # refill precreated objects
1909 $LFS setstripe -i0 -c1 $f0
1911 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1912 # force QoS allocation policy
1913 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1914 stack_trap "do_nodes $mdts $LCTL set_param \
1915 lov.*.qos_threshold_rr=$saved" EXIT
1918 # one OST is unavailable, but still have few objects preallocated
1920 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1921 rm -rf $f1 $DIR/$tdir*" EXIT
1923 for ((i=0; i < 7; i++)); do
1924 mkdir $DIR/$tdir$i || error "can't create dir"
1925 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1926 error "can't set striping"
1928 for ((i=0; i < 7; i++)); do
1929 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1933 run_test 27oo "don't let few threads to reserve too many objects"
1936 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1938 remote_mds_nodsh && skip "remote MDS with nodsh"
1939 remote_ost_nodsh && skip "remote OST with nodsh"
1942 rm -f $DIR/$tdir/$tfile
1943 test_mkdir $DIR/$tdir
1945 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1946 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1947 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1949 exhaust_precreations 0 0x80000215
1950 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1951 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1952 $LFS getstripe $DIR/$tdir/$tfile
1956 run_test 27p "append to a truncated file with some full OSTs"
1959 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1961 remote_mds_nodsh && skip "remote MDS with nodsh"
1962 remote_ost_nodsh && skip "remote OST with nodsh"
1965 rm -f $DIR/$tdir/$tfile
1967 mkdir_on_mdt0 $DIR/$tdir
1968 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1969 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1970 error "truncate $DIR/$tdir/$tfile failed"
1971 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1973 exhaust_all_precreations 0x215
1975 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1976 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1980 run_test 27q "append to truncated file with all OSTs full (should error)"
1983 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1985 remote_mds_nodsh && skip "remote MDS with nodsh"
1986 remote_ost_nodsh && skip "remote OST with nodsh"
1989 rm -f $DIR/$tdir/$tfile
1990 exhaust_precreations 0 0x80000215
1992 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1996 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1998 test_27s() { # bug 10725
1999 test_mkdir $DIR/$tdir
2000 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2001 local stripe_count=0
2002 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2003 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2004 error "stripe width >= 2^32 succeeded" || true
2007 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2009 test_27t() { # bug 10864
2014 $WLFS getstripe $tfile
2017 run_test 27t "check that utils parse path correctly"
2019 test_27u() { # bug 4900
2020 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2021 remote_mds_nodsh && skip "remote MDS with nodsh"
2024 local list=$(comma_list $(mdts_nodes))
2026 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2027 do_nodes $list $LCTL set_param fail_loc=0x139
2028 test_mkdir -p $DIR/$tdir
2029 stack_trap "simple_cleanup_common 1000"
2030 createmany -o $DIR/$tdir/$tfile 1000
2031 do_nodes $list $LCTL set_param fail_loc=0
2033 TLOG=$TMP/$tfile.getstripe
2034 $LFS getstripe $DIR/$tdir > $TLOG
2035 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2036 [[ $OBJS -gt 0 ]] &&
2037 error "$OBJS objects created on OST-0. See $TLOG" ||
2040 run_test 27u "skip object creation on OSC w/o objects"
2042 test_27v() { # bug 4900
2043 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2045 remote_mds_nodsh && skip "remote MDS with nodsh"
2046 remote_ost_nodsh && skip "remote OST with nodsh"
2048 exhaust_all_precreations 0x215
2051 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2053 touch $DIR/$tdir/$tfile
2054 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2056 for (( i=1; i < OSTCOUNT; i++ )); do
2057 do_facet ost$i lctl set_param fail_loc=0x705
2059 local START=`date +%s`
2060 createmany -o $DIR/$tdir/$tfile 32
2062 local FINISH=`date +%s`
2063 local TIMEOUT=`lctl get_param -n timeout`
2064 local PROCESS=$((FINISH - START))
2065 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2066 error "$FINISH - $START >= $TIMEOUT / 2"
2067 sleep $((TIMEOUT / 2 - PROCESS))
2070 run_test 27v "skip object creation on slow OST"
2072 test_27w() { # bug 10997
2073 test_mkdir $DIR/$tdir
2074 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2075 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2076 error "stripe size $size != 65536" || true
2077 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2078 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2080 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2083 [[ $OSTCOUNT -lt 2 ]] &&
2084 skip_env "skipping multiple stripe count/offset test"
2086 test_mkdir $DIR/$tdir
2087 for i in $(seq 1 $OSTCOUNT); do
2089 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2090 error "setstripe -c $i -i $offset failed"
2091 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2092 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2093 [ $count -ne $i ] && error "stripe count $count != $i" || true
2094 [ $index -ne $offset ] &&
2095 error "stripe offset $index != $offset" || true
2098 run_test 27wa "check $LFS setstripe -c -i options"
2101 remote_ost_nodsh && skip "remote OST with nodsh"
2102 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2105 OFFSET=$(($OSTCOUNT - 1))
2107 local OST=$(ostname_from_index $OSTIDX)
2109 test_mkdir $DIR/$tdir
2110 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2111 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2113 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2114 for i in $(seq 0 $OFFSET); do
2115 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2116 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2117 error "OST0 was degraded but new created file still use it"
2119 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2121 run_test 27x "create files while OST0 is degraded"
2124 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2125 remote_mds_nodsh && skip "remote MDS with nodsh"
2126 remote_ost_nodsh && skip "remote OST with nodsh"
2127 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2129 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2130 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2131 osp.$mdtosc.prealloc_last_id)
2132 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2133 osp.$mdtosc.prealloc_next_id)
2134 local fcount=$((last_id - next_id))
2135 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2136 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2138 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2139 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2140 local OST_DEACTIVE_IDX=-1
2145 for OSC in $MDS_OSCS; do
2146 OST=$(osc_to_ost $OSC)
2147 OSTIDX=$(index_from_ostuuid $OST)
2148 if [ $OST_DEACTIVE_IDX == -1 ]; then
2149 OST_DEACTIVE_IDX=$OSTIDX
2151 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2152 echo $OSC "is Deactivated:"
2153 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2157 OSTIDX=$(index_from_ostuuid $OST)
2158 test_mkdir $DIR/$tdir
2159 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2161 for OSC in $MDS_OSCS; do
2162 OST=$(osc_to_ost $OSC)
2163 OSTIDX=$(index_from_ostuuid $OST)
2164 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2165 echo $OST "is degraded:"
2166 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2167 obdfilter.$OST.degraded=1
2172 createmany -o $DIR/$tdir/$tfile $fcount
2174 for OSC in $MDS_OSCS; do
2175 OST=$(osc_to_ost $OSC)
2176 OSTIDX=$(index_from_ostuuid $OST)
2177 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2178 echo $OST "is recovered from degraded:"
2179 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2180 obdfilter.$OST.degraded=0
2182 do_facet $SINGLEMDS lctl --device %$OSC activate
2186 # all osp devices get activated, hence -1 stripe count restored
2187 local stripe_count=0
2189 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2190 # devices get activated.
2192 $LFS setstripe -c -1 $DIR/$tfile
2193 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2195 [ $stripe_count -ne $OSTCOUNT ] &&
2196 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2199 run_test 27y "create files while OST0 is degraded and the rest inactive"
2205 lmm_count=$($LFS getstripe -c $1)
2206 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2207 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2209 local old_ifs="$IFS"
2211 fid=($($LFS path2fid $1))
2214 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2215 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2217 # compare lmm_seq and lu_fid->f_seq
2218 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2219 # compare lmm_object_id and lu_fid->oid
2220 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2222 # check the trusted.fid attribute of the OST objects of the file
2223 local have_obdidx=false
2225 $LFS getstripe $1 | while read obdidx oid hex seq; do
2226 # skip lines up to and including "obdidx"
2227 [ -z "$obdidx" ] && break
2228 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2229 $have_obdidx || continue
2231 local ost=$((obdidx + 1))
2232 local dev=$(ostdevname $ost)
2235 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2237 seq=$(echo $seq | sed -e "s/^0x//g")
2238 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2239 oid_hex=$(echo $oid)
2241 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2243 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2247 # Don't unmount/remount the OSTs if we don't need to do that.
2248 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2249 # update too, until that use mount/ll_decode_filter_fid/mount.
2250 # Re-enable when debugfs will understand new filter_fid.
2252 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2253 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2254 $dev 2>/dev/null" | grep "parent=")
2256 if [ -z "$ff" ]; then
2258 mount_fstype ost$ost
2259 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2260 $(facet_mntpt ost$ost)/$obj_file)
2261 unmount_fstype ost$ost
2262 start ost$ost $dev $OST_MOUNT_OPTS
2266 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2268 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2270 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2271 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2273 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2274 # stripe_size=1048576 component_id=1 component_start=0 \
2275 # component_end=33554432
2276 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2277 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2278 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2280 if grep -q 'stripe=' <<<$ff; then
2281 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2283 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2284 # into f_ver in this case. See comment on ff_parent.
2285 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2288 # compare lmm_seq and filter_fid->ff_parent.f_seq
2289 [ $ff_pseq = $lmm_seq ] ||
2290 error "FF parent SEQ $ff_pseq != $lmm_seq"
2291 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2292 [ $ff_poid = $lmm_oid ] ||
2293 error "FF parent OID $ff_poid != $lmm_oid"
2294 (($ff_pstripe == $stripe_nr)) ||
2295 error "FF stripe $ff_pstripe != $stripe_nr"
2297 stripe_nr=$((stripe_nr + 1))
2298 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2300 if grep -q 'stripe_count=' <<<$ff; then
2301 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2302 -e 's/ .*//' <<<$ff)
2303 [ $lmm_count = $ff_scnt ] ||
2304 error "FF stripe count $lmm_count != $ff_scnt"
2310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2311 remote_ost_nodsh && skip "remote OST with nodsh"
2313 test_mkdir $DIR/$tdir
2314 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2315 { error "setstripe -c -1 failed"; return 1; }
2316 # We need to send a write to every object to get parent FID info set.
2317 # This _should_ also work for setattr, but does not currently.
2318 # touch $DIR/$tdir/$tfile-1 ||
2319 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2320 { error "dd $tfile-1 failed"; return 2; }
2321 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2322 { error "setstripe -c -1 failed"; return 3; }
2323 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2324 { error "dd $tfile-2 failed"; return 4; }
2326 # make sure write RPCs have been sent to OSTs
2329 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2330 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2332 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2334 test_27A() { # b=19102
2335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2337 save_layout_restore_at_exit $MOUNT
2338 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2339 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2340 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2341 local default_size=$($LFS getstripe -S $MOUNT)
2342 local default_offset=$($LFS getstripe -i $MOUNT)
2343 local dsize=$(do_facet $SINGLEMDS \
2344 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2345 [ $default_size -eq $dsize ] ||
2346 error "stripe size $default_size != $dsize"
2347 [ $default_offset -eq -1 ] ||
2348 error "stripe offset $default_offset != -1"
2350 run_test 27A "check filesystem-wide default LOV EA values"
2352 test_27B() { # LU-2523
2353 test_mkdir $DIR/$tdir
2354 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2356 # open f1 with O_LOV_DELAY_CREATE
2358 # call setstripe ioctl on open file descriptor for f1
2360 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2364 # open f1 with O_LOV_DELAY_CREATE
2366 # call setstripe ioctl on open file descriptor for f1
2368 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2370 # Allow multiop to fail in imitation of NFS's busted semantics.
2373 run_test 27B "call setstripe on open unlinked file/rename victim"
2375 # 27C family tests full striping and overstriping
2376 test_27Ca() { #LU-2871
2377 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2385 test_mkdir $DIR/$tdir
2387 for i in $(seq 0 $((OSTCOUNT - 1))); do
2388 # set stripe across all OSTs starting from OST$i
2389 $LFS setstripe -i $i -c -1 $tfile$i
2390 # get striping information
2391 ost_idx=($($LFS getstripe $tfile$i |
2392 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2393 echo "OST Index: ${ost_idx[*]}"
2396 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2397 error "${#ost_idx[@]} != $OSTCOUNT"
2399 for index in $(seq 0 $((OSTCOUNT - 1))); do
2401 for j in "${ost_idx[@]}"; do
2402 if [ $index -eq $j ]; then
2408 error "Can not find $index in ${ost_idx[*]}"
2412 run_test 27Ca "check full striping across all OSTs"
2415 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2416 skip "server does not support overstriping"
2417 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2418 skip_env "too many osts, skipping"
2420 test_mkdir -p $DIR/$tdir
2421 local setcount=$(($OSTCOUNT * 2))
2422 [ $setcount -lt 160 ] || large_xattr_enabled ||
2423 skip_env "ea_inode feature disabled"
2425 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2426 error "setstripe failed"
2428 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2429 [ $count -eq $setcount ] ||
2430 error "stripe count $count, should be $setcount"
2432 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2433 error "overstriped should be set in pattern"
2435 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2438 run_test 27Cb "more stripes than OSTs with -C"
2441 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2442 skip "server does not support overstriping"
2443 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2445 test_mkdir -p $DIR/$tdir
2446 local setcount=$(($OSTCOUNT - 1))
2448 [ $setcount -lt 160 ] || large_xattr_enabled ||
2449 skip_env "ea_inode feature disabled"
2451 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2452 error "setstripe failed"
2454 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2455 [ $count -eq $setcount ] ||
2456 error "stripe count $count, should be $setcount"
2458 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2459 error "overstriped should not be set in pattern"
2461 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2464 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2467 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2468 skip "server does not support overstriping"
2469 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2470 large_xattr_enabled || skip_env "ea_inode feature disabled"
2472 test_mkdir -p $DIR/$tdir
2473 local setcount=$LOV_MAX_STRIPE_COUNT
2475 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2476 error "setstripe failed"
2478 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2479 [ $count -eq $setcount ] ||
2480 error "stripe count $count, should be $setcount"
2482 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2483 error "overstriped should be set in pattern"
2485 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2488 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2490 run_test 27Cd "test maximum stripe count"
2493 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2494 skip "server does not support overstriping"
2495 test_mkdir -p $DIR/$tdir
2497 pool_add $TESTNAME || error "Pool creation failed"
2498 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2502 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2503 error "setstripe failed"
2505 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2506 [ $count -eq $setcount ] ||
2507 error "stripe count $count, should be $setcount"
2509 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2510 error "overstriped should be set in pattern"
2512 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2515 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2517 run_test 27Ce "test pool with overstriping"
2520 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2521 skip "server does not support overstriping"
2522 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2523 skip_env "too many osts, skipping"
2525 test_mkdir -p $DIR/$tdir
2527 local setcount=$(($OSTCOUNT * 2))
2528 [ $setcount -lt 160 ] || large_xattr_enabled ||
2529 skip_env "ea_inode feature disabled"
2531 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2532 error "setstripe failed"
2534 echo 1 > $DIR/$tdir/$tfile
2536 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2537 [ $count -eq $setcount ] ||
2538 error "stripe count $count, should be $setcount"
2540 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2541 error "overstriped should be set in pattern"
2543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2546 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2548 run_test 27Cf "test default inheritance with overstriping"
2551 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2552 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2553 remote_mds_nodsh && skip "remote MDS with nodsh"
2555 local POOL=${POOL:-testpool}
2557 local last_ost=$(($OSTCOUNT - 1))
2559 local ost_list=$(seq $first_ost $ost_step $last_ost)
2560 local ost_range="$first_ost $last_ost $ost_step"
2562 test_mkdir $DIR/$tdir
2563 pool_add $POOL || error "pool_add failed"
2564 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2567 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2569 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2570 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2571 skip27D+=" -s 30,31"
2572 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2573 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2574 skip27D+=" -s 32,33"
2575 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2577 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2578 error "llapi_layout_test failed"
2580 destroy_test_pools || error "destroy test pools failed"
2582 run_test 27D "validate llapi_layout API"
2584 # Verify that default_easize is increased from its initial value after
2585 # accessing a widely striped file.
2587 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2588 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2589 skip "client does not have LU-3338 fix"
2591 # 72 bytes is the minimum space required to store striping
2592 # information for a file striped across one OST:
2593 # (sizeof(struct lov_user_md_v3) +
2594 # sizeof(struct lov_user_ost_data_v1))
2596 $LCTL set_param -n llite.*.default_easize $min_easize ||
2597 error "lctl set_param failed"
2598 local easize=$($LCTL get_param -n llite.*.default_easize)
2600 [ $easize -eq $min_easize ] ||
2601 error "failed to set default_easize"
2603 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2604 error "setstripe failed"
2605 # In order to ensure stat() call actually talks to MDS we need to
2606 # do something drastic to this file to shake off all lock, e.g.
2607 # rename it (kills lookup lock forcing cache cleaning)
2608 mv $DIR/$tfile $DIR/${tfile}-1
2609 ls -l $DIR/${tfile}-1
2612 easize=$($LCTL get_param -n llite.*.default_easize)
2614 [ $easize -gt $min_easize ] ||
2615 error "default_easize not updated"
2617 run_test 27E "check that default extended attribute size properly increases"
2619 test_27F() { # LU-5346/LU-7975
2620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2621 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2622 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2623 skip "Need MDS version at least 2.8.51"
2624 remote_ost_nodsh && skip "remote OST with nodsh"
2626 test_mkdir $DIR/$tdir
2628 $LFS setstripe -c 2 $DIR/$tdir
2630 # stop all OSTs to reproduce situation for LU-7975 ticket
2631 for num in $(seq $OSTCOUNT); do
2635 # open/create f0 with O_LOV_DELAY_CREATE
2636 # truncate f0 to a non-0 size
2638 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2640 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2641 # open/write it again to force delayed layout creation
2642 cat /etc/hosts > $DIR/$tdir/f0 &
2646 for num in $(seq $OSTCOUNT); do
2647 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2648 error "ost$num failed to start"
2651 wait $catpid || error "cat failed"
2653 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2654 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2655 error "wrong stripecount"
2658 run_test 27F "Client resend delayed layout creation with non-zero size"
2660 test_27G() { #LU-10629
2661 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2662 skip "Need MDS version at least 2.11.51"
2663 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2664 remote_mds_nodsh && skip "remote MDS with nodsh"
2665 local POOL=${POOL:-testpool}
2666 local ostrange="0 0 1"
2668 test_mkdir $DIR/$tdir
2669 touch $DIR/$tdir/$tfile.nopool
2670 pool_add $POOL || error "pool_add failed"
2671 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2672 $LFS setstripe -p $POOL $DIR/$tdir
2674 local pool=$($LFS getstripe -p $DIR/$tdir)
2676 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2677 touch $DIR/$tdir/$tfile.default
2678 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2679 $LFS find $DIR/$tdir -type f --pool $POOL
2680 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2681 [[ "$found" == "2" ]] ||
2682 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2684 $LFS setstripe -d $DIR/$tdir
2686 pool=$($LFS getstripe -p -d $DIR/$tdir)
2688 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2690 run_test 27G "Clear OST pool from stripe"
2693 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2694 skip "Need MDS version newer than 2.11.54"
2695 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2696 test_mkdir $DIR/$tdir
2697 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2698 touch $DIR/$tdir/$tfile
2699 $LFS getstripe -c $DIR/$tdir/$tfile
2700 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2701 error "two-stripe file doesn't have two stripes"
2703 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2704 $LFS getstripe -y $DIR/$tdir/$tfile
2705 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2706 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2707 error "expected l_ost_idx: [02]$ not matched"
2709 # make sure ost list has been cleared
2710 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2711 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2712 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2714 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2716 run_test 27H "Set specific OSTs stripe"
2719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2720 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2721 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2722 skip "Need MDS version newer than 2.12.52"
2723 local pool=$TESTNAME
2724 local ostrange="1 1 1"
2726 save_layout_restore_at_exit $MOUNT
2727 $LFS setstripe -c 2 -i 0 $MOUNT
2728 pool_add $pool || error "pool_add failed"
2729 pool_add_targets $pool $ostrange ||
2730 error "pool_add_targets failed"
2731 test_mkdir $DIR/$tdir
2732 $LFS setstripe -p $pool $DIR/$tdir
2733 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2734 $LFS getstripe $DIR/$tdir/$tfile
2736 run_test 27I "check that root dir striping does not break parent dir one"
2739 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2740 skip "Need MDS version newer than 2.12.51"
2742 test_mkdir $DIR/$tdir
2743 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2744 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2746 # create foreign file (raw way)
2747 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2748 error "creating $tfile w/ hex flags w/o --foreign should fail"
2750 ! $LFS setstripe --foreign --flags foo \
2751 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2752 error "creating $tfile with '--flags foo' should fail"
2754 ! $LFS setstripe --foreign --flags 0xffffffff \
2755 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2756 error "creating $tfile w/ 0xffffffff flags should fail"
2758 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2759 -t 1 -F 0xda08 || error "create_foreign_file failed"
2761 # verify foreign file (raw way)
2762 parse_foreign_file -f $DIR/$tdir/$tfile |
2763 grep "lov_foreign_magic: 0x0BD70BD0" ||
2764 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2765 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2766 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2767 parse_foreign_file -f $DIR/$tdir/$tfile |
2768 grep "lov_foreign_size: 73" ||
2769 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2770 parse_foreign_file -f $DIR/$tdir/$tfile |
2771 grep "lov_foreign_type: 1" ||
2772 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2773 parse_foreign_file -f $DIR/$tdir/$tfile |
2774 grep "lov_foreign_flags: 0x0000DA08" ||
2775 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2776 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2777 grep "lov_foreign_value: 0x" |
2778 sed -e 's/lov_foreign_value: 0x//')
2779 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2780 [[ $lov = ${lov2// /} ]] ||
2781 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2783 # create foreign file (lfs + API)
2784 $LFS setstripe --foreign=none --flags 0xda08 \
2785 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2786 error "$DIR/$tdir/${tfile}2: create failed"
2788 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2789 grep "lfm_magic:.*0x0BD70BD0" ||
2790 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2791 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2792 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2793 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2794 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2795 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2796 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2797 grep "lfm_flags:.*0x0000DA08" ||
2798 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2799 $LFS getstripe $DIR/$tdir/${tfile}2 |
2800 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2801 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2803 # modify striping should fail
2804 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2805 error "$DIR/$tdir/$tfile: setstripe should fail"
2806 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2807 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2810 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2811 cat $DIR/$tdir/${tfile}2 &&
2812 error "$DIR/$tdir/${tfile}2: read should fail"
2813 cat /etc/passwd > $DIR/$tdir/$tfile &&
2814 error "$DIR/$tdir/$tfile: write should fail"
2815 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2816 error "$DIR/$tdir/${tfile}2: write should fail"
2819 chmod 222 $DIR/$tdir/$tfile ||
2820 error "$DIR/$tdir/$tfile: chmod failed"
2821 chmod 222 $DIR/$tdir/${tfile}2 ||
2822 error "$DIR/$tdir/${tfile}2: chmod failed"
2825 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2826 error "$DIR/$tdir/$tfile: chown failed"
2827 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2828 error "$DIR/$tdir/${tfile}2: chown failed"
2830 # rename should work
2831 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2832 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2833 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2834 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2836 #remove foreign file
2837 rm $DIR/$tdir/${tfile}.new ||
2838 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2839 rm $DIR/$tdir/${tfile}2.new ||
2840 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2842 run_test 27J "basic ops on file with foreign LOV"
2845 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2846 skip "Need MDS version newer than 2.12.49"
2848 test_mkdir $DIR/$tdir
2849 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2850 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2852 # create foreign dir (raw way)
2853 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2854 error "creating $tdir w/ hex flags w/o --foreign should fail"
2856 ! $LFS setdirstripe --foreign --flags foo \
2857 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2858 error "creating $tdir with '--flags foo' should fail"
2860 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2861 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2862 error "creating $tdir w/ 0xffffffff flags should fail"
2864 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2865 error "create_foreign_dir FAILED"
2867 # verify foreign dir (raw way)
2868 parse_foreign_dir -d $DIR/$tdir/$tdir |
2869 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2870 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2871 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2872 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2873 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2874 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2875 parse_foreign_dir -d $DIR/$tdir/$tdir |
2876 grep "lmv_foreign_flags: 55813$" ||
2877 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2878 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2879 grep "lmv_foreign_value: 0x" |
2880 sed 's/lmv_foreign_value: 0x//')
2881 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2883 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2885 # create foreign dir (lfs + API)
2886 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2887 $DIR/$tdir/${tdir}2 ||
2888 error "$DIR/$tdir/${tdir}2: create failed"
2890 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2892 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2893 grep "lfm_magic:.*0x0CD50CD0" ||
2894 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2895 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2896 # - sizeof(lfm_type) - sizeof(lfm_flags)
2897 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2898 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2899 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2900 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2901 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2902 grep "lfm_flags:.*0x0000DA05" ||
2903 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2904 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2905 grep "lfm_value.*${uuid1}@${uuid2}" ||
2906 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2908 # file create in dir should fail
2909 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2910 touch $DIR/$tdir/${tdir}2/$tfile &&
2911 error "$DIR/${tdir}2: file create should fail"
2914 chmod 777 $DIR/$tdir/$tdir ||
2915 error "$DIR/$tdir: chmod failed"
2916 chmod 777 $DIR/$tdir/${tdir}2 ||
2917 error "$DIR/${tdir}2: chmod failed"
2920 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2921 error "$DIR/$tdir: chown failed"
2922 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2923 error "$DIR/${tdir}2: chown failed"
2925 # rename should work
2926 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2927 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2928 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2929 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2932 rmdir $DIR/$tdir/${tdir}.new ||
2933 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2934 rmdir $DIR/$tdir/${tdir}2.new ||
2935 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2937 run_test 27K "basic ops on dir with foreign LMV"
2940 remote_mds_nodsh && skip "remote MDS with nodsh"
2942 local POOL=${POOL:-$TESTNAME}
2944 pool_add $POOL || error "pool_add failed"
2946 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2947 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2948 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2950 run_test 27L "lfs pool_list gives correct pool name"
2953 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2954 skip "Need MDS version >= than 2.12.57"
2955 remote_mds_nodsh && skip "remote MDS with nodsh"
2956 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2958 # Set default striping on directory
2961 local mdts=$(comma_list $(mdts_nodes))
2963 # if we run against a 2.12 server which lacks overstring support
2964 # then the connect_flag will not report overstriping, even if client
2966 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2967 stripe_opt="-C $setcount"
2968 elif (( $OSTCOUNT >= $setcount )); then
2969 stripe_opt="-c $setcount"
2971 skip "server does not support overstriping"
2974 test_mkdir $DIR/$tdir
2976 # Validate existing append_* params and ensure restore
2977 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
2978 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
2979 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
2981 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2982 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
2983 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
2985 $LFS setstripe $stripe_opt $DIR/$tdir
2987 echo 1 > $DIR/$tdir/${tfile}.1
2988 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2989 [ $count -eq $setcount ] ||
2990 error "(1) stripe count $count, should be $setcount"
2992 local appendcount=$orig_count
2993 echo 1 >> $DIR/$tdir/${tfile}.2_append
2994 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2995 [ $count -eq $appendcount ] ||
2996 error "(2)stripe count $count, should be $appendcount for append"
2998 # Disable O_APPEND striping, verify it works
2999 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3001 # Should now get the default striping, which is 4
3003 echo 1 >> $DIR/$tdir/${tfile}.3_append
3004 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3005 [ $count -eq $setcount ] ||
3006 error "(3) stripe count $count, should be $setcount"
3008 # Try changing the stripe count for append files
3009 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3011 # Append striping is now 2 (directory default is still 4)
3013 echo 1 >> $DIR/$tdir/${tfile}.4_append
3014 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3015 [ $count -eq $appendcount ] ||
3016 error "(4) stripe count $count, should be $appendcount for append"
3018 # Test append stripe count of -1
3019 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3020 appendcount=$OSTCOUNT
3021 echo 1 >> $DIR/$tdir/${tfile}.5
3022 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3023 [ $count -eq $appendcount ] ||
3024 error "(5) stripe count $count, should be $appendcount for append"
3026 # Set append striping back to default of 1
3027 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3029 # Try a new default striping, PFL + DOM
3030 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3032 # Create normal DOM file, DOM returns stripe count == 0
3034 touch $DIR/$tdir/${tfile}.6
3035 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3036 [ $count -eq $setcount ] ||
3037 error "(6) stripe count $count, should be $setcount"
3041 echo 1 >> $DIR/$tdir/${tfile}.7_append
3042 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3043 [ $count -eq $appendcount ] ||
3044 error "(7) stripe count $count, should be $appendcount for append"
3046 # Clean up DOM layout
3047 $LFS setstripe -d $DIR/$tdir
3049 save_layout_restore_at_exit $MOUNT
3050 # Now test that append striping works when layout is from root
3051 $LFS setstripe -c 2 $MOUNT
3052 # Make a special directory for this
3053 mkdir $DIR/${tdir}/${tdir}.2
3055 # Verify for normal file
3057 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3058 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3059 [ $count -eq $setcount ] ||
3060 error "(8) stripe count $count, should be $setcount"
3063 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3064 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3065 [ $count -eq $appendcount ] ||
3066 error "(9) stripe count $count, should be $appendcount for append"
3068 # Now test O_APPEND striping with pools
3069 pool_add $TESTNAME || error "pool creation failed"
3070 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3071 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3073 echo 1 >> $DIR/$tdir/${tfile}.10_append
3075 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3076 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3078 # Check that count is still correct
3080 echo 1 >> $DIR/$tdir/${tfile}.11_append
3081 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3082 [ $count -eq $appendcount ] ||
3083 error "(11) stripe count $count, should be $appendcount for append"
3085 # Disable O_APPEND stripe count, verify pool works separately
3086 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3088 echo 1 >> $DIR/$tdir/${tfile}.12_append
3090 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3091 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3093 # Remove pool setting, verify it's not applied
3094 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3096 echo 1 >> $DIR/$tdir/${tfile}.13_append
3098 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3099 [ "$pool" = "" ] || error "(13) pool found: $pool"
3101 run_test 27M "test O_APPEND striping"
3104 combined_mgs_mds && skip "needs separate MGS/MDT"
3106 pool_add $TESTNAME || error "pool_add failed"
3107 do_facet mgs "$LCTL pool_list $FSNAME" |
3108 grep -Fx "${FSNAME}.${TESTNAME}" ||
3109 error "lctl pool_list on MGS failed"
3111 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3113 clean_foreign_symlink() {
3115 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3116 for i in $DIR/$tdir/* ; do
3117 $LFS unlink_foreign $i || true
3122 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3123 skip "Need MDS version newer than 2.12.51"
3125 test_mkdir $DIR/$tdir
3126 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3127 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3129 trap clean_foreign_symlink EXIT
3131 # enable foreign_symlink behaviour
3132 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3134 # foreign symlink LOV format is a partial path by default
3136 # create foreign file (lfs + API)
3137 $LFS setstripe --foreign=symlink --flags 0xda05 \
3138 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3139 error "$DIR/$tdir/${tfile}: create failed"
3141 $LFS getstripe -v $DIR/$tdir/${tfile} |
3142 grep "lfm_magic:.*0x0BD70BD0" ||
3143 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3144 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3145 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3146 $LFS getstripe -v $DIR/$tdir/${tfile} |
3147 grep "lfm_flags:.*0x0000DA05" ||
3148 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3149 $LFS getstripe $DIR/$tdir/${tfile} |
3150 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3151 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3153 # modify striping should fail
3154 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3155 error "$DIR/$tdir/$tfile: setstripe should fail"
3157 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3158 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3159 cat /etc/passwd > $DIR/$tdir/$tfile &&
3160 error "$DIR/$tdir/$tfile: write should fail"
3162 # rename should succeed
3163 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3164 error "$DIR/$tdir/$tfile: rename has failed"
3166 #remove foreign_symlink file should fail
3167 rm $DIR/$tdir/${tfile}.new &&
3168 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3171 mkdir /tmp/${uuid1} ||
3172 error "/tmp/${uuid1}: mkdir has failed"
3173 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3174 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3175 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3176 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3177 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3178 #read should succeed now
3179 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3180 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3181 #write should succeed now
3182 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3183 error "$DIR/$tdir/${tfile}.new: write should succeed"
3184 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3185 error "$DIR/$tdir/${tfile}.new: diff has failed"
3186 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3187 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3189 #check that getstripe still works
3190 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3191 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3193 # chmod should still succeed
3194 chmod 644 $DIR/$tdir/${tfile}.new ||
3195 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3197 # chown should still succeed
3198 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3199 error "$DIR/$tdir/${tfile}.new: chown has failed"
3201 # rename should still succeed
3202 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3203 error "$DIR/$tdir/${tfile}.new: rename has failed"
3205 #remove foreign_symlink file should still fail
3206 rm $DIR/$tdir/${tfile} &&
3207 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3209 #use special ioctl() to unlink foreign_symlink file
3210 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3211 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3214 run_test 27O "basic ops on foreign file of symlink type"
3217 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3218 skip "Need MDS version newer than 2.12.49"
3220 test_mkdir $DIR/$tdir
3221 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3222 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3224 trap clean_foreign_symlink EXIT
3226 # enable foreign_symlink behaviour
3227 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3229 # foreign symlink LMV format is a partial path by default
3231 # create foreign dir (lfs + API)
3232 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3233 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3234 error "$DIR/$tdir/${tdir}: create failed"
3236 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3238 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3239 grep "lfm_magic:.*0x0CD50CD0" ||
3240 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3241 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3242 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3243 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3244 grep "lfm_flags:.*0x0000DA05" ||
3245 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3246 $LFS getdirstripe $DIR/$tdir/${tdir} |
3247 grep "lfm_value.*${uuid1}/${uuid2}" ||
3248 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3250 # file create in dir should fail
3251 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3252 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3254 # rename should succeed
3255 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3256 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3258 #remove foreign_symlink dir should fail
3259 rmdir $DIR/$tdir/${tdir}.new &&
3260 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3263 mkdir -p /tmp/${uuid1}/${uuid2} ||
3264 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3265 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3266 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3267 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3268 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3269 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3270 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3271 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3273 #check that getstripe fails now that foreign_symlink enabled
3274 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3275 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3277 # file create in dir should work now
3278 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3279 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3280 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3281 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3282 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3283 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3285 # chmod should still succeed
3286 chmod 755 $DIR/$tdir/${tdir}.new ||
3287 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3289 # chown should still succeed
3290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3291 error "$DIR/$tdir/${tdir}.new: chown has failed"
3293 # rename should still succeed
3294 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3295 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3297 #remove foreign_symlink dir should still fail
3298 rmdir $DIR/$tdir/${tdir} &&
3299 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3301 #use special ioctl() to unlink foreign_symlink file
3302 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3303 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3305 #created file should still exist
3306 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3307 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3308 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3309 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3311 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3314 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3315 stack_trap "rm -f $TMP/$tfile*"
3317 test_mkdir $DIR/$tdir-1
3318 test_mkdir $DIR/$tdir-2
3320 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3321 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3323 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3324 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3326 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3327 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3329 # Create some bad symlinks and ensure that we don't loop
3330 # forever or something. These should return ELOOP (40) and
3331 # ENOENT (2) but I don't want to test for that because there's
3332 # always some weirdo architecture that needs to ruin
3333 # everything by defining these error numbers differently.
3335 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3336 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3338 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3339 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3343 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3346 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3347 skip "need MDS 2.14.55 or later"
3348 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3350 local testdir="$DIR/$tdir"
3351 test_mkdir -p $testdir
3352 stack_trap "rm -rf $testdir"
3353 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3355 local f1="$testdir/f1"
3356 touch $f1 || error "failed to touch $f1"
3357 local count=$($LFS getstripe -c $f1)
3358 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3360 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3361 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3363 local maxcount=$(($OSTCOUNT - 1))
3364 local mdts=$(comma_list $(mdts_nodes))
3365 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3366 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3368 local f2="$testdir/f2"
3369 touch $f2 || error "failed to touch $f2"
3370 local count=$($LFS getstripe -c $f2)
3371 (( $count == $maxcount )) || error "wrong stripe count"
3373 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3376 [ $(facet_host client) == $(facet_host ost1) ] &&
3377 skip "need ost1 and client on different nodes"
3379 #define OBD_FAIL_OSC_NO_GRANT 0x411
3380 $LCTL set_param fail_loc=0x20000411 fail_val=1
3381 #define OBD_FAIL_OST_ENOSPC 0x215
3382 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3383 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3384 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3385 error "multiop failed"
3387 run_test 27T "no eio on close on partial write due to enosp"
3390 local dir=$DIR/$tdir
3391 local file=$dir/$tfile
3392 local append_pool=${TESTNAME}-append
3393 local normal_pool=${TESTNAME}-normal
3397 local mdts=$(comma_list $(mdts_nodes))
3400 # (( $MDS1_VERSION >= $(version_code 2.15.42) )) ||
3401 # skip "Need MDS version at least 2.15.42"
3403 # Validate existing append_* params and ensure restore
3404 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3405 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3406 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3408 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3409 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3410 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3412 pool_add $append_pool || error "pool creation failed"
3413 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3415 pool_add $normal_pool || error "pool creation failed"
3416 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3419 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3422 $LFS getstripe $file.1
3424 pool=$($LFS getstripe -p $file.1)
3425 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3427 stripe_count2=$($LFS getstripe -c $file.1)
3428 ((stripe_count2 == stripe_count)) ||
3429 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3431 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3434 $LFS getstripe $file.2
3436 pool=$($LFS getstripe -p $file.2)
3437 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3439 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3442 $LFS getstripe $file.3
3444 stripe_count2=$($LFS getstripe -c $file.3)
3445 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3447 run_test 27U "append pool and stripe count work with composite default layout"
3449 # createtest also checks that device nodes are created and
3450 # then visible correctly (#2091)
3451 test_28() { # bug 2091
3453 $CREATETEST $DIR/d28/ct || error "createtest failed"
3455 run_test 28 "create/mknod/mkdir with bad file types ============"
3458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3460 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3462 stack_trap "restore_opencache"
3465 sync; sleep 1; sync # flush out any dirty pages from previous tests
3472 declare -i LOCKCOUNTORIG=0
3473 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3474 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3476 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3478 declare -i LOCKUNUSEDCOUNTORIG=0
3479 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3480 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3487 declare -i LOCKCOUNTCURRENT=0
3488 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3489 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3492 declare -i LOCKUNUSEDCOUNTCURRENT=0
3493 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3494 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3497 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3498 $LCTL set_param -n ldlm.dump_namespaces ""
3499 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3500 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3501 log "dumped log to $TMP/test_29.dk (bug 5793)"
3504 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3505 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3506 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3507 log "dumped log to $TMP/test_29.dk (bug 5793)"
3511 run_test 29 "IT_GETATTR regression ============================"
3513 test_30a() { # was test_30
3514 cp $(which ls) $DIR || cp /bin/ls $DIR
3515 $DIR/ls / || error "Can't execute binary from lustre"
3518 run_test 30a "execute binary from Lustre (execve) =============="
3521 cp `which ls` $DIR || cp /bin/ls $DIR
3523 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3526 run_test 30b "execute binary from Lustre as non-root ==========="
3528 test_30c() { # b=22376
3529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3531 cp $(which ls) $DIR || cp /bin/ls $DIR
3533 cancel_lru_locks mdc
3534 cancel_lru_locks osc
3535 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3538 run_test 30c "execute binary from Lustre without read perms ===="
3541 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3543 for i in {1..10}; do
3544 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3547 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3548 wait $PID || error "executing dd from Lustre failed"
3554 run_test 30d "execute binary from Lustre while clear locks"
3557 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3558 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3560 run_test 31a "open-unlink file =================================="
3563 touch $DIR/f31 || error "touch $DIR/f31 failed"
3564 ln $DIR/f31 $DIR/f31b || error "ln failed"
3565 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3566 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3568 run_test 31b "unlink file with multiple links while open ======="
3571 touch $DIR/f31 || error "touch $DIR/f31 failed"
3572 ln $DIR/f31 $DIR/f31c || error "ln failed"
3573 multiop_bg_pause $DIR/f31 O_uc ||
3574 error "multiop_bg_pause for $DIR/f31 failed"
3576 $MULTIOP $DIR/f31c Ouc
3577 kill -USR1 $MULTIPID
3580 run_test 31c "open-unlink file with multiple links ============="
3583 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3584 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3586 run_test 31d "remove of open directory ========================="
3588 test_31e() { # bug 2904
3589 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3591 run_test 31e "remove of open non-empty directory ==============="
3593 test_31f() { # bug 4554
3594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3597 test_mkdir $DIR/d31f
3598 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3599 cp /etc/hosts $DIR/d31f
3601 $LFS getstripe $DIR/d31f/hosts
3602 multiop_bg_pause $DIR/d31f D_c || return 1
3605 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3606 test_mkdir $DIR/d31f
3607 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3608 cp /etc/hosts $DIR/d31f
3610 $LFS getstripe $DIR/d31f/hosts
3611 multiop_bg_pause $DIR/d31f D_c || return 1
3614 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3615 wait $MULTIPID || error "first opendir $MULTIPID failed"
3619 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3620 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3623 run_test 31f "remove of open directory with open-unlink file ==="
3626 echo "-- cross directory link --"
3627 test_mkdir -c1 $DIR/${tdir}ga
3628 test_mkdir -c1 $DIR/${tdir}gb
3629 touch $DIR/${tdir}ga/f
3630 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3631 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3632 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3633 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3634 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3636 run_test 31g "cross directory link==============="
3639 echo "-- cross directory link --"
3640 test_mkdir -c1 $DIR/${tdir}
3641 test_mkdir -c1 $DIR/${tdir}/dir
3642 touch $DIR/${tdir}/f
3643 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3644 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3645 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3646 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3647 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3649 run_test 31h "cross directory link under child==============="
3652 echo "-- cross directory link --"
3653 test_mkdir -c1 $DIR/$tdir
3654 test_mkdir -c1 $DIR/$tdir/dir
3655 touch $DIR/$tdir/dir/f
3656 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3657 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3658 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3659 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3660 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3662 run_test 31i "cross directory link under parent==============="
3665 test_mkdir -c1 -p $DIR/$tdir
3666 test_mkdir -c1 -p $DIR/$tdir/dir1
3667 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3668 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3669 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3670 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3673 run_test 31j "link for directory==============="
3676 test_mkdir -c1 -p $DIR/$tdir
3678 touch $DIR/$tdir/exist
3679 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3680 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3681 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3682 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3683 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3684 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3685 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3688 run_test 31k "link to file: the same, non-existing, dir==============="
3694 touch $DIR/d31m2/exist
3695 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3696 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3697 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3698 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3699 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3700 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3703 run_test 31m "link to file: the same, non-existing, dir==============="
3706 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3707 nlink=$(stat --format=%h $DIR/$tfile)
3708 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3710 local cmd="exec $fd<$DIR/$tfile"
3713 trap "eval $cmd" EXIT
3714 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3715 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3716 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3717 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3718 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3721 run_test 31n "check link count of unlinked file"
3724 local tempfile=$(mktemp $1_XXXXXX)
3725 mlink $tempfile $1 2> /dev/null &&
3726 echo "$BASHPID: link $tempfile to $1 succeeded"
3730 test_31o() { # LU-2901
3731 test_mkdir $DIR/$tdir
3732 for LOOP in $(seq 100); do
3733 rm -f $DIR/$tdir/$tfile*
3734 for THREAD in $(seq 8); do
3735 link_one $DIR/$tdir/$tfile.$LOOP &
3738 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3739 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3740 error "$LINKS duplicate links to $tfile.$LOOP" &&
3744 run_test 31o "duplicate hard links with same filename"
3747 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3749 test_mkdir $DIR/$tdir
3750 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3751 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3753 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3754 error "open unlink test1 failed"
3755 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3756 error "open unlink test2 failed"
3758 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3759 error "test1 still exists"
3760 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3761 error "test2 still exists"
3763 run_test 31p "remove of open striped directory"
3766 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3768 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3769 index=$($LFS getdirstripe -i $DIR/$tdir)
3770 [ $index -eq 3 ] || error "first stripe index $index != 3"
3771 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3772 [ $index -eq 1 ] || error "second stripe index $index != 1"
3774 # when "-c <stripe_count>" is set, the number of MDTs specified after
3775 # "-i" should equal to the stripe count
3776 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3778 run_test 31q "create striped directory on specific MDTs"
3782 touch $DIR/$tfile.target
3783 touch $DIR/$tfile.source
3785 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3786 $LCTL set_param fail_loc=0x1419 fail_val=3
3787 cat $DIR/$tfile.target &
3790 # Guarantee open is waiting before we get here
3792 mv $DIR/$tfile.source $DIR/$tfile.target
3796 if [[ $RC -ne 0 ]]; then
3797 error "open with cat failed, rc=$RC"
3800 run_test 31r "open-rename(replace) race"
3802 cleanup_test32_mount() {
3805 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3806 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3807 losetup -d $loopdev || true
3813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3815 echo "== more mountpoints and symlinks ================="
3816 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3817 trap cleanup_test32_mount EXIT
3818 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3819 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3820 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3821 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3822 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3823 cleanup_test32_mount
3825 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3830 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3831 trap cleanup_test32_mount EXIT
3832 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3833 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3834 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3835 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3836 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3837 cleanup_test32_mount
3839 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3844 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3845 trap cleanup_test32_mount EXIT
3846 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3847 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3848 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3849 test_mkdir -p $DIR/$tdir/d2/test_dir
3850 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3851 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3852 cleanup_test32_mount
3854 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3859 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3860 trap cleanup_test32_mount EXIT
3861 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3862 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3863 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3864 test_mkdir -p $DIR/$tdir/d2/test_dir
3865 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3866 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3867 cleanup_test32_mount
3869 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3873 test_mkdir -p $DIR/$tdir/tmp
3874 local tmp_dir=$DIR/$tdir/tmp
3875 ln -s $DIR/$tdir $tmp_dir/symlink11
3876 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3877 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3878 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3880 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3884 test_mkdir -p $DIR/$tdir/tmp
3885 local tmp_dir=$DIR/$tdir/tmp
3886 ln -s $DIR/$tdir $tmp_dir/symlink11
3887 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3888 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3889 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3891 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3894 local tmp_dir=$DIR/$tdir/tmp
3895 test_mkdir -p $tmp_dir
3896 test_mkdir $DIR/${tdir}2
3897 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3898 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3899 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3900 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3901 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3902 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3904 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3907 rm -fr $DIR/$tdir $DIR/${tdir}2
3908 tmp_dir=$DIR/$tdir/tmp
3909 test_mkdir -p $tmp_dir
3910 test_mkdir $DIR/${tdir}2
3911 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3912 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3913 ls $tmp_dir/symlink12 || error "listing symlink12"
3914 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3916 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3921 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3922 trap cleanup_test32_mount EXIT
3923 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3924 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3925 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3926 touch $DIR/$tdir/test_file
3927 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3928 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3929 cleanup_test32_mount
3931 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3936 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3937 trap cleanup_test32_mount EXIT
3938 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3939 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3940 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3941 touch $DIR/$tdir/test_file
3942 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3943 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3944 cleanup_test32_mount
3946 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3952 trap cleanup_test32_mount EXIT
3953 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3954 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3955 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3956 test_mkdir -p $DIR/$tdir/d2
3957 touch $DIR/$tdir/d2/test_file || error "touch failed"
3958 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3959 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3960 cleanup_test32_mount
3962 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3968 trap cleanup_test32_mount EXIT
3969 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3970 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3971 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3972 test_mkdir -p $DIR/$tdir/d2
3973 touch $DIR/$tdir/d2/test_file || error "touch failed"
3974 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3975 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3976 cleanup_test32_mount
3978 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3982 test_mkdir -p $DIR/d32m/tmp
3983 TMP_DIR=$DIR/d32m/tmp
3984 ln -s $DIR $TMP_DIR/symlink11
3985 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3986 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3987 error "symlink11 not a link"
3988 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3989 error "symlink01 not a link"
3991 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3995 test_mkdir -p $DIR/d32n/tmp
3996 TMP_DIR=$DIR/d32n/tmp
3997 ln -s $DIR $TMP_DIR/symlink11
3998 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3999 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4000 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4002 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4006 test_mkdir -p $DIR/d32o/tmp
4007 TMP_DIR=$DIR/d32o/tmp
4008 ln -s $DIR/$tfile $TMP_DIR/symlink12
4009 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4010 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4011 error "symlink12 not a link"
4012 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4013 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4014 error "$DIR/d32o/tmp/symlink12 not file type"
4015 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4016 error "$DIR/d32o/symlink02 not file type"
4018 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4028 test_mkdir -p $DIR/d32p/tmp
4030 TMP_DIR=$DIR/d32p/tmp
4032 ln -s $DIR/$tfile $TMP_DIR/symlink12
4034 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4036 cat $DIR/d32p/tmp/symlink12 ||
4037 error "Can't open $DIR/d32p/tmp/symlink12"
4039 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4042 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4047 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4048 trap cleanup_test32_mount EXIT
4049 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4050 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4051 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4052 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4053 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4054 cleanup_test32_mount
4056 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4061 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4062 trap cleanup_test32_mount EXIT
4063 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4064 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4065 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4066 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4067 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4068 cleanup_test32_mount
4070 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4075 chmod 444 $DIR/$tfile
4076 chown $RUNAS_ID $DIR/$tfile
4078 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4081 run_test 33aa "write file with mode 444 (should return error)"
4085 test_mkdir $DIR/$tdir
4086 chown $RUNAS_ID $DIR/$tdir
4087 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4088 error "$RUNAS create $tdir/$tfile failed"
4089 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4090 error "open RDWR" || true
4092 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4096 test_mkdir $DIR/$tdir
4097 chown $RUNAS_ID $DIR/$tdir
4098 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4100 run_test 33b "test open file with malformed flags (No panic)"
4103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4104 remote_ost_nodsh && skip "remote OST with nodsh"
4112 test_mkdir $DIR/$tdir
4113 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4116 for ostnum in $(seq $OSTCOUNT); do
4117 # test-framework's OST numbering is one-based, while Lustre's
4119 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4120 # check if at least some write_bytes stats are counted
4121 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4122 obdfilter.$ostname.stats |
4123 awk '/^write_bytes/ {print $7}' )
4124 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4125 if (( ${write_bytes:-0} > 0 )); then
4131 $all_zeros || return 0
4134 echo foo > $DIR/$tdir/bar
4138 # Total up write_bytes after writing. We'd better find non-zeros.
4139 for ostnum in $(seq $OSTCOUNT); do
4140 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4141 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4142 obdfilter/$ostname/stats |
4143 awk '/^write_bytes/ {print $7}' )
4144 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4145 if (( ${write_bytes:-0} > 0 )); then
4152 for ostnum in $(seq $OSTCOUNT); do
4153 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4154 echo "Check write_bytes is in obdfilter.*.stats:"
4155 do_facet ost$ostnum lctl get_param -n \
4156 obdfilter.$ostname.stats
4158 error "OST not keeping write_bytes stats (b=22312)"
4161 run_test 33c "test write_bytes stats"
4164 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4168 local remote_dir=$DIR/$tdir/remote_dir
4170 test_mkdir $DIR/$tdir
4171 $LFS mkdir -i $MDTIDX $remote_dir ||
4172 error "create remote directory failed"
4174 touch $remote_dir/$tfile
4175 chmod 444 $remote_dir/$tfile
4176 chown $RUNAS_ID $remote_dir/$tfile
4178 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4180 chown $RUNAS_ID $remote_dir
4181 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4182 error "create" || true
4183 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4184 error "open RDWR" || true
4185 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4187 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4190 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4194 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4195 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4196 mkdir $DIR/$tdir/local_dir
4198 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4199 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4200 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4202 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4203 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4205 rmdir $DIR/$tdir/* || error "rmdir failed"
4208 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4209 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4210 mkdir $DIR/$tdir/local_dir
4212 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4213 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4214 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4216 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4217 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4219 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4222 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4223 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4224 mkdir $DIR/$tdir/local_dir
4226 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4227 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4228 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4230 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4231 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4233 run_test 33e "mkdir and striped directory should have same mode"
4237 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4241 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4242 remote_mds_nodsh && skip "remote MDS with nodsh"
4245 chmod go+rwx $DIR/$tdir
4246 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4247 trap cleanup_33f EXIT
4249 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4250 error "cannot create striped directory"
4252 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4253 error "cannot create files in striped directory"
4255 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4256 error "cannot remove files in striped directory"
4258 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4259 error "cannot remove striped directory"
4263 run_test 33f "nonroot user can create, access, and remove a striped directory"
4266 mkdir -p $DIR/$tdir/dir2
4268 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4270 [[ $err =~ "exists" ]] || error "Not exists error"
4272 run_test 33g "nonroot user create already existing root created file"
4278 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4279 error "lfs mkdir -H $hash_type $tdir failed"
4280 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4282 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4286 for fname in $DIR/$tdir/$tfile.bak \
4287 $DIR/$tdir/$tfile.SAV \
4288 $DIR/$tdir/$tfile.orig \
4289 $DIR/$tdir/$tfile~; do
4290 touch $fname || error "touch $fname failed"
4291 index2=$($LFS getstripe -m $fname)
4292 (( $index == $index2 )) ||
4293 error "$fname MDT index mismatch $index != $index2"
4297 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4300 for pattern in ${patterns[*]}; do
4301 echo "pattern $pattern"
4302 fname=$DIR/$tdir/$pattern
4303 for (( i = 0; i < $count; i++ )); do
4304 fname=$(mktemp $DIR/$tdir/$pattern) ||
4305 error "mktemp $DIR/$tdir/$pattern failed"
4306 index2=$($LFS getstripe -m $fname)
4307 (( $index == $index2 )) && continue
4309 failed=$((failed + 1))
4310 echo "$fname MDT index mismatch $index != $index2"
4314 echo "$failed/$count MDT index mismatches, expect ~2-4"
4315 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4320 # verify that "crush" is still broken with all files on same MDT,
4321 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4322 [[ "$hash_type" == "crush" ]] && expect=$count ||
4323 expect=$((count / MDSCOUNT))
4325 # crush2 doesn't put all-numeric suffixes on the same MDT,
4326 # filename like $tfile.12345678 should *not* be considered temp
4327 for pattern in ${patterns[*]}; do
4328 local base=${pattern%%X*}
4329 local suff=${pattern#$base}
4331 echo "pattern $pattern"
4332 for (( i = 0; i < $count; i++ )); do
4333 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4334 touch $fname || error "touch $fname failed"
4335 index2=$($LFS getstripe -m $fname)
4336 (( $index != $index2 )) && continue
4342 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4343 (( same / ${#patterns[*]} < expect * 5 / 4 &&
4344 same / ${#patterns[*]} > expect * 4 / 5 )) ||
4345 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4348 # crush2 doesn't put suffixes with special characters on the same MDT
4349 # filename like $tfile.txt.1234 should *not* be considered temp
4350 for pattern in ${patterns[*]}; do
4351 local base=${pattern%%X*}
4352 local suff=${pattern#$base}
4354 pattern=$base...${suff/XXX}
4355 echo "pattern=$pattern"
4356 for (( i = 0; i < $count; i++ )); do
4357 fname=$(mktemp $DIR/$tdir/$pattern) ||
4358 error "touch $fname failed"
4359 index2=$($LFS getstripe -m $fname)
4360 (( $index != $index2 )) && continue
4366 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4367 (( same / ${#patterns[*]} < expect * 5 / 4 &&
4368 same / ${#patterns[*]} > expect * 4 / 5 )) ||
4369 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4373 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4374 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4375 skip "Need MDS version at least 2.13.50"
4379 run_test 33h "temp file is located on the same MDT as target (crush)"
4382 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4383 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4384 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4385 skip "Need MDS version at least 2.15.0 for crush2"
4389 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4393 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4395 local FNAME=$(str_repeat 'f' 250)
4397 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4398 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4403 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4405 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4407 lctl --device %$MDC deactivate
4408 stack_trap "lctl --device %$MDC activate"
4409 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4410 total=$(\ls -l $DIR/$tdir | wc -l)
4411 # "ls -l" will list total in the first line
4412 total=$((total - 1))
4413 (( total + count == 1000 )) ||
4414 error "ls list $total files, $count files on MDT1"
4416 run_test 33i "striped directory can be accessed when one MDT is down"
4418 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4421 $MCREATE $DIR/f34 || error "mcreate failed"
4422 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4423 error "getstripe failed"
4424 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4425 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4426 error "getstripe failed"
4427 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4428 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4430 run_test 34a "truncate file that has not been opened ==========="
4433 [ ! -f $DIR/f34 ] && test_34a
4434 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4435 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4436 $OPENFILE -f O_RDONLY $DIR/f34
4437 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4438 error "getstripe failed"
4439 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4440 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4442 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4445 [ ! -f $DIR/f34 ] && test_34a
4446 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4447 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4448 $OPENFILE -f O_RDWR $DIR/f34
4449 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4450 error "$LFS getstripe failed"
4451 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4452 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4454 run_test 34c "O_RDWR opening file-with-size works =============="
4457 [ ! -f $DIR/f34 ] && test_34a
4458 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4460 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4461 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4464 run_test 34d "write to sparse file ============================="
4468 $MCREATE $DIR/f34e || error "mcreate failed"
4469 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4470 $CHECKSTAT -s 1000 $DIR/f34e ||
4471 error "Size of $DIR/f34e not equal to 1000 bytes"
4472 $OPENFILE -f O_RDWR $DIR/f34e
4473 $CHECKSTAT -s 1000 $DIR/f34e ||
4474 error "Size of $DIR/f34e not equal to 1000 bytes"
4476 run_test 34e "create objects, some with size and some without =="
4478 test_34f() { # bug 6242, 6243
4479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4483 $MCREATE $DIR/f34f || error "mcreate failed"
4484 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4485 dd if=$DIR/f34f of=$TMP/f34f
4486 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4487 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4488 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4489 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4490 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4492 run_test 34f "read from a file with no objects until EOF ======="
4495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4497 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4499 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4500 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4501 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4502 cancel_lru_locks osc
4503 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4504 error "wrong size after lock cancel"
4506 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4507 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4508 error "expanding truncate failed"
4509 cancel_lru_locks osc
4510 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4511 error "wrong expanded size after lock cancel"
4513 run_test 34g "truncate long file ==============================="
4516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4521 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4522 sync # Flush the cache so that multiop below does not block on cache
4523 # flush when getting the group lock
4524 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4527 # Since just timed wait is not good enough, let's do a sync write
4528 # that way we are sure enough time for a roundtrip + processing
4529 # passed + 2 seconds of extra margin.
4530 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4534 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4535 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4539 local nsz=`stat -c %s $DIR/$tfile`
4540 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4542 run_test 34h "ftruncate file under grouplock should not block"
4545 cp /bin/sh $DIR/f35a
4547 chown $RUNAS_ID $DIR/f35a
4548 $RUNAS $DIR/f35a && error || true
4551 run_test 35a "exec file with mode 444 (should return and not leak)"
4555 utime $DIR/f36 || error "utime failed for MDS"
4557 run_test 36a "MDS utime check (mknod, utime)"
4561 utime $DIR/f36 || error "utime failed for OST"
4563 run_test 36b "OST utime check (open, utime)"
4568 chown $RUNAS_ID $DIR/d36
4569 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4571 run_test 36c "non-root MDS utime check (mknod, utime)"
4574 [ ! -d $DIR/d36 ] && test_36c
4575 echo "" > $DIR/d36/f36
4576 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4578 run_test 36d "non-root OST utime check (open, utime)"
4581 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4583 test_mkdir $DIR/$tdir
4584 touch $DIR/$tdir/$tfile
4585 $RUNAS utime $DIR/$tdir/$tfile &&
4586 error "utime worked, expected failure" || true
4588 run_test 36e "utime on non-owned file (should return error)"
4592 local LANG_SAVE=$LANG
4593 local LC_LANG_SAVE=$LC_LANG
4594 export LANG=C LC_LANG=C # for date language
4596 DATESTR="Dec 20 2000"
4597 test_mkdir $DIR/$tdir
4598 lctl set_param fail_loc=$fl
4600 cp /etc/hosts $DIR/$tdir/$tfile
4601 sync & # write RPC generated with "current" inode timestamp, but delayed
4603 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4604 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4605 cancel_lru_locks $OSC
4606 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4608 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4609 echo "BEFORE: $LS_BEFORE" && \
4610 echo "AFTER : $LS_AFTER" && \
4611 echo "WANT : $DATESTR" && \
4612 error "$DIR/$tdir/$tfile timestamps changed" || true
4614 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4620 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4621 subr_36fh "0x80000214"
4623 run_test 36f "utime on file racing with OST BRW write =========="
4626 remote_ost_nodsh && skip "remote OST with nodsh"
4627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4628 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4629 skip "Need MDS version at least 2.12.51"
4634 local tgt="obdfilter"
4636 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4638 test_mkdir $DIR/$tdir
4639 fmd_max_age=$(do_facet $facet \
4640 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4643 echo "FMD max age: ${fmd_max_age}s"
4644 touch $DIR/$tdir/$tfile
4645 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4646 gawk '{cnt=cnt+$1} END{print cnt}')
4647 echo "FMD before: $fmd"
4649 error "FMD wasn't create by touch"
4650 sleep $((fmd_max_age + 12))
4651 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4652 gawk '{cnt=cnt+$1} END{print cnt}')
4653 echo "FMD after: $fmd"
4655 error "FMD wasn't expired by ping"
4657 run_test 36g "FMD cache expiry ====================="
4660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4662 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4663 subr_36fh "0x80000227"
4665 run_test 36h "utime on file racing with OST BRW write =========="
4668 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4670 test_mkdir $DIR/$tdir
4671 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4673 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4674 local new_mtime=$((mtime + 200))
4676 #change Modify time of striped dir
4677 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4678 error "change mtime failed"
4680 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4682 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4684 run_test 36i "change mtime on striped directory"
4686 # test_37 - duplicate with tests 32q 32r
4689 local file=$DIR/$tfile
4691 openfile -f O_DIRECTORY $file
4694 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4695 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4697 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4699 test_39a() { # was test_39
4701 touch $DIR/${tfile}2
4702 # ls -l $DIR/$tfile $DIR/${tfile}2
4703 # ls -lu $DIR/$tfile $DIR/${tfile}2
4704 # ls -lc $DIR/$tfile $DIR/${tfile}2
4706 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4707 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4709 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4711 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4713 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4714 error "O_TRUNC didn't change timestamps"
4717 run_test 39a "mtime changed on create"
4720 test_mkdir -c1 $DIR/$tdir
4721 cp -p /etc/passwd $DIR/$tdir/fopen
4722 cp -p /etc/passwd $DIR/$tdir/flink
4723 cp -p /etc/passwd $DIR/$tdir/funlink
4724 cp -p /etc/passwd $DIR/$tdir/frename
4725 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4728 echo "aaaaaa" >> $DIR/$tdir/fopen
4729 echo "aaaaaa" >> $DIR/$tdir/flink
4730 echo "aaaaaa" >> $DIR/$tdir/funlink
4731 echo "aaaaaa" >> $DIR/$tdir/frename
4733 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4734 local link_new=`stat -c %Y $DIR/$tdir/flink`
4735 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4736 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4738 cat $DIR/$tdir/fopen > /dev/null
4739 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4740 rm -f $DIR/$tdir/funlink2
4741 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4743 for (( i=0; i < 2; i++ )) ; do
4744 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4745 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4746 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4747 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4749 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4750 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4751 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4752 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4754 cancel_lru_locks $OSC
4755 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4758 run_test 39b "mtime change on open, link, unlink, rename ======"
4760 # this should be set to past
4761 TEST_39_MTIME=`date -d "1 year ago" +%s`
4767 local mtime0=`stat -c %Y $DIR1/$tfile`
4769 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4770 local mtime1=`stat -c %Y $DIR1/$tfile`
4771 [ "$mtime1" = $TEST_39_MTIME ] || \
4772 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4775 echo hello >> $DIR1/$tfile
4777 local mtime2=`stat -c %Y $DIR1/$tfile`
4778 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4779 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4781 mv $DIR1/$tfile $DIR1/$tfile-1
4783 for (( i=0; i < 2; i++ )) ; do
4784 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4785 [ "$mtime2" = "$mtime3" ] || \
4786 error "mtime ($mtime2) changed (to $mtime3) on rename"
4788 cancel_lru_locks $OSC
4789 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4792 run_test 39c "mtime change on rename ==========================="
4796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4799 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4801 for (( i=0; i < 2; i++ )) ; do
4802 local mtime=`stat -c %Y $DIR1/$tfile`
4803 [ $mtime = $TEST_39_MTIME ] || \
4804 error "mtime($mtime) is not set to $TEST_39_MTIME"
4806 cancel_lru_locks $OSC
4807 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4810 run_test 39d "create, utime, stat =============================="
4814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4817 local mtime1=`stat -c %Y $DIR1/$tfile`
4819 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4821 for (( i=0; i < 2; i++ )) ; do
4822 local mtime2=`stat -c %Y $DIR1/$tfile`
4823 [ $mtime2 = $TEST_39_MTIME ] || \
4824 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4826 cancel_lru_locks $OSC
4827 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4830 run_test 39e "create, stat, utime, stat ========================"
4834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4837 mtime1=`stat -c %Y $DIR1/$tfile`
4840 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4842 for (( i=0; i < 2; i++ )) ; do
4843 local mtime2=`stat -c %Y $DIR1/$tfile`
4844 [ $mtime2 = $TEST_39_MTIME ] || \
4845 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4847 cancel_lru_locks $OSC
4848 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4851 run_test 39f "create, stat, sleep, utime, stat ================="
4855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4857 echo hello >> $DIR1/$tfile
4858 local mtime1=`stat -c %Y $DIR1/$tfile`
4861 chmod o+r $DIR1/$tfile
4863 for (( i=0; i < 2; i++ )) ; do
4864 local mtime2=`stat -c %Y $DIR1/$tfile`
4865 [ "$mtime1" = "$mtime2" ] || \
4866 error "lost mtime: $mtime2, should be $mtime1"
4868 cancel_lru_locks $OSC
4869 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4872 run_test 39g "write, chmod, stat ==============================="
4876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4882 echo hello >> $DIR1/$tfile
4883 local mtime1=`stat -c %Y $DIR1/$tfile`
4885 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4887 if [ "$d1" != "$d2" ]; then
4888 echo "write and touch not within one second"
4890 for (( i=0; i < 2; i++ )) ; do
4891 local mtime2=`stat -c %Y $DIR1/$tfile`
4892 [ "$mtime2" = $TEST_39_MTIME ] || \
4893 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4895 cancel_lru_locks $OSC
4896 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4900 run_test 39h "write, utime within one second, stat ============="
4903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4908 echo hello >> $DIR1/$tfile
4909 local mtime1=`stat -c %Y $DIR1/$tfile`
4911 mv $DIR1/$tfile $DIR1/$tfile-1
4913 for (( i=0; i < 2; i++ )) ; do
4914 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4916 [ "$mtime1" = "$mtime2" ] || \
4917 error "lost mtime: $mtime2, should be $mtime1"
4919 cancel_lru_locks $OSC
4920 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4923 run_test 39i "write, rename, stat =============================="
4926 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4928 start_full_debug_logging
4932 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4933 lctl set_param fail_loc=0x80000412
4934 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4935 error "multiop failed"
4937 local mtime1=`stat -c %Y $DIR1/$tfile`
4939 mv $DIR1/$tfile $DIR1/$tfile-1
4941 kill -USR1 $multipid
4942 wait $multipid || error "multiop close failed"
4944 for (( i=0; i < 2; i++ )) ; do
4945 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4946 [ "$mtime1" = "$mtime2" ] ||
4947 error "mtime is lost on close: $mtime2, " \
4951 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4953 lctl set_param fail_loc=0
4954 stop_full_debug_logging
4956 run_test 39j "write, rename, close, stat ======================="
4959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4964 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4966 local mtime1=`stat -c %Y $DIR1/$tfile`
4968 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4970 kill -USR1 $multipid
4971 wait $multipid || error "multiop close failed"
4973 for (( i=0; i < 2; i++ )) ; do
4974 local mtime2=`stat -c %Y $DIR1/$tfile`
4976 [ "$mtime2" = $TEST_39_MTIME ] || \
4977 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4980 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4983 run_test 39k "write, utime, close, stat ========================"
4985 # this should be set to future
4986 TEST_39_ATIME=`date -d "1 year" +%s`
4989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4990 remote_mds_nodsh && skip "remote MDS with nodsh"
4992 local atime_diff=$(do_facet $SINGLEMDS \
4993 lctl get_param -n mdd.*MDT0000*.atime_diff)
4995 mkdir_on_mdt0 $DIR/$tdir
4997 # test setting directory atime to future
4998 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4999 local atime=$(stat -c %X $DIR/$tdir)
5000 [ "$atime" = $TEST_39_ATIME ] ||
5001 error "atime is not set to future: $atime, $TEST_39_ATIME"
5003 # test setting directory atime from future to now
5004 local now=$(date +%s)
5005 touch -a -d @$now $DIR/$tdir
5007 atime=$(stat -c %X $DIR/$tdir)
5008 [ "$atime" -eq "$now" ] ||
5009 error "atime is not updated from future: $atime, $now"
5011 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5014 # test setting directory atime when now > dir atime + atime_diff
5015 local d1=$(date +%s)
5017 local d2=$(date +%s)
5018 cancel_lru_locks mdc
5019 atime=$(stat -c %X $DIR/$tdir)
5020 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5021 error "atime is not updated : $atime, should be $d2"
5023 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5026 # test not setting directory atime when now < dir atime + atime_diff
5028 cancel_lru_locks mdc
5029 atime=$(stat -c %X $DIR/$tdir)
5030 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5031 error "atime is updated to $atime, should remain $d1<atime<$d2"
5033 do_facet $SINGLEMDS \
5034 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5036 run_test 39l "directory atime update ==========================="
5039 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5043 local far_past_mtime=$(date -d "May 29 1953" +%s)
5044 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5046 touch -m -d @$far_past_mtime $DIR1/$tfile
5047 touch -a -d @$far_past_atime $DIR1/$tfile
5049 for (( i=0; i < 2; i++ )) ; do
5050 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5051 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5052 error "atime or mtime set incorrectly"
5054 cancel_lru_locks $OSC
5055 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5058 run_test 39m "test atime and mtime before 1970"
5060 test_39n() { # LU-3832
5061 remote_mds_nodsh && skip "remote MDS with nodsh"
5063 local atime_diff=$(do_facet $SINGLEMDS \
5064 lctl get_param -n mdd.*MDT0000*.atime_diff)
5069 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5072 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5073 atime0=$(stat -c %X $DIR/$tfile)
5076 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5077 atime1=$(stat -c %X $DIR/$tfile)
5080 cancel_lru_locks mdc
5081 cancel_lru_locks osc
5082 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5083 atime2=$(stat -c %X $DIR/$tfile)
5085 do_facet $SINGLEMDS \
5086 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5088 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5089 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5091 run_test 39n "check that O_NOATIME is honored"
5094 TESTDIR=$DIR/$tdir/$tfile
5095 [ -e $TESTDIR ] && rm -rf $TESTDIR
5102 links2=$(stat -c %h .)
5103 [ $(($links1 + 2)) != $links2 ] &&
5104 error "wrong links count $(($links1 + 2)) != $links2"
5106 links3=$(stat -c %h .)
5107 [ $(($links1 + 1)) != $links3 ] &&
5108 error "wrong links count $links1 != $links3"
5111 run_test 39o "directory cached attributes updated after create"
5114 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5117 TESTDIR=$DIR/$tdir/$tdir
5118 [ -e $TESTDIR ] && rm -rf $TESTDIR
5119 test_mkdir -p $TESTDIR
5123 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5124 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5126 links2=$(stat -c %h .)
5127 [ $(($links1 + 2)) != $links2 ] &&
5128 error "wrong links count $(($links1 + 2)) != $links2"
5130 links3=$(stat -c %h .)
5131 [ $(($links1 + 1)) != $links3 ] &&
5132 error "wrong links count $links1 != $links3"
5135 run_test 39p "remote directory cached attributes updated after create ========"
5138 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5139 skip "no atime update on old OST"
5140 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5141 skip_env "ldiskfs only test"
5145 saved_adiff=$(do_facet ost1 \
5146 lctl get_param -n obdfilter.*OST0000.atime_diff)
5147 stack_trap "do_facet ost1 \
5148 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5150 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5152 $LFS setstripe -i 0 $DIR/$tfile
5153 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5154 error "can't write initial file"
5155 cancel_lru_locks osc
5157 # exceed atime_diff and access file
5159 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5160 error "can't udpate atime"
5162 local atime_cli=$(stat -c %X $DIR/$tfile)
5163 echo "client atime: $atime_cli"
5164 # allow atime update to be written to device
5165 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5168 local ostdev=$(ostdevname 1)
5169 local fid=($(lfs getstripe -y $DIR/$tfile |
5170 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
5171 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
5172 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5174 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5175 local atime_ost=$(do_facet ost1 "$cmd" |&
5176 awk -F'[: ]' '/atime:/ { print $4 }')
5177 (( atime_cli == atime_ost )) ||
5178 error "atime on client $atime_cli != ost $atime_ost"
5180 run_test 39r "lazy atime update on OST"
5182 test_39q() { # LU-8041
5183 local testdir=$DIR/$tdir
5185 multiop_bg_pause $testdir D_c || error "multiop failed"
5187 cancel_lru_locks mdc
5188 kill -USR1 $multipid
5189 local atime=$(stat -c %X $testdir)
5190 [ "$atime" -ne 0 ] || error "atime is zero"
5192 run_test 39q "close won't zero out atime"
5195 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5196 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5197 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5198 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5199 error "$tfile is not 4096 bytes in size"
5201 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5205 small_write $DIR/f41 18
5207 run_test 41 "test small file write + fstat ====================="
5209 count_ost_writes() {
5210 lctl get_param -n ${OSC}.*.stats |
5211 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5212 END { printf("%0.0f", writes) }'
5219 BG_DIRTY_RATIO_SAVE=10
5220 MAX_BG_DIRTY_RATIO=25
5224 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5225 # dirty_ratio, dirty_background_ratio
5226 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5227 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5228 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5229 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5231 # if file not here, we are a 2.4 kernel
5232 kill -CONT `pidof kupdated`
5237 # setup the trap first, so someone cannot exit the test at the
5238 # exact wrong time and mess up a machine
5239 trap start_writeback EXIT
5240 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5241 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5242 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5243 sysctl -w vm.dirty_writeback_centisecs=0
5244 sysctl -w vm.dirty_writeback_centisecs=0
5245 # save and increase /proc/sys/vm/dirty_ratio
5246 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5247 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5248 # save and increase /proc/sys/vm/dirty_background_ratio
5249 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5250 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5252 # if file not here, we are a 2.4 kernel
5253 kill -STOP `pidof kupdated`
5257 # ensure that all stripes have some grant before we test client-side cache
5259 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5260 dd if=/dev/zero of=$i bs=4k count=1
5265 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5266 # file truncation, and file removal.
5268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5271 cancel_lru_locks $OSC
5273 sync; sleep 1; sync # just to be safe
5274 BEFOREWRITES=`count_ost_writes`
5275 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5276 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5277 AFTERWRITES=`count_ost_writes`
5278 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5279 error "$BEFOREWRITES < $AFTERWRITES"
5282 run_test 42a "ensure that we don't flush on close"
5285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5288 cancel_lru_locks $OSC
5291 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5292 BEFOREWRITES=$(count_ost_writes)
5293 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5294 AFTERWRITES=$(count_ost_writes)
5295 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5296 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5298 BEFOREWRITES=$(count_ost_writes)
5299 sync || error "sync: $?"
5300 AFTERWRITES=$(count_ost_writes)
5301 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5302 error "$BEFOREWRITES < $AFTERWRITES on sync"
5304 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5308 run_test 42b "test destroy of file with cached dirty data ======"
5310 # if these tests just want to test the effect of truncation,
5311 # they have to be very careful. consider:
5312 # - the first open gets a {0,EOF}PR lock
5313 # - the first write conflicts and gets a {0, count-1}PW
5314 # - the rest of the writes are under {count,EOF}PW
5315 # - the open for truncate tries to match a {0,EOF}PR
5316 # for the filesize and cancels the PWs.
5317 # any number of fixes (don't get {0,EOF} on open, match
5318 # composite locks, do smarter file size management) fix
5319 # this, but for now we want these tests to verify that
5320 # the cancellation with truncate intent works, so we
5321 # start the file with a full-file pw lock to match against
5322 # until the truncate.
5327 cancel_lru_locks $OSC
5329 # prime the file with 0,EOF PW to match
5333 # now the real test..
5334 dd if=/dev/zero of=$file bs=1024 count=100
5335 BEFOREWRITES=`count_ost_writes`
5336 $TRUNCATE $file $offset
5337 cancel_lru_locks $OSC
5338 AFTERWRITES=`count_ost_writes`
5343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5346 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5347 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5350 run_test 42c "test partial truncate of file with cached dirty data"
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5355 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5356 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5357 $LCTL set_param debug=+cache
5360 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5361 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5364 run_test 42d "test complete truncate of file with cached dirty data"
5366 test_42e() { # bug22074
5367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5369 local TDIR=$DIR/${tdir}e
5370 local pages=16 # hardcoded 16 pages, don't change it.
5371 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5372 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5376 test_mkdir $DIR/${tdir}e
5377 $LFS setstripe -c 1 $TDIR
5378 createmany -o $TDIR/f $files
5380 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5382 # we assume that with $OSTCOUNT files, at least one of them will
5383 # be allocated on OST0.
5384 warmup_files=$((OSTCOUNT * max_dirty_mb))
5385 createmany -o $TDIR/w $warmup_files
5387 # write a large amount of data into one file and sync, to get good
5388 # avail_grant number from OST.
5389 for ((i=0; i<$warmup_files; i++)); do
5390 idx=$($LFS getstripe -i $TDIR/w$i)
5391 [ $idx -ne 0 ] && continue
5392 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5395 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5397 $LCTL get_param $proc_osc0/cur_dirty_bytes
5398 $LCTL get_param $proc_osc0/cur_grant_bytes
5400 # create as much dirty pages as we can while not to trigger the actual
5401 # RPCs directly. but depends on the env, VFS may trigger flush during this
5402 # period, hopefully we are good.
5403 for ((i=0; i<$warmup_files; i++)); do
5404 idx=$($LFS getstripe -i $TDIR/w$i)
5405 [ $idx -ne 0 ] && continue
5406 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5408 $LCTL get_param $proc_osc0/cur_dirty_bytes
5409 $LCTL get_param $proc_osc0/cur_grant_bytes
5411 # perform the real test
5412 $LCTL set_param $proc_osc0/rpc_stats 0
5413 for ((;i<$files; i++)); do
5414 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5415 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5418 $LCTL get_param $proc_osc0/rpc_stats
5421 local have_ppr=false
5422 $LCTL get_param $proc_osc0/rpc_stats |
5423 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5424 # skip lines until we are at the RPC histogram data
5425 [ "$PPR" == "pages" ] && have_ppr=true && continue
5426 $have_ppr || continue
5428 # we only want the percent stat for < 16 pages
5429 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5431 percent=$((percent + WPCT))
5432 if [[ $percent -gt 15 ]]; then
5433 error "less than 16-pages write RPCs" \
5440 run_test 42e "verify sub-RPC writes are not done synchronously"
5442 test_43A() { # was test_43
5443 test_mkdir $DIR/$tdir
5444 cp -p /bin/ls $DIR/$tdir/$tfile
5445 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5447 # give multiop a chance to open
5450 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5452 # Wait for multiop to exit
5455 run_test 43A "execution of file opened for write should return -ETXTBSY"
5458 test_mkdir $DIR/$tdir
5459 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5460 $DIR/$tdir/sleep 60 &
5462 # Make sure exec of $tdir/sleep wins race with truncate
5464 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5467 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5470 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5472 test_mkdir $DIR/$tdir
5473 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5474 $DIR/$tdir/sleep 60 &
5476 # Make sure exec of $tdir/sleep wins race with truncate
5478 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5481 run_test 43b "truncate of file being executed should return -ETXTBSY"
5484 local testdir="$DIR/$tdir"
5487 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5488 ( cd $testdir && md5sum -c )
5490 run_test 43c "md5sum of copy into lustre"
5492 test_44A() { # was test_44
5493 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5495 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5496 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5498 run_test 44A "zero length read from a sparse stripe"
5501 local nstripe=$($LFS getstripe -c -d $DIR)
5502 [ -z "$nstripe" ] && skip "can't get stripe info"
5503 [[ $nstripe -gt $OSTCOUNT ]] &&
5504 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5506 local stride=$($LFS getstripe -S -d $DIR)
5507 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5508 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5511 OFFSETS="0 $((stride/2)) $((stride-1))"
5512 for offset in $OFFSETS; do
5513 for i in $(seq 0 $((nstripe-1))); do
5514 local GLOBALOFFSETS=""
5516 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5517 local myfn=$DIR/d44a-$size
5518 echo "--------writing $myfn at $size"
5519 ll_sparseness_write $myfn $size ||
5520 error "ll_sparseness_write"
5521 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5522 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5523 error "ll_sparseness_verify $GLOBALOFFSETS"
5525 for j in $(seq 0 $((nstripe-1))); do
5527 size=$((((j + $nstripe )*$stride + $offset)))
5528 ll_sparseness_write $myfn $size ||
5529 error "ll_sparseness_write"
5530 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5532 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5533 error "ll_sparseness_verify $GLOBALOFFSETS"
5538 run_test 44a "test sparse pwrite ==============================="
5542 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5548 before=`dirty_osc_total`
5549 echo executing "\"$*\""
5551 after=`dirty_osc_total`
5552 echo before $before, after $after
5555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5558 # Obtain grants from OST if it supports it
5559 echo blah > ${f}_grant
5562 do_dirty_record "echo blah > $f"
5563 [[ $before -eq $after ]] && error "write wasn't cached"
5564 do_dirty_record "> $f"
5565 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5566 do_dirty_record "echo blah > $f"
5567 [[ $before -eq $after ]] && error "write wasn't cached"
5568 do_dirty_record "sync"
5569 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5570 do_dirty_record "echo blah > $f"
5571 [[ $before -eq $after ]] && error "write wasn't cached"
5572 do_dirty_record "cancel_lru_locks osc"
5573 [[ $before -gt $after ]] ||
5574 error "lock cancellation didn't lower dirty count"
5577 run_test 45 "osc io page accounting ============================"
5579 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5580 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5581 # objects offset and an assert hit when an rpc was built with 1023's mapped
5582 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5589 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5591 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5592 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5596 run_test 46 "dirtying a previously written page ================"
5598 # test_47 is removed "Device nodes check" is moved to test_28
5600 test_48a() { # bug 2399
5601 [ "$mds1_FSTYPE" = "zfs" ] &&
5602 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5603 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5605 test_mkdir $DIR/$tdir
5607 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5608 test_mkdir $DIR/$tdir
5609 touch foo || error "'touch foo' failed after recreating cwd"
5611 touch .foo || error "'touch .foo' failed after recreating cwd"
5613 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5614 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5615 cd . || error "'cd .' failed after recreating cwd"
5616 mkdir . && error "'mkdir .' worked after recreating cwd"
5617 rmdir . && error "'rmdir .' worked after recreating cwd"
5618 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5619 cd .. || error "'cd ..' failed after recreating cwd"
5621 run_test 48a "Access renamed working dir (should return errors)="
5623 test_48b() { # bug 2399
5625 test_mkdir $DIR/$tdir
5627 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5628 touch foo && error "'touch foo' worked after removing cwd"
5629 mkdir foo && error "'mkdir foo' worked after removing cwd"
5630 touch .foo && error "'touch .foo' worked after removing cwd"
5631 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5632 ls . > /dev/null && error "'ls .' worked after removing cwd"
5633 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5634 mkdir . && error "'mkdir .' worked after removing cwd"
5635 rmdir . && error "'rmdir .' worked after removing cwd"
5636 ln -s . foo && error "'ln -s .' worked after removing cwd"
5637 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5639 run_test 48b "Access removed working dir (should return errors)="
5641 test_48c() { # bug 2350
5642 #lctl set_param debug=-1
5645 test_mkdir -p $DIR/$tdir/dir
5647 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5648 $TRACE touch foo && error "touch foo worked after removing cwd"
5649 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5650 touch .foo && error "touch .foo worked after removing cwd"
5651 mkdir .foo && error "mkdir .foo worked after removing cwd"
5652 $TRACE ls . && error "'ls .' worked after removing cwd"
5653 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5654 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5655 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5656 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5657 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5659 run_test 48c "Access removed working subdir (should return errors)"
5661 test_48d() { # bug 2350
5662 #lctl set_param debug=-1
5665 test_mkdir -p $DIR/$tdir/dir
5667 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5668 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5669 $TRACE touch foo && error "'touch foo' worked after removing parent"
5670 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5671 touch .foo && error "'touch .foo' worked after removing parent"
5672 mkdir .foo && error "mkdir .foo worked after removing parent"
5673 $TRACE ls . && error "'ls .' worked after removing parent"
5674 $TRACE ls .. && error "'ls ..' worked after removing parent"
5675 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5676 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5677 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5680 run_test 48d "Access removed parent subdir (should return errors)"
5682 test_48e() { # bug 4134
5683 #lctl set_param debug=-1
5686 test_mkdir -p $DIR/$tdir/dir
5688 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5689 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5690 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5691 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5692 # On a buggy kernel addition of "touch foo" after cd .. will
5693 # produce kernel oops in lookup_hash_it
5694 touch ../foo && error "'cd ..' worked after recreate parent"
5696 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5698 run_test 48e "Access to recreated parent subdir (should return errors)"
5701 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5702 skip "need MDS >= 2.13.55"
5703 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5704 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5705 skip "needs different host for mdt1 mdt2"
5706 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5708 $LFS mkdir -i0 $DIR/$tdir
5709 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5711 for d in sub1 sub2 sub3; do
5712 #define OBD_FAIL_OSD_REF_DEL 0x19c
5713 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5714 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5717 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5719 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5721 test_49() { # LU-1030
5722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5723 remote_ost_nodsh && skip "remote OST with nodsh"
5725 # get ost1 size - $FSNAME-OST0000
5726 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5728 # write 800M at maximum
5729 [[ $ost1_size -lt 2 ]] && ost1_size=2
5730 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5732 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5733 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5736 # change max_pages_per_rpc while writing the file
5737 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5738 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5739 # loop until dd process exits
5740 while ps ax -opid | grep -wq $dd_pid; do
5741 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5742 sleep $((RANDOM % 5 + 1))
5744 # restore original max_pages_per_rpc
5745 $LCTL set_param $osc1_mppc=$orig_mppc
5746 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5748 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5752 test_mkdir $DIR/$tdir
5754 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5756 run_test 50 "special situations: /proc symlinks ==============="
5758 test_51a() { # was test_51
5759 # bug 1516 - create an empty entry right after ".." then split dir
5760 test_mkdir -c1 $DIR/$tdir
5761 touch $DIR/$tdir/foo
5762 $MCREATE $DIR/$tdir/bar
5764 createmany -m $DIR/$tdir/longfile 201
5766 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5767 $MCREATE $DIR/$tdir/longfile$FNUM
5772 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5774 run_test 51a "special situations: split htree with empty entry =="
5776 cleanup_print_lfs_df () {
5783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5785 local dir=$DIR/$tdir
5786 local nrdirs=$((65536 + 100))
5788 # cleanup the directory
5791 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5795 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5796 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5797 [[ $numfree -lt $nrdirs ]] &&
5798 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5800 # need to check free space for the directories as well
5801 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5802 numfree=$(( blkfree / $(fs_inode_ksize) ))
5803 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5805 trap cleanup_print_lfs_df EXIT
5808 createmany -d $dir/d $nrdirs || {
5809 unlinkmany $dir/d $nrdirs
5810 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5814 nrdirs=$(ls -U $dir | wc -l)
5816 # unlink all but 100 subdirectories, then check it still works
5818 local delete=$((nrdirs - left))
5823 # for ldiskfs the nlink count should be 1, but this is OSD specific
5824 # and so this is listed for informational purposes only
5825 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5826 unlinkmany -d $dir/d $delete ||
5827 error "unlink of first $delete subdirs failed"
5829 echo "nlink between: $(stat -c %h $dir)"
5830 local found=$(ls -U $dir | wc -l)
5831 [ $found -ne $left ] &&
5832 error "can't find subdirs: found only $found, expected $left"
5834 unlinkmany -d $dir/d $delete $left ||
5835 error "unlink of second $left subdirs failed"
5836 # regardless of whether the backing filesystem tracks nlink accurately
5837 # or not, the nlink count shouldn't be more than "." and ".." here
5838 local after=$(stat -c %h $dir)
5839 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5840 echo "nlink after: $after"
5842 cleanup_print_lfs_df
5844 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5847 local stripecount=$1
5850 log "create files with stripecount=$stripecount"
5851 $LFS setstripe -C $stripecount $DIR/$tdir
5852 createmany -o $DIR/$tdir/t- $nfiles
5853 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5854 for ((n = 0; n < $OSTCOUNT; n++)); do
5855 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5856 END { printf("%0.0f", objs) }' $TMP/$tfile)
5857 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5858 '($1 == '$n') { objs += 1 } \
5859 END { printf("%0.0f", objs) }')
5860 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5862 unlinkmany $DIR/$tdir/t- $nfiles
5867 local max=6 # allow variance of (1 - $min/$max) = 33% by default
5869 # For some combinations of stripecount and OSTCOUNT current code
5870 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
5871 # than others. Rather than skipping this test entirely, check that
5872 # and keep testing to ensure imbalance does not get worse. LU-15282
5873 (( (OSTCOUNT == 6 && stripecount == 4) ||
5874 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
5875 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
5876 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
5877 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5878 { $LFS df && $LFS df -i &&
5879 error "stripecount=$stripecount: " \
5880 "OST $n has fewer objects vs. OST $nlast " \
5881 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
5882 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5883 { $LFS df && $LFS df -i &&
5884 error "stripecount=$stripecount: " \
5885 "OST $n has more objects vs. OST $nlast " \
5886 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
5888 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
5889 { $LFS df && $LFS df -i &&
5890 error "stripecount=$stripecount: " \
5891 "OST $n has fewer #0 objects vs. OST $nlast " \
5892 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
5893 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
5894 { $LFS df && $LFS df -i &&
5895 error "stripecount=$stripecount: " \
5896 "OST $n has more #0 objects vs. OST $nlast " \
5897 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
5902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5903 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5907 local nfiles=$((per_ost * OSTCOUNT))
5908 local mdts=$(comma_list $(mdts_nodes))
5909 local param="osp.*.create_count"
5910 local qos_old=$(do_facet mds1 \
5911 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
5914 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
5915 stack_trap "do_nodes $mdts \
5916 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
5918 test_mkdir $DIR/$tdir
5919 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
5920 (( dirstripes > 0 )) || dirstripes=1
5922 # Ensure enough OST objects precreated for tests to pass without
5923 # running out of objects. This is an LOV r-r OST algorithm test,
5924 # not an OST object precreation test.
5925 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
5926 (( old >= nfiles )) ||
5928 local create_count=$((nfiles * OSTCOUNT / dirstripes))
5930 do_nodes $mdts "$LCTL set_param $param=$create_count"
5931 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
5933 # trigger precreation from all MDTs for all OSTs
5934 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
5935 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
5939 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
5940 sleep 8 # allow object precreation to catch up
5941 test_51d_sub $stripecount $nfiles
5944 run_test 51d "check LOV round-robin OST object distribution"
5947 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5948 skip_env "ldiskfs only test"
5951 test_mkdir -c1 $DIR/$tdir
5952 test_mkdir -c1 $DIR/$tdir/d0
5954 touch $DIR/$tdir/d0/foo
5955 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5956 error "file exceed 65000 nlink limit!"
5957 unlinkmany $DIR/$tdir/d0/f- 65001
5960 run_test 51e "check file nlink limit"
5963 test_mkdir $DIR/$tdir
5966 local ulimit_old=$(ulimit -n)
5967 local spare=20 # number of spare fd's for scripts/libraries, etc.
5968 local mdt=$($LFS getstripe -m $DIR/$tdir)
5969 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5971 echo "MDT$mdt numfree=$numfree, max=$max"
5972 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5973 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5974 while ! ulimit -n $((numfree + spare)); do
5975 numfree=$((numfree * 3 / 4))
5977 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5979 echo "left ulimit at $ulimit_old"
5982 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5983 unlinkmany $DIR/$tdir/f $numfree
5984 error "create+open $numfree files in $DIR/$tdir failed"
5986 ulimit -n $ulimit_old
5988 # if createmany exits at 120s there will be fewer than $numfree files
5989 unlinkmany $DIR/$tdir/f $numfree || true
5991 run_test 51f "check many open files limit"
5994 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5995 test_mkdir $DIR/$tdir
5996 touch $DIR/$tdir/foo
5997 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5998 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5999 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6000 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6001 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6003 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6004 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6005 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6007 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6008 cp -r $DIR/$tdir $TMP/
6009 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6011 run_test 52a "append-only flag test (should return errors)"
6014 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6015 test_mkdir $DIR/$tdir
6016 touch $DIR/$tdir/foo
6017 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6018 cat test > $DIR/$tdir/foo && error "cat test worked"
6019 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6020 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6021 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6023 echo foo >> $DIR/$tdir/foo && error "echo worked"
6024 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6025 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6026 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6027 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6029 chattr -i $DIR/$tdir/foo || error "chattr failed"
6031 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6033 run_test 52b "immutable flag test (should return errors) ======="
6036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6037 remote_mds_nodsh && skip "remote MDS with nodsh"
6038 remote_ost_nodsh && skip "remote OST with nodsh"
6051 local support_last_seq=true
6053 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6054 support_last_seq=false
6057 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6059 for value in $(do_facet $SINGLEMDS \
6060 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6061 param=$(echo ${value[0]} | cut -d "=" -f1)
6062 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6064 if $support_last_seq; then
6065 param_seq=$(echo $param |
6066 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6067 mds_last_seq=$(do_facet $SINGLEMDS \
6068 $LCTL get_param -n $param_seq)
6070 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6072 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6073 node=$(facet_active_host ost$((ostnum+1)))
6074 param="obdfilter.$ostname.last_id"
6075 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6076 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6077 ost_last_id=$ost_last
6079 if $support_last_seq; then
6080 ost_last_id=$(echo $ost_last |
6081 awk -F':' '{print $2}' |
6083 ost_last_seq=$(echo $ost_last |
6084 awk -F':' '{print $1}')
6085 [[ $ost_last_seq = $mds_last_seq ]] || continue
6088 if [[ $ost_last_id != $mds_last ]]; then
6089 error "$ost_last_id != $mds_last"
6096 $found || error "can not match last_seq/last_id for $mdtosc"
6099 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6102 perl -MSocket -e ';' || skip "no Socket perl module installed"
6104 $SOCKETSERVER $DIR/socket ||
6105 error "$SOCKETSERVER $DIR/socket failed: $?"
6106 $SOCKETCLIENT $DIR/socket ||
6107 error "$SOCKETCLIENT $DIR/socket failed: $?"
6108 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
6110 run_test 54a "unix domain socket test =========================="
6116 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6118 run_test 54b "char device works in lustre ======================"
6121 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6122 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6123 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6125 for i in $(seq 3 7); do
6126 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6135 loopdev="$DIR/loop54c"
6138 $UMOUNT $DIR/$tdir || rc=$?
6139 losetup -d $loopdev || true
6140 losetup -d $LOOPDEV || true
6141 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6148 loopdev="$DIR/loop54c"
6151 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6152 trap cleanup_54c EXIT
6153 mknod $loopdev b 7 $LOOPNUM
6154 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6155 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6156 losetup $loopdev $DIR/$tfile ||
6157 error "can't set up $loopdev for $DIR/$tfile"
6158 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6159 test_mkdir $DIR/$tdir
6160 mount -t ext2 $loopdev $DIR/$tdir ||
6161 error "error mounting $loopdev on $DIR/$tdir"
6162 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6165 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6169 run_test 54c "block device works in lustre ====================="
6172 local pipe="$DIR/$tfile.pipe"
6173 local string="aaaaaa"
6176 echo -n "$string" > $pipe &
6177 local result=$(cat $pipe)
6178 [[ "$result" == "$string" ]] || error "$result != $string"
6180 run_test 54d "fifo device works in lustre ======================"
6185 cp -aL /dev/console $f
6186 echo $string > $f || error "echo $string to $f failed"
6188 run_test 54e "console/tty device works in lustre ======================"
6193 local dir=$DIR/$tdir
6196 test_mkdir -p $dir/dir
6197 for i in $(seq $numfiles); do
6199 touch $dir/dir/file$i
6202 local numcomp=$($LFS getstripe --component-count $dir)
6204 [[ $numcomp == 0 ]] && numcomp=1
6206 # test lfs getstripe with --recursive
6207 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6209 [[ $filenum -eq $((numfiles * 2)) ]] ||
6210 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6211 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6212 [[ $filenum -eq $numfiles ]] ||
6213 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6214 echo "$LFS getstripe showed obdidx or l_ost_idx"
6216 # test lfs getstripe with file instead of dir
6217 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6218 [[ $filenum -eq 1 ]] ||
6219 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6220 echo "$LFS getstripe file1 passed"
6222 #test lfs getstripe with --verbose
6223 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6224 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6225 error "$LFS getstripe --verbose $dir: "\
6226 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6227 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6228 error "$LFS getstripe $dir: showed lmm_magic"
6230 #test lfs getstripe with -v prints lmm_fid
6231 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6232 local countfids=$((numdirs + numfiles * numcomp))
6233 [[ $filenum -eq $countfids ]] ||
6234 error "$LFS getstripe -v $dir: "\
6235 "got $filenum want $countfids lmm_fid"
6236 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6237 error "$LFS getstripe $dir: showed lmm_fid by default"
6238 echo "$LFS getstripe --verbose passed"
6240 #check for FID information
6241 local fid1=$($LFS getstripe --fid $dir/file1)
6242 local fid2=$($LFS getstripe --verbose $dir/file1 |
6243 awk '/lmm_fid: / { print $2; exit; }')
6244 local fid3=$($LFS path2fid $dir/file1)
6246 [ "$fid1" != "$fid2" ] &&
6247 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6248 [ "$fid1" != "$fid3" ] &&
6249 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6250 echo "$LFS getstripe --fid passed"
6252 #test lfs getstripe with --obd
6253 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6254 error "$LFS getstripe --obd wrong_uuid: should return error"
6256 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6259 local obduuid=$(ostuuid_from_index $ostidx)
6260 local found=$($LFS getstripe -r --obd $obduuid $dir |
6261 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6263 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6264 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6266 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6269 [[ $found -eq $filenum ]] ||
6270 error "$LFS getstripe --obd: found $found expect $filenum"
6271 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6272 sed '/^[ ]*'${ostidx}'[ ]/d' |
6273 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6274 error "$LFS getstripe --obd: should not show file on other obd"
6275 echo "$LFS getstripe --obd passed"
6277 run_test 56a "check $LFS getstripe"
6280 local dir=$DIR/$tdir
6284 for i in $(seq $numdirs); do
6285 test_mkdir $dir/dir$i
6288 # test lfs getdirstripe default mode is non-recursion, which is
6289 # different from lfs getstripe
6290 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6292 [[ $dircnt -eq 1 ]] ||
6293 error "$LFS getdirstripe: found $dircnt, not 1"
6294 dircnt=$($LFS getdirstripe --recursive $dir |
6295 grep -c lmv_stripe_count)
6296 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6297 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6299 run_test 56b "check $LFS getdirstripe"
6302 remote_ost_nodsh && skip "remote OST with nodsh"
6305 local ost_name=$(ostname_from_index $ost_idx)
6306 local old_status=$(ost_dev_status $ost_idx)
6307 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6309 [[ -z "$old_status" ]] ||
6310 skip_env "OST $ost_name is in $old_status status"
6312 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6313 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6314 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6315 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6316 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6317 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6320 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6321 error "$LFS df -v showing inactive devices"
6324 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6326 [[ "$new_status" =~ "D" ]] ||
6327 error "$ost_name status is '$new_status', missing 'D'"
6328 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6329 [[ "$new_status" =~ "N" ]] ||
6330 error "$ost_name status is '$new_status', missing 'N'"
6332 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6333 [[ "$new_status" =~ "f" ]] ||
6334 error "$ost_name status is '$new_status', missing 'f'"
6337 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6338 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6339 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6340 [[ -z "$p" ]] && restore_lustre_params < $p || true
6343 new_status=$(ost_dev_status $ost_idx)
6344 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6345 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6346 # can't check 'f' as devices may actually be on flash
6348 run_test 56c "check 'lfs df' showing device status"
6351 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6352 local osts=$($LFS df -v $MOUNT | grep -c OST)
6356 (( mdts == MDSCOUNT )) ||
6357 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6358 (( osts == OSTCOUNT )) ||
6359 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6361 run_test 56d "'lfs df -v' prints only configured devices"
6364 err_enoent=2 # No such file or directory
6365 err_eopnotsupp=95 # Operation not supported
6367 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6368 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6370 # Check for handling of path not exists
6371 output=$($LFS df $enoent_mnt 2>&1)
6374 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6375 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6376 error "expect failure $err_enoent, not $ret"
6378 # Check for handling of non-Lustre FS
6379 output=$($LFS df $notsup_mnt)
6382 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6383 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6384 error "expect success $err_eopnotsupp, not $ret"
6386 # Check for multiple LustreFS argument
6387 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6390 [[ $output -eq 3 && $ret -eq 0 ]] ||
6391 error "expect success 3, not $output, rc = $ret"
6393 # Check for correct non-Lustre FS handling among multiple
6395 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6396 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6399 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6400 error "expect success 2, not $output, rc = $ret"
6402 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6407 local local_tdir="$1"
6408 local local_numfiles="$2"
6409 local local_numdirs="$3"
6410 local dir_params="$4"
6411 local dir_stripe_params="$5"
6413 if [ ! -d "$local_tdir" ] ; then
6414 test_mkdir -p $dir_stripe_params $local_tdir
6415 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6416 for i in $(seq $local_numfiles) ; do
6417 touch $local_tdir/file$i
6419 for i in $(seq $local_numdirs) ; do
6420 test_mkdir $dir_stripe_params $local_tdir/dir$i
6421 for j in $(seq $local_numfiles) ; do
6422 touch $local_tdir/dir$i/file$j
6428 setup_56_special() {
6430 local local_numfiles=$2
6431 local local_numdirs=$3
6433 setup_56 $local_tdir $local_numfiles $local_numdirs
6435 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6436 for i in $(seq $local_numfiles) ; do
6437 mknod $local_tdir/loop${i}b b 7 $i
6438 mknod $local_tdir/null${i}c c 1 3
6439 ln -s $local_tdir/file1 $local_tdir/link${i}
6441 for i in $(seq $local_numdirs) ; do
6442 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6443 mknod $local_tdir/dir$i/null${i}c c 1 3
6444 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6450 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6451 local expected=$(($NUMDIRS + 2))
6453 setup_56 $dir $NUMFILES $NUMDIRS
6455 # test lfs find with -name
6456 for i in $(seq $NUMFILES) ; do
6457 local nums=$($LFS find -name "*$i" $dir | wc -l)
6459 [ $nums -eq $expected ] ||
6460 error "lfs find -name '*$i' $dir wrong: "\
6461 "found $nums, expected $expected"
6464 run_test 56g "check lfs find -name"
6467 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6468 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6470 setup_56 $dir $NUMFILES $NUMDIRS
6472 # test lfs find with ! -name
6473 for i in $(seq $NUMFILES) ; do
6474 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6476 [ $nums -eq $expected ] ||
6477 error "lfs find ! -name '*$i' $dir wrong: "\
6478 "found $nums, expected $expected"
6481 run_test 56h "check lfs find ! -name"
6484 local dir=$DIR/$tdir
6488 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6491 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6493 run_test 56i "check 'lfs find -ost UUID' skips directories"
6496 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6498 setup_56_special $dir $NUMFILES $NUMDIRS
6500 local expected=$((NUMDIRS + 1))
6501 local cmd="$LFS find -type d $dir"
6502 local nums=$($cmd | wc -l)
6504 [ $nums -eq $expected ] ||
6505 error "'$cmd' wrong: found $nums, expected $expected"
6507 run_test 56j "check lfs find -type d"
6510 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6512 setup_56_special $dir $NUMFILES $NUMDIRS
6514 local expected=$(((NUMDIRS + 1) * NUMFILES))
6515 local cmd="$LFS find -type f $dir"
6516 local nums=$($cmd | wc -l)
6518 [ $nums -eq $expected ] ||
6519 error "'$cmd' wrong: found $nums, expected $expected"
6521 run_test 56k "check lfs find -type f"
6524 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6526 setup_56_special $dir $NUMFILES $NUMDIRS
6528 local expected=$((NUMDIRS + NUMFILES))
6529 local cmd="$LFS find -type b $dir"
6530 local nums=$($cmd | wc -l)
6532 [ $nums -eq $expected ] ||
6533 error "'$cmd' wrong: found $nums, expected $expected"
6535 run_test 56l "check lfs find -type b"
6538 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6540 setup_56_special $dir $NUMFILES $NUMDIRS
6542 local expected=$((NUMDIRS + NUMFILES))
6543 local cmd="$LFS find -type c $dir"
6544 local nums=$($cmd | wc -l)
6545 [ $nums -eq $expected ] ||
6546 error "'$cmd' wrong: found $nums, expected $expected"
6548 run_test 56m "check lfs find -type c"
6551 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6552 setup_56_special $dir $NUMFILES $NUMDIRS
6554 local expected=$((NUMDIRS + NUMFILES))
6555 local cmd="$LFS find -type l $dir"
6556 local nums=$($cmd | wc -l)
6558 [ $nums -eq $expected ] ||
6559 error "'$cmd' wrong: found $nums, expected $expected"
6561 run_test 56n "check lfs find -type l"
6564 local dir=$DIR/$tdir
6566 setup_56 $dir $NUMFILES $NUMDIRS
6567 utime $dir/file1 > /dev/null || error "utime (1)"
6568 utime $dir/file2 > /dev/null || error "utime (2)"
6569 utime $dir/dir1 > /dev/null || error "utime (3)"
6570 utime $dir/dir2 > /dev/null || error "utime (4)"
6571 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6572 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6575 local nums=$($LFS find -mtime +0 $dir | wc -l)
6577 [ $nums -eq $expected ] ||
6578 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6581 cmd="$LFS find -mtime 0 $dir"
6582 nums=$($cmd | wc -l)
6583 [ $nums -eq $expected ] ||
6584 error "'$cmd' wrong: found $nums, expected $expected"
6586 run_test 56o "check lfs find -mtime for old files"
6589 local dir=$DIR/$tdir
6593 # just to make sure there is something that won't be found
6595 touch $dir/$tfile.now
6597 for age in year week day hour min; do
6598 count=$((count + 1))
6600 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6601 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6602 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6604 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6605 local nums=$($cmd | wc -l)
6606 [ $nums -eq $expected ] ||
6607 error "'$cmd' wrong: found $nums, expected $expected"
6609 cmd="$LFS find $dir -atime $count${age:0:1}"
6610 nums=$($cmd | wc -l)
6611 [ $nums -eq $expected ] ||
6612 error "'$cmd' wrong: found $nums, expected $expected"
6616 cmd="$LFS find $dir -ctime +1s -type f"
6617 nums=$($cmd | wc -l)
6618 (( $nums == $count * 2 + 1)) ||
6619 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6621 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6623 test_newerXY_base() {
6626 local dir=$DIR/$tdir
6630 if [ $y == "t" ]; then
6631 if [ $x == "b" ]; then
6632 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6634 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6637 ref=$DIR/$tfile.newer.$x$y
6638 touch $ref || error "touch $ref failed"
6641 echo "before = $ref"
6643 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6645 if [ $y == "t" ]; then
6646 if [ $x == "b" ]; then
6647 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6649 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6652 negref=$DIR/$tfile.negnewer.$x$y
6653 touch $negref || error "touch $negref failed"
6656 echo "after = $negref"
6657 local cmd="$LFS find $dir -newer$x$y $ref"
6658 local nums=$(eval $cmd | wc -l)
6659 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6661 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6662 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6664 cmd="$LFS find $dir ! -newer$x$y $negref"
6665 nums=$(eval $cmd | wc -l)
6666 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6667 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6669 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6670 nums=$(eval $cmd | wc -l)
6671 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6672 error "'$cmd' wrong: found $nums between, expected $expected"; }
6678 test_newerXY_base "a" "a"
6679 test_newerXY_base "a" "m"
6680 test_newerXY_base "a" "c"
6681 test_newerXY_base "m" "a"
6682 test_newerXY_base "m" "m"
6683 test_newerXY_base "m" "c"
6684 test_newerXY_base "c" "a"
6685 test_newerXY_base "c" "m"
6686 test_newerXY_base "c" "c"
6688 [[ -n "$sles_version" ]] &&
6689 echo "skip timestamp tests on SLES, LU-13665" && return 0
6691 test_newerXY_base "a" "t"
6692 test_newerXY_base "m" "t"
6693 test_newerXY_base "c" "t"
6695 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6696 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6697 ! btime_supported && echo "btime unsupported" && return 0
6699 test_newerXY_base "b" "b"
6700 test_newerXY_base "b" "t"
6702 run_test 56oc "check lfs find -newerXY work"
6705 local dir=$DIR/$tdir
6710 $LFS find $dir -btime -1d -type f
6717 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6718 ! btime_supported && skip "btime unsupported on MDS"
6720 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6721 ! btime_supported && skip "btime unsupported on clients"
6723 local dir=$DIR/$tdir
6724 local ref=$DIR/$tfile.ref
6725 local negref=$DIR/$tfile.negref
6727 mkdir $dir || error "mkdir $dir failed"
6728 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6729 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6730 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6731 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6732 touch $ref || error "touch $ref failed"
6733 # sleep 3 seconds at least
6736 local before=$(do_facet mds1 date +%s)
6737 local skew=$(($(date +%s) - before + 1))
6739 if (( skew < 0 && skew > -5 )); then
6740 sleep $((0 - skew + 1))
6744 # Set the dir stripe params to limit files all on MDT0,
6745 # otherwise we need to calc the max clock skew between
6746 # the client and MDTs.
6747 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6749 touch $negref || error "touch $negref failed"
6751 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6752 local nums=$($cmd | wc -l)
6753 local expected=$(((NUMFILES + 1) * NUMDIRS))
6755 [ $nums -eq $expected ] ||
6756 error "'$cmd' wrong: found $nums, expected $expected"
6758 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6759 nums=$($cmd | wc -l)
6760 expected=$((NUMFILES + 1))
6761 [ $nums -eq $expected ] ||
6762 error "'$cmd' wrong: found $nums, expected $expected"
6764 [ $skew -lt 0 ] && return
6766 local after=$(do_facet mds1 date +%s)
6767 local age=$((after - before + 1 + skew))
6769 cmd="$LFS find $dir -btime -${age}s -type f"
6770 nums=$($cmd | wc -l)
6771 expected=$(((NUMFILES + 1) * NUMDIRS))
6773 echo "Clock skew between client and server: $skew, age:$age"
6774 [ $nums -eq $expected ] ||
6775 error "'$cmd' wrong: found $nums, expected $expected"
6777 expected=$(($NUMDIRS + 1))
6778 cmd="$LFS find $dir -btime -${age}s -type d"
6779 nums=$($cmd | wc -l)
6780 [ $nums -eq $expected ] ||
6781 error "'$cmd' wrong: found $nums, expected $expected"
6782 rm -f $ref $negref || error "Failed to remove $ref $negref"
6784 run_test 56od "check lfs find -btime with units"
6787 [ $RUNAS_ID -eq $UID ] &&
6788 skip_env "RUNAS_ID = UID = $UID -- skipping"
6790 local dir=$DIR/$tdir
6792 setup_56 $dir $NUMFILES $NUMDIRS
6793 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6795 local expected=$NUMFILES
6796 local cmd="$LFS find -uid $RUNAS_ID $dir"
6797 local nums=$($cmd | wc -l)
6799 [ $nums -eq $expected ] ||
6800 error "'$cmd' wrong: found $nums, expected $expected"
6802 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6803 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6804 nums=$($cmd | wc -l)
6805 [ $nums -eq $expected ] ||
6806 error "'$cmd' wrong: found $nums, expected $expected"
6808 run_test 56p "check lfs find -uid and ! -uid"
6811 [ $RUNAS_ID -eq $UID ] &&
6812 skip_env "RUNAS_ID = UID = $UID -- skipping"
6814 local dir=$DIR/$tdir
6816 setup_56 $dir $NUMFILES $NUMDIRS
6817 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6819 local expected=$NUMFILES
6820 local cmd="$LFS find -gid $RUNAS_GID $dir"
6821 local nums=$($cmd | wc -l)
6823 [ $nums -eq $expected ] ||
6824 error "'$cmd' wrong: found $nums, expected $expected"
6826 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6827 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6828 nums=$($cmd | wc -l)
6829 [ $nums -eq $expected ] ||
6830 error "'$cmd' wrong: found $nums, expected $expected"
6832 run_test 56q "check lfs find -gid and ! -gid"
6835 local dir=$DIR/$tdir
6837 setup_56 $dir $NUMFILES $NUMDIRS
6840 local cmd="$LFS find -size 0 -type f -lazy $dir"
6841 local nums=$($cmd | wc -l)
6843 [ $nums -eq $expected ] ||
6844 error "'$cmd' wrong: found $nums, expected $expected"
6845 cmd="$LFS find -size 0 -type f $dir"
6846 nums=$($cmd | wc -l)
6847 [ $nums -eq $expected ] ||
6848 error "'$cmd' wrong: found $nums, expected $expected"
6851 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6852 nums=$($cmd | wc -l)
6853 [ $nums -eq $expected ] ||
6854 error "'$cmd' wrong: found $nums, expected $expected"
6855 cmd="$LFS find ! -size 0 -type f $dir"
6856 nums=$($cmd | wc -l)
6857 [ $nums -eq $expected ] ||
6858 error "'$cmd' wrong: found $nums, expected $expected"
6860 echo "test" > $dir/$tfile
6861 echo "test2" > $dir/$tfile.2 && sync
6863 cmd="$LFS find -size 5 -type f -lazy $dir"
6864 nums=$($cmd | wc -l)
6865 [ $nums -eq $expected ] ||
6866 error "'$cmd' wrong: found $nums, expected $expected"
6867 cmd="$LFS find -size 5 -type f $dir"
6868 nums=$($cmd | wc -l)
6869 [ $nums -eq $expected ] ||
6870 error "'$cmd' wrong: found $nums, expected $expected"
6873 cmd="$LFS find -size +5 -type f -lazy $dir"
6874 nums=$($cmd | wc -l)
6875 [ $nums -eq $expected ] ||
6876 error "'$cmd' wrong: found $nums, expected $expected"
6877 cmd="$LFS find -size +5 -type f $dir"
6878 nums=$($cmd | wc -l)
6879 [ $nums -eq $expected ] ||
6880 error "'$cmd' wrong: found $nums, expected $expected"
6883 cmd="$LFS find -size +0 -type f -lazy $dir"
6884 nums=$($cmd | wc -l)
6885 [ $nums -eq $expected ] ||
6886 error "'$cmd' wrong: found $nums, expected $expected"
6887 cmd="$LFS find -size +0 -type f $dir"
6888 nums=$($cmd | wc -l)
6889 [ $nums -eq $expected ] ||
6890 error "'$cmd' wrong: found $nums, expected $expected"
6893 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6894 nums=$($cmd | wc -l)
6895 [ $nums -eq $expected ] ||
6896 error "'$cmd' wrong: found $nums, expected $expected"
6897 cmd="$LFS find ! -size -5 -type f $dir"
6898 nums=$($cmd | wc -l)
6899 [ $nums -eq $expected ] ||
6900 error "'$cmd' wrong: found $nums, expected $expected"
6903 cmd="$LFS find -size -5 -type f -lazy $dir"
6904 nums=$($cmd | wc -l)
6905 [ $nums -eq $expected ] ||
6906 error "'$cmd' wrong: found $nums, expected $expected"
6907 cmd="$LFS find -size -5 -type f $dir"
6908 nums=$($cmd | wc -l)
6909 [ $nums -eq $expected ] ||
6910 error "'$cmd' wrong: found $nums, expected $expected"
6912 run_test 56r "check lfs find -size works"
6919 cancel_lru_locks $OSC
6921 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6922 local nums=$($cmd | wc -l)
6924 [ $nums -eq $expected ] ||
6925 error "'$cmd' wrong: found $nums, expected $expected"
6927 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6929 if (( rpcs_before + glimpses != rpcs_after )); then
6930 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6931 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6933 if [[ $glimpses == 0 ]]; then
6934 error "'$cmd' should not send glimpse RPCs to OST"
6936 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6942 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6943 skip "MDS < 2.12.58 doesn't return LSOM data"
6944 local dir=$DIR/$tdir
6945 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6947 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6949 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6950 $LCTL set_param -n llite.*.statahead_agl=0
6951 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6953 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6954 # open and close all files to ensure LSOM is updated
6955 cancel_lru_locks $OSC
6956 find $dir -type f | xargs cat > /dev/null
6958 # expect_found glimpse_rpcs command_to_run
6959 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6960 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6961 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6962 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6964 echo "test" > $dir/$tfile
6965 echo "test2" > $dir/$tfile.2 && sync
6966 cancel_lru_locks $OSC
6967 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6969 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6970 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6971 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6972 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6974 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6975 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6976 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6977 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6978 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6979 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6981 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6984 local dir=$DIR/$tdir
6985 local tmp=$TMP/$tfile.log
6988 test_mkdir -p $dir || error "failed to mkdir $dir"
6989 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6990 error "failed to setstripe $dir/$tfile"
6991 mdt_idx=$($LFS getdirstripe -i $dir)
6992 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6994 stack_trap "rm -f $tmp" EXIT
6995 $LFS find --size +100K --ost 0 $dir |& tee $tmp
6996 ! grep -q obd_uuid $tmp ||
6997 error "failed to find --size +100K --ost 0 $dir"
6998 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
6999 ! grep -q obd_uuid $tmp ||
7000 error "failed to find --size +100K --mdt $mdt_idx $dir"
7002 run_test 56rb "check lfs find --size --ost/--mdt works"
7005 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7006 local dir=$DIR/$tdir
7009 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7010 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7011 (( $MDSCOUNT > 2 )) &&
7012 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7013 mkdir $dir/$tdir-{1..10}
7014 touch $dir/$tfile-{1..10}
7016 found=$($LFS find $dir --mdt-count 2 | wc -l)
7018 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7020 found=$($LFS find $dir -T +1 | wc -l)
7021 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7022 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7024 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7026 (( $found == $expect )) || error "found $found all_char, expect $expect"
7028 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7029 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7030 (( $found == $expect )) || error "found $found all_char, expect $expect"
7032 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7034 test_56s() { # LU-611 #LU-9369
7035 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7037 local dir=$DIR/$tdir
7038 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7040 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7041 for i in $(seq $NUMDIRS); do
7042 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7045 local expected=$NUMDIRS
7046 local cmd="$LFS find -c $OSTCOUNT $dir"
7047 local nums=$($cmd | wc -l)
7049 [ $nums -eq $expected ] || {
7050 $LFS getstripe -R $dir
7051 error "'$cmd' wrong: found $nums, expected $expected"
7054 expected=$((NUMDIRS + onestripe))
7055 cmd="$LFS find -stripe-count +0 -type f $dir"
7056 nums=$($cmd | wc -l)
7057 [ $nums -eq $expected ] || {
7058 $LFS getstripe -R $dir
7059 error "'$cmd' wrong: found $nums, expected $expected"
7063 cmd="$LFS find -stripe-count 1 -type f $dir"
7064 nums=$($cmd | wc -l)
7065 [ $nums -eq $expected ] || {
7066 $LFS getstripe -R $dir
7067 error "'$cmd' wrong: found $nums, expected $expected"
7070 cmd="$LFS find -stripe-count -2 -type f $dir"
7071 nums=$($cmd | wc -l)
7072 [ $nums -eq $expected ] || {
7073 $LFS getstripe -R $dir
7074 error "'$cmd' wrong: found $nums, expected $expected"
7078 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7079 nums=$($cmd | wc -l)
7080 [ $nums -eq $expected ] || {
7081 $LFS getstripe -R $dir
7082 error "'$cmd' wrong: found $nums, expected $expected"
7085 run_test 56s "check lfs find -stripe-count works"
7087 test_56t() { # LU-611 #LU-9369
7088 local dir=$DIR/$tdir
7090 setup_56 $dir 0 $NUMDIRS
7091 for i in $(seq $NUMDIRS); do
7092 $LFS setstripe -S 8M $dir/dir$i/$tfile
7095 local expected=$NUMDIRS
7096 local cmd="$LFS find -S 8M $dir"
7097 local nums=$($cmd | wc -l)
7099 [ $nums -eq $expected ] || {
7100 $LFS getstripe -R $dir
7101 error "'$cmd' wrong: found $nums, expected $expected"
7105 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7107 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7109 expected=$(((NUMDIRS + 1) * NUMFILES))
7110 cmd="$LFS find -stripe-size 512k -type f $dir"
7111 nums=$($cmd | wc -l)
7112 [ $nums -eq $expected ] ||
7113 error "'$cmd' wrong: found $nums, expected $expected"
7115 cmd="$LFS find -stripe-size +320k -type f $dir"
7116 nums=$($cmd | wc -l)
7117 [ $nums -eq $expected ] ||
7118 error "'$cmd' wrong: found $nums, expected $expected"
7120 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7121 cmd="$LFS find -stripe-size +200k -type f $dir"
7122 nums=$($cmd | wc -l)
7123 [ $nums -eq $expected ] ||
7124 error "'$cmd' wrong: found $nums, expected $expected"
7126 cmd="$LFS find -stripe-size -640k -type f $dir"
7127 nums=$($cmd | wc -l)
7128 [ $nums -eq $expected ] ||
7129 error "'$cmd' wrong: found $nums, expected $expected"
7132 cmd="$LFS find -stripe-size 256k -type f $dir"
7133 nums=$($cmd | wc -l)
7134 [ $nums -eq $expected ] ||
7135 error "'$cmd' wrong: found $nums, expected $expected"
7137 cmd="$LFS find -stripe-size -320k -type f $dir"
7138 nums=$($cmd | wc -l)
7139 [ $nums -eq $expected ] ||
7140 error "'$cmd' wrong: found $nums, expected $expected"
7143 cmd="$LFS find -stripe-size 1024k -type f $dir"
7144 nums=$($cmd | wc -l)
7145 [ $nums -eq $expected ] ||
7146 error "'$cmd' wrong: found $nums, expected $expected"
7148 run_test 56t "check lfs find -stripe-size works"
7150 test_56u() { # LU-611
7151 local dir=$DIR/$tdir
7153 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7155 if [[ $OSTCOUNT -gt 1 ]]; then
7156 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7162 local expected=$(((NUMDIRS + 1) * NUMFILES))
7163 local cmd="$LFS find -stripe-index 0 -type f $dir"
7164 local nums=$($cmd | wc -l)
7166 [ $nums -eq $expected ] ||
7167 error "'$cmd' wrong: found $nums, expected $expected"
7170 cmd="$LFS find -stripe-index 1 -type f $dir"
7171 nums=$($cmd | wc -l)
7172 [ $nums -eq $expected ] ||
7173 error "'$cmd' wrong: found $nums, expected $expected"
7175 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7176 nums=$($cmd | wc -l)
7177 [ $nums -eq $expected ] ||
7178 error "'$cmd' wrong: found $nums, expected $expected"
7181 # This should produce an error and not return any files
7182 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7183 nums=$($cmd 2>/dev/null | wc -l)
7184 [ $nums -eq $expected ] ||
7185 error "'$cmd' wrong: found $nums, expected $expected"
7187 if [[ $OSTCOUNT -gt 1 ]]; then
7188 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7189 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7190 nums=$($cmd | wc -l)
7191 [ $nums -eq $expected ] ||
7192 error "'$cmd' wrong: found $nums, expected $expected"
7195 run_test 56u "check lfs find -stripe-index works"
7199 local dir=$DIR/$tdir
7201 setup_56 $dir $NUMFILES $NUMDIRS
7203 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7204 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7206 for file in $($LFS find -m $UUID $dir); do
7207 file_midx=$($LFS getstripe -m $file)
7208 [ $file_midx -eq $mdt_idx ] ||
7209 error "lfs find -m $UUID != getstripe -m $file_midx"
7212 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7215 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7216 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7218 local dir=$DIR/$tdir
7220 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7222 local stripe_size=$($LFS getstripe -S -d $dir) ||
7223 error "$LFS getstripe -S -d $dir failed"
7224 stripe_size=${stripe_size%% *}
7226 local file_size=$((stripe_size * OSTCOUNT))
7227 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7228 local required_space=$((file_num * file_size))
7229 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7231 [[ $free_space -le $((required_space / 1024)) ]] &&
7232 skip_env "need $required_space, have $free_space kbytes"
7235 local dd_count=$((file_size / dd_bs))
7237 # write data into the files
7242 for i in $(seq $NUMFILES); do
7244 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7245 error "write data into $file failed"
7247 for i in $(seq $NUMDIRS); do
7248 for j in $(seq $NUMFILES); do
7249 file=$dir/dir$i/file$j
7250 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7251 error "write data into $file failed"
7255 # $LFS_MIGRATE will fail if hard link migration is unsupported
7256 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
7257 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7258 error "creating links to $dir/dir1/file1 failed"
7263 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
7266 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7269 eval $cmd || error "$cmd failed"
7271 check_stripe_count $dir/file1 $expected
7273 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
7275 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7276 # OST 1 if it is on OST 0. This file is small enough to
7277 # be on only one stripe.
7278 file=$dir/migr_1_ost
7279 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7280 error "write data into $file failed"
7281 local obdidx=$($LFS getstripe -i $file)
7282 local oldmd5=$(md5sum $file)
7285 [[ $obdidx -eq 0 ]] && newobdidx=1
7286 cmd="$LFS migrate -i $newobdidx $file"
7288 eval $cmd || error "$cmd failed"
7290 local realobdix=$($LFS getstripe -i $file)
7291 local newmd5=$(md5sum $file)
7293 [[ $newobdidx -ne $realobdix ]] &&
7294 error "new OST is different (was=$obdidx, "\
7295 "wanted=$newobdidx, got=$realobdix)"
7296 [[ "$oldmd5" != "$newmd5" ]] &&
7297 error "md5sum differ: $oldmd5, $newmd5"
7301 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7303 eval $cmd || error "$cmd failed"
7305 for j in $(seq $NUMFILES); do
7306 check_stripe_count $dir/dir1/file$j $expected
7309 # lfs_migrate works with lfs find
7310 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7311 $LFS_MIGRATE -y -c $expected"
7313 eval $cmd || error "$cmd failed"
7315 for i in $(seq 2 $NUMFILES); do
7316 check_stripe_count $dir/file$i $expected
7318 for i in $(seq 2 $NUMDIRS); do
7319 for j in $(seq $NUMFILES); do
7320 check_stripe_count $dir/dir$i/file$j $expected
7324 run_test 56w "check lfs_migrate -c stripe_count works"
7327 local file1=$DIR/$tdir/file1
7328 local create_pool=false
7329 local initial_pool=$($LFS getstripe -p $DIR)
7333 echo -n "Creating test dir..."
7334 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7337 echo -n "Creating test file..."
7338 touch $file1 || error "cannot create file"
7341 echo -n "Detecting existing pools..."
7342 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7344 if [ ${#pool_list[@]} -gt 0 ]; then
7345 echo "${pool_list[@]}"
7346 for thispool in "${pool_list[@]}"; do
7347 if [[ -z "$initial_pool" ||
7348 "$initial_pool" != "$thispool" ]]; then
7350 echo "Using existing pool '$pool'"
7355 echo "none detected."
7357 if [ -z "$pool" ]; then
7358 pool=${POOL:-testpool}
7359 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7360 echo -n "Creating pool '$pool'..."
7362 pool_add $pool &> /dev/null ||
7363 error "pool_add failed"
7366 echo -n "Adding target to pool..."
7367 pool_add_targets $pool 0 0 1 &> /dev/null ||
7368 error "pool_add_targets failed"
7372 echo -n "Setting pool using -p option..."
7373 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7374 error "migrate failed rc = $?"
7377 echo -n "Verifying test file is in pool after migrating..."
7378 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7379 error "file was not migrated to pool $pool"
7382 echo -n "Removing test file from pool '$pool'..."
7383 # "lfs migrate $file" won't remove the file from the pool
7384 # until some striping information is changed.
7385 $LFS migrate -c 1 $file1 &> /dev/null ||
7386 error "cannot remove from pool"
7387 [ "$($LFS getstripe -p $file1)" ] &&
7388 error "pool still set"
7391 echo -n "Setting pool using --pool option..."
7392 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7393 error "migrate failed rc = $?"
7398 if $create_pool; then
7399 destroy_test_pools 2> /dev/null ||
7400 error "destroy test pools failed"
7403 run_test 56wb "check lfs_migrate pool support"
7406 local file1="$DIR/$tdir/file1"
7413 echo -n "Creating test dir..."
7414 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7415 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7416 error "cannot set stripe by '-S 1M -c 1'"
7419 echo -n "Setting initial stripe for test file..."
7420 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7421 error "cannot set stripe"
7422 cur_ssize=$($LFS getstripe -S "$file1")
7423 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7426 # File currently set to -S 512K -c 1
7428 # Ensure -c and -S options are rejected when -R is set
7429 echo -n "Verifying incompatible options are detected..."
7430 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7431 error "incompatible -c and -R options not detected"
7432 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7433 error "incompatible -S and -R options not detected"
7436 # Ensure unrecognized options are passed through to 'lfs migrate'
7437 echo -n "Verifying -S option is passed through to lfs migrate..."
7438 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7439 error "migration failed"
7440 cur_ssize=$($LFS getstripe -S "$file1")
7441 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7444 # File currently set to -S 1M -c 1
7446 # Ensure long options are supported
7447 echo -n "Verifying long options supported..."
7448 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7449 error "long option without argument not supported"
7450 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7451 error "long option with argument not supported"
7452 cur_ssize=$($LFS getstripe -S "$file1")
7453 [ $cur_ssize -eq 524288 ] ||
7454 error "migrate --stripe-size $cur_ssize != 524288"
7457 # File currently set to -S 512K -c 1
7459 if [ "$OSTCOUNT" -gt 1 ]; then
7460 echo -n "Verifying explicit stripe count can be set..."
7461 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7462 error "migrate failed"
7463 cur_scount=$($LFS getstripe -c "$file1")
7464 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7468 # File currently set to -S 512K -c 1 or -S 512K -c 2
7470 # Ensure parent striping is used if -R is set, and no stripe
7471 # count or size is specified
7472 echo -n "Setting stripe for parent directory..."
7473 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7474 error "cannot set stripe '-S 2M -c 1'"
7477 echo -n "Verifying restripe option uses parent stripe settings..."
7478 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7479 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7480 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7481 error "migrate failed"
7482 cur_ssize=$($LFS getstripe -S "$file1")
7483 [ $cur_ssize -eq $parent_ssize ] ||
7484 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7485 cur_scount=$($LFS getstripe -c "$file1")
7486 [ $cur_scount -eq $parent_scount ] ||
7487 error "migrate -R stripe_count $cur_scount != $parent_scount"
7490 # File currently set to -S 1M -c 1
7492 # Ensure striping is preserved if -R is not set, and no stripe
7493 # count or size is specified
7494 echo -n "Verifying striping size preserved when not specified..."
7495 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7496 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7497 error "cannot set stripe on parent directory"
7498 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7499 error "migrate failed"
7500 cur_ssize=$($LFS getstripe -S "$file1")
7501 [ $cur_ssize -eq $orig_ssize ] ||
7502 error "migrate by default $cur_ssize != $orig_ssize"
7505 # Ensure file name properly detected when final option has no argument
7506 echo -n "Verifying file name properly detected..."
7507 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7508 error "file name interpreted as option argument"
7514 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7517 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7519 local file1=$DIR/$tdir/file1
7521 echo -n "Creating test dir..."
7522 test_mkdir $DIR/$tdir || error "cannot create dir"
7525 echo -n "Creating test file..."
7529 # Ensure 'lfs migrate' will fail by using a non-existent option,
7530 # and make sure rsync is not called to recover
7531 echo -n "Make sure --no-rsync option works..."
7532 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7533 grep -q 'refusing to fall back to rsync' ||
7534 error "rsync was called with --no-rsync set"
7537 # Ensure rsync is called without trying 'lfs migrate' first
7538 echo -n "Make sure --rsync option works..."
7539 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7540 grep -q 'falling back to rsync' &&
7541 error "lfs migrate was called with --rsync set"
7544 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7545 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7546 grep -q 'at the same time' ||
7547 error "--rsync and --no-rsync accepted concurrently"
7553 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7559 test_mkdir $td || error "cannot create $td"
7560 touch $tf || error "cannot touch $tf"
7562 echo -n "Make sure --non-direct|-D works..."
7563 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7564 grep -q "lfs migrate --non-direct" ||
7565 error "--non-direct option cannot work correctly"
7566 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7567 grep -q "lfs migrate -D" ||
7568 error "-D option cannot work correctly"
7571 run_test 56we "check lfs_migrate --non-direct|-D support"
7574 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7575 check_swap_layouts_support
7577 local dir=$DIR/$tdir
7578 local ref1=/etc/passwd
7579 local file1=$dir/file1
7581 test_mkdir $dir || error "creating dir $dir"
7582 $LFS setstripe -c 2 $file1
7584 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7585 stripe=$($LFS getstripe -c $file1)
7586 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7587 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7592 run_test 56x "lfs migration support"
7595 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7596 check_swap_layouts_support
7598 local dir=$DIR/$tdir/$testnum
7602 local ref1=/etc/passwd
7603 local file1=$dir/file1
7605 $LFS setstripe -c 2 $file1
7607 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7609 local stripe=$($LFS getstripe -c $file1)
7611 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7612 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7617 run_test 56xa "lfs migration --block support"
7619 check_migrate_links() {
7621 local file1="$dir/file1"
7625 local total_count=$(($begin + $count - 1))
7626 local symlink_count=10
7629 if [ ! -f "$file1" ]; then
7630 echo -n "creating initial file..."
7631 $LFS setstripe -c 1 -S "512k" "$file1" ||
7632 error "cannot setstripe initial file"
7635 echo -n "creating symlinks..."
7636 for s in $(seq 1 $symlink_count); do
7637 ln -s "$file1" "$dir/slink$s" ||
7638 error "cannot create symlinks"
7642 echo -n "creating nonlinked files..."
7643 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7644 error "cannot create nonlinked files"
7649 if [ ! -f "$dir/file$total_count" ]; then
7650 echo -n "creating hard links $begin:$total_count..."
7651 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7652 /dev/null || error "cannot create hard links"
7656 echo -n "checking number of hard links listed in xattrs..."
7657 local fid=$($LFS getstripe -F "$file1")
7658 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7661 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7662 skip "hard link list has unexpected size, skipping test"
7664 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7665 error "link names should exceed xattrs size"
7668 echo -n "migrating files..."
7669 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7671 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7674 # make sure all links have been properly migrated
7675 echo -n "verifying files..."
7676 fid=$($LFS getstripe -F "$file1") ||
7677 error "cannot get fid for file $file1"
7678 for i in $(seq 2 $total_count); do
7679 local fid2=$($LFS getstripe -F $dir/file$i)
7681 [ "$fid2" == "$fid" ] ||
7682 error "migrated hard link has mismatched FID"
7685 # make sure hard links were properly detected, and migration was
7686 # performed only once for the entire link set; nonlinked files should
7688 local actual=$(grep -c 'done' <<< "$migrate_out")
7689 local expected=$(($uniq_count + 1))
7691 [ "$actual" -eq "$expected" ] ||
7692 error "hard links individually migrated ($actual != $expected)"
7694 # make sure the correct number of hard links are present
7695 local hardlinks=$(stat -c '%h' "$file1")
7697 [ $hardlinks -eq $total_count ] ||
7698 error "num hard links $hardlinks != $total_count"
7705 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7706 skip "Need MDS version at least 2.10.55"
7708 local dir="$DIR/$tdir"
7710 test_mkdir "$dir" || error "cannot create dir $dir"
7712 echo "testing lfs migrate mode when all links fit within xattrs"
7713 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7715 echo "testing rsync mode when all links fit within xattrs"
7716 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7718 echo "testing lfs migrate mode when all links do not fit within xattrs"
7719 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7721 echo "testing rsync mode when all links do not fit within xattrs"
7722 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7724 chown -R $RUNAS_ID $dir
7725 echo "testing non-root lfs migrate mode when not all links are in xattr"
7726 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7731 run_test 56xb "lfs migration hard link support"
7734 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7736 local dir="$DIR/$tdir"
7738 test_mkdir "$dir" || error "cannot create dir $dir"
7740 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7741 echo -n "Setting initial stripe for 20MB test file..."
7742 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7743 error "cannot setstripe 20MB file"
7745 echo -n "Sizing 20MB test file..."
7746 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7748 echo -n "Verifying small file autostripe count is 1..."
7749 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7750 error "cannot migrate 20MB file"
7751 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7752 error "cannot get stripe for $dir/20mb"
7753 [ $stripe_count -eq 1 ] ||
7754 error "unexpected stripe count $stripe_count for 20MB file"
7758 # Test 2: File is small enough to fit within the available space on
7759 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7760 # have at least an additional 1KB for each desired stripe for test 3
7761 echo -n "Setting stripe for 1GB test file..."
7762 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7764 echo -n "Sizing 1GB test file..."
7765 # File size is 1GB + 3KB
7766 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7769 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7770 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7771 if (( avail > 524288 * OSTCOUNT )); then
7772 echo -n "Migrating 1GB file..."
7773 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7774 error "cannot migrate 1GB file"
7776 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7777 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7778 error "cannot getstripe for 1GB file"
7779 [ $stripe_count -eq 2 ] ||
7780 error "unexpected stripe count $stripe_count != 2"
7784 # Test 3: File is too large to fit within the available space on
7785 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7786 if [ $OSTCOUNT -ge 3 ]; then
7787 # The required available space is calculated as
7788 # file size (1GB + 3KB) / OST count (3).
7789 local kb_per_ost=349526
7791 echo -n "Migrating 1GB file with limit..."
7792 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7793 error "cannot migrate 1GB file with limit"
7796 stripe_count=$($LFS getstripe -c "$dir/1gb")
7797 echo -n "Verifying 1GB autostripe count with limited space..."
7798 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7799 error "unexpected stripe count $stripe_count (min 3)"
7806 run_test 56xc "lfs migration autostripe"
7809 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7811 local dir=$DIR/$tdir
7812 local f_mgrt=$dir/$tfile.mgrt
7813 local f_yaml=$dir/$tfile.yaml
7814 local f_copy=$dir/$tfile.copy
7815 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7816 local layout_copy="-c 2 -S 2M -i 1"
7817 local yamlfile=$dir/yamlfile
7818 local layout_before;
7821 test_mkdir "$dir" || error "cannot create dir $dir"
7822 $LFS setstripe $layout_yaml $f_yaml ||
7823 error "cannot setstripe $f_yaml with layout $layout_yaml"
7824 $LFS getstripe --yaml $f_yaml > $yamlfile
7825 $LFS setstripe $layout_copy $f_copy ||
7826 error "cannot setstripe $f_copy with layout $layout_copy"
7828 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7830 # 1. test option --yaml
7831 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7832 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7833 layout_before=$(get_layout_param $f_yaml)
7834 layout_after=$(get_layout_param $f_mgrt)
7835 [ "$layout_after" == "$layout_before" ] ||
7836 error "lfs_migrate --yaml: $layout_after != $layout_before"
7838 # 2. test option --copy
7839 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7840 error "cannot migrate $f_mgrt with --copy $f_copy"
7841 layout_before=$(get_layout_param $f_copy)
7842 layout_after=$(get_layout_param $f_mgrt)
7843 [ "$layout_after" == "$layout_before" ] ||
7844 error "lfs_migrate --copy: $layout_after != $layout_before"
7846 run_test 56xd "check lfs_migrate --yaml and --copy support"
7849 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7851 local dir=$DIR/$tdir
7852 local f_comp=$dir/$tfile
7853 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7854 local layout_before=""
7855 local layout_after=""
7857 test_mkdir "$dir" || error "cannot create dir $dir"
7858 $LFS setstripe $layout $f_comp ||
7859 error "cannot setstripe $f_comp with layout $layout"
7860 layout_before=$(get_layout_param $f_comp)
7861 dd if=/dev/zero of=$f_comp bs=1M count=4
7863 # 1. migrate a comp layout file by lfs_migrate
7864 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7865 layout_after=$(get_layout_param $f_comp)
7866 [ "$layout_before" == "$layout_after" ] ||
7867 error "lfs_migrate: $layout_before != $layout_after"
7869 # 2. migrate a comp layout file by lfs migrate
7870 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7871 layout_after=$(get_layout_param $f_comp)
7872 [ "$layout_before" == "$layout_after" ] ||
7873 error "lfs migrate: $layout_before != $layout_after"
7875 run_test 56xe "migrate a composite layout file"
7878 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7880 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7881 skip "Need server version at least 2.13.53"
7883 local dir=$DIR/$tdir
7884 local f_comp=$dir/$tfile
7885 local layout="-E 1M -c1 -E -1 -c2"
7889 test_mkdir "$dir" || error "cannot create dir $dir"
7890 $LFS setstripe $layout $f_comp ||
7891 error "cannot setstripe $f_comp with layout $layout"
7892 fid_before=$($LFS getstripe --fid $f_comp)
7893 dd if=/dev/zero of=$f_comp bs=1M count=4
7895 # 1. migrate a comp layout file to a comp layout
7896 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7897 fid_after=$($LFS getstripe --fid $f_comp)
7898 [ "$fid_before" == "$fid_after" ] ||
7899 error "comp-to-comp migrate: $fid_before != $fid_after"
7901 # 2. migrate a comp layout file to a plain layout
7902 $LFS migrate -c2 $f_comp ||
7903 error "cannot migrate $f_comp by lfs migrate"
7904 fid_after=$($LFS getstripe --fid $f_comp)
7905 [ "$fid_before" == "$fid_after" ] ||
7906 error "comp-to-plain migrate: $fid_before != $fid_after"
7908 # 3. migrate a plain layout file to a comp layout
7909 $LFS migrate $layout $f_comp ||
7910 error "cannot migrate $f_comp by lfs migrate"
7911 fid_after=$($LFS getstripe --fid $f_comp)
7912 [ "$fid_before" == "$fid_after" ] ||
7913 error "plain-to-comp migrate: $fid_before != $fid_after"
7915 run_test 56xf "FID is not lost during migration of a composite layout file"
7917 check_file_ost_range() {
7924 file_range=($($LFS getstripe -y "$file" |
7925 awk '/l_ost_idx:/ { print $NF }'))
7927 if [[ "${#file_range[@]}" = 0 ]]; then
7928 echo "No osts found for $file"
7932 for idx in "${file_range[@]}"; do
7933 [[ " $range " =~ " $idx " ]] ||
7941 local stripe_opt="$1"
7944 local pool_ostidx="$(seq $* | tr '\n' ' ')"
7946 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
7947 error "Fail to migrate $tfile on $pool"
7948 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
7949 error "$tfile is not in pool $pool"
7950 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
7951 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
7955 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7956 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
7957 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
7958 skip "Need MDS version newer than 2.14.52"
7960 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
7961 local -a pool_ranges=("0 0" "1 1" "0 1")
7964 for i in "${!pool_names[@]}"; do
7965 pool_add ${pool_names[$i]} ||
7966 error "pool_add failed (pool: ${pool_names[$i]})"
7967 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
7968 error "pool_add_targets failed (pool: ${pool_names[$i]})"
7971 # init the file to migrate
7972 $LFS setstripe -c1 -i1 $DIR/$tfile ||
7973 error "Unable to create $tfile on OST1"
7974 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
7975 error "Unable to write on $tfile"
7977 echo "1. migrate $tfile on pool ${pool_names[0]}"
7978 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
7980 echo "2. migrate $tfile on pool ${pool_names[2]}"
7981 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
7983 echo "3. migrate $tfile on pool ${pool_names[1]}"
7984 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
7986 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
7987 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
7991 destroy_test_pools ||
7992 error "pool_destroy failed"
7994 run_test 56xg "lfs migrate pool support"
7997 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7998 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8001 local dir=$DIR/$tdir
8005 test_mkdir -p $dir || error "creating dir $dir"
8006 touch $f1 || error "creating std file $f1"
8007 $MULTIOP $f2 H2c || error "creating released file $f2"
8009 # a directory can be raid0, so ask only for files
8010 res=$($LFS find $dir -L raid0 -type f | wc -l)
8011 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8013 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8014 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8016 # only files can be released, so no need to force file search
8017 res=$($LFS find $dir -L released)
8018 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8020 res=$($LFS find $dir -type f \! -L released)
8021 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8023 run_test 56y "lfs find -L raid0|released"
8025 test_56z() { # LU-4824
8026 # This checks to make sure 'lfs find' continues after errors
8027 # There are two classes of errors that should be caught:
8028 # - If multiple paths are provided, all should be searched even if one
8030 # - If errors are encountered during the search, it should not terminate
8032 local dir=$DIR/$tdir
8036 for i in d{0..9}; do
8038 touch $dir/$i/$tfile
8040 $LFS find $DIR/non_existent_dir $dir &&
8041 error "$LFS find did not return an error"
8042 # Make a directory unsearchable. This should NOT be the last entry in
8043 # directory order. Arbitrarily pick the 6th entry
8044 chmod 700 $($LFS find $dir -type d | sed '6!d')
8046 $RUNAS $LFS find $DIR/non_existent $dir
8047 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8049 # The user should be able to see 10 directories and 9 files
8050 (( count == 19 )) ||
8051 error "$LFS find found $count != 19 entries after error"
8053 run_test 56z "lfs find should continue after an error"
8055 test_56aa() { # LU-5937
8056 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8058 local dir=$DIR/$tdir
8061 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8063 createmany -o $dir/striped_dir/${tfile}- 1024
8064 local dirs=$($LFS find --size +8k $dir/)
8066 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8068 run_test 56aa "lfs find --size under striped dir"
8070 test_56ab() { # LU-10705
8071 test_mkdir $DIR/$tdir
8072 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8073 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8074 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8075 # Flush writes to ensure valid blocks. Need to be more thorough for
8076 # ZFS, since blocks are not allocated/returned to client immediately.
8078 wait_zfs_commit ost1 2
8079 cancel_lru_locks osc
8082 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8084 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8086 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8087 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8089 rm -f $DIR/$tdir/$tfile.[123]
8091 run_test 56ab "lfs find --blocks"
8095 local dir="$DIR/$tdir"
8096 local perms=(001 002 003 004 005 006 007
8097 010 020 030 040 050 060 070
8098 100 200 300 400 500 600 700
8099 111 222 333 444 555 666 777)
8100 local perm_minus=(8 8 4 8 4 4 2
8104 local perm_slash=(8 8 12 8 12 12 14
8107 16 16 24 16 24 24 28)
8110 for perm in ${perms[*]}; do
8111 touch "$dir/$tfile.$perm"
8112 chmod $perm "$dir/$tfile.$perm"
8115 for ((i = 0; i < ${#perms[*]}; i++)); do
8116 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8118 error "lfs find -perm ${perms[i]}:"\
8121 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8122 (( $num == ${perm_minus[i]} )) ||
8123 error "lfs find -perm -${perms[i]}:"\
8124 "$num != ${perm_minus[i]}"
8126 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8127 (( $num == ${perm_slash[i]} )) ||
8128 error "lfs find -perm /${perms[i]}:"\
8129 "$num != ${perm_slash[i]}"
8132 run_test 56aca "check lfs find -perm with octal representation"
8135 local dir=$DIR/$tdir
8136 # p is the permission of write and execute for user, group and other
8137 # without the umask. It is used to test +wx.
8138 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8139 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8140 local symbolic=(+t a+t u+t g+t o+t
8146 o=r,ug+o,u+w u=r,a+u,u+w
8147 g=r,ugo=g,u+w u+x,+X +X
8148 u+x,u+X u+X u+x,g+X o+r,+X
8152 for perm in ${perms[*]}; do
8153 touch "$dir/$tfile.$perm"
8154 chmod $perm "$dir/$tfile.$perm"
8157 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8158 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8161 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8164 run_test 56acb "check lfs find -perm with symbolic representation"
8167 local dir=$DIR/$tdir
8168 local tests="17777 787 789 abcd
8169 ug=uu ug=a ug=gu uo=ou urw
8173 for err in $tests; do
8174 if $LFS find $dir -perm $err 2>/dev/null; then
8175 error "lfs find -perm $err: parsing should have failed"
8179 run_test 56acc "check parsing error for lfs find -perm"
8182 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8183 skip "Need MDS version at least 2.10.50"
8185 # Create composite files with one component
8186 local dir=$DIR/$tdir
8188 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8189 # Create composite files with three components
8190 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8191 # Create non-composite files
8192 createmany -o $dir/${tfile}- 10
8194 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8196 [[ $nfiles == 10 ]] ||
8197 error "lfs find -E 1M found $nfiles != 10 files"
8199 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8200 [[ $nfiles == 25 ]] ||
8201 error "lfs find ! -E 1M found $nfiles != 25 files"
8203 # All files have a component that starts at 0
8204 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8205 [[ $nfiles == 35 ]] ||
8206 error "lfs find --component-start 0 - $nfiles != 35 files"
8208 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8209 [[ $nfiles == 15 ]] ||
8210 error "lfs find --component-start 2M - $nfiles != 15 files"
8212 # All files created here have a componenet that does not starts at 2M
8213 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8214 [[ $nfiles == 35 ]] ||
8215 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8217 # Find files with a specified number of components
8218 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8219 [[ $nfiles == 15 ]] ||
8220 error "lfs find --component-count 3 - $nfiles != 15 files"
8222 # Remember non-composite files have a component count of zero
8223 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8224 [[ $nfiles == 10 ]] ||
8225 error "lfs find --component-count 0 - $nfiles != 10 files"
8227 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8228 [[ $nfiles == 20 ]] ||
8229 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8231 # All files have a flag called "init"
8232 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8233 [[ $nfiles == 35 ]] ||
8234 error "lfs find --component-flags init - $nfiles != 35 files"
8236 # Multi-component files will have a component not initialized
8237 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8238 [[ $nfiles == 15 ]] ||
8239 error "lfs find !--component-flags init - $nfiles != 15 files"
8244 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8247 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8248 skip "Need MDS version at least 2.10.57"
8258 # create mirrored directories and mirrored files
8259 mkdir $td || error "mkdir $td failed"
8260 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8261 createmany -o $tf- 10 || error "create $tf- failed"
8263 for i in $(seq 2); do
8265 mkdir $dir || error "mkdir $dir failed"
8266 $LFS mirror create -N$((3 + i)) $dir ||
8267 error "create mirrored dir $dir failed"
8268 createmany -o $dir/$tfile- 10 ||
8269 error "create $dir/$tfile- failed"
8272 # change the states of some mirrored files
8274 for i in $(seq 2); do
8276 for j in $(seq 4 9); do
8277 echo foo > $dir/$tfile-$j
8281 # find mirrored files with specific mirror count
8282 cmd="$LFS find --mirror-count 3 --type f $td"
8283 nfiles=$($cmd | wc -l)
8284 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8286 cmd="$LFS find ! --mirror-count 3 --type f $td"
8287 nfiles=$($cmd | wc -l)
8288 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8290 cmd="$LFS find --mirror-count +2 --type f $td"
8291 nfiles=$($cmd | wc -l)
8292 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8294 cmd="$LFS find --mirror-count -6 --type f $td"
8295 nfiles=$($cmd | wc -l)
8296 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8298 # find mirrored files with specific file state
8299 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8300 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8302 cmd="$LFS find --mirror-state=ro --type f $td"
8303 nfiles=$($cmd | wc -l)
8304 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8306 cmd="$LFS find ! --mirror-state=ro --type f $td"
8307 nfiles=$($cmd | wc -l)
8308 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8310 cmd="$LFS find --mirror-state=wp --type f $td"
8311 nfiles=$($cmd | wc -l)
8312 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8314 cmd="$LFS find ! --mirror-state=sp --type f $td"
8315 nfiles=$($cmd | wc -l)
8316 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8318 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8320 test_56da() { # LU-14179
8321 local path=$DIR/$tdir
8326 local longdir=$(str_repeat 'a' 255)
8328 for i in {1..15}; do
8335 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8340 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8343 touch $(str_repeat 'f' 255)
8345 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8346 error "lfs find reported an error"
8350 run_test 56da "test lfs find with long paths"
8352 test_56ea() { #LU-10378
8353 local path=$DIR/$tdir
8354 local pool=$TESTNAME
8357 pool_add $pool || error "pool_add $pool failed"
8358 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8359 error "adding targets to $pool failed"
8361 # Set default pool on directory before creating file
8362 mkdir $path || error "mkdir $path failed"
8363 $LFS setstripe -p $pool $path ||
8364 error "set OST pool on $pool failed"
8365 touch $path/$tfile || error "touch $path/$tfile failed"
8367 # Compare basic file attributes from -printf and stat
8368 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8369 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8371 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8372 error "Attrs from lfs find and stat don't match"
8374 # Compare Lustre attributes from lfs find and lfs getstripe
8375 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8376 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8377 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8378 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8379 local fpool=$($LFS getstripe --pool $path/$tfile)
8380 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8382 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8383 error "Attrs from lfs find and lfs getstripe don't match"
8385 # Verify behavior for unknown escape/format sequences
8386 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8388 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8389 error "Escape/format codes don't match"
8391 run_test 56ea "test lfs find -printf option"
8394 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8395 # note test will not do anything if MDS is not local
8396 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8397 skip_env "ldiskfs only test"
8399 remote_mds_nodsh && skip "remote MDS with nodsh"
8401 local MNTDEV="osd*.*MDT*.mntdev"
8402 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8403 [ -z "$DEV" ] && error "can't access $MNTDEV"
8404 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8405 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8406 error "can't access $DEV"
8407 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8408 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8412 run_test 57a "verify MDS filesystem created with large inodes =="
8415 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8416 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8417 skip_env "ldiskfs only test"
8419 remote_mds_nodsh && skip "remote MDS with nodsh"
8421 local dir=$DIR/$tdir
8424 local fileN=$dir/f$filecount
8426 rm -rf $dir || error "removing $dir"
8428 local mdtidx=$($LFS getstripe -m $dir)
8429 local mdtname=MDT$(printf %04x $mdtidx)
8430 local facet=mds$((mdtidx + 1))
8432 echo "mcreating $filecount files"
8433 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8435 # verify that files do not have EAs yet
8436 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8437 error "$file1 has an EA"
8438 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8439 error "$fileN has an EA"
8443 df $dir #make sure we get new statfs data
8444 local mdsfree=$(do_facet $facet \
8445 lctl get_param -n osd*.*$mdtname.kbytesfree)
8446 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8449 echo "opening files to create objects/EAs"
8450 for file in $(seq -f $dir/f%g 1 $filecount); do
8451 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8452 error "opening $file"
8455 # verify that files have EAs now
8456 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8457 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8459 sleep 1 #make sure we get new statfs data
8461 local mdsfree2=$(do_facet $facet \
8462 lctl get_param -n osd*.*$mdtname.kbytesfree)
8463 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8465 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8466 if [ "$mdsfree" != "$mdsfree2" ]; then
8467 error "MDC before $mdcfree != after $mdcfree2"
8469 echo "MDC before $mdcfree != after $mdcfree2"
8470 echo "unable to confirm if MDS has large inodes"
8475 run_test 57b "default LOV EAs are stored inside large inodes ==="
8478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8479 [ -z "$(which wiretest 2>/dev/null)" ] &&
8480 skip_env "could not find wiretest"
8484 run_test 58 "verify cross-platform wire constants =============="
8487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8489 echo "touch 130 files"
8490 createmany -o $DIR/f59- 130
8492 unlinkmany $DIR/f59- 130
8494 # wait for commitment of removal
8495 wait_delete_completed
8497 run_test 59 "verify cancellation of llog records async ========="
8499 TEST60_HEAD="test_60 run $RANDOM"
8501 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8502 remote_mgs_nodsh && skip "remote MGS with nodsh"
8503 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8504 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8505 skip_env "missing subtest run-llog.sh"
8507 log "$TEST60_HEAD - from kernel mode"
8508 do_facet mgs "$LCTL dk > /dev/null"
8509 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8510 do_facet mgs $LCTL dk > $TMP/$tfile
8512 # LU-6388: test llog_reader
8513 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8514 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8515 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8516 skip_env "missing llog_reader"
8517 local fstype=$(facet_fstype mgs)
8518 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8519 skip_env "Only for ldiskfs or zfs type mgs"
8521 local mntpt=$(facet_mntpt mgs)
8522 local mgsdev=$(mgsdevname 1)
8534 #get fid and record list
8535 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8537 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8539 #remount mgs as ldiskfs or zfs type
8540 stop mgs || error "stop mgs failed"
8541 mount_fstype mgs || error "remount mgs failed"
8542 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8545 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8546 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8551 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8553 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8555 echo "obj_file is $obj_file"
8556 do_facet mgs $llog_reader $obj_file
8558 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8559 awk '{ print $3 }' | sed -e "s/^type=//g")
8560 if [ $rec_type != $rec ]; then
8561 echo "FAILED test_60a wrong record type $rec_type," \
8567 #check obj path if record type is LLOG_LOGID_MAGIC
8568 if [ "$rec" == "1064553b" ]; then
8569 path=$(do_facet mgs $llog_reader $obj_file |
8570 grep "path=" | awk '{ print $NF }' |
8571 sed -e "s/^path=//g")
8572 if [ $obj_file != $mntpt/$path ]; then
8573 echo "FAILED test_60a wrong obj path" \
8574 "$montpt/$path, should be $obj_file"
8581 #restart mgs before "error", otherwise it will block the next test
8582 stop mgs || error "stop mgs failed"
8583 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8584 $pass || error "test failed, see FAILED test_60a messages for specifics"
8586 run_test 60a "llog_test run from kernel module and test llog_reader"
8588 test_60b() { # bug 6411
8589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8592 LLOG_COUNT=$(do_facet mgs dmesg |
8593 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8594 /llog_[a-z]*.c:[0-9]/ {
8606 [[ $LLOG_COUNT -gt 120 ]] &&
8607 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8609 run_test 60b "limit repeated messages from CERROR/CWARN"
8612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8614 echo "create 5000 files"
8615 createmany -o $DIR/f60c- 5000
8616 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8617 lctl set_param fail_loc=0x80000137
8618 unlinkmany $DIR/f60c- 5000
8619 lctl set_param fail_loc=0
8621 run_test 60c "unlink file when mds full"
8624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8626 SAVEPRINTK=$(lctl get_param -n printk)
8627 # verify "lctl mark" is even working"
8628 MESSAGE="test message ID $RANDOM $$"
8629 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8630 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8632 lctl set_param printk=0 || error "set lnet.printk failed"
8633 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8634 MESSAGE="new test message ID $RANDOM $$"
8635 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8636 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8637 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8639 lctl set_param -n printk="$SAVEPRINTK"
8641 run_test 60d "test printk console message masking"
8644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8645 remote_mds_nodsh && skip "remote MDS with nodsh"
8648 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8649 do_facet mds1 lctl set_param fail_loc=0x15b
8652 run_test 60e "no space while new llog is being created"
8655 local old_path=$($LCTL get_param -n debug_path)
8657 stack_trap "$LCTL set_param debug_path=$old_path"
8658 stack_trap "rm -f $TMP/$tfile*"
8659 rm -f $TMP/$tfile* 2> /dev/null
8660 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8661 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8662 test_mkdir $DIR/$tdir
8663 # retry in case the open is cached and not released
8664 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8665 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8669 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8671 run_test 60f "change debug_path works"
8677 test_mkdir -c $MDSCOUNT $DIR/$tdir
8682 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8683 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8685 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8686 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8687 index=$((index + 1))
8693 for i in {0..100}; do
8694 # define OBD_FAIL_OSD_TXN_START 0x19a
8695 local index=$((i % MDSCOUNT + 1))
8697 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8704 for i in $(seq $MDSCOUNT); do
8705 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8708 mkdir $DIR/$tdir/new || error "mkdir failed"
8709 rmdir $DIR/$tdir/new || error "rmdir failed"
8711 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8713 for i in $(seq $MDSCOUNT); do
8714 wait_update_facet mds$i "$LCTL get_param -n \
8715 mdd.$(facet_svc mds$i).lfsck_namespace |
8716 awk '/^status/ { print \\\$2 }'" "completed"
8720 rm -rf $DIR/$tdir || error "rmdir failed"
8722 run_test 60g "transaction abort won't cause MDT hung"
8725 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8726 skip "Need MDS version at least 2.12.52"
8727 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8731 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8732 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8733 for fail_loc in 0x80000188 0x80000189; do
8734 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8735 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8736 error "mkdir $dir-$fail_loc failed"
8737 for i in {0..10}; do
8738 # create may fail on missing stripe
8739 echo $i > $DIR/$tdir-$fail_loc/$i
8741 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8742 error "getdirstripe $tdir-$fail_loc failed"
8743 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8744 error "migrate $tdir-$fail_loc failed"
8745 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8746 error "getdirstripe $tdir-$fail_loc failed"
8747 pushd $DIR/$tdir-$fail_loc
8749 echo $f | cmp $f - || error "$f data mismatch"
8752 rm -rf $DIR/$tdir-$fail_loc
8755 run_test 60h "striped directory with missing stripes can be accessed"
8757 function t60i_load() {
8759 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8760 $LCTL set_param fail_loc=0x131c fail_val=1
8761 for ((i=0; i<5000; i++)); do
8762 touch $DIR/$tdir/f$i
8767 changelog_register || error "changelog_register failed"
8768 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8769 changelog_users $SINGLEMDS | grep -q $cl_user ||
8770 error "User $cl_user not found in changelog_users"
8771 changelog_chmask "ALL"
8774 for((i=0; i<100; i++)); do
8775 changelog_dump >/dev/null ||
8776 error "can't read changelog"
8780 changelog_deregister || error "changelog_deregister failed"
8781 $LCTL set_param fail_loc=0
8783 run_test 60i "llog: new record vs reader race"
8786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8789 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8790 cancel_lru_locks osc
8791 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8794 run_test 61a "mmap() writes don't make sync hang ================"
8797 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8799 run_test 61b "mmap() of unstriped file is successful"
8801 # bug 2330 - insufficient obd_match error checking causes LBUG
8803 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8807 cancel_lru_locks osc
8808 lctl set_param fail_loc=0x405
8809 cat $f && error "cat succeeded, expect -EIO"
8810 lctl set_param fail_loc=0
8812 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8813 # match every page all of the time.
8814 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8816 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8817 # Though this test is irrelevant anymore, it helped to reveal some
8818 # other grant bugs (LU-4482), let's keep it.
8819 test_63a() { # was test_63
8820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8822 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8824 for i in `seq 10` ; do
8825 dd if=/dev/zero of=$DIR/f63 bs=8k &
8831 rm -f $DIR/f63 || true
8833 run_test 63a "Verify oig_wait interruption does not crash ======="
8835 # bug 2248 - async write errors didn't return to application on sync
8836 # bug 3677 - async write errors left page locked
8838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8841 lctl set_param debug=-1
8843 # ensure we have a grant to do async writes
8844 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8847 sync # sync lest earlier test intercept the fail_loc
8849 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8850 lctl set_param fail_loc=0x80000406
8851 $MULTIOP $DIR/$tfile Owy && \
8852 error "sync didn't return ENOMEM"
8853 sync; sleep 2; sync # do a real sync this time to flush page
8854 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8855 error "locked page left in cache after async error" || true
8858 run_test 63b "async write errors should be returned to fsync ==="
8861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8864 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8866 run_test 64a "verify filter grant calculations (in kernel) ====="
8869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8871 bash oos.sh $MOUNT || error "oos.sh failed: $?"
8873 run_test 64b "check out-of-space detection on client"
8876 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8878 run_test 64c "verify grant shrink"
8884 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8887 # this does exactly what osc_request.c:osc_announce_cached() does in
8888 # order to calculate max amount of grants to ask from server
8892 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8893 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8895 ((rpc_in_flight++));
8896 nrpages=$((nrpages * rpc_in_flight))
8898 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8900 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8902 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8903 local undirty=$((nrpages * PAGE_SIZE))
8905 local max_extent_pages
8906 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8907 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8908 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8909 local grant_extent_tax
8910 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8912 undirty=$((undirty + nrextents * grant_extent_tax))
8917 # this is size of unit for grant allocation. It should be equal to
8918 # what tgt_grant.c:tgt_grant_chunk() calculates
8922 local grant_extent_tax
8924 max_brw_size=$(import_param $tgt max_brw_size)
8926 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8928 echo $(((max_brw_size + grant_extent_tax) * 2))
8932 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8933 skip "OST < 2.10.55 doesn't limit grants enough"
8935 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8937 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8938 skip "no grant_param connect flag"
8940 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8942 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8943 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8946 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8947 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8949 $LFS setstripe $DIR/$tfile -i 0 -c 1
8950 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8953 while kill -0 $ddpid; do
8954 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8956 if [[ $cur_grant -gt $max_cur_granted ]]; then
8958 error "cur_grant $cur_grant > $max_cur_granted"
8964 run_test 64d "check grant limit exceed"
8970 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8972 ((cur_grants == expected)) ||
8973 error "$msg: grants mismatch: $cur_grants, expected $expected"
8977 echo $((($1 + $2 - 1) & ~($2 - 1)))
8981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8982 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8983 skip "Need OSS version at least 2.11.56"
8985 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8986 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8987 $LCTL set_param debug=+cache
8989 # Remount client to reset grant
8990 remount_client $MOUNT || error "failed to remount client"
8991 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8993 local init_grants=$(import_param $osc_tgt initial_grant)
8995 check_grants $osc_tgt $init_grants "init grants"
8997 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8998 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8999 local gbs=$(import_param $osc_tgt grant_block_size)
9001 # write random number of bytes from max_brw_size / 4 to max_brw_size
9002 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9003 # align for direct io
9004 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9005 # round to grant consumption unit
9006 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9008 local grants=$((wb_round_up + extent_tax))
9010 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9012 # define OBD_FAIL_TGT_NO_GRANT 0x725
9013 # make the server not grant more back
9014 do_facet ost1 $LCTL set_param fail_loc=0x725
9015 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9017 do_facet ost1 $LCTL set_param fail_loc=0
9019 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9021 rm -f $DIR/$tfile || error "rm failed"
9023 # Remount client to reset grant
9024 remount_client $MOUNT || error "failed to remount client"
9025 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9027 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9029 # define OBD_FAIL_TGT_NO_GRANT 0x725
9030 # make the server not grant more back
9031 do_facet ost1 $LCTL set_param fail_loc=0x725
9032 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9033 do_facet ost1 $LCTL set_param fail_loc=0
9035 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9037 run_test 64e "check grant consumption (no grant allocation)"
9040 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9042 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9043 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9044 $LCTL set_param debug=+cache
9046 # Remount client to reset grant
9047 remount_client $MOUNT || error "failed to remount client"
9048 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9050 local init_grants=$(import_param $osc_tgt initial_grant)
9051 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9052 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9053 local gbs=$(import_param $osc_tgt grant_block_size)
9054 local chunk=$(grant_chunk $osc_tgt)
9056 # write random number of bytes from max_brw_size / 4 to max_brw_size
9057 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9058 # align for direct io
9059 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9060 # round to grant consumption unit
9061 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9063 local grants=$((wb_round_up + extent_tax))
9065 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9066 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9067 error "error writing to $DIR/$tfile"
9069 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9070 "direct io with grant allocation"
9072 rm -f $DIR/$tfile || error "rm failed"
9074 # Remount client to reset grant
9075 remount_client $MOUNT || error "failed to remount client"
9076 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9078 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9080 local cmd="oO_WRONLY:w${write_bytes}_yc"
9082 $MULTIOP $DIR/$tfile $cmd &
9086 check_grants $osc_tgt $((init_grants - grants)) \
9087 "buffered io, not write rpc"
9089 kill -USR1 $MULTIPID
9092 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9093 "buffered io, one RPC"
9095 run_test 64f "check grant consumption (with grant allocation)"
9098 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9099 skip "Need MDS version at least 2.14.56"
9101 local mdts=$(comma_list $(mdts_nodes))
9103 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9105 stack_trap "$LCTL set_param $old"
9107 # generate dirty pages and increase dirty granted on MDT
9108 stack_trap "rm -f $DIR/$tfile-*"
9109 for (( i = 0; i < 10; i++)); do
9110 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9111 error "can't set stripe"
9112 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9114 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9115 $LFS getstripe $DIR/$tfile-$i
9116 error "not DoM file"
9123 # wait until grant shrink reset grant dirty on MDTs
9124 for ((i = 0; i < 120; i++)); do
9125 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9126 awk '{sum=sum+$1} END {print sum}')
9127 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9128 echo "$grant_dirty grants, $vm_dirty pages"
9129 (( grant_dirty + vm_dirty == 0 )) && break
9130 (( i == 3 )) && sync &&
9131 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9135 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9136 awk '{sum=sum+$1} END {print sum}')
9137 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9139 run_test 64g "grant shrink on MDT"
9142 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9143 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9145 local instance=$($LFS getname -i $DIR)
9146 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9147 local num_exps=$(do_facet ost1 \
9148 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9149 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9150 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9151 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9153 # 10MiB is for file to be written, max_brw_size * 16 *
9154 # num_exps is space reserve so that tgt_grant_shrink() decided
9156 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9157 (( avail * 1024 < expect )) &&
9158 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9160 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9161 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9162 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9163 $LCTL set_param osc.*OST0000*.grant_shrink=1
9164 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9166 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9167 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9169 # drop cache so that coming read would do rpc
9170 cancel_lru_locks osc
9172 # shrink interval is set to 10, pause for 7 seconds so that
9173 # grant thread did not wake up yet but coming read entered
9174 # shrink mode for rpc (osc_should_shrink_grant())
9177 declare -a cur_grant_bytes
9178 declare -a tot_granted
9179 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9180 tot_granted[0]=$(do_facet ost1 \
9181 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9183 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9185 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9186 tot_granted[1]=$(do_facet ost1 \
9187 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9189 # grant change should be equal on both sides
9190 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9191 tot_granted[0] - tot_granted[1])) ||
9192 error "grant change mismatch, " \
9193 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9194 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9196 run_test 64h "grant shrink on read"
9199 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9200 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9202 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9203 remote_ost_nodsh && skip "remote OSTs with nodsh"
9205 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9207 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9209 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9210 local instance=$($LFS getname -i $DIR)
9212 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9213 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9215 # shrink grants and simulate rpc loss
9216 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9217 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9218 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9222 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9224 local testid=$(echo $TESTNAME | tr '_' ' ')
9226 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9227 grep "GRANT, real grant" &&
9228 error "client has more grants then it owns" || true
9230 run_test 64i "shrink on reconnect"
9232 # bug 1414 - set/get directories' stripe info
9234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9236 test_mkdir $DIR/$tdir
9238 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9240 run_test 65a "directory with no stripe info"
9243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9245 test_mkdir $DIR/$tdir
9246 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9248 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9251 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9253 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9257 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9259 test_mkdir $DIR/$tdir
9260 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9262 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9263 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9265 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9267 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9270 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9272 test_mkdir $DIR/$tdir
9273 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9274 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9276 if [[ $STRIPECOUNT -le 0 ]]; then
9278 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9279 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9280 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9282 sc=$(($STRIPECOUNT - 1))
9284 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9285 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9286 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9287 error "lverify failed"
9289 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9294 test_mkdir $DIR/$tdir
9296 $LFS setstripe $DIR/$tdir || error "setstripe"
9297 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9298 error "no stripe info failed"
9300 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9302 run_test 65e "directory setstripe defaults"
9305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9307 test_mkdir $DIR/${tdir}f
9308 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9309 error "setstripe succeeded" || true
9311 run_test 65f "dir setstripe permission (should return error) ==="
9314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9316 test_mkdir $DIR/$tdir
9317 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9319 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9320 error "setstripe -S failed"
9321 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9322 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9323 error "delete default stripe failed"
9325 run_test 65g "directory setstripe -d"
9328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9330 test_mkdir $DIR/$tdir
9331 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9333 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9334 error "setstripe -S failed"
9335 test_mkdir $DIR/$tdir/dd1
9336 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9337 error "stripe info inherit failed"
9339 run_test 65h "directory stripe info inherit ===================="
9342 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9344 save_layout_restore_at_exit $MOUNT
9346 # bug6367: set non-default striping on root directory
9347 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9349 # bug12836: getstripe on -1 default directory striping
9350 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9352 # bug12836: getstripe -v on -1 default directory striping
9353 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9355 # bug12836: new find on -1 default directory striping
9356 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9358 run_test 65i "various tests to set root directory striping"
9360 test_65j() { # bug6367
9361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9365 # if we aren't already remounting for each test, do so for this test
9366 if [ "$I_MOUNTED" = "yes" ]; then
9367 cleanup || error "failed to unmount"
9371 save_layout_restore_at_exit $MOUNT
9373 $LFS setstripe -d $MOUNT || error "setstripe failed"
9375 run_test 65j "set default striping on root directory (bug 6367)="
9379 wait_delete_completed
9380 do_facet $SINGLEMDS "lctl set_param -n \
9381 osp.$ost*MDT0000.max_create_count=$max_count"
9382 do_facet $SINGLEMDS "lctl set_param -n \
9383 osp.$ost*MDT0000.create_count=$count"
9384 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9385 echo $INACTIVE_OSC "is Activate"
9387 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9390 test_65k() { # bug11679
9391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9392 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9393 remote_mds_nodsh && skip "remote MDS with nodsh"
9395 local disable_precreate=true
9396 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9397 disable_precreate=false
9399 echo "Check OST status: "
9400 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9401 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9403 for OSC in $MDS_OSCS; do
9404 echo $OSC "is active"
9405 do_facet $SINGLEMDS lctl --device %$OSC activate
9408 for INACTIVE_OSC in $MDS_OSCS; do
9409 local ost=$(osc_to_ost $INACTIVE_OSC)
9410 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9411 lov.*md*.target_obd |
9412 awk -F: /$ost/'{ print $1 }' | head -n 1)
9415 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9416 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9418 echo "Deactivate: " $INACTIVE_OSC
9419 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9421 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9422 osp.$ost*MDT0000.create_count")
9423 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9424 osp.$ost*MDT0000.max_create_count")
9425 $disable_precreate &&
9426 do_facet $SINGLEMDS "lctl set_param -n \
9427 osp.$ost*MDT0000.max_create_count=0"
9429 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9430 [ -f $DIR/$tdir/$idx ] && continue
9431 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9432 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9434 error "setstripe $idx should succeed"; }
9435 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9437 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9440 do_facet $SINGLEMDS "lctl set_param -n \
9441 osp.$ost*MDT0000.max_create_count=$max_count"
9442 do_facet $SINGLEMDS "lctl set_param -n \
9443 osp.$ost*MDT0000.create_count=$count"
9444 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9445 echo $INACTIVE_OSC "is Activate"
9447 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9450 run_test 65k "validate manual striping works properly with deactivated OSCs"
9452 test_65l() { # bug 12836
9453 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9455 test_mkdir -p $DIR/$tdir/test_dir
9456 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9457 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9459 run_test 65l "lfs find on -1 stripe dir ========================"
9462 local layout=$(save_layout $MOUNT)
9463 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9464 restore_layout $MOUNT $layout
9465 error "setstripe should fail by non-root users"
9469 run_test 65m "normal user can't set filesystem default stripe"
9472 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9473 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9474 skip "Need MDS version at least 2.12.50"
9475 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9477 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9478 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9479 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9481 save_layout_restore_at_exit $MOUNT
9483 # new subdirectory under root directory should not inherit
9484 # the default layout from root
9485 local dir1=$MOUNT/$tdir-1
9486 mkdir $dir1 || error "mkdir $dir1 failed"
9487 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9488 error "$dir1 shouldn't have LOV EA"
9490 # delete the default layout on root directory
9491 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9493 local dir2=$MOUNT/$tdir-2
9494 mkdir $dir2 || error "mkdir $dir2 failed"
9495 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9496 error "$dir2 shouldn't have LOV EA"
9498 # set a new striping pattern on root directory
9499 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9500 local new_def_stripe_size=$((def_stripe_size * 2))
9501 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9502 error "set stripe size on $MOUNT failed"
9504 # new file created in $dir2 should inherit the new stripe size from
9505 # the filesystem default
9506 local file2=$dir2/$tfile-2
9507 touch $file2 || error "touch $file2 failed"
9509 local file2_stripe_size=$($LFS getstripe -S $file2)
9510 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9512 echo "file2_stripe_size: '$file2_stripe_size'"
9513 echo "new_def_stripe_size: '$new_def_stripe_size'"
9514 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9517 local dir3=$MOUNT/$tdir-3
9518 mkdir $dir3 || error "mkdir $dir3 failed"
9519 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9520 # the root layout, which is the actual default layout that will be used
9521 # when new files are created in $dir3.
9522 local dir3_layout=$(get_layout_param $dir3)
9523 local root_dir_layout=$(get_layout_param $MOUNT)
9524 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9526 echo "dir3_layout: '$dir3_layout'"
9527 echo "root_dir_layout: '$root_dir_layout'"
9528 error "$dir3 should show the default layout from $MOUNT"
9531 # set OST pool on root directory
9532 local pool=$TESTNAME
9533 pool_add $pool || error "add $pool failed"
9534 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9535 error "add targets to $pool failed"
9537 $LFS setstripe -p $pool $MOUNT ||
9538 error "set OST pool on $MOUNT failed"
9540 # new file created in $dir3 should inherit the pool from
9541 # the filesystem default
9542 local file3=$dir3/$tfile-3
9543 touch $file3 || error "touch $file3 failed"
9545 local file3_pool=$($LFS getstripe -p $file3)
9546 [[ "$file3_pool" = "$pool" ]] ||
9547 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9549 local dir4=$MOUNT/$tdir-4
9550 mkdir $dir4 || error "mkdir $dir4 failed"
9551 local dir4_layout=$(get_layout_param $dir4)
9552 root_dir_layout=$(get_layout_param $MOUNT)
9553 echo "$LFS getstripe -d $dir4"
9554 $LFS getstripe -d $dir4
9555 echo "$LFS getstripe -d $MOUNT"
9556 $LFS getstripe -d $MOUNT
9557 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9559 echo "dir4_layout: '$dir4_layout'"
9560 echo "root_dir_layout: '$root_dir_layout'"
9561 error "$dir4 should show the default layout from $MOUNT"
9564 # new file created in $dir4 should inherit the pool from
9565 # the filesystem default
9566 local file4=$dir4/$tfile-4
9567 touch $file4 || error "touch $file4 failed"
9569 local file4_pool=$($LFS getstripe -p $file4)
9570 [[ "$file4_pool" = "$pool" ]] ||
9571 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9573 # new subdirectory under non-root directory should inherit
9574 # the default layout from its parent directory
9575 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9576 error "set directory layout on $dir4 failed"
9578 local dir5=$dir4/$tdir-5
9579 mkdir $dir5 || error "mkdir $dir5 failed"
9581 dir4_layout=$(get_layout_param $dir4)
9582 local dir5_layout=$(get_layout_param $dir5)
9583 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9585 echo "dir4_layout: '$dir4_layout'"
9586 echo "dir5_layout: '$dir5_layout'"
9587 error "$dir5 should inherit the default layout from $dir4"
9590 # though subdir under ROOT doesn't inherit default layout, but
9591 # its sub dir/file should be created with default layout.
9592 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9593 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9594 skip "Need MDS version at least 2.12.59"
9596 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9597 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9598 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9600 if [ $default_lmv_hash == "none" ]; then
9601 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9603 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9604 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9607 $LFS setdirstripe -D -c 2 $MOUNT ||
9608 error "setdirstripe -D -c 2 failed"
9609 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9610 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9611 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9613 # $dir4 layout includes pool
9614 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9615 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9616 error "pool lost on setstripe"
9617 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9618 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9619 error "pool lost on compound layout setstripe"
9621 run_test 65n "don't inherit default layout from root for new subdirectories"
9623 # bug 2543 - update blocks count on client
9625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9627 local COUNT=${COUNT:-8}
9628 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9629 sync; sync_all_data; sync; sync_all_data
9630 cancel_lru_locks osc
9631 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
9632 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9634 run_test 66 "update inode blocks count on client ==============="
9637 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9641 swapon -s | awk '($1 == "'$1'") { print $4 }'
9644 # bug5265, obdfilter oa2dentry return -ENOENT
9645 # #define OBD_FAIL_SRV_ENOENT 0x217
9647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9648 remote_ost_nodsh && skip "remote OST with nodsh"
9651 $LFS setstripe -c 1 -i 0 $f
9653 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9655 do_facet ost1 lctl set_param fail_loc=0x217
9656 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9657 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9659 do_facet ost1 lctl set_param fail_loc=0
9660 $DIRECTIO write $f 0 2 || error "write error"
9662 cancel_lru_locks osc
9663 $DIRECTIO read $f 0 1 || error "read error"
9665 do_facet ost1 lctl set_param fail_loc=0x217
9666 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9668 do_facet ost1 lctl set_param fail_loc=0
9671 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9674 test_mkdir $DIR/$tdir
9675 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9676 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9678 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9680 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9682 [ "$RUNAS_ID" = "$UID" ] &&
9683 skip_env "RUNAS_ID = UID = $UID -- skipping"
9684 # Check that testing environment is properly set up. Skip if not
9685 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9686 skip_env "User $RUNAS_ID does not exist - skipping"
9689 chmod 777 $DIR/$tfile
9690 chmod ug+s $DIR/$tfile
9691 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9692 error "$RUNAS dd $DIR/$tfile failed"
9693 # See if we are still setuid/sgid
9694 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9695 error "S/gid is not dropped on write"
9696 # Now test that MDS is updated too
9697 cancel_lru_locks mdc
9698 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9699 error "S/gid is not dropped on MDS"
9702 run_test 72a "Test that remove suid works properly (bug5695) ===="
9704 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9707 [ "$RUNAS_ID" = "$UID" ] &&
9708 skip_env "RUNAS_ID = UID = $UID -- skipping"
9709 [ "$RUNAS_ID" -eq 0 ] &&
9710 skip_env "RUNAS_ID = 0 -- skipping"
9711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9712 # Check that testing environment is properly set up. Skip if not
9713 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9714 skip_env "User $RUNAS_ID does not exist - skipping"
9716 touch $DIR/${tfile}-f{g,u}
9717 test_mkdir $DIR/${tfile}-dg
9718 test_mkdir $DIR/${tfile}-du
9719 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9720 chmod g+s $DIR/${tfile}-{f,d}g
9721 chmod u+s $DIR/${tfile}-{f,d}u
9722 for perm in 777 2777 4777; do
9723 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9724 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9725 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9726 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9730 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9732 # bug 3462 - multiple simultaneous MDC requests
9734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9736 test_mkdir $DIR/d73-1
9737 test_mkdir $DIR/d73-2
9738 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9741 lctl set_param fail_loc=0x80000129
9742 $MULTIOP $DIR/d73-1/f73-2 Oc &
9744 lctl set_param fail_loc=0
9746 $MULTIOP $DIR/d73-2/f73-3 Oc &
9750 wait $pid1 || return 1
9754 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9755 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9756 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9760 run_test 73 "multiple MDC requests (should not deadlock)"
9762 test_74a() { # bug 6149, 6184
9763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9766 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9768 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9769 # will spin in a tight reconnection loop
9770 $LCTL set_param fail_loc=0x8000030e
9771 # get any lock that won't be difficult - lookup works.
9773 $LCTL set_param fail_loc=0
9777 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9779 test_74b() { # bug 13310
9780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9782 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9784 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9785 # will spin in a tight reconnection loop
9786 $LCTL set_param fail_loc=0x8000030e
9787 # get a "difficult" lock
9789 $LCTL set_param fail_loc=0
9793 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9798 #define OBD_FAIL_LDLM_NEW_LOCK
9799 $LCTL set_param fail_loc=0x319
9800 touch $DIR/$tfile && error "touch successful"
9801 $LCTL set_param fail_loc=0
9804 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9806 slab_lic=/sys/kernel/slab/lustre_inode_cache
9808 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9809 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9810 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9813 test_76a() { # Now for b=20433, added originally in b=1443
9814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9816 cancel_lru_locks osc
9817 # there may be some slab objects cached per core
9818 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9819 local before=$(num_objects)
9820 local count=$((512 * cpus))
9821 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9822 local margin=$((count / 10))
9823 if [[ -f $slab_lic/aliases ]]; then
9824 local aliases=$(cat $slab_lic/aliases)
9825 (( aliases > 0 )) && margin=$((margin * aliases))
9828 echo "before slab objects: $before"
9829 for i in $(seq $count); do
9833 cancel_lru_locks osc
9834 local after=$(num_objects)
9835 echo "created: $count, after slab objects: $after"
9836 # shared slab counts are not very accurate, allow significant margin
9837 # the main goal is that the cache growth is not permanently > $count
9838 while (( after > before + margin )); do
9840 after=$(num_objects)
9842 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9843 if (( wait > 60 )); then
9844 error "inode slab grew from $before+$margin to $after"
9848 run_test 76a "confirm clients recycle inodes properly ===="
9851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9852 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9855 local before=$(num_objects)
9857 for i in $(seq $count); do
9862 local after=$(num_objects)
9865 while (( after > before )); do
9867 after=$(num_objects)
9869 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9870 if (( wait > 60 )); then
9871 error "inode slab grew from $before to $after"
9875 echo "slab objects before: $before, after: $after"
9877 run_test 76b "confirm clients recycle directory inodes properly ===="
9882 # Note: in sptlrpc modes which enable its own bulk checksum, the
9883 # original crc32_le bulk checksum will be automatically disabled,
9884 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9885 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9886 # In this case set_checksums() will not be no-op, because sptlrpc
9887 # bulk checksum will be enabled all through the test.
9889 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9890 lctl set_param -n osc.*.checksums $1
9894 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9895 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9896 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9897 tr -d [] | head -n1)}
9900 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9902 log "set checksum type to $1, rc = $rc"
9906 get_osc_checksum_type()
9908 # arugment 1: OST name, like OST0000
9910 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9911 sed 's/.*\[\(.*\)\].*/\1/g')
9913 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9917 F77_TMP=$TMP/f77-temp
9920 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9921 error "error writing to $F77_TMP"
9924 test_77a() { # bug 10889
9925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9926 $GSS && skip_env "could not run with gss"
9928 [ ! -f $F77_TMP ] && setup_f77
9930 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9934 run_test 77a "normal checksum read/write operation"
9936 test_77b() { # bug 10889
9937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9938 $GSS && skip_env "could not run with gss"
9940 [ ! -f $F77_TMP ] && setup_f77
9941 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9942 $LCTL set_param fail_loc=0x80000409
9945 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9946 error "dd error: $?"
9947 $LCTL set_param fail_loc=0
9949 for algo in $CKSUM_TYPES; do
9950 cancel_lru_locks osc
9951 set_checksum_type $algo
9952 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9953 $LCTL set_param fail_loc=0x80000408
9954 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
9955 $LCTL set_param fail_loc=0
9958 set_checksum_type $ORIG_CSUM_TYPE
9961 run_test 77b "checksum error on client write, read"
9966 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
9968 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
9969 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
9970 $check_ost && [ -n "$ost_file_prefix" ] &&
9971 do_facet ost1 rm -f ${ost_file_prefix}\*
9975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9976 $GSS && skip_env "could not run with gss"
9977 remote_ost_nodsh && skip "remote OST with nodsh"
9980 local osc_file_prefix
9982 local check_ost=false
9983 local ost_file_prefix
9989 # ensure corruption will occur on first OSS/OST
9990 $LFS setstripe -i 0 $DIR/$tfile
9992 [ ! -f $F77_TMP ] && setup_f77
9993 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9994 error "dd write error: $?"
9995 fid=$($LFS path2fid $DIR/$tfile)
9997 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10000 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10001 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10003 echo "OSS do not support bulk pages dump upon error"
10006 osc_file_prefix=$($LCTL get_param -n debug_path)
10007 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10009 trap cleanup_77c EXIT
10012 # enable bulk pages dump upon error on Client
10013 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10014 # enable bulk pages dump upon error on OSS
10016 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10018 # flush Client cache to allow next read to reach OSS
10019 cancel_lru_locks osc
10021 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10022 $LCTL set_param fail_loc=0x80000408
10023 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10024 $LCTL set_param fail_loc=0
10028 # check cksum dump on Client
10029 osc_file=$(ls ${osc_file_prefix}*)
10030 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10031 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10032 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10033 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10034 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10036 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10037 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10038 error "dump content does not match on Client"
10040 $check_ost || skip "No need to check cksum dump on OSS"
10042 # check cksum dump on OSS
10043 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10044 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10045 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10046 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10047 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10048 error "dump content does not match on OSS"
10052 run_test 77c "checksum error on client read with debug"
10054 test_77d() { # bug 10889
10055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10056 $GSS && skip_env "could not run with gss"
10058 stack_trap "rm -f $DIR/$tfile"
10059 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10060 $LCTL set_param fail_loc=0x80000409
10062 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10063 error "direct write: rc=$?"
10064 $LCTL set_param fail_loc=0
10067 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10068 $LCTL set_param fail_loc=0x80000408
10070 cancel_lru_locks osc
10071 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10072 error "direct read: rc=$?"
10073 $LCTL set_param fail_loc=0
10076 run_test 77d "checksum error on OST direct write, read"
10078 test_77f() { # bug 10889
10079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10080 $GSS && skip_env "could not run with gss"
10083 stack_trap "rm -f $DIR/$tfile"
10084 for algo in $CKSUM_TYPES; do
10085 cancel_lru_locks osc
10086 set_checksum_type $algo
10087 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10088 $LCTL set_param fail_loc=0x409
10089 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10090 error "direct write succeeded"
10091 $LCTL set_param fail_loc=0
10093 set_checksum_type $ORIG_CSUM_TYPE
10096 run_test 77f "repeat checksum error on write (expect error)"
10098 test_77g() { # bug 10889
10099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10100 $GSS && skip_env "could not run with gss"
10101 remote_ost_nodsh && skip "remote OST with nodsh"
10103 [ ! -f $F77_TMP ] && setup_f77
10105 local file=$DIR/$tfile
10106 stack_trap "rm -f $file" EXIT
10108 $LFS setstripe -c 1 -i 0 $file
10109 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10110 do_facet ost1 lctl set_param fail_loc=0x8000021a
10112 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10113 error "write error: rc=$?"
10114 do_facet ost1 lctl set_param fail_loc=0
10117 cancel_lru_locks osc
10118 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10119 do_facet ost1 lctl set_param fail_loc=0x8000021b
10121 cmp $F77_TMP $file || error "file compare failed"
10122 do_facet ost1 lctl set_param fail_loc=0
10125 run_test 77g "checksum error on OST write, read"
10127 test_77k() { # LU-10906
10128 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10129 $GSS && skip_env "could not run with gss"
10131 local cksum_param="osc.$FSNAME*.checksums"
10132 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10136 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10137 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10138 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10141 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10142 error "failed to set checksum=$i on MGS"
10143 wait_update $HOSTNAME "$get_checksum" $i
10145 echo "remount client, checksum should be $i"
10146 remount_client $MOUNT || error "failed to remount client"
10147 checksum=$(eval $get_checksum)
10148 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10150 # remove persistent param to avoid races with checksum mountopt below
10151 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10152 error "failed to delete checksum on MGS"
10154 for opt in "checksum" "nochecksum"; do
10155 #remount with mount option
10156 echo "remount client with option $opt, checksum should be $i"
10157 umount_client $MOUNT || error "failed to umount client"
10158 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10159 error "failed to mount client with option '$opt'"
10160 checksum=$(eval $get_checksum)
10161 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10165 remount_client $MOUNT || error "failed to remount client"
10167 run_test 77k "enable/disable checksum correctly"
10170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10171 $GSS && skip_env "could not run with gss"
10174 stack_trap "set_checksums $ORIG_CSUM" EXIT
10175 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10177 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10179 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10180 for algo in $CKSUM_TYPES; do
10181 set_checksum_type $algo || error "fail to set checksum type $algo"
10182 osc_algo=$(get_osc_checksum_type OST0000)
10183 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10185 # no locks, no reqs to let the connection idle
10186 cancel_lru_locks osc
10187 lru_resize_disable osc
10188 wait_osc_import_state client ost1 IDLE
10190 # ensure ost1 is connected
10191 stat $DIR/$tfile >/dev/null || error "can't stat"
10192 wait_osc_import_state client ost1 FULL
10194 osc_algo=$(get_osc_checksum_type OST0000)
10195 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10199 run_test 77l "preferred checksum type is remembered after reconnected"
10201 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10206 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10207 skip "Need at least version 2.14.52"
10208 local param=checksum_speed
10210 $LCTL get_param $param || error "reading $param failed"
10212 csum_speeds=$($LCTL get_param -n $param)
10214 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10215 error "known checksum types are missing"
10217 run_test 77m "Verify checksum_speed is correctly read"
10219 check_filefrag_77n() {
10224 while read extidx a b start end rest; do
10225 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10226 nr_ext=$(( $nr_ext + 1 ))
10227 starts+=( ${start%..} )
10230 done < <( filefrag -sv $1 )
10232 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10237 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10240 $TRUNCATE $DIR/$tfile 0
10241 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10242 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10243 check_filefrag_77n $DIR/$tfile ||
10244 skip "$tfile blocks not contiguous around hole"
10247 stack_trap "set_checksums $ORIG_CSUM" EXIT
10248 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10249 stack_trap "rm -f $DIR/$tfile"
10251 for algo in $CKSUM_TYPES; do
10252 if [[ "$algo" =~ ^t10 ]]; then
10253 set_checksum_type $algo ||
10254 error "fail to set checksum type $algo"
10255 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10256 error "fail to read $tfile with $algo"
10262 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10265 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10266 skip "Need MDS version at least 2.14.55"
10267 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10268 skip "Need OST version at least 2.14.55"
10269 local ofd=obdfilter
10272 # print OST checksum_type
10273 echo "$ofd.$FSNAME-*.checksum_type:"
10274 do_nodes $(comma_list $(osts_nodes)) \
10275 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10277 # print MDT checksum_type
10278 echo "$mdt.$FSNAME-*.checksum_type:"
10279 do_nodes $(comma_list $(mdts_nodes)) \
10280 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10282 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10283 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10285 (( $o_count == $OSTCOUNT )) ||
10286 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10288 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10289 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10291 (( $m_count == $MDSCOUNT )) ||
10292 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10294 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10296 cleanup_test_78() {
10301 test_78() { # bug 10901
10302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10303 remote_ost || skip_env "local OST"
10306 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10307 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10308 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10309 echo "MemTotal: $MEMTOTAL"
10311 # reserve 256MB of memory for the kernel and other running processes,
10312 # and then take 1/2 of the remaining memory for the read/write buffers.
10313 if [ $MEMTOTAL -gt 512 ] ;then
10314 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10316 # for those poor memory-starved high-end clusters...
10317 MEMTOTAL=$((MEMTOTAL / 2))
10319 echo "Mem to use for directio: $MEMTOTAL"
10321 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10322 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10323 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10324 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10326 echo "Smallest OST: $SMALLESTOST"
10327 [[ $SMALLESTOST -lt 10240 ]] &&
10328 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10330 trap cleanup_test_78 EXIT
10332 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10333 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10335 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10336 echo "File size: $F78SIZE"
10337 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10338 for i in $(seq 1 $NSEQ); do
10339 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10340 echo directIO rdwr round $i of $NSEQ
10341 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10346 run_test 78 "handle large O_DIRECT writes correctly ============"
10348 test_79() { # bug 12743
10349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10351 wait_delete_completed
10353 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10354 BKFREE=$(calc_osc_kbytes kbytesfree)
10355 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10357 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10358 DFTOTAL=`echo $STRING | cut -d, -f1`
10359 DFUSED=`echo $STRING | cut -d, -f2`
10360 DFAVAIL=`echo $STRING | cut -d, -f3`
10361 DFFREE=$(($DFTOTAL - $DFUSED))
10363 ALLOWANCE=$((64 * $OSTCOUNT))
10365 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10366 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10367 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10369 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10370 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10371 error "df free($DFFREE) mismatch OST free($BKFREE)"
10373 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10374 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10375 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10378 run_test 79 "df report consistency check ======================="
10380 test_80() { # bug 10718
10381 remote_ost_nodsh && skip "remote OST with nodsh"
10382 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10384 # relax strong synchronous semantics for slow backends like ZFS
10385 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10386 local soc="obdfilter.*.sync_lock_cancel"
10387 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10389 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10390 if [ -z "$save" ]; then
10391 soc="obdfilter.*.sync_on_lock_cancel"
10392 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10395 if [ "$save" != "never" ]; then
10396 local hosts=$(comma_list $(osts_nodes))
10398 do_nodes $hosts $LCTL set_param $soc=never
10399 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10403 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10404 sync; sleep 1; sync
10405 local before=$(date +%s)
10406 cancel_lru_locks osc
10407 local after=$(date +%s)
10408 local diff=$((after - before))
10409 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10413 run_test 80 "Page eviction is equally fast at high offsets too"
10415 test_81a() { # LU-456
10416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10417 remote_ost_nodsh && skip "remote OST with nodsh"
10419 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10420 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10421 do_facet ost1 lctl set_param fail_loc=0x80000228
10423 # write should trigger a retry and success
10424 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10425 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10427 if [ $RC -ne 0 ] ; then
10428 error "write should success, but failed for $RC"
10431 run_test 81a "OST should retry write when get -ENOSPC ==============="
10433 test_81b() { # LU-456
10434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10435 remote_ost_nodsh && skip "remote OST with nodsh"
10437 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10438 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10439 do_facet ost1 lctl set_param fail_loc=0x228
10441 # write should retry several times and return -ENOSPC finally
10442 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10443 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10446 if [ $RC -ne $ENOSPC ] ; then
10447 error "dd should fail for -ENOSPC, but succeed."
10450 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10453 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10455 test_mkdir $DIR/$tdir.cvsroot
10456 chown $RUNAS_ID $DIR/$tdir.cvsroot
10459 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10462 # some versions of cvs import exit(1) when asked to import links or
10463 # files they can't read. ignore those files.
10464 local toignore=$(find . -type l -printf '-I %f\n' -o \
10465 ! -perm /4 -printf '-I %f\n')
10466 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10467 $tdir.reposname vtag rtag
10470 test_mkdir $DIR/$tdir.reposname
10471 chown $RUNAS_ID $DIR/$tdir.reposname
10472 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10474 cd $DIR/$tdir.reposname
10476 $RUNAS cvs add -m 'addmsg' foo99
10478 $RUNAS cvs commit -m 'nomsg' foo99
10479 rm -fr $DIR/$tdir.cvsroot
10481 run_test 99 "cvs strange file/directory operations"
10484 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10485 [[ "$NETTYPE" =~ tcp ]] ||
10486 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10487 remote_ost_nodsh && skip "remote OST with nodsh"
10488 remote_mds_nodsh && skip "remote MDS with nodsh"
10490 skip "useless for local single node setup"
10492 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10493 [ "$PROT" != "tcp" ] && continue
10494 RPORT=$(echo $REMOTE | cut -d: -f2)
10495 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10498 LPORT=`echo $LOCAL | cut -d: -f2`
10499 if [ $LPORT -ge 1024 ]; then
10500 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10502 error_exit "local: $LPORT > 1024, remote: $RPORT"
10505 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10507 run_test 100 "check local port using privileged port ==========="
10509 function get_named_value()
10513 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10516 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10517 awk '/^max_cached_mb/ { print $2 }')
10520 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10525 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10530 local cache_limit=32
10532 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10533 trap cleanup_101a EXIT
10534 $LCTL set_param -n llite.*.read_ahead_stats=0
10535 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10538 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10540 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10541 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10544 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10545 get_named_value 'read.but.discarded'); do
10546 discard=$(($discard + $s))
10550 $LCTL get_param osc.*-osc*.rpc_stats
10551 $LCTL get_param llite.*.read_ahead_stats
10553 # Discard is generally zero, but sometimes a few random reads line up
10554 # and trigger larger readahead, which is wasted & leads to discards.
10555 if [[ $(($discard)) -gt $nreads ]]; then
10556 error "too many ($discard) discarded pages"
10558 rm -f $DIR/$tfile || true
10560 run_test 101a "check read-ahead for random reads"
10562 setup_test101bc() {
10563 test_mkdir $DIR/$tdir
10565 local FILE_LENGTH=$2
10568 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10570 local list=$(comma_list $(osts_nodes))
10571 set_osd_param $list '' read_cache_enable 0
10572 set_osd_param $list '' writethrough_cache_enable 0
10574 trap cleanup_test101bc EXIT
10575 # prepare the read-ahead file
10576 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10578 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10579 count=$FILE_SIZE_MB 2> /dev/null
10583 cleanup_test101bc() {
10588 local list=$(comma_list $(osts_nodes))
10589 set_osd_param $list '' read_cache_enable 1
10590 set_osd_param $list '' writethrough_cache_enable 1
10594 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10599 local stripe_size=$2
10600 local stride_length=$((stripe_size / read_size))
10601 local stride_width=$((stride_length * OSTCOUNT))
10602 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10603 (stride_width - stride_length) ))
10604 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10605 get_named_value 'read.but.discarded' | calc_total)
10607 if [[ $discard -gt $discard_limit ]]; then
10608 $LCTL get_param llite.*.read_ahead_stats
10609 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
10611 echo "Read-ahead success for size ${read_size}"
10616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10617 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10619 local STRIPE_SIZE=1048576
10620 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10622 if [ $SLOW == "yes" ]; then
10623 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10625 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10628 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10630 # prepare the read-ahead file
10631 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10632 cancel_lru_locks osc
10633 for BIDX in 2 4 8 16 32 64 128 256
10635 local BSIZE=$((BIDX*4096))
10636 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10637 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10638 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10639 $LCTL set_param -n llite.*.read_ahead_stats=0
10640 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10641 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10642 cancel_lru_locks osc
10643 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10648 run_test 101b "check stride-io mode read-ahead ================="
10651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10653 local STRIPE_SIZE=1048576
10654 local FILE_LENGTH=$((STRIPE_SIZE*100))
10657 local osc_rpc_stats
10659 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10661 cancel_lru_locks osc
10662 $LCTL set_param osc.*.rpc_stats=0
10663 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10664 $LCTL get_param osc.*.rpc_stats
10665 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10666 local stats=$($LCTL get_param -n $osc_rpc_stats)
10667 local lines=$(echo "$stats" | awk 'END {print NR;}')
10670 if [ $lines -le 20 ]; then
10671 echo "continue debug"
10674 for size in 1 2 4 8; do
10675 local rpc=$(echo "$stats" |
10676 awk '($1 == "'$size':") {print $2; exit; }')
10677 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10678 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10680 echo "$osc_rpc_stats check passed!"
10685 run_test 101c "check stripe_size aligned read-ahead"
10688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10690 local file=$DIR/$tfile
10691 local sz_MB=${FILESIZE_101d:-80}
10692 local ra_MB=${READAHEAD_MB:-40}
10694 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10695 [ $free_MB -lt $sz_MB ] &&
10696 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10698 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10699 $LFS setstripe -c -1 $file || error "setstripe failed"
10701 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10702 echo Cancel LRU locks on lustre client to flush the client cache
10703 cancel_lru_locks osc
10705 echo Disable read-ahead
10706 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10707 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10708 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10709 $LCTL get_param -n llite.*.max_read_ahead_mb
10711 echo "Reading the test file $file with read-ahead disabled"
10712 local sz_KB=$((sz_MB * 1024 / 4))
10713 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10714 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10715 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10716 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10718 echo "Cancel LRU locks on lustre client to flush the client cache"
10719 cancel_lru_locks osc
10720 echo Enable read-ahead with ${ra_MB}MB
10721 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10723 echo "Reading the test file $file with read-ahead enabled"
10724 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10725 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10727 echo "read-ahead disabled time read $raOFF"
10728 echo "read-ahead enabled time read $raON"
10731 wait_delete_completed
10733 # use awk for this check instead of bash because it handles decimals
10734 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10735 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10737 run_test 101d "file read with and without read-ahead enabled"
10740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10742 local file=$DIR/$tfile
10743 local size_KB=500 #KB
10747 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10748 local need_KB=$((count * size_KB))
10749 [[ $free_KB -le $need_KB ]] &&
10750 skip_env "Need free space $need_KB, have $free_KB"
10752 echo "Creating $count ${size_KB}K test files"
10753 for ((i = 0; i < $count; i++)); do
10754 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10757 echo "Cancel LRU locks on lustre client to flush the client cache"
10758 cancel_lru_locks $OSC
10760 echo "Reset readahead stats"
10761 $LCTL set_param -n llite.*.read_ahead_stats=0
10763 for ((i = 0; i < $count; i++)); do
10764 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10767 $LCTL get_param llite.*.max_cached_mb
10768 $LCTL get_param llite.*.read_ahead_stats
10769 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10770 get_named_value 'misses' | calc_total)
10772 for ((i = 0; i < $count; i++)); do
10773 rm -rf $file.$i 2>/dev/null
10776 #10000 means 20% reads are missing in readahead
10777 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10779 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10782 which iozone || skip_env "no iozone installed"
10784 local old_debug=$($LCTL get_param debug)
10785 old_debug=${old_debug#*=}
10786 $LCTL set_param debug="reada mmap"
10788 # create a test file
10789 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10791 echo Cancel LRU locks on lustre client to flush the client cache
10792 cancel_lru_locks osc
10794 echo Reset readahead stats
10795 $LCTL set_param -n llite.*.read_ahead_stats=0
10797 echo mmap read the file with small block size
10798 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10801 echo checking missing pages
10802 $LCTL get_param llite.*.read_ahead_stats
10803 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10804 get_named_value 'misses' | calc_total)
10806 $LCTL set_param debug="$old_debug"
10807 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10810 run_test 101f "check mmap read performance"
10812 test_101g_brw_size_test() {
10814 local pages=$((mb * 1048576 / PAGE_SIZE))
10815 local file=$DIR/$tfile
10817 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10818 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10819 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10820 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10824 stack_trap "rm -f $file" EXIT
10825 $LCTL set_param -n osc.*.rpc_stats=0
10827 # 10 RPCs should be enough for the test
10829 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10830 { error "dd write ${mb} MB blocks failed"; return 3; }
10831 cancel_lru_locks osc
10832 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10833 { error "dd write ${mb} MB blocks failed"; return 4; }
10835 # calculate number of full-sized read and write RPCs
10836 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10837 sed -n '/pages per rpc/,/^$/p' |
10838 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10839 END { print reads,writes }'))
10840 # allow one extra full-sized read RPC for async readahead
10841 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10842 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10843 [[ ${rpcs[1]} == $count ]] ||
10844 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10848 remote_ost_nodsh && skip "remote OST with nodsh"
10851 local osts=$(get_facets OST)
10852 local list=$(comma_list $(osts_nodes))
10853 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10854 local brw_size="obdfilter.*.brw_size"
10856 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10858 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10860 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10861 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10862 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10863 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10864 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10865 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10867 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10870 if [[ $orig_mb -lt 16 ]]; then
10871 save_lustre_params $osts "$brw_size" > $p
10872 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10873 error "set 16MB RPC size failed"
10875 echo "remount client to enable new RPC size"
10876 remount_client $MOUNT || error "remount_client failed"
10879 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10880 # should be able to set brw_size=12, but no rpc_stats for that
10881 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10884 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10886 if [[ $orig_mb -lt 16 ]]; then
10887 restore_lustre_params < $p
10888 remount_client $MOUNT || error "remount_client restore failed"
10891 rm -f $p $DIR/$tfile
10893 run_test 101g "Big bulk(4/16 MiB) readahead"
10896 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10898 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10899 error "dd 70M file failed"
10900 echo Cancel LRU locks on lustre client to flush the client cache
10901 cancel_lru_locks osc
10903 echo "Reset readahead stats"
10904 $LCTL set_param -n llite.*.read_ahead_stats 0
10906 echo "Read 10M of data but cross 64M bundary"
10907 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10908 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10909 get_named_value 'misses' | calc_total)
10910 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10911 rm -f $p $DIR/$tfile
10913 run_test 101h "Readahead should cover current read window"
10916 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10917 error "dd 10M file failed"
10919 local max_per_file_mb=$($LCTL get_param -n \
10920 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10921 cancel_lru_locks osc
10922 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10923 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10924 error "set max_read_ahead_per_file_mb to 1 failed"
10926 echo "Reset readahead stats"
10927 $LCTL set_param llite.*.read_ahead_stats=0
10929 dd if=$DIR/$tfile of=/dev/null bs=2M
10931 $LCTL get_param llite.*.read_ahead_stats
10932 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10933 awk '/misses/ { print $2 }')
10934 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10937 run_test 101i "allow current readahead to exceed reservation"
10940 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10941 error "setstripe $DIR/$tfile failed"
10942 local file_size=$((1048576 * 16))
10943 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10944 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10946 echo Disable read-ahead
10947 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10949 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10950 for blk in $PAGE_SIZE 1048576 $file_size; do
10951 cancel_lru_locks osc
10952 echo "Reset readahead stats"
10953 $LCTL set_param -n llite.*.read_ahead_stats=0
10954 local count=$(($file_size / $blk))
10955 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
10956 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10957 get_named_value 'failed.to.fast.read' | calc_total)
10958 $LCTL get_param -n llite.*.read_ahead_stats
10959 [ $miss -eq $count ] || error "expected $count got $miss"
10962 rm -f $p $DIR/$tfile
10964 run_test 101j "A complete read block should be submitted when no RA"
10967 test_mkdir $DIR/$tdir
10968 chown $RUNAS_ID $DIR/$tdir
10971 STRIPE_COUNT=$OSTCOUNT
10972 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
10974 trap cleanup_test102 EXIT
10976 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
10978 for num in 1 2 3 4; do
10979 for count in $(seq 1 $STRIPE_COUNT); do
10980 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
10981 local size=`expr $STRIPE_SIZE \* $num`
10982 local file=file"$num-$idx-$count"
10983 $1 $LFS setstripe -S $size -i $idx -c $count $file
10989 $1 tar cf $TMP/f102.tar $tdir --xattrs
10992 cleanup_test102() {
10994 rm -f $TMP/f102.tar
10995 rm -rf $DIR/d0.sanity/d102
10999 [ "$UID" != 0 ] && skip "must run as root"
11000 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11001 skip_env "must have user_xattr"
11003 [ -z "$(which setfattr 2>/dev/null)" ] &&
11004 skip_env "could not find setfattr"
11006 local testfile=$DIR/$tfile
11009 echo "set/get xattr..."
11010 setfattr -n trusted.name1 -v value1 $testfile ||
11011 error "setfattr -n trusted.name1=value1 $testfile failed"
11012 getfattr -n trusted.name1 $testfile 2> /dev/null |
11013 grep "trusted.name1=.value1" ||
11014 error "$testfile missing trusted.name1=value1"
11016 setfattr -n user.author1 -v author1 $testfile ||
11017 error "setfattr -n user.author1=author1 $testfile failed"
11018 getfattr -n user.author1 $testfile 2> /dev/null |
11019 grep "user.author1=.author1" ||
11020 error "$testfile missing trusted.author1=author1"
11022 echo "listxattr..."
11023 setfattr -n trusted.name2 -v value2 $testfile ||
11024 error "$testfile unable to set trusted.name2"
11025 setfattr -n trusted.name3 -v value3 $testfile ||
11026 error "$testfile unable to set trusted.name3"
11027 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11028 grep "trusted.name" | wc -l) -eq 3 ] ||
11029 error "$testfile missing 3 trusted.name xattrs"
11031 setfattr -n user.author2 -v author2 $testfile ||
11032 error "$testfile unable to set user.author2"
11033 setfattr -n user.author3 -v author3 $testfile ||
11034 error "$testfile unable to set user.author3"
11035 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11036 grep "user.author" | wc -l) -eq 3 ] ||
11037 error "$testfile missing 3 user.author xattrs"
11039 echo "remove xattr..."
11040 setfattr -x trusted.name1 $testfile ||
11041 error "$testfile error deleting trusted.name1"
11042 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11043 error "$testfile did not delete trusted.name1 xattr"
11045 setfattr -x user.author1 $testfile ||
11046 error "$testfile error deleting user.author1"
11047 echo "set lustre special xattr ..."
11048 $LFS setstripe -c1 $testfile
11049 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11050 awk -F "=" '/trusted.lov/ { print $2 }' )
11051 setfattr -n "trusted.lov" -v $lovea $testfile ||
11052 error "$testfile doesn't ignore setting trusted.lov again"
11053 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11054 error "$testfile allow setting invalid trusted.lov"
11057 run_test 102a "user xattr test =================================="
11059 check_102b_layout() {
11061 local testfile=$DIR/$tfile
11063 echo "test layout '$layout'"
11064 $LFS setstripe $layout $testfile || error "setstripe failed"
11065 $LFS getstripe -y $testfile
11067 echo "get/set/list trusted.lov xattr ..." # b=10930
11068 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11069 [[ "$value" =~ "trusted.lov" ]] ||
11070 error "can't get trusted.lov from $testfile"
11071 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11072 error "getstripe failed"
11074 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11076 value=$(cut -d= -f2 <<<$value)
11077 # LU-13168: truncated xattr should fail if short lov_user_md header
11078 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11079 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11080 for len in $lens; do
11081 echo "setfattr $len $testfile.2"
11082 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11083 [ $len -lt 66 ] && error "short xattr len=$len worked"
11085 local stripe_size=$($LFS getstripe -S $testfile.2)
11086 local stripe_count=$($LFS getstripe -c $testfile.2)
11087 [[ $stripe_size -eq 65536 ]] ||
11088 error "stripe size $stripe_size != 65536"
11089 [[ $stripe_count -eq $stripe_count_orig ]] ||
11090 error "stripe count $stripe_count != $stripe_count_orig"
11091 rm $testfile $testfile.2
11095 [ -z "$(which setfattr 2>/dev/null)" ] &&
11096 skip_env "could not find setfattr"
11097 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11099 # check plain layout
11100 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11102 # and also check composite layout
11103 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11106 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11109 [ -z "$(which setfattr 2>/dev/null)" ] &&
11110 skip_env "could not find setfattr"
11111 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11113 # b10930: get/set/list lustre.lov xattr
11114 echo "get/set/list lustre.lov xattr ..."
11115 test_mkdir $DIR/$tdir
11116 chown $RUNAS_ID $DIR/$tdir
11117 local testfile=$DIR/$tdir/$tfile
11118 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11119 error "setstripe failed"
11120 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11121 error "getstripe failed"
11122 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11123 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11125 local testfile2=${testfile}2
11126 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11127 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11129 $RUNAS $MCREATE $testfile2
11130 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11131 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11132 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11133 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11134 [ $stripe_count -eq $STRIPECOUNT ] ||
11135 error "stripe count $stripe_count != $STRIPECOUNT"
11137 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11139 compare_stripe_info1() {
11140 local stripe_index_all_zero=true
11142 for num in 1 2 3 4; do
11143 for count in $(seq 1 $STRIPE_COUNT); do
11144 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11145 local size=$((STRIPE_SIZE * num))
11146 local file=file"$num-$offset-$count"
11147 stripe_size=$($LFS getstripe -S $PWD/$file)
11148 [[ $stripe_size -ne $size ]] &&
11149 error "$file: size $stripe_size != $size"
11150 stripe_count=$($LFS getstripe -c $PWD/$file)
11151 # allow fewer stripes to be created, ORI-601
11152 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11153 error "$file: count $stripe_count != $count"
11154 stripe_index=$($LFS getstripe -i $PWD/$file)
11155 [[ $stripe_index -ne 0 ]] &&
11156 stripe_index_all_zero=false
11160 $stripe_index_all_zero &&
11161 error "all files are being extracted starting from OST index 0"
11165 have_xattrs_include() {
11166 tar --help | grep -q xattrs-include &&
11167 echo --xattrs-include="lustre.*"
11171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11172 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11174 XINC=$(have_xattrs_include)
11176 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11177 cd $DIR/$tdir/$tdir
11178 compare_stripe_info1
11180 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11184 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11186 XINC=$(have_xattrs_include)
11188 test_mkdir $DIR/$tdir.restore
11190 tar cf - --xattrs $tdir | tar xf - \
11191 -C $DIR/$tdir.restore --xattrs $XINC
11192 cd $DIR/$tdir.restore/$tdir
11193 compare_stripe_info1
11195 run_test 102f "tar copy files, not keep osts"
11198 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11199 skip "must have user_xattr"
11200 [ -z "$(which setfattr 2>/dev/null)" ] &&
11201 skip_env "could not find setfattr"
11202 [ -z "$(which getfattr 2>/dev/null)" ] &&
11203 skip_env "could not find getfattr"
11205 local xsize=${1:-1024} # in bytes
11206 local file=$DIR/$tfile
11207 local value="$(generate_string $xsize)"
11208 local xbig=trusted.big
11212 log "save $xbig on $file"
11213 if [ -z "$toobig" ]
11215 setfattr -n $xbig -v $value $file ||
11216 error "saving $xbig on $file failed"
11218 setfattr -n $xbig -v $value $file &&
11219 error "saving $xbig on $file succeeded"
11223 local orig=$(get_xattr_value $xbig $file)
11224 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11226 local xsml=trusted.sml
11227 log "save $xsml on $file"
11228 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11230 local new=$(get_xattr_value $xbig $file)
11231 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11233 log "grow $xsml on $file"
11234 setfattr -n $xsml -v "$value" $file ||
11235 error "growing $xsml on $file failed"
11237 new=$(get_xattr_value $xbig $file)
11238 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11239 log "$xbig still valid after growing $xsml"
11244 test_102h() { # bug 15777
11247 run_test 102h "grow xattr from inside inode to external block"
11250 large_xattr_enabled || skip_env "ea_inode feature disabled"
11252 echo "setting xattr of max xattr size: $(max_xattr_size)"
11253 grow_xattr $(max_xattr_size)
11255 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11256 echo "This should fail:"
11257 grow_xattr $(($(max_xattr_size) + 10)) 1
11259 run_test 102ha "grow xattr from inside inode to external inode"
11261 test_102i() { # bug 17038
11262 [ -z "$(which getfattr 2>/dev/null)" ] &&
11263 skip "could not find getfattr"
11266 ln -s $DIR/$tfile $DIR/${tfile}link
11267 getfattr -n trusted.lov $DIR/$tfile ||
11268 error "lgetxattr on $DIR/$tfile failed"
11269 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11270 grep -i "no such attr" ||
11271 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11272 rm -f $DIR/$tfile $DIR/${tfile}link
11274 run_test 102i "lgetxattr test on symbolic link ============"
11277 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11278 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11280 XINC=$(have_xattrs_include)
11281 setup_test102 "$RUNAS"
11282 chown $RUNAS_ID $DIR/$tdir
11283 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11284 cd $DIR/$tdir/$tdir
11285 compare_stripe_info1 "$RUNAS"
11287 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11290 [ -z "$(which setfattr 2>/dev/null)" ] &&
11291 skip "could not find setfattr"
11294 # b22187 just check that does not crash for regular file.
11295 setfattr -n trusted.lov $DIR/$tfile
11296 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11297 local test_kdir=$DIR/$tdir
11298 test_mkdir $test_kdir
11299 local default_size=$($LFS getstripe -S $test_kdir)
11300 local default_count=$($LFS getstripe -c $test_kdir)
11301 local default_offset=$($LFS getstripe -i $test_kdir)
11302 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11303 error 'dir setstripe failed'
11304 setfattr -n trusted.lov $test_kdir
11305 local stripe_size=$($LFS getstripe -S $test_kdir)
11306 local stripe_count=$($LFS getstripe -c $test_kdir)
11307 local stripe_offset=$($LFS getstripe -i $test_kdir)
11308 [ $stripe_size -eq $default_size ] ||
11309 error "stripe size $stripe_size != $default_size"
11310 [ $stripe_count -eq $default_count ] ||
11311 error "stripe count $stripe_count != $default_count"
11312 [ $stripe_offset -eq $default_offset ] ||
11313 error "stripe offset $stripe_offset != $default_offset"
11314 rm -rf $DIR/$tfile $test_kdir
11316 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11319 [ -z "$(which getfattr 2>/dev/null)" ] &&
11320 skip "could not find getfattr"
11322 # LU-532 trusted. xattr is invisible to non-root
11323 local testfile=$DIR/$tfile
11327 echo "listxattr as user..."
11328 chown $RUNAS_ID $testfile
11329 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11330 grep -q "trusted" &&
11331 error "$testfile trusted xattrs are user visible"
11335 run_test 102l "listxattr size test =================================="
11337 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11338 local path=$DIR/$tfile
11341 listxattr_size_check $path || error "listattr_size_check $path failed"
11343 run_test 102m "Ensure listxattr fails on small bufffer ========"
11347 getxattr() { # getxattr path name
11348 # Return the base64 encoding of the value of xattr name on path.
11352 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11354 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11356 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11358 getfattr --absolute-names --encoding=base64 --name=$name $path |
11359 awk -F= -v name=$name '$1 == name {
11360 print substr($0, index($0, "=") + 1);
11364 test_102n() { # LU-4101 mdt: protect internal xattrs
11365 [ -z "$(which setfattr 2>/dev/null)" ] &&
11366 skip "could not find setfattr"
11367 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11369 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11372 local file0=$DIR/$tfile.0
11373 local file1=$DIR/$tfile.1
11374 local xattr0=$TMP/$tfile.0
11375 local xattr1=$TMP/$tfile.1
11376 local namelist="lov lma lmv link fid version som hsm"
11380 rm -rf $file0 $file1 $xattr0 $xattr1
11381 touch $file0 $file1
11383 # Get 'before' xattrs of $file1.
11384 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11386 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11387 namelist+=" lfsck_namespace"
11388 for name in $namelist; do
11389 # Try to copy xattr from $file0 to $file1.
11390 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11392 setfattr --name=trusted.$name --value="$value" $file1 ||
11393 error "setxattr 'trusted.$name' failed"
11395 # Try to set a garbage xattr.
11396 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11398 if [[ x$name == "xlov" ]]; then
11399 setfattr --name=trusted.lov --value="$value" $file1 &&
11400 error "setxattr invalid 'trusted.lov' success"
11402 setfattr --name=trusted.$name --value="$value" $file1 ||
11403 error "setxattr invalid 'trusted.$name' failed"
11406 # Try to remove the xattr from $file1. We don't care if this
11407 # appears to succeed or fail, we just don't want there to be
11408 # any changes or crashes.
11409 setfattr --remove=$trusted.$name $file1 2> /dev/null
11412 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11415 # Try to copy xattr from $file0 to $file1.
11416 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11418 setfattr --name=trusted.$name --value="$value" $file1 ||
11419 error "setxattr 'trusted.$name' failed"
11421 # Try to set a garbage xattr.
11422 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11424 setfattr --name=trusted.$name --value="$value" $file1 ||
11425 error "setxattr 'trusted.$name' failed"
11427 # Try to remove the xattr from $file1. We don't care if this
11428 # appears to succeed or fail, we just don't want there to be
11429 # any changes or crashes.
11430 setfattr --remove=$trusted.$name $file1 2> /dev/null
11433 # Get 'after' xattrs of file1.
11434 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11436 if ! diff $xattr0 $xattr1; then
11437 error "before and after xattrs of '$file1' differ"
11440 rm -rf $file0 $file1 $xattr0 $xattr1
11444 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11446 test_102p() { # LU-4703 setxattr did not check ownership
11447 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11448 skip "MDS needs to be at least 2.5.56"
11450 local testfile=$DIR/$tfile
11454 echo "setfacl as user..."
11455 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11456 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11458 echo "setfattr as user..."
11459 setfacl -m "u:$RUNAS_ID:---" $testfile
11460 $RUNAS setfattr -x system.posix_acl_access $testfile
11461 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11463 run_test 102p "check setxattr(2) correctly fails without permission"
11466 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11467 skip "MDS needs to be at least 2.6.92"
11469 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11471 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11474 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11475 skip "MDS needs to be at least 2.6.93"
11477 touch $DIR/$tfile || error "touch"
11478 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11479 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11480 rm $DIR/$tfile || error "rm"
11483 mkdir -p $DIR/$tdir || error "mkdir"
11484 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11485 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11486 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11487 error "$testfile error deleting user.author1"
11488 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11489 grep "user.$(basename $tdir)" &&
11490 error "$tdir did not delete user.$(basename $tdir)"
11491 rmdir $DIR/$tdir || error "rmdir"
11494 test_mkdir $DIR/$tdir
11495 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11496 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11497 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11498 error "$testfile error deleting user.author1"
11499 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11500 grep "user.$(basename $tdir)" &&
11501 error "$tdir did not delete user.$(basename $tdir)"
11502 rmdir $DIR/$tdir || error "rm striped dir"
11504 run_test 102r "set EAs with empty values"
11507 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11508 skip "MDS needs to be at least 2.11.52"
11510 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11512 save_lustre_params client "llite.*.xattr_cache" > $save
11514 for cache in 0 1; do
11515 lctl set_param llite.*.xattr_cache=$cache
11518 touch $DIR/$tfile || error "touch"
11519 for prefix in lustre security system trusted user; do
11520 # Note getxattr() may fail with 'Operation not
11521 # supported' or 'No such attribute' depending
11522 # on prefix and cache.
11523 getfattr -n $prefix.n102s $DIR/$tfile &&
11524 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11528 restore_lustre_params < $save
11530 run_test 102s "getting nonexistent xattrs should fail"
11533 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11534 skip "MDS needs to be at least 2.11.52"
11536 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11538 save_lustre_params client "llite.*.xattr_cache" > $save
11540 for cache in 0 1; do
11541 lctl set_param llite.*.xattr_cache=$cache
11543 for buf_size in 0 256; do
11545 touch $DIR/$tfile || error "touch"
11546 setfattr -n user.multiop $DIR/$tfile
11547 $MULTIOP $DIR/$tfile oa$buf_size ||
11548 error "cannot get zero length xattr value (buf_size = $buf_size)"
11552 restore_lustre_params < $save
11554 run_test 102t "zero length xattr values handled correctly"
11558 local test=$LUSTRE/tests/acl/$1.test
11559 local tmp=$(mktemp -t $1-XXXXXX).test
11567 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
11568 local sedgroups="-e s/:users/:$grp/g"
11569 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
11571 sed $sedusers $sedgroups < $test > $tmp
11572 stack_trap "rm -f $tmp"
11573 [[ -s $tmp ]] || error "sed failed to create test script"
11575 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
11576 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
11580 [ "$UID" != 0 ] && skip "must run as root"
11581 $GSS && skip_env "could not run under gss"
11582 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
11583 skip_env "must have acl enabled"
11584 which setfacl || skip_env "could not find setfacl"
11585 remote_mds_nodsh && skip "remote MDS with nodsh"
11587 ACLBIN=${ACLBIN:-"bin"}
11588 ACLDMN=${ACLDMN:-"daemon"}
11589 ACLGRP=${ACLGRP:-"users"}
11590 ACLNBD=${ACLNBD:-"nobody"}
11593 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
11594 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
11596 if ! id $ACLBIN ; then
11598 skip_env "can't find suitable ACL 'bin' $ACLBIN"
11601 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
11602 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
11603 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
11605 if ! id $ACLDMN ; then
11607 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
11610 if ! getent group $ACLGRP; then
11611 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
11613 if ! getent group $ACLGRP; then
11614 echo "cannot find group '$ACLGRP', adding it"
11616 add_group 60000 $ACLGRP
11620 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
11621 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
11622 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11624 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11625 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
11627 if ! getent group $ACLGRP; then
11628 echo "cannot find group '$ACLGRP', adding it"
11630 add_group 60000 $ACLGRP
11632 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11633 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11635 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
11639 gpasswd -a $ACLDMN $ACLBIN ||
11640 error "setting client group failed" # LU-5641
11641 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
11642 error "setting MDS group failed" # LU-5641
11644 declare -a identity_old
11646 for num in $(seq $MDSCOUNT); do
11647 switch_identity $num true || identity_old[$num]=$?
11650 SAVE_UMASK=$(umask)
11652 mkdir -p $DIR/$tdir
11655 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
11656 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
11657 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
11658 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
11659 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
11660 # CentOS7- uses nobody=99, while newer distros use nobody=65534
11661 if ! id -u $ACLNBD ||
11662 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
11664 if ! id -u $ACLNBD; then
11668 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
11669 add_group $(id -u $ACLNBD) $ACLNBD
11670 if ! getent group $ACLNBD; then
11674 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
11675 [[ -n "$ACLNBD" ]] && which setfattr; then
11676 run_acl_subtest permissions_xattr \
11677 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
11678 elif [[ -z "$ACLNBD" ]]; then
11679 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
11681 echo "skip 'permission_xattr' test - missing setfattr command"
11683 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
11685 # inheritance test got from HP
11686 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11687 chmod +x make-tree || error "chmod +x failed"
11688 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
11691 echo "LU-974 ignore umask when acl is enabled..."
11692 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
11693 if [ $MDSCOUNT -ge 2 ]; then
11694 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
11697 echo "LU-2561 newly created file is same size as directory..."
11698 if [ "$mds1_FSTYPE" != "zfs" ]; then
11699 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
11701 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
11704 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
11709 for num in $(seq $MDSCOUNT); do
11710 if [ "${identity_old[$num]}" = 1 ]; then
11711 switch_identity $num false || identity_old[$num]=$?
11715 run_test 103a "acl test"
11721 for U in {0..511}; do
11723 local O=$(printf "%04o" $U)
11725 umask $(printf "%04o" $((511 ^ $O)))
11726 $LFS setstripe -c 1 $DIR/$tfile.s$O
11727 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11729 (( $S == ($O & 0666) )) ||
11730 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11732 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11733 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11734 (( $S == ($O & 0666) )) ||
11735 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11737 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11738 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11739 (( $S == ($O & 0666) )) ||
11740 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11741 rm -f $DIR/$tfile.[smp]$0
11745 # limit the concurrently running threads to 64. LU-11878
11746 local idx=$((U % 64))
11747 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11752 run_test 103b "umask lfs setstripe"
11755 mkdir -p $DIR/$tdir
11756 cp -rp $DIR/$tdir $DIR/$tdir.bak
11758 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11759 error "$DIR/$tdir shouldn't contain default ACL"
11760 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11761 error "$DIR/$tdir.bak shouldn't contain default ACL"
11764 run_test 103c "'cp -rp' won't set empty acl"
11769 local saved_debug=$($LCTL get_param -n debug)
11771 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
11772 skip "MDS needs to be at least 2.14.52"
11774 large_xattr_enabled || skip_env "ea_inode feature disabled"
11776 mkdir -p $DIR/$tdir
11777 # add big LOV EA to cause reply buffer overflow earlier
11778 $LFS setstripe -C 1000 $DIR/$tdir
11779 lctl set_param mdc.*-mdc*.stats=clear
11781 $LCTL set_param debug=0
11782 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11783 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11785 # add a large number of default ACLs (expect 8000+ for 2.13+)
11786 for U in {2..7000}; do
11787 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11788 error "Able to add just $U default ACLs"
11790 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11791 echo "$numacl default ACLs created"
11793 stat $DIR/$tdir || error "Cannot stat directory"
11794 # check file creation
11795 touch $DIR/$tdir/$tfile ||
11796 error "failed to create $tfile with $numacl default ACLs"
11797 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11798 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11799 echo "$fileacl ACLs were inherited"
11800 (( $fileacl == $numacl )) ||
11801 error "Not all default ACLs were inherited: $numacl != $fileacl"
11802 # check that new ACLs creation adds new ACLs to inherited ACLs
11803 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11804 error "Cannot set new ACL"
11805 numacl=$((numacl + 1))
11806 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11807 (( $fileacl == $numacl )) ||
11808 error "failed to add new ACL: $fileacl != $numacl as expected"
11809 # adds more ACLs to a file to reach their maximum at 8000+
11811 for U in {20000..25000}; do
11812 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11813 numacl=$((numacl + 1))
11815 echo "Added $numacl more ACLs to the file"
11816 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11817 echo "Total $fileacl ACLs in file"
11818 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11819 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11820 rmdir $DIR/$tdir || error "Cannot remove directory"
11822 run_test 103e "inheritance of big amount of default ACLs"
11825 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11826 skip "MDS needs to be at least 2.14.51"
11828 large_xattr_enabled || skip_env "ea_inode feature disabled"
11830 # enable changelog to consume more internal MDD buffers
11833 mkdir -p $DIR/$tdir
11835 $LFS setstripe -C 1000 $DIR/$tdir
11836 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11837 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11838 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11839 rmdir $DIR/$tdir || error "Cannot remove directory"
11841 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11844 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11847 lfs df || error "lfs df failed"
11848 lfs df -ih || error "lfs df -ih failed"
11849 lfs df -h $DIR || error "lfs df -h $DIR failed"
11850 lfs df -i $DIR || error "lfs df -i $DIR failed"
11851 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11852 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11854 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11855 lctl --device %$OSC deactivate
11856 lfs df || error "lfs df with deactivated OSC failed"
11857 lctl --device %$OSC activate
11858 # wait the osc back to normal
11859 wait_osc_import_ready client ost
11861 lfs df || error "lfs df with reactivated OSC failed"
11864 run_test 104a "lfs df [-ih] [path] test ========================="
11867 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11868 [ $RUNAS_ID -eq $UID ] &&
11869 skip_env "RUNAS_ID = UID = $UID -- skipping"
11871 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11872 grep "Permission denied" | wc -l)))
11873 if [ $denied_cnt -ne 0 ]; then
11874 error "lfs check servers test failed"
11877 run_test 104b "$RUNAS lfs check servers test ===================="
11880 # Verify $1 is within range of $2.
11881 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11882 # $1 is <= 2% of $2. Else Fail.
11885 # Strip all units (M, G, T)
11886 actual=$(echo $1 | tr -d A-Z)
11887 expect=$(echo $2 | tr -d A-Z)
11889 expect_lo=$(($expect * 98 / 100)) # 2% below
11890 expect_hi=$(($expect * 102 / 100)) # 2% above
11892 # permit 2% drift above and below
11893 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11898 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11900 local ost_param="osd-zfs.$FSNAME-OST0000."
11901 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11902 local ofacets=$(get_facets OST)
11903 local mfacets=$(get_facets MDS)
11904 local saved_ost_blocks=
11905 local saved_mdt_blocks=
11907 echo "Before recordsize change"
11908 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11909 df=($(df -h | grep "$MOUNT"$))
11912 echo "lfs output : ${lfs_df[*]}"
11913 echo "df output : ${df[*]}"
11915 for facet in ${ofacets//,/ }; do
11916 if [ -z $saved_ost_blocks ]; then
11917 saved_ost_blocks=$(do_facet $facet \
11918 lctl get_param -n $ost_param.blocksize)
11919 echo "OST Blocksize: $saved_ost_blocks"
11921 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11922 do_facet $facet zfs set recordsize=32768 $ost
11925 # BS too small. Sufficient for functional testing.
11926 for facet in ${mfacets//,/ }; do
11927 if [ -z $saved_mdt_blocks ]; then
11928 saved_mdt_blocks=$(do_facet $facet \
11929 lctl get_param -n $mdt_param.blocksize)
11930 echo "MDT Blocksize: $saved_mdt_blocks"
11932 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11933 do_facet $facet zfs set recordsize=32768 $mdt
11936 # Give new values chance to reflect change
11939 echo "After recordsize change"
11940 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11941 df_after=($(df -h | grep "$MOUNT"$))
11944 echo "lfs output : ${lfs_df_after[*]}"
11945 echo "df output : ${df_after[*]}"
11948 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11949 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11950 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11951 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11952 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
11953 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
11956 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
11957 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
11958 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
11959 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
11960 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
11961 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
11963 # Restore MDT recordize back to original
11964 for facet in ${mfacets//,/ }; do
11965 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11966 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
11969 # Restore OST recordize back to original
11970 for facet in ${ofacets//,/ }; do
11971 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11972 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
11977 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
11980 (( $RUNAS_ID != $UID )) ||
11981 skip_env "RUNAS_ID = UID = $UID -- skipping"
11983 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
11984 skip "lustre version doesn't support lctl dl with non-root"
11986 # debugfs only allows root users to access files, so the
11987 # previous move of the "devices" file to debugfs broke
11988 # "lctl dl" for non-root users. The LU-9680 Netlink
11989 # interface again allows non-root users to list devices.
11990 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
11991 error "lctl dl doesn't work for non root"
11993 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
11994 [ "$ost_count" -eq $OSTCOUNT ] ||
11995 error "lctl dl reports wrong number of OST devices"
11997 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
11998 [ "$mdt_count" -eq $MDSCOUNT ] ||
11999 error "lctl dl reports wrong number of MDT devices"
12001 run_test 104d "$RUNAS lctl dl test"
12004 # doesn't work on 2.4 kernels
12006 if $(flock_is_enabled); then
12007 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12009 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12013 run_test 105a "flock when mounted without -o flock test ========"
12017 if $(flock_is_enabled); then
12018 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12020 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12024 run_test 105b "fcntl when mounted without -o flock test ========"
12028 if $(flock_is_enabled); then
12029 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12031 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12035 run_test 105c "lockf when mounted without -o flock test"
12037 test_105d() { # bug 15924
12038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12040 test_mkdir $DIR/$tdir
12041 flock_is_enabled || skip_env "mount w/o flock enabled"
12042 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12043 $LCTL set_param fail_loc=0x80000315
12044 flocks_test 2 $DIR/$tdir
12046 run_test 105d "flock race (should not freeze) ========"
12048 test_105e() { # bug 22660 && 22040
12049 flock_is_enabled || skip_env "mount w/o flock enabled"
12052 flocks_test 3 $DIR/$tfile
12054 run_test 105e "Two conflicting flocks from same process"
12056 test_106() { #bug 10921
12057 test_mkdir $DIR/$tdir
12058 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12059 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12061 run_test 106 "attempt exec of dir followed by chown of that dir"
12064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12072 local save_pattern=$(sysctl -n kernel.core_pattern)
12073 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12074 sysctl -w kernel.core_pattern=$file
12075 sysctl -w kernel.core_uses_pid=0
12077 ulimit -c unlimited
12083 kill -s 11 $SLEEPPID
12085 if [ -e $file ]; then
12086 size=`stat -c%s $file`
12087 [ $size -eq 0 ] && error "Fail to create core file $file"
12089 error "Fail to create core file $file"
12092 sysctl -w kernel.core_pattern=$save_pattern
12093 sysctl -w kernel.core_uses_pid=$save_uses_pid
12096 run_test 107 "Coredump on SIG"
12099 test_mkdir $DIR/$tdir
12100 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12101 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12102 error "mkdir with 256 char should fail, but did not"
12103 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12104 error "create with 255 char failed"
12105 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12106 error "create with 256 char should fail, but did not"
12111 run_test 110 "filename length checking"
12114 # Purpose: To verify dynamic thread (OSS) creation.
12117 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12118 remote_ost_nodsh && skip "remote OST with nodsh"
12120 # Lustre does not stop service threads once they are started.
12121 # Reset number of running threads to default.
12126 local save_params="$TMP/sanity-$TESTNAME.parameters"
12128 # Get ll_ost_io count before I/O
12129 OSTIO_pre=$(do_facet ost1 \
12130 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
12131 # Exit if lustre is not running (ll_ost_io not running).
12132 [ -z "$OSTIO_pre" ] && error "no OSS threads"
12134 echo "Starting with $OSTIO_pre threads"
12135 local thread_max=$((OSTIO_pre * 2))
12136 local rpc_in_flight=$((thread_max * 2))
12137 # this is limited to OSC_MAX_RIF_MAX (256)
12138 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
12139 thread_max=$((rpc_in_flight / 2))
12140 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
12143 # Number of I/O Process proposed to be started.
12145 local facets=$(get_facets OST)
12147 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
12148 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
12150 # Set in_flight to $rpc_in_flight
12151 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
12152 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
12153 nfiles=${rpc_in_flight}
12154 # Set ost thread_max to $thread_max
12155 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
12157 # 5 Minutes should be sufficient for max number of OSS
12158 # threads(thread_max) to be created.
12162 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
12163 test_mkdir $DIR/$tdir
12164 for i in $(seq $nfiles); do
12165 local file=$DIR/$tdir/${tfile}-$i
12166 $LFS setstripe -c -1 -i 0 $file
12167 ($WTL $file $timeout)&
12170 # I/O Started - Wait for thread_started to reach thread_max or report
12171 # error if thread_started is more than thread_max.
12172 echo "Waiting for thread_started to reach thread_max"
12173 local thread_started=0
12174 local end_time=$((SECONDS + timeout))
12176 while [ $SECONDS -le $end_time ] ; do
12178 # Get ost i/o thread_started count.
12179 thread_started=$(do_facet ost1 \
12181 ost.OSS.ost_io.threads_started | cut -d= -f2")
12182 # Break out if thread_started is equal/greater than thread_max
12183 if [[ $thread_started -ge $thread_max ]]; then
12184 echo ll_ost_io thread_started $thread_started, \
12185 equal/greater than thread_max $thread_max
12191 # Cleanup - We have the numbers, Kill i/o jobs if running.
12192 jobcount=($(jobs -p))
12193 for i in $(seq 0 $((${#jobcount[@]}-1)))
12195 kill -9 ${jobcount[$i]}
12196 if [ $? -ne 0 ] ; then
12198 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
12202 # Cleanup files left by WTL binary.
12203 for i in $(seq $nfiles); do
12204 local file=$DIR/$tdir/${tfile}-$i
12206 if [ $? -ne 0 ] ; then
12207 echo "Warning: Failed to delete file $file"
12211 restore_lustre_params <$save_params
12212 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
12214 # Error out if no new thread has started or Thread started is greater
12216 if [[ $thread_started -le $OSTIO_pre ||
12217 $thread_started -gt $thread_max ]]; then
12218 error "ll_ost_io: thread_started $thread_started" \
12219 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
12220 "No new thread started or thread started greater " \
12224 run_test 115 "verify dynamic thread creation===================="
12226 test_116a() { # was previously test_116()
12227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12228 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12229 remote_mds_nodsh && skip "remote MDS with nodsh"
12231 echo -n "Free space priority "
12232 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12237 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12238 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12239 stack_trap simple_cleanup_common
12241 # Check if we need to generate uneven OSTs
12242 test_mkdir -p $DIR/$tdir/OST${MINI}
12243 local FILL=$((MINV / 4))
12244 local DIFF=$((MAXV - MINV))
12245 local DIFF2=$((DIFF * 100 / MINV))
12247 local threshold=$(do_facet $SINGLEMDS \
12248 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12249 threshold=${threshold%%%}
12250 echo -n "Check for uneven OSTs: "
12251 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12253 if [[ $DIFF2 -gt $threshold ]]; then
12255 echo "Don't need to fill OST$MINI"
12257 # generate uneven OSTs. Write 2% over the QOS threshold value
12259 DIFF=$((threshold - DIFF2 + 2))
12260 DIFF2=$((MINV * DIFF / 100))
12261 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12262 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12263 error "setstripe failed"
12264 DIFF=$((DIFF2 / 2048))
12266 while [ $i -lt $DIFF ]; do
12268 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12269 bs=2M count=1 2>/dev/null
12278 DIFF=$((MAXV - MINV))
12279 DIFF2=$((DIFF * 100 / MINV))
12280 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12281 if [ $DIFF2 -gt $threshold ]; then
12284 skip "QOS imbalance criteria not met"
12292 # now fill using QOS
12293 $LFS setstripe -c 1 $DIR/$tdir
12294 FILL=$((FILL / 200))
12295 if [ $FILL -gt 600 ]; then
12298 echo "writing $FILL files to QOS-assigned OSTs"
12300 while [ $i -lt $FILL ]; do
12302 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12303 count=1 2>/dev/null
12306 echo "wrote $i 200k files"
12310 echo "Note: free space may not be updated, so measurements might be off"
12312 DIFF2=$((MAXV - MINV))
12313 echo "free space delta: orig $DIFF final $DIFF2"
12314 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12315 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12316 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12317 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12318 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12319 if [[ $DIFF -gt 0 ]]; then
12320 FILL=$((DIFF2 * 100 / DIFF - 100))
12321 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12324 # Figure out which files were written where
12325 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12326 awk '/'$MINI1': / {print $2; exit}')
12328 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12329 echo "$MINC files created on smaller OST $MINI1"
12330 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12331 awk '/'$MAXI1': / {print $2; exit}')
12333 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12334 echo "$MAXC files created on larger OST $MAXI1"
12335 if [[ $MINC -gt 0 ]]; then
12336 FILL=$((MAXC * 100 / MINC - 100))
12337 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12339 [[ $MAXC -gt $MINC ]] ||
12340 error_ignore LU-9 "stripe QOS didn't balance free space"
12342 run_test 116a "stripe QOS: free space balance ==================="
12344 test_116b() { # LU-2093
12345 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12346 remote_mds_nodsh && skip "remote MDS with nodsh"
12348 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12349 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12350 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12351 [ -z "$old_rr" ] && skip "no QOS"
12352 do_facet $SINGLEMDS lctl set_param \
12353 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12354 mkdir -p $DIR/$tdir
12355 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12356 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12357 do_facet $SINGLEMDS lctl set_param fail_loc=0
12359 do_facet $SINGLEMDS lctl set_param \
12360 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12362 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12364 test_117() # bug 10891
12366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12368 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12369 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12370 lctl set_param fail_loc=0x21e
12371 > $DIR/$tfile || error "truncate failed"
12372 lctl set_param fail_loc=0
12373 echo "Truncate succeeded."
12376 run_test 117 "verify osd extend =========="
12378 NO_SLOW_RESENDCOUNT=4
12379 export OLD_RESENDCOUNT=""
12380 set_resend_count () {
12381 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12382 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12383 lctl set_param -n $PROC_RESENDCOUNT $1
12384 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12387 # for reduce test_118* time (b=14842)
12388 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12390 # Reset async IO behavior after error case
12392 FILE=$DIR/reset_async
12394 # Ensure all OSCs are cleared
12395 $LFS setstripe -c -1 $FILE
12396 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12401 test_118a() #bug 11710
12403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12407 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12408 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12409 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12411 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12412 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12417 run_test 118a "verify O_SYNC works =========="
12421 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12422 remote_ost_nodsh && skip "remote OST with nodsh"
12426 #define OBD_FAIL_SRV_ENOENT 0x217
12427 set_nodes_failloc "$(osts_nodes)" 0x217
12428 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12430 set_nodes_failloc "$(osts_nodes)" 0
12431 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12432 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12435 if [[ $RC -eq 0 ]]; then
12436 error "Must return error due to dropped pages, rc=$RC"
12440 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12441 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12445 echo "Dirty pages not leaked on ENOENT"
12447 # Due to the above error the OSC will issue all RPCs syncronously
12448 # until a subsequent RPC completes successfully without error.
12449 $MULTIOP $DIR/$tfile Ow4096yc
12454 run_test 118b "Reclaim dirty pages on fatal error =========="
12458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12460 # for 118c, restore the original resend count, LU-1940
12461 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12462 set_resend_count $OLD_RESENDCOUNT
12463 remote_ost_nodsh && skip "remote OST with nodsh"
12467 #define OBD_FAIL_OST_EROFS 0x216
12468 set_nodes_failloc "$(osts_nodes)" 0x216
12470 # multiop should block due to fsync until pages are written
12471 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12475 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12476 error "Multiop failed to block on fsync, pid=$MULTIPID"
12479 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12481 if [[ $WRITEBACK -eq 0 ]]; then
12482 error "No page in writeback, writeback=$WRITEBACK"
12485 set_nodes_failloc "$(osts_nodes)" 0
12488 if [[ $RC -ne 0 ]]; then
12489 error "Multiop fsync failed, rc=$RC"
12492 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12493 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12495 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12496 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12500 echo "Dirty pages flushed via fsync on EROFS"
12503 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12505 # continue to use small resend count to reduce test_118* time (b=14842)
12506 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12511 remote_ost_nodsh && skip "remote OST with nodsh"
12515 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12516 set_nodes_failloc "$(osts_nodes)" 0x214
12517 # multiop should block due to fsync until pages are written
12518 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12522 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12523 error "Multiop failed to block on fsync, pid=$MULTIPID"
12526 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12528 if [[ $WRITEBACK -eq 0 ]]; then
12529 error "No page in writeback, writeback=$WRITEBACK"
12532 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12533 set_nodes_failloc "$(osts_nodes)" 0
12535 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12536 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12538 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12539 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12543 echo "Dirty pages gaurenteed flushed via fsync"
12546 run_test 118d "Fsync validation inject a delay of the bulk =========="
12549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12553 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12554 lctl set_param fail_loc=0x8000040a
12556 # Should simulate EINVAL error which is fatal
12557 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12559 if [[ $RC -eq 0 ]]; then
12560 error "Must return error due to dropped pages, rc=$RC"
12563 lctl set_param fail_loc=0x0
12565 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12566 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12567 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12569 if [[ $LOCKED -ne 0 ]]; then
12570 error "Locked pages remain in cache, locked=$LOCKED"
12573 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12574 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12578 echo "No pages locked after fsync"
12583 run_test 118f "Simulate unrecoverable OSC side error =========="
12586 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12590 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12591 lctl set_param fail_loc=0x406
12593 # simulate local -ENOMEM
12594 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12597 lctl set_param fail_loc=0
12598 if [[ $RC -eq 0 ]]; then
12599 error "Must return error due to dropped pages, rc=$RC"
12602 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12603 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12604 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12606 if [[ $LOCKED -ne 0 ]]; then
12607 error "Locked pages remain in cache, locked=$LOCKED"
12610 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12611 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12615 echo "No pages locked after fsync"
12620 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12623 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12624 remote_ost_nodsh && skip "remote OST with nodsh"
12628 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12629 set_nodes_failloc "$(osts_nodes)" 0x20e
12630 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12631 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12634 set_nodes_failloc "$(osts_nodes)" 0
12635 if [[ $RC -eq 0 ]]; then
12636 error "Must return error due to dropped pages, rc=$RC"
12639 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12640 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12641 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12643 if [[ $LOCKED -ne 0 ]]; then
12644 error "Locked pages remain in cache, locked=$LOCKED"
12647 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12648 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12652 echo "No pages locked after fsync"
12656 run_test 118h "Verify timeout in handling recoverables errors =========="
12658 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12662 remote_ost_nodsh && skip "remote OST with nodsh"
12666 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12667 set_nodes_failloc "$(osts_nodes)" 0x20e
12669 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12670 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12673 set_nodes_failloc "$(osts_nodes)" 0
12677 if [[ $RC -ne 0 ]]; then
12678 error "got error, but should be not, rc=$RC"
12681 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12682 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12683 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12684 if [[ $LOCKED -ne 0 ]]; then
12685 error "Locked pages remain in cache, locked=$LOCKED"
12688 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12689 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12693 echo "No pages locked after fsync"
12697 run_test 118i "Fix error before timeout in recoverable error =========="
12699 [ "$SLOW" = "no" ] && set_resend_count 4
12702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12703 remote_ost_nodsh && skip "remote OST with nodsh"
12707 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12708 set_nodes_failloc "$(osts_nodes)" 0x220
12710 # return -EIO from OST
12711 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12713 set_nodes_failloc "$(osts_nodes)" 0x0
12714 if [[ $RC -eq 0 ]]; then
12715 error "Must return error due to dropped pages, rc=$RC"
12718 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12719 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12720 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12721 if [[ $LOCKED -ne 0 ]]; then
12722 error "Locked pages remain in cache, locked=$LOCKED"
12725 # in recoverable error on OST we want resend and stay until it finished
12726 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12727 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12731 echo "No pages locked after fsync"
12735 run_test 118j "Simulate unrecoverable OST side error =========="
12739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12740 remote_ost_nodsh && skip "remote OSTs with nodsh"
12742 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12743 set_nodes_failloc "$(osts_nodes)" 0x20e
12744 test_mkdir $DIR/$tdir
12746 for ((i=0;i<10;i++)); do
12747 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12748 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12755 set_nodes_failloc "$(osts_nodes)" 0
12758 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12760 test_118l() # LU-646
12762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12764 test_mkdir $DIR/$tdir
12765 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12768 run_test 118l "fsync dir"
12770 test_118m() # LU-3066
12772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12774 test_mkdir $DIR/$tdir
12775 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12778 run_test 118m "fdatasync dir ========="
12780 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12788 remote_ost_nodsh && skip "remote OSTs with nodsh"
12790 # Sleep to avoid a cached response.
12791 #define OBD_STATFS_CACHE_SECONDS 1
12794 # Inject a 10 second delay in the OST_STATFS handler.
12795 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12796 set_nodes_failloc "$(osts_nodes)" 0x242
12799 stat --file-system $MOUNT > /dev/null
12802 set_nodes_failloc "$(osts_nodes)" 0
12804 if ((end - begin > 20)); then
12805 error "statfs took $((end - begin)) seconds, expected 10"
12808 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12810 test_119a() # bug 11737
12812 BSIZE=$((512 * 1024))
12813 directio write $DIR/$tfile 0 1 $BSIZE
12814 # We ask to read two blocks, which is more than a file size.
12815 # directio will indicate an error when requested and actual
12816 # sizes aren't equeal (a normal situation in this case) and
12817 # print actual read amount.
12818 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12819 if [ "$NOB" != "$BSIZE" ]; then
12820 error "read $NOB bytes instead of $BSIZE"
12824 run_test 119a "Short directIO read must return actual read amount"
12826 test_119b() # bug 11737
12828 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12830 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12831 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12833 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12834 error "direct read failed"
12837 run_test 119b "Sparse directIO read must return actual read amount"
12839 test_119c() # bug 13099
12842 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12843 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12846 run_test 119c "Testing for direct read hitting hole"
12848 test_119d() # bug 15950
12850 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12852 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12853 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12855 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12856 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12857 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12858 lctl set_param fail_loc=0x40d
12859 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12862 cat $DIR/$tfile > /dev/null &
12863 lctl set_param fail_loc=0
12866 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12868 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12869 error "the read rpcs have not completed in 2s"
12871 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12873 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12877 remote_mds_nodsh && skip "remote MDS with nodsh"
12878 test_mkdir -i0 -c1 $DIR/$tdir
12879 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12880 skip_env "no early lock cancel on server"
12882 lru_resize_disable mdc
12883 lru_resize_disable osc
12884 cancel_lru_locks mdc
12885 # asynchronous object destroy at MDT could cause bl ast to client
12886 cancel_lru_locks osc
12888 stat $DIR/$tdir > /dev/null
12889 can1=$(do_facet mds1 \
12890 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12891 awk '/ldlm_cancel/ {print $2}')
12892 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12893 awk '/ldlm_bl_callback/ {print $2}')
12894 test_mkdir -i0 -c1 $DIR/$tdir/d1
12895 can2=$(do_facet mds1 \
12896 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12897 awk '/ldlm_cancel/ {print $2}')
12898 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12899 awk '/ldlm_bl_callback/ {print $2}')
12900 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12901 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12902 lru_resize_enable mdc
12903 lru_resize_enable osc
12905 run_test 120a "Early Lock Cancel: mkdir test"
12908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12909 remote_mds_nodsh && skip "remote MDS with nodsh"
12910 test_mkdir $DIR/$tdir
12911 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12912 skip_env "no early lock cancel on server"
12914 lru_resize_disable mdc
12915 lru_resize_disable osc
12916 cancel_lru_locks mdc
12917 stat $DIR/$tdir > /dev/null
12918 can1=$(do_facet $SINGLEMDS \
12919 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12920 awk '/ldlm_cancel/ {print $2}')
12921 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12922 awk '/ldlm_bl_callback/ {print $2}')
12923 touch $DIR/$tdir/f1
12924 can2=$(do_facet $SINGLEMDS \
12925 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12926 awk '/ldlm_cancel/ {print $2}')
12927 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12928 awk '/ldlm_bl_callback/ {print $2}')
12929 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12930 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12931 lru_resize_enable mdc
12932 lru_resize_enable osc
12934 run_test 120b "Early Lock Cancel: create test"
12937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12938 remote_mds_nodsh && skip "remote MDS with nodsh"
12939 test_mkdir -i0 -c1 $DIR/$tdir
12940 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12941 skip "no early lock cancel on server"
12943 lru_resize_disable mdc
12944 lru_resize_disable osc
12945 test_mkdir -i0 -c1 $DIR/$tdir/d1
12946 test_mkdir -i0 -c1 $DIR/$tdir/d2
12947 touch $DIR/$tdir/d1/f1
12948 cancel_lru_locks mdc
12949 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12950 can1=$(do_facet mds1 \
12951 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12952 awk '/ldlm_cancel/ {print $2}')
12953 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12954 awk '/ldlm_bl_callback/ {print $2}')
12955 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12956 can2=$(do_facet mds1 \
12957 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12958 awk '/ldlm_cancel/ {print $2}')
12959 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12960 awk '/ldlm_bl_callback/ {print $2}')
12961 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12962 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12963 lru_resize_enable mdc
12964 lru_resize_enable osc
12966 run_test 120c "Early Lock Cancel: link test"
12969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12970 remote_mds_nodsh && skip "remote MDS with nodsh"
12971 test_mkdir -i0 -c1 $DIR/$tdir
12972 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12973 skip_env "no early lock cancel on server"
12975 lru_resize_disable mdc
12976 lru_resize_disable osc
12978 cancel_lru_locks mdc
12979 stat $DIR/$tdir > /dev/null
12980 can1=$(do_facet mds1 \
12981 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12982 awk '/ldlm_cancel/ {print $2}')
12983 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12984 awk '/ldlm_bl_callback/ {print $2}')
12985 chmod a+x $DIR/$tdir
12986 can2=$(do_facet mds1 \
12987 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12988 awk '/ldlm_cancel/ {print $2}')
12989 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12990 awk '/ldlm_bl_callback/ {print $2}')
12991 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12992 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12993 lru_resize_enable mdc
12994 lru_resize_enable osc
12996 run_test 120d "Early Lock Cancel: setattr test"
12999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13000 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13001 skip_env "no early lock cancel on server"
13002 remote_mds_nodsh && skip "remote MDS with nodsh"
13004 local dlmtrace_set=false
13006 test_mkdir -i0 -c1 $DIR/$tdir
13007 lru_resize_disable mdc
13008 lru_resize_disable osc
13009 ! $LCTL get_param debug | grep -q dlmtrace &&
13010 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13011 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13012 cancel_lru_locks mdc
13013 cancel_lru_locks osc
13014 dd if=$DIR/$tdir/f1 of=/dev/null
13015 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13016 # XXX client can not do early lock cancel of OST lock
13017 # during unlink (LU-4206), so cancel osc lock now.
13019 cancel_lru_locks osc
13020 can1=$(do_facet mds1 \
13021 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13022 awk '/ldlm_cancel/ {print $2}')
13023 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13024 awk '/ldlm_bl_callback/ {print $2}')
13025 unlink $DIR/$tdir/f1
13027 can2=$(do_facet mds1 \
13028 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13029 awk '/ldlm_cancel/ {print $2}')
13030 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13031 awk '/ldlm_bl_callback/ {print $2}')
13032 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
13033 $LCTL dk $TMP/cancel.debug.txt
13034 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
13035 $LCTL dk $TMP/blocking.debug.txt
13036 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
13037 lru_resize_enable mdc
13038 lru_resize_enable osc
13040 run_test 120e "Early Lock Cancel: unlink test"
13043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13044 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13045 skip_env "no early lock cancel on server"
13046 remote_mds_nodsh && skip "remote MDS with nodsh"
13048 test_mkdir -i0 -c1 $DIR/$tdir
13049 lru_resize_disable mdc
13050 lru_resize_disable osc
13051 test_mkdir -i0 -c1 $DIR/$tdir/d1
13052 test_mkdir -i0 -c1 $DIR/$tdir/d2
13053 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
13054 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
13055 cancel_lru_locks mdc
13056 cancel_lru_locks osc
13057 dd if=$DIR/$tdir/d1/f1 of=/dev/null
13058 dd if=$DIR/$tdir/d2/f2 of=/dev/null
13059 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
13060 # XXX client can not do early lock cancel of OST lock
13061 # during rename (LU-4206), so cancel osc lock now.
13063 cancel_lru_locks osc
13064 can1=$(do_facet mds1 \
13065 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13066 awk '/ldlm_cancel/ {print $2}')
13067 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13068 awk '/ldlm_bl_callback/ {print $2}')
13069 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13071 can2=$(do_facet mds1 \
13072 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13073 awk '/ldlm_cancel/ {print $2}')
13074 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13075 awk '/ldlm_bl_callback/ {print $2}')
13076 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13077 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13078 lru_resize_enable mdc
13079 lru_resize_enable osc
13081 run_test 120f "Early Lock Cancel: rename test"
13084 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13085 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13086 skip_env "no early lock cancel on server"
13087 remote_mds_nodsh && skip "remote MDS with nodsh"
13089 lru_resize_disable mdc
13090 lru_resize_disable osc
13092 echo create $count files
13093 test_mkdir $DIR/$tdir
13094 cancel_lru_locks mdc
13095 cancel_lru_locks osc
13098 can0=$(do_facet $SINGLEMDS \
13099 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13100 awk '/ldlm_cancel/ {print $2}')
13101 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13102 awk '/ldlm_bl_callback/ {print $2}')
13103 createmany -o $DIR/$tdir/f $count
13105 can1=$(do_facet $SINGLEMDS \
13106 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13107 awk '/ldlm_cancel/ {print $2}')
13108 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13109 awk '/ldlm_bl_callback/ {print $2}')
13111 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13112 echo rm $count files
13115 can2=$(do_facet $SINGLEMDS \
13116 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13117 awk '/ldlm_cancel/ {print $2}')
13118 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13119 awk '/ldlm_bl_callback/ {print $2}')
13121 echo total: $count removes in $((t2-t1))
13122 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13124 # wait for commitment of removal
13125 lru_resize_enable mdc
13126 lru_resize_enable osc
13128 run_test 120g "Early Lock Cancel: performance test"
13130 test_121() { #bug #10589
13131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13134 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13135 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13136 lctl set_param fail_loc=0x310
13137 cancel_lru_locks osc > /dev/null
13138 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13139 lctl set_param fail_loc=0
13140 [[ $reads -eq $writes ]] ||
13141 error "read $reads blocks, must be $writes blocks"
13143 run_test 121 "read cancel race ========="
13145 test_123a_base() { # was test 123, statahead(bug 11401)
13149 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13150 log "testing UP system. Performance may be lower than expected."
13153 running_in_vm && SLOWOK=1
13156 test_mkdir $DIR/$tdir
13157 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13158 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13160 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13161 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13163 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13164 lctl set_param -n llite.*.statahead_max 0
13165 lctl get_param llite.*.statahead_max
13166 cancel_lru_locks mdc
13167 cancel_lru_locks osc
13169 time $lsx $DIR/$tdir | wc -l
13171 delta=$((etime - stime))
13172 log "$lsx $i files without statahead: $delta sec"
13173 lctl set_param llite.*.statahead_max=$max
13175 swrong=$(lctl get_param -n llite.*.statahead_stats |
13176 awk '/statahead.wrong:/ { print $NF }')
13177 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13178 cancel_lru_locks mdc
13179 cancel_lru_locks osc
13181 time $lsx $DIR/$tdir | wc -l
13183 delta_sa=$((etime - stime))
13184 log "$lsx $i files with statahead: $delta_sa sec"
13185 lctl get_param -n llite.*.statahead_stats
13186 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13187 awk '/statahead.wrong:/ { print $NF }')
13189 [[ $swrong -lt $ewrong ]] &&
13190 log "statahead was stopped, maybe too many locks held!"
13191 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13193 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
13194 max=$(lctl get_param -n llite.*.statahead_max |
13196 lctl set_param -n llite.*.statahead_max 0
13197 lctl get_param llite.*.statahead_max
13198 cancel_lru_locks mdc
13199 cancel_lru_locks osc
13201 time $lsx $DIR/$tdir | wc -l
13203 delta=$((etime - stime))
13204 log "$lsx $i files again without statahead: $delta sec"
13205 lctl set_param llite.*.statahead_max=$max
13206 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
13207 if [ $SLOWOK -eq 0 ]; then
13208 error "$lsx $i files is slower with statahead!"
13210 log "$lsx $i files is slower with statahead!"
13216 [ $delta -gt 20 ] && break
13217 [ $delta -gt 8 ] && MULT=$((50 / delta))
13218 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
13226 delta=$((etime - stime))
13227 log "rm -r $DIR/$tdir/: $delta seconds"
13229 lctl get_param -n llite.*.statahead_stats
13233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13235 test_123a_base "ls -l"
13237 run_test 123aa "verify statahead work"
13240 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13242 statx_supported || skip_env "Test must be statx() syscall supported"
13244 test_123a_base "$STATX -l"
13246 run_test 123ab "verify statahead work by using statx"
13249 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13251 statx_supported || skip_env "Test must be statx() syscall supported"
13258 cancel_lru_locks $OSC
13259 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13260 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
13261 awk '/agl.total:/ { print $NF }')
13262 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
13263 test_123a_base "$STATX --cached=always -D"
13264 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
13265 awk '/agl.total:/ { print $NF }')
13266 [ $agl_before -eq $agl_after ] ||
13267 error "Should not trigger AGL thread - $agl_before:$agl_after"
13268 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13269 [ $rpcs_after -eq $rpcs_before ] ||
13270 error "$STATX should not send glimpse RPCs to $OSC"
13272 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
13274 test_123b () { # statahead(bug 15027)
13275 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13277 test_mkdir $DIR/$tdir
13278 createmany -o $DIR/$tdir/$tfile-%d 1000
13280 cancel_lru_locks mdc
13281 cancel_lru_locks osc
13283 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13284 lctl set_param fail_loc=0x80000803
13285 ls -lR $DIR/$tdir > /dev/null
13287 lctl set_param fail_loc=0x0
13288 lctl get_param -n llite.*.statahead_stats
13293 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13296 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13298 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13299 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13300 touch $DIR/$tdir.1/{1..3}
13301 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13303 remount_client $MOUNT
13305 $MULTIOP $DIR/$tdir.0 Q
13307 # let statahead to complete
13308 ls -l $DIR/$tdir.0 > /dev/null
13310 testid=$(echo $TESTNAME | tr '_' ' ')
13311 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13312 error "statahead warning" || true
13314 run_test 123c "Can not initialize inode warning on DNE statahead"
13321 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
13322 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
13323 error "setdirstripe $DIR/$tdir failed"
13324 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
13325 remount_client $MOUNT
13326 $LCTL get_param llite.*.statahead_max
13327 $LCTL set_param llite.*.statahead_stats=0 ||
13328 error "clear statahead_stats failed"
13329 swrong=$(lctl get_param -n llite.*.statahead_stats |
13330 awk '/statahead.wrong:/ { print $NF }')
13331 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
13332 # wait for statahead thread finished to update hit/miss stats.
13334 $LCTL get_param -n llite.*.statahead_stats
13335 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13336 awk '/statahead.wrong:/ { print $NF }')
13337 (( $swrong == $ewrong )) ||
13338 log "statahead was stopped, maybe too many locks held!"
13340 run_test 123d "Statahead on striped directories works correctly"
13343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13344 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13345 skip_env "no lru resize on server"
13349 test_mkdir $DIR/$tdir
13351 log "create $NR files at $DIR/$tdir"
13352 createmany -o $DIR/$tdir/f $NR ||
13353 error "failed to create $NR files in $DIR/$tdir"
13355 cancel_lru_locks mdc
13356 ls -l $DIR/$tdir > /dev/null
13360 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13361 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13362 LRU_SIZE=$($LCTL get_param -n $PARAM)
13363 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13364 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13366 log "NS=$(basename $NSDIR)"
13371 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13372 skip "Not enough cached locks created!"
13374 log "LRU=$LRU_SIZE"
13378 # We know that lru resize allows one client to hold $LIMIT locks
13379 # for 10h. After that locks begin to be killed by client.
13381 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13383 if [ $LIMIT -lt $LRU_SIZE ]; then
13384 skip "Limit is too small $LIMIT"
13387 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13388 # killing locks. Some time was spent for creating locks. This means
13389 # that up to the moment of sleep finish we must have killed some of
13390 # them (10-100 locks). This depends on how fast ther were created.
13391 # Many of them were touched in almost the same moment and thus will
13392 # be killed in groups.
13393 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13395 # Use $LRU_SIZE_B here to take into account real number of locks
13396 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13397 local LRU_SIZE_B=$LRU_SIZE
13399 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13400 log "OLD_LVF=$OLD_LVF"
13401 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13403 # Let's make sure that we really have some margin. Client checks
13404 # cached locks every 10 sec.
13405 SLEEP=$((SLEEP+20))
13406 log "Sleep ${SLEEP} sec"
13408 while ((SEC<$SLEEP)); do
13412 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13413 echo -n "$LRU_SIZE"
13416 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13417 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13419 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13420 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13421 unlinkmany $DIR/$tdir/f $NR
13425 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13426 log "unlink $NR files at $DIR/$tdir"
13427 unlinkmany $DIR/$tdir/f $NR
13429 run_test 124a "lru resize ======================================="
13431 get_max_pool_limit()
13433 local limit=$($LCTL get_param \
13434 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13436 for l in $limit; do
13437 if [[ $l -gt $max ]]; then
13445 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13446 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13447 skip_env "no lru resize on server"
13449 LIMIT=$(get_max_pool_limit)
13451 NR=$(($(default_lru_size)*20))
13452 if [[ $NR -gt $LIMIT ]]; then
13453 log "Limit lock number by $LIMIT locks"
13457 IFree=$(mdsrate_inodes_available)
13458 if [ $IFree -lt $NR ]; then
13459 log "Limit lock number by $IFree inodes"
13463 lru_resize_disable mdc
13464 test_mkdir -p $DIR/$tdir/disable_lru_resize
13466 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13467 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13468 cancel_lru_locks mdc
13471 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13474 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13477 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13481 nolruresize_delta=$((etime-stime))
13482 log "ls -la time: $nolruresize_delta seconds"
13483 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13484 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13486 lru_resize_enable mdc
13487 test_mkdir -p $DIR/$tdir/enable_lru_resize
13489 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13490 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13491 cancel_lru_locks mdc
13494 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13497 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13500 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13504 lruresize_delta=$((etime-stime))
13505 log "ls -la time: $lruresize_delta seconds"
13506 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13508 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13509 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13510 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13511 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13513 log "lru resize performs the same with no lru resize"
13515 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13517 run_test 124b "lru resize (performance test) ======================="
13520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13521 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13522 skip_env "no lru resize on server"
13524 # cache ununsed locks on client
13526 cancel_lru_locks mdc
13527 test_mkdir $DIR/$tdir
13528 createmany -o $DIR/$tdir/f $nr ||
13529 error "failed to create $nr files in $DIR/$tdir"
13530 ls -l $DIR/$tdir > /dev/null
13532 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13533 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13534 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13535 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13536 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13538 # set lru_max_age to 1 sec
13539 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13540 echo "sleep $((recalc_p * 2)) seconds..."
13541 sleep $((recalc_p * 2))
13543 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13544 # restore lru_max_age
13545 $LCTL set_param -n $nsdir.lru_max_age $max_age
13546 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13547 unlinkmany $DIR/$tdir/f $nr
13549 run_test 124c "LRUR cancel very aged locks"
13552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13553 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13554 skip_env "no lru resize on server"
13556 # cache ununsed locks on client
13559 lru_resize_disable mdc
13560 stack_trap "lru_resize_enable mdc" EXIT
13562 cancel_lru_locks mdc
13564 # asynchronous object destroy at MDT could cause bl ast to client
13565 test_mkdir $DIR/$tdir
13566 createmany -o $DIR/$tdir/f $nr ||
13567 error "failed to create $nr files in $DIR/$tdir"
13568 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13570 ls -l $DIR/$tdir > /dev/null
13572 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13573 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13574 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13575 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13577 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13579 # set lru_max_age to 1 sec
13580 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13581 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13583 echo "sleep $((recalc_p * 2)) seconds..."
13584 sleep $((recalc_p * 2))
13586 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13588 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13590 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13592 test_125() { # 13358
13593 $LCTL get_param -n llite.*.client_type | grep -q local ||
13594 skip "must run as local client"
13595 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13596 skip_env "must have acl enabled"
13597 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13599 test_mkdir $DIR/$tdir
13600 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13601 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
13602 error "setfacl $DIR/$tdir failed"
13603 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13605 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13607 test_126() { # bug 12829/13455
13608 $GSS && skip_env "must run as gss disabled"
13609 $LCTL get_param -n llite.*.client_type | grep -q local ||
13610 skip "must run as local client"
13611 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13613 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13614 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13616 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13618 run_test 126 "check that the fsgid provided by the client is taken into account"
13620 test_127a() { # bug 15521
13621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13622 local name count samp unit min max sum sumsq
13624 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13625 echo "stats before reset"
13626 $LCTL get_param osc.*.stats
13627 $LCTL set_param osc.*.stats=0
13628 local fsize=$((2048 * 1024))
13630 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13631 cancel_lru_locks osc
13632 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13634 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
13635 stack_trap "rm -f $TMP/$tfile.tmp"
13636 while read name count samp unit min max sum sumsq; do
13637 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13638 [ ! $min ] && error "Missing min value for $name proc entry"
13639 eval $name=$count || error "Wrong proc format"
13642 read_bytes|write_bytes)
13643 [[ "$unit" =~ "bytes" ]] ||
13644 error "unit is not 'bytes': $unit"
13645 (( $min >= 4096 )) || error "min is too small: $min"
13646 (( $min <= $fsize )) || error "min is too big: $min"
13647 (( $max >= 4096 )) || error "max is too small: $max"
13648 (( $max <= $fsize )) || error "max is too big: $max"
13649 (( $sum == $fsize )) || error "sum is wrong: $sum"
13650 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13651 error "sumsquare is too small: $sumsq"
13652 (( $sumsq <= $fsize * $fsize )) ||
13653 error "sumsquare is too big: $sumsq"
13655 ost_read|ost_write)
13656 [[ "$unit" =~ "usec" ]] ||
13657 error "unit is not 'usec': $unit"
13661 done < $DIR/$tfile.tmp
13663 #check that we actually got some stats
13664 [ "$read_bytes" ] || error "Missing read_bytes stats"
13665 [ "$write_bytes" ] || error "Missing write_bytes stats"
13666 [ "$read_bytes" != 0 ] || error "no read done"
13667 [ "$write_bytes" != 0 ] || error "no write done"
13669 run_test 127a "verify the client stats are sane"
13671 test_127b() { # bug LU-333
13672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13673 local name count samp unit min max sum sumsq
13675 echo "stats before reset"
13676 $LCTL get_param llite.*.stats
13677 $LCTL set_param llite.*.stats=0
13679 # perform 2 reads and writes so MAX is different from SUM.
13680 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13681 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13682 cancel_lru_locks osc
13683 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13684 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13686 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13687 stack_trap "rm -f $TMP/$tfile.tmp"
13688 while read name count samp unit min max sum sumsq; do
13689 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13690 eval $name=$count || error "Wrong proc format"
13693 read_bytes|write_bytes)
13694 [[ "$unit" =~ "bytes" ]] ||
13695 error "unit is not 'bytes': $unit"
13696 (( $count == 2 )) || error "count is not 2: $count"
13697 (( $min == $PAGE_SIZE )) ||
13698 error "min is not $PAGE_SIZE: $min"
13699 (( $max == $PAGE_SIZE )) ||
13700 error "max is not $PAGE_SIZE: $max"
13701 (( $sum == $PAGE_SIZE * 2 )) ||
13702 error "sum is not $((PAGE_SIZE * 2)): $sum"
13705 [[ "$unit" =~ "usec" ]] ||
13706 error "unit is not 'usec': $unit"
13710 done < $TMP/$tfile.tmp
13712 #check that we actually got some stats
13713 [ "$read_bytes" ] || error "Missing read_bytes stats"
13714 [ "$write_bytes" ] || error "Missing write_bytes stats"
13715 [ "$read_bytes" != 0 ] || error "no read done"
13716 [ "$write_bytes" != 0 ] || error "no write done"
13718 run_test 127b "verify the llite client stats are sane"
13720 test_127c() { # LU-12394
13721 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13728 $LCTL set_param llite.*.extents_stats=1
13729 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13731 # Use two stripes so there is enough space in default config
13732 $LFS setstripe -c 2 $DIR/$tfile
13734 # Extent stats start at 0-4K and go in power of two buckets
13735 # LL_HIST_START = 12 --> 2^12 = 4K
13736 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13737 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13739 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13741 # Write and read, 2x each, second time at a non-zero offset
13742 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13743 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13744 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13745 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13749 $LCTL get_param llite.*.extents_stats
13752 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13754 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13756 reads=$(echo $bucket | awk '{print $5}')
13757 writes=$(echo $bucket | awk '{print $9}')
13758 [ "$reads" -eq $count ] ||
13759 error "$reads reads in < $bsize bucket, expect $count"
13760 [ "$writes" -eq $count ] ||
13761 error "$writes writes in < $bsize bucket, expect $count"
13764 # Test mmap write and read
13765 $LCTL set_param llite.*.extents_stats=c
13767 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13768 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13769 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13771 $LCTL get_param llite.*.extents_stats
13773 count=$(((size*1024) / PAGE_SIZE))
13775 bsize=$((2 * PAGE_SIZE / 1024))K
13777 bucket=$($LCTL get_param -n llite.*.extents_stats |
13779 reads=$(echo $bucket | awk '{print $5}')
13780 writes=$(echo $bucket | awk '{print $9}')
13781 # mmap writes fault in the page first, creating an additonal read
13782 [ "$reads" -eq $((2 * count)) ] ||
13783 error "$reads reads in < $bsize bucket, expect $count"
13784 [ "$writes" -eq $count ] ||
13785 error "$writes writes in < $bsize bucket, expect $count"
13787 run_test 127c "test llite extent stats with regular & mmap i/o"
13789 test_128() { # bug 15212
13791 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13796 result=$(grep error $TMP/$tfile.log)
13797 rm -f $DIR/$tfile $TMP/$tfile.log
13798 [ -z "$result" ] ||
13799 error "consecutive find's under interactive lfs failed"
13801 run_test 128 "interactive lfs for 2 consecutive find's"
13803 set_dir_limits () {
13808 local ldproc=/proc/fs/ldiskfs
13809 local facets=$(get_facets MDS)
13811 for facet in ${facets//,/ }; do
13812 canondev=$(ldiskfs_canon \
13813 *.$(convert_facet2label $facet).mntdev $facet)
13814 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13815 ldproc=/sys/fs/ldiskfs
13816 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13817 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13821 check_mds_dmesg() {
13822 local facets=$(get_facets MDS)
13823 for facet in ${facets//,/ }; do
13824 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13831 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13832 skip "Need MDS version with at least 2.5.56"
13833 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13834 skip_env "ldiskfs only test"
13836 remote_mds_nodsh && skip "remote MDS with nodsh"
13839 local has_warning=false
13842 mkdir -p $DIR/$tdir
13844 # block size of mds1
13845 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13846 set_dir_limits $maxsize $((maxsize * 6 / 8))
13847 stack_trap "set_dir_limits 0 0"
13848 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13849 local dirsize=$(stat -c%s "$DIR/$tdir")
13851 while (( $dirsize <= $maxsize )); do
13852 $MCREATE $DIR/$tdir/file_base_$nfiles
13854 # check two errors:
13855 # ENOSPC for ext4 max_dir_size, which has been used since
13856 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13857 if (( rc == ENOSPC )); then
13859 echo "rc=$rc returned as expected after $nfiles files"
13861 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13862 error "create failed w/o dir size limit"
13864 # messages may be rate limited if test is run repeatedly
13865 check_mds_dmesg '"is approaching max"' ||
13866 echo "warning message should be output"
13867 check_mds_dmesg '"has reached max"' ||
13868 echo "reached message should be output"
13870 dirsize=$(stat -c%s "$DIR/$tdir")
13872 [[ $dirsize -ge $maxsize ]] && return 0
13873 error "dirsize $dirsize < $maxsize after $nfiles files"
13874 elif (( rc != 0 )); then
13877 nfiles=$((nfiles + 1))
13878 dirsize=$(stat -c%s "$DIR/$tdir")
13881 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13883 run_test 129 "test directory size limit ========================"
13892 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13893 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
13895 trap cleanup_130 EXIT RETURN
13897 local fm_file=$DIR/$tfile
13898 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13899 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13900 error "dd failed for $fm_file"
13902 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
13903 filefrag -ves $fm_file
13905 [[ "$ost1_FSTYPE" != "zfs" ]] ||
13906 skip "LU-1941: FIEMAP unimplemented on ZFS"
13907 (( $rc == 0 )) || error "filefrag $fm_file failed"
13909 filefrag_op=$(filefrag -ve -k $fm_file |
13910 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13911 local lun=$($LFS getstripe -i $fm_file)
13913 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
13916 for line in $filefrag_op; do
13917 local frag_lun=$(echo $line | cut -d: -f5)
13918 local ext_len=$(echo $line | cut -d: -f4)
13920 if (( $frag_lun != $lun )); then
13921 error "FIEMAP on 1-stripe file($fm_file) failed"
13924 (( tot_len += ext_len ))
13927 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13928 error "FIEMAP on 1-stripe file($fm_file) failed"
13932 echo "FIEMAP on single striped file succeeded"
13934 run_test 130a "FIEMAP (1-stripe file)"
13937 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13939 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
13940 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
13941 [[ "$ost1_FSTYPE" != "zfs" ]] ||
13942 skip "LU-1941: FIEMAP unimplemented on ZFS"
13944 trap cleanup_130 EXIT RETURN
13946 local fm_file=$DIR/$tfile
13947 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13948 error "setstripe on $fm_file"
13950 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13951 error "dd failed on $fm_file"
13953 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13954 filefrag_op=$(filefrag -ve -k $fm_file |
13955 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13957 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
13958 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13964 for line in $filefrag_op; do
13965 local frag_lun=$(echo $line | cut -d: -f5 |
13966 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13967 local ext_len=$(echo $line | cut -d: -f4)
13968 if (( $frag_lun != $last_lun )); then
13969 if (( tot_len != 1024 )); then
13970 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
13973 (( num_luns += 1 ))
13977 (( tot_len += ext_len ))
13980 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
13981 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
13985 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
13987 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
13990 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13992 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
13993 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
13994 [[ "$ost1_FSTYPE" != "zfs" ]] ||
13995 skip "LU-1941: FIEMAP unimplemented on ZFS"
13997 trap cleanup_130 EXIT RETURN
13999 local fm_file=$DIR/$tfile
14000 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
14002 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
14003 error "dd failed on $fm_file"
14005 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14006 filefrag_op=$(filefrag -ve -k $fm_file |
14007 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14009 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14010 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14015 for line in $filefrag_op; do
14016 local frag_lun=$(echo $line | cut -d: -f5 |
14017 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14018 local ext_len=$(echo $line | cut -d: -f4)
14019 if (( $frag_lun != $last_lun )); then
14020 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
14021 if (( logical != 512 )); then
14022 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
14025 if (( tot_len != 512 )); then
14026 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14029 (( num_luns += 1 ))
14033 (( tot_len += ext_len ))
14036 if (( num_luns != 2 || tot_len != 512 )); then
14037 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14041 echo "FIEMAP on 2-stripe file with hole succeeded"
14043 run_test 130c "FIEMAP (2-stripe file with hole)"
14046 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
14048 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14049 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14050 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14051 skip "LU-1941: FIEMAP unimplemented on ZFS"
14053 trap cleanup_130 EXIT RETURN
14055 local fm_file=$DIR/$tfile
14056 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14057 error "setstripe on $fm_file"
14059 local actual_stripe_count=$($LFS getstripe -c $fm_file)
14060 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
14061 error "dd failed on $fm_file"
14063 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14064 filefrag_op=$(filefrag -ve -k $fm_file |
14065 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14067 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14068 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14073 for line in $filefrag_op; do
14074 local frag_lun=$(echo $line | cut -d: -f5 |
14075 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14076 local ext_len=$(echo $line | cut -d: -f4)
14077 if (( $frag_lun != $last_lun )); then
14078 if (( tot_len != 1024 )); then
14079 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14082 (( num_luns += 1 ))
14086 (( tot_len += ext_len ))
14089 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
14090 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14094 echo "FIEMAP on N-stripe file succeeded"
14096 run_test 130d "FIEMAP (N-stripe file)"
14099 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14101 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14102 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14103 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14104 skip "LU-1941: FIEMAP unimplemented on ZFS"
14106 trap cleanup_130 EXIT RETURN
14108 local fm_file=$DIR/$tfile
14109 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
14112 local expected_len=$(( (num_blks / 2) * 64 ))
14113 for ((i = 0; i < $num_blks; i++)); do
14114 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
14115 conv=notrunc > /dev/null 2>&1
14118 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14119 filefrag_op=$(filefrag -ve -k $fm_file |
14120 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14122 local last_lun=$(echo $filefrag_op | cut -d: -f5)
14127 for line in $filefrag_op; do
14128 local frag_lun=$(echo $line | cut -d: -f5)
14129 local ext_len=$(echo $line | cut -d: -f4)
14130 if (( $frag_lun != $last_lun )); then
14131 if (( tot_len != $expected_len )); then
14132 error "OST$last_lun $tot_len != $expected_len"
14134 (( num_luns += 1 ))
14138 (( tot_len += ext_len ))
14141 if (( num_luns != 2 || tot_len != $expected_len )); then
14142 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
14145 echo "FIEMAP with continuation calls succeeded"
14147 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
14150 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14151 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14152 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14153 skip "LU-1941: FIEMAP unimplemented on ZFS"
14155 local fm_file=$DIR/$tfile
14156 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
14157 error "multiop create with lov_delay_create on $fm_file"
14159 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14160 filefrag_extents=$(filefrag -vek $fm_file |
14161 awk '/extents? found/ { print $2 }')
14162 if (( $filefrag_extents != 0 )); then
14163 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
14168 run_test 130f "FIEMAP (unstriped file)"
14171 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
14172 skip "Need MDS version with at least 2.12.53 for overstriping"
14173 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14174 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14175 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14176 skip "LU-1941: FIEMAP unimplemented on ZFS"
14178 local file=$DIR/$tfile
14179 local nr=$((OSTCOUNT * 100))
14181 $LFS setstripe -C $nr $file || error "failed to setstripe -C $nr $file"
14183 stack_trap "rm -f $file"
14184 dd if=/dev/zero of=$file count=$nr bs=1M
14186 nr=$($LFS getstripe -c $file)
14188 local extents=$(filefrag -v $file |
14189 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
14191 echo "filefrag list $extents extents in file with stripecount $nr"
14192 if (( extents < nr )); then
14193 $LFS getstripe $file
14195 error "filefrag printed $extents < $nr extents"
14198 run_test 130g "FIEMAP (overstripe file)"
14200 # Test for writev/readv
14202 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
14203 error "writev test failed"
14204 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
14205 error "readv failed"
14208 run_test 131a "test iov's crossing stripe boundary for writev/readv"
14211 local fsize=$((524288 + 1048576 + 1572864))
14212 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
14213 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14214 error "append writev test failed"
14216 ((fsize += 1572864 + 1048576))
14217 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
14218 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14219 error "append writev test failed"
14222 run_test 131b "test append writev"
14225 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
14228 run_test 131c "test read/write on file w/o objects"
14231 rwv -f $DIR/$tfile -w -n 1 1572864
14232 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
14233 if [ "$NOB" != 1572864 ]; then
14234 error "Short read filed: read $NOB bytes instead of 1572864"
14238 run_test 131d "test short read"
14241 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
14242 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
14243 error "read hitting hole failed"
14246 run_test 131e "test read hitting hole"
14254 # open 11 samples [usecs] 468 4793 13658 35791898
14256 mds*) res=($(do_facet $facet \
14257 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
14259 ost*) res=($(do_facet $facet \
14260 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
14262 *) error "Wrong facet '$facet'" ;;
14264 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
14265 # if $want is zero, it means any stat increment is ok.
14266 if (( $want > 0 )); then
14267 local count=${res[1]}
14269 if (( $count != $want )); then
14270 if [[ $facet =~ "mds" ]]; then
14271 do_nodes $(comma_list $(mdts_nodes)) \
14272 $LCTL get_param mdt.*.md_stats
14274 do_nodes $(comma_list $(osts-nodes)) \
14275 $LCTL get_param obdfilter.*.stats
14277 error "The $op counter on $facet is $count, not $want"
14283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14284 remote_ost_nodsh && skip "remote OST with nodsh"
14285 remote_mds_nodsh && skip "remote MDS with nodsh"
14286 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14287 skip_env "MDS doesn't support rename stats"
14289 local testdir=$DIR/${tdir}/stats_testdir
14291 mkdir -p $DIR/${tdir}
14294 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14295 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14297 # verify mdt stats first.
14298 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14299 check_stats $SINGLEMDS "mkdir" 1
14301 # clear "open" from "lfs mkdir" above
14302 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14303 touch ${testdir}/${tfile} || error "touch failed"
14304 check_stats $SINGLEMDS "open" 1
14305 check_stats $SINGLEMDS "close" 1
14306 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14307 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14308 check_stats $SINGLEMDS "mknod" 2
14310 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14311 check_stats $SINGLEMDS "unlink" 1
14312 rm -f ${testdir}/${tfile} || error "file remove failed"
14313 check_stats $SINGLEMDS "unlink" 2
14315 # remove working dir and check mdt stats again.
14316 rmdir ${testdir} || error "rmdir failed"
14317 check_stats $SINGLEMDS "rmdir" 1
14319 local testdir1=$DIR/${tdir}/stats_testdir1
14320 mkdir -p ${testdir}
14321 mkdir -p ${testdir1}
14322 touch ${testdir1}/test1
14323 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14324 check_stats $SINGLEMDS "crossdir_rename" 1
14326 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14327 check_stats $SINGLEMDS "samedir_rename" 1
14329 rm -rf $DIR/${tdir}
14331 run_test 133a "Verifying MDT stats ========================================"
14336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14337 remote_ost_nodsh && skip "remote OST with nodsh"
14338 remote_mds_nodsh && skip "remote MDS with nodsh"
14340 local testdir=$DIR/${tdir}/stats_testdir
14342 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14343 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14344 touch ${testdir}/${tfile} || error "touch failed"
14345 cancel_lru_locks mdc
14348 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14349 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14351 # extra mdt stats verification.
14352 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14353 check_stats $SINGLEMDS "setattr" 1
14354 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14355 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14357 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14358 check_stats $SINGLEMDS "getattr" 1
14360 rm -rf $DIR/${tdir}
14362 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14363 # so the check below is not reliable
14364 [ $MDSCOUNT -eq 1 ] || return 0
14366 # Sleep to avoid a cached response.
14367 #define OBD_STATFS_CACHE_SECONDS 1
14369 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14370 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14371 $LFS df || error "lfs failed"
14372 check_stats $SINGLEMDS "statfs" 1
14374 # check aggregated statfs (LU-10018)
14375 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14377 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14380 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14381 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14383 check_stats $SINGLEMDS "statfs" 1
14385 # We want to check that the client didn't send OST_STATFS to
14386 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14387 # extra care is needed here.
14388 if remote_mds; then
14389 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14390 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14392 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14393 [ "$res" ] && error "OST got STATFS"
14398 run_test 133b "Verifying extra MDT stats =================================="
14401 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14402 remote_ost_nodsh && skip "remote OST with nodsh"
14403 remote_mds_nodsh && skip "remote MDS with nodsh"
14405 local testdir=$DIR/$tdir/stats_testdir
14407 test_mkdir -p $testdir
14409 # verify obdfilter stats.
14410 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14412 cancel_lru_locks osc
14413 wait_delete_completed
14416 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14417 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14419 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14422 cancel_lru_locks osc
14423 check_stats ost1 "write" 1
14425 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14426 check_stats ost1 "read" 1
14428 > $testdir/$tfile || error "truncate failed"
14429 check_stats ost1 "punch" 1
14431 rm -f $testdir/$tfile || error "file remove failed"
14432 wait_delete_completed
14433 check_stats ost1 "destroy" 1
14437 run_test 133c "Verifying OST stats ========================================"
14444 while [ $value -ge 2 ]; do
14449 if [ $orig -gt $order ]; then
14457 local size=('K' 'M' 'G' 'T');
14459 local size_string=$value
14461 while [ $value -ge 1024 ]; do
14462 if [ $i -gt 3 ]; then
14463 #T is the biggest unit we get here, if that is bigger,
14465 size_string=${value}T
14468 value=$((value >> 10))
14469 if [ $value -lt 1024 ]; then
14470 size_string=${value}${size[$i]}
14479 get_rename_size() {
14481 local context=${2:-.}
14482 local sample=$(do_facet $SINGLEMDS $LCTL \
14483 get_param mdt.$FSNAME-MDT0000.rename_stats |
14484 grep -A1 $context |
14485 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14491 remote_ost_nodsh && skip "remote OST with nodsh"
14492 remote_mds_nodsh && skip "remote MDS with nodsh"
14493 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14494 skip_env "MDS doesn't support rename stats"
14496 local testdir1=$DIR/${tdir}/stats_testdir1
14497 local testdir2=$DIR/${tdir}/stats_testdir2
14498 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
14500 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14502 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
14503 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
14505 createmany -o $testdir1/test 512 || error "createmany failed"
14507 # check samedir rename size
14508 mv ${testdir1}/test0 ${testdir1}/test_0
14510 local testdir1_size=$(ls -l $DIR/${tdir} |
14511 awk '/stats_testdir1/ {print $5}')
14512 local testdir2_size=$(ls -l $DIR/${tdir} |
14513 awk '/stats_testdir2/ {print $5}')
14515 testdir1_size=$(order_2 $testdir1_size)
14516 testdir2_size=$(order_2 $testdir2_size)
14518 testdir1_size=$(size_in_KMGT $testdir1_size)
14519 testdir2_size=$(size_in_KMGT $testdir2_size)
14521 echo "source rename dir size: ${testdir1_size}"
14522 echo "target rename dir size: ${testdir2_size}"
14524 local cmd="do_facet $SINGLEMDS $LCTL "
14525 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14527 eval $cmd || error "$cmd failed"
14528 local samedir=$($cmd | grep 'same_dir')
14529 local same_sample=$(get_rename_size $testdir1_size)
14530 [ -z "$samedir" ] && error "samedir_rename_size count error"
14531 [[ $same_sample -eq 1 ]] ||
14532 error "samedir_rename_size error $same_sample"
14533 echo "Check same dir rename stats success"
14535 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14537 # check crossdir rename size
14538 mv ${testdir1}/test_0 ${testdir2}/test_0
14540 testdir1_size=$(ls -l $DIR/${tdir} |
14541 awk '/stats_testdir1/ {print $5}')
14542 testdir2_size=$(ls -l $DIR/${tdir} |
14543 awk '/stats_testdir2/ {print $5}')
14545 testdir1_size=$(order_2 $testdir1_size)
14546 testdir2_size=$(order_2 $testdir2_size)
14548 testdir1_size=$(size_in_KMGT $testdir1_size)
14549 testdir2_size=$(size_in_KMGT $testdir2_size)
14551 echo "source rename dir size: ${testdir1_size}"
14552 echo "target rename dir size: ${testdir2_size}"
14554 eval $cmd || error "$cmd failed"
14555 local crossdir=$($cmd | grep 'crossdir')
14556 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14557 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14558 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14559 [[ $src_sample -eq 1 ]] ||
14560 error "crossdir_rename_size error $src_sample"
14561 [[ $tgt_sample -eq 1 ]] ||
14562 error "crossdir_rename_size error $tgt_sample"
14563 echo "Check cross dir rename stats success"
14564 rm -rf $DIR/${tdir}
14566 run_test 133d "Verifying rename_stats ========================================"
14569 remote_mds_nodsh && skip "remote MDS with nodsh"
14570 remote_ost_nodsh && skip "remote OST with nodsh"
14571 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14573 local testdir=$DIR/${tdir}/stats_testdir
14574 local ctr f0 f1 bs=32768 count=42 sum
14576 mkdir -p ${testdir} || error "mkdir failed"
14578 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14580 for ctr in {write,read}_bytes; do
14582 cancel_lru_locks osc
14584 do_facet ost1 $LCTL set_param -n \
14585 "obdfilter.*.exports.clear=clear"
14587 if [ $ctr = write_bytes ]; then
14589 f1=${testdir}/${tfile}
14591 f0=${testdir}/${tfile}
14595 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14598 cancel_lru_locks osc
14600 sum=$(do_facet ost1 $LCTL get_param \
14601 "obdfilter.*.exports.*.stats" |
14602 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14603 $1 == ctr { sum += $7 }
14604 END { printf("%0.0f", sum) }')
14606 if ((sum != bs * count)); then
14607 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14611 rm -rf $DIR/${tdir}
14613 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14616 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14617 skip "too old lustre for get_param -R ($facet_ver)"
14619 # verifying readability.
14620 $LCTL get_param -R '*' &> /dev/null
14622 # Verifing writability with badarea_io.
14623 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14624 local skipped_params='force_lbug|changelog_mask|daemon_file'
14625 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14626 egrep -v "$skipped_params" |
14627 xargs -n 1 find $proc_dirs -name |
14628 xargs -n 1 badarea_io ||
14629 error "client badarea_io failed"
14631 # remount the FS in case writes/reads /proc break the FS
14632 cleanup || error "failed to unmount"
14633 setup || error "failed to setup"
14635 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14638 remote_mds_nodsh && skip "remote MDS with nodsh"
14639 remote_ost_nodsh && skip "remote OST with nodsh"
14641 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14642 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14644 for facet in mds1 ost1; do
14645 local facet_ver=$(lustre_version_code $facet)
14646 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14647 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14649 log "$facet: too old lustre for get_param -R"
14651 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14652 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14653 tr -d = | egrep -v $skipped_params |
14654 xargs -n 1 find $proc_dirs -name |
14655 xargs -n 1 badarea_io" ||
14656 error "$facet badarea_io failed"
14658 skip_noexit "$facet: too old lustre for get_param -R"
14662 # remount the FS in case writes/reads /proc break the FS
14663 cleanup || error "failed to unmount"
14664 setup || error "failed to setup"
14666 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14669 remote_mds_nodsh && skip "remote MDS with nodsh"
14670 remote_ost_nodsh && skip "remote OST with nodsh"
14671 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14672 skip "Need MDS version at least 2.9.54"
14675 for facet in client mds1 ost1; do
14676 # Get the list of files that are missing the terminating newline
14677 local plist=$(do_facet $facet
14678 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14680 for ent in $plist; do
14681 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14682 awk -v FS='\v' -v RS='\v\v' \
14683 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14684 print FILENAME}'" 2>/dev/null)
14685 [ -z $missing ] || {
14686 do_facet $facet $LCTL get_param $ent | od -An -tx1
14687 error "file does not end with newline: $facet-$ent"
14692 run_test 133h "Proc files should end with newlines"
14695 remote_mds_nodsh && skip "remote MDS with nodsh"
14696 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14697 skip "Need MDS version at least 2.7.54"
14699 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14700 cancel_lru_locks mdc
14702 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14703 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14704 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14707 createmany -o $DIR/$tdir/f $nr ||
14708 error "failed to create $nr files in $DIR/$tdir"
14709 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14711 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14712 do_facet mds1 $LCTL set_param fail_loc=0x327
14713 do_facet mds1 $LCTL set_param fail_val=500
14716 echo "sleep 10 seconds ..."
14718 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14720 do_facet mds1 $LCTL set_param fail_loc=0
14721 do_facet mds1 $LCTL set_param fail_val=0
14722 [ $lck_cnt -lt $unused ] ||
14723 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14726 unlinkmany $DIR/$tdir/f $nr
14728 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14731 remote_mds_nodsh && skip "remote MDS with nodsh"
14732 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14733 skip "Need MDS version at least 2.7.54"
14735 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14736 cancel_lru_locks mdc
14738 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14739 ldlm.lock_reclaim_threshold_mb)
14740 # disable reclaim temporarily
14741 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14743 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14744 do_facet mds1 $LCTL set_param fail_loc=0x328
14745 do_facet mds1 $LCTL set_param fail_val=500
14747 $LCTL set_param debug=+trace
14750 createmany -o $DIR/$tdir/f $nr &
14751 local create_pid=$!
14753 echo "Sleep $TIMEOUT seconds ..."
14755 if ! ps -p $create_pid > /dev/null 2>&1; then
14756 do_facet mds1 $LCTL set_param fail_loc=0
14757 do_facet mds1 $LCTL set_param fail_val=0
14758 do_facet mds1 $LCTL set_param \
14759 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14760 error "createmany finished incorrectly!"
14762 do_facet mds1 $LCTL set_param fail_loc=0
14763 do_facet mds1 $LCTL set_param fail_val=0
14764 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14765 wait $create_pid || return 1
14767 unlinkmany $DIR/$tdir/f $nr
14769 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14772 remote_mds_nodsh && skip "remote MDS with nodsh"
14773 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14774 skip "Need MDS version at least 2.13.50"
14777 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14779 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14780 #set only one record at plain llog
14781 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14783 #fill already existed plain llog each 64767
14784 #wrapping whole catalog
14785 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14787 createmany -o $DIR/$tdir/$tfile_ 64700
14788 for (( i = 0; i < 64700; i = i + 2 ))
14790 rm $DIR/$tdir/$tfile_$i &
14791 rm $DIR/$tdir/$tfile_$((i + 1)) &
14796 #waiting osp synchronization
14797 wait_delete_completed
14799 run_test 135 "Race catalog processing"
14802 remote_mds_nodsh && skip "remote MDS with nodsh"
14803 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14804 skip "Need MDS version at least 2.13.50"
14807 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14808 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14809 #set only one record at plain llog
14810 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14811 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14813 #fill already existed 2 plain llogs each 64767
14814 #wrapping whole catalog
14815 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14816 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14817 wait_delete_completed
14819 createmany -o $DIR/$tdir/$tfile_ 10
14822 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14823 for (( i = 0; i < 10; i = i + 3 ))
14825 rm $DIR/$tdir/$tfile_$i &
14826 rm $DIR/$tdir/$tfile_$((i + 1)) &
14830 rm $DIR/$tdir/$tfile_$((i + 2)) &
14833 #waiting osp synchronization
14834 wait_delete_completed
14836 run_test 136 "Race catalog processing 2"
14838 test_140() { #bug-17379
14839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14841 test_mkdir $DIR/$tdir
14842 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14843 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14845 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14846 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14848 while i=$((i + 1)); do
14850 cd $i || error "Changing to $i"
14851 ln -s ../stat stat || error "Creating stat symlink"
14852 # Read the symlink until ELOOP present,
14853 # not LBUGing the system is considered success,
14854 # we didn't overrun the stack.
14855 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14856 if [ $ret -ne 0 ]; then
14857 if [ $ret -eq 40 ]; then
14860 error "Open stat symlink"
14866 echo "The symlink depth = $i"
14867 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14868 error "Invalid symlink depth"
14870 # Test recursive symlink
14871 ln -s symlink_self symlink_self
14872 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14873 echo "open symlink_self returns $ret"
14874 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14876 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14881 local TF="$TMP/$tfile"
14883 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14884 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14886 cancel_lru_locks $OSC
14887 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14888 remount_client $MOUNT
14890 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14893 $TRUNCATE $DIR/$tfile 6000
14894 cancel_lru_locks $OSC
14895 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14898 echo "12345" >>$DIR/$tfile
14899 cancel_lru_locks $OSC
14900 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14903 echo "12345" >>$DIR/$tfile
14904 cancel_lru_locks $OSC
14905 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14907 run_test 150a "truncate/append tests"
14910 check_set_fallocate_or_skip
14913 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14914 check_fallocate $DIR/$tfile || skip_eopnotsupp "fallocate failed"
14916 run_test 150b "Verify fallocate (prealloc) functionality"
14919 check_set_fallocate_or_skip
14922 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14923 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14925 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14926 # precomputed md5sum for 20MB of zeroes
14927 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14928 local sum=($(md5sum $DIR/$tfile))
14930 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14932 check_set_fallocate 1
14935 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14936 sum=($(md5sum $DIR/$tfile))
14938 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14940 run_test 150bb "Verify fallocate modes both zero space"
14943 check_set_fallocate_or_skip
14944 local striping="-c2"
14946 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14947 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14948 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14949 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14950 local want=$((OSTCOUNT * 1048576))
14952 # Must allocate all requested space, not more than 5% extra
14953 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14954 error "bytes $bytes is not $want"
14958 echo "verify fallocate on PFL file"
14960 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14962 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
14963 error "Create $DIR/$tfile failed"
14964 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
14965 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14966 want=$((512 * 1048576))
14968 # Must allocate all requested space, not more than 5% extra
14969 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14970 error "bytes $bytes is not $want"
14972 run_test 150c "Verify fallocate Size and Blocks"
14975 check_set_fallocate_or_skip
14976 local striping="-c2"
14978 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14980 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14981 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
14982 error "setstripe failed"
14983 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
14984 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
14985 local want=$((OSTCOUNT * 1048576))
14987 # Must allocate all requested space, not more than 5% extra
14988 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14989 error "bytes $bytes is not $want"
14991 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
14994 check_set_fallocate_or_skip
14998 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14999 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15000 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15002 # Find OST with Minimum Size
15003 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15004 sort -un | head -1)
15006 # Get 100MB per OST of the available space to reduce run time
15007 # else 60% of the available space if we are running SLOW tests
15008 if [ $SLOW == "no" ]; then
15009 local space=$((1024 * 100 * OSTCOUNT))
15011 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
15014 fallocate -l${space}k $DIR/$tfile ||
15015 error "fallocate ${space}k $DIR/$tfile failed"
15016 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
15018 # get size immediately after fallocate. This should be correctly
15020 local size=$(stat -c '%s' $DIR/$tfile)
15021 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
15023 # Sleep for a while for statfs to get updated. And not pull from cache.
15026 echo "df after fallocate:"
15029 (( size / 1024 == space )) || error "size $size != requested $space"
15030 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
15031 error "used $used < space $space"
15033 rm $DIR/$tfile || error "rm failed"
15035 wait_delete_completed
15037 echo "df after unlink:"
15040 run_test 150e "Verify 60% of available OST space consumed by fallocate"
15045 local want_size_before=20480 # in bytes
15046 local want_blocks_before=40 # 512 sized blocks
15047 local want_blocks_after=24 # 512 sized blocks
15048 local length=$(((want_blocks_before - want_blocks_after) * 512))
15050 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15051 skip "need at least 2.14.0 for fallocate punch"
15053 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15054 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15057 check_set_fallocate_or_skip
15058 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15060 [[ "x$DOM" == "xyes" ]] &&
15061 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
15063 echo "Verify fallocate punch: Range within the file range"
15064 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15065 error "dd failed for bs 4096 and count 5"
15067 # Call fallocate with punch range which is within the file range
15068 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
15069 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
15070 # client must see changes immediately after fallocate
15071 size=$(stat -c '%s' $DIR/$tfile)
15072 blocks=$(stat -c '%b' $DIR/$tfile)
15074 # Verify punch worked.
15075 (( blocks == want_blocks_after )) ||
15076 error "punch failed: blocks $blocks != $want_blocks_after"
15078 (( size == want_size_before )) ||
15079 error "punch failed: size $size != $want_size_before"
15081 # Verify there is hole in file
15082 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
15083 # precomputed md5sum
15084 local expect="4a9a834a2db02452929c0a348273b4aa"
15086 cksum=($(md5sum $DIR/$tfile))
15087 [[ "${cksum[0]}" == "$expect" ]] ||
15088 error "unexpected MD5SUM after punch: ${cksum[0]}"
15090 # Start second sub-case for fallocate punch.
15091 echo "Verify fallocate punch: Range overlapping and less than blocksize"
15092 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15093 error "dd failed for bs 4096 and count 5"
15095 # Punch range less than block size will have no change in block count
15096 want_blocks_after=40 # 512 sized blocks
15098 # Punch overlaps two blocks and less than blocksize
15099 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
15100 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
15101 size=$(stat -c '%s' $DIR/$tfile)
15102 blocks=$(stat -c '%b' $DIR/$tfile)
15104 # Verify punch worked.
15105 (( blocks == want_blocks_after )) ||
15106 error "punch failed: blocks $blocks != $want_blocks_after"
15108 (( size == want_size_before )) ||
15109 error "punch failed: size $size != $want_size_before"
15111 # Verify if range is really zero'ed out. We expect Zeros.
15112 # precomputed md5sum
15113 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
15114 cksum=($(md5sum $DIR/$tfile))
15115 [[ "${cksum[0]}" == "$expect" ]] ||
15116 error "unexpected MD5SUM after punch: ${cksum[0]}"
15118 run_test 150f "Verify fallocate punch functionality"
15126 local BS=4096 # Block size in bytes
15128 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15129 skip "need at least 2.14.0 for fallocate punch"
15131 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15132 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15135 check_set_fallocate_or_skip
15136 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15138 if [[ "x$DOM" == "xyes" ]]; then
15139 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
15140 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
15142 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15143 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15146 # Get 100MB per OST of the available space to reduce run time
15147 # else 60% of the available space if we are running SLOW tests
15148 if [ $SLOW == "no" ]; then
15149 space=$((1024 * 100 * OSTCOUNT))
15151 # Find OST with Minimum Size
15152 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15153 sort -un | head -1)
15154 echo "min size OST: $space"
15155 space=$(((space * 60)/100 * OSTCOUNT))
15157 # space in 1k units, round to 4k blocks
15158 local blkcount=$((space * 1024 / $BS))
15160 echo "Verify fallocate punch: Very large Range"
15161 fallocate -l${space}k $DIR/$tfile ||
15162 error "fallocate ${space}k $DIR/$tfile failed"
15163 # write 1M at the end, start and in the middle
15164 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
15165 error "dd failed: bs $BS count 256"
15166 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
15167 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
15168 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
15169 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
15172 size=$(stat -c '%s' $DIR/$tfile)
15174 # gather punch length.
15175 local punch_size=$((size - (BS * 2)))
15177 echo "punch_size = $punch_size"
15178 echo "size - punch_size: $((size - punch_size))"
15179 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
15181 # Call fallocate to punch all except 2 blocks. We leave the
15182 # first and the last block
15183 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
15184 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
15185 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
15187 size_after=$(stat -c '%s' $DIR/$tfile)
15188 blocks_after=$(stat -c '%b' $DIR/$tfile)
15190 # Verify punch worked.
15191 # Size should be kept
15192 (( size == size_after )) ||
15193 error "punch failed: size $size != $size_after"
15195 # two 4k data blocks to remain plus possible 1 extra extent block
15196 (( blocks_after <= ((BS / 512) * 3) )) ||
15197 error "too many blocks remains: $blocks_after"
15199 # Verify that file has hole between the first and the last blocks
15200 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
15201 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
15203 echo "Hole at [$hole_start, $hole_end)"
15204 (( hole_start == BS )) ||
15205 error "no hole at offset $BS after punch"
15207 (( hole_end == BS + punch_size )) ||
15208 error "data at offset $hole_end < $((BS + punch_size))"
15210 run_test 150g "Verify fallocate punch on large range"
15212 #LU-2902 roc_hit was not able to read all values from lproc
15213 function roc_hit_init() {
15214 local list=$(comma_list $(osts_nodes))
15215 local dir=$DIR/$tdir-check
15216 local file=$dir/$tfile
15222 #use setstripe to do a write to every ost
15223 for i in $(seq 0 $((OSTCOUNT-1))); do
15224 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
15225 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
15226 idx=$(printf %04x $i)
15227 BEFORE=$(get_osd_param $list *OST*$idx stats |
15228 awk '$1 == "cache_access" {sum += $7}
15229 END { printf("%0.0f", sum) }')
15231 cancel_lru_locks osc
15232 cat $file >/dev/null
15234 AFTER=$(get_osd_param $list *OST*$idx stats |
15235 awk '$1 == "cache_access" {sum += $7}
15236 END { printf("%0.0f", sum) }')
15238 echo BEFORE:$BEFORE AFTER:$AFTER
15239 if ! let "AFTER - BEFORE == 4"; then
15241 error "roc_hit is not safe to use"
15249 function roc_hit() {
15250 local list=$(comma_list $(osts_nodes))
15251 echo $(get_osd_param $list '' stats |
15252 awk '$1 == "cache_hit" {sum += $7}
15253 END { printf("%0.0f", sum) }')
15256 function set_cache() {
15259 if [ "$2" == "off" ]; then
15262 local list=$(comma_list $(osts_nodes))
15263 set_osd_param $list '' $1_cache_enable $on
15265 cancel_lru_locks osc
15269 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15270 remote_ost_nodsh && skip "remote OST with nodsh"
15273 local list=$(comma_list $(osts_nodes))
15275 # check whether obdfilter is cache capable at all
15276 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
15277 skip "not cache-capable obdfilter"
15280 # check cache is enabled on all obdfilters
15281 if get_osd_param $list '' read_cache_enable | grep 0; then
15282 skip "oss cache is disabled"
15285 set_osd_param $list '' writethrough_cache_enable 1
15287 # check write cache is enabled on all obdfilters
15288 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
15289 skip "oss write cache is NOT enabled"
15294 #define OBD_FAIL_OBD_NO_LRU 0x609
15295 do_nodes $list $LCTL set_param fail_loc=0x609
15297 # pages should be in the case right after write
15298 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15301 local BEFORE=$(roc_hit)
15302 cancel_lru_locks osc
15303 cat $DIR/$tfile >/dev/null
15304 local AFTER=$(roc_hit)
15306 do_nodes $list $LCTL set_param fail_loc=0
15308 if ! let "AFTER - BEFORE == CPAGES"; then
15309 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15312 cancel_lru_locks osc
15313 # invalidates OST cache
15314 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15315 set_osd_param $list '' read_cache_enable 0
15316 cat $DIR/$tfile >/dev/null
15318 # now data shouldn't be found in the cache
15320 cancel_lru_locks osc
15321 cat $DIR/$tfile >/dev/null
15323 if let "AFTER - BEFORE != 0"; then
15324 error "IN CACHE: before: $BEFORE, after: $AFTER"
15327 set_osd_param $list '' read_cache_enable 1
15330 run_test 151 "test cache on oss and controls ==============================="
15333 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15335 local TF="$TMP/$tfile"
15337 # simulate ENOMEM during write
15338 #define OBD_FAIL_OST_NOMEM 0x226
15339 lctl set_param fail_loc=0x80000226
15340 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15342 sync || error "sync failed"
15343 lctl set_param fail_loc=0
15345 # discard client's cache
15346 cancel_lru_locks osc
15348 # simulate ENOMEM during read
15349 lctl set_param fail_loc=0x80000226
15350 cmp $TF $DIR/$tfile || error "cmp failed"
15351 lctl set_param fail_loc=0
15355 run_test 152 "test read/write with enomem ============================"
15358 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15360 run_test 153 "test if fdatasync does not crash ======================="
15362 dot_lustre_fid_permission_check() {
15364 local ffid=$MOUNT/.lustre/fid/$fid
15367 echo "stat fid $fid"
15368 stat $ffid || error "stat $ffid failed."
15369 echo "touch fid $fid"
15370 touch $ffid || error "touch $ffid failed."
15371 echo "write to fid $fid"
15372 cat /etc/hosts > $ffid || error "write $ffid failed."
15373 echo "read fid $fid"
15374 diff /etc/hosts $ffid || error "read $ffid failed."
15375 echo "append write to fid $fid"
15376 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15377 echo "rename fid $fid"
15378 mv $ffid $test_dir/$tfile.1 &&
15379 error "rename $ffid to $tfile.1 should fail."
15380 touch $test_dir/$tfile.1
15381 mv $test_dir/$tfile.1 $ffid &&
15382 error "rename $tfile.1 to $ffid should fail."
15383 rm -f $test_dir/$tfile.1
15384 echo "truncate fid $fid"
15385 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15386 echo "link fid $fid"
15387 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15388 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15389 echo "setfacl fid $fid"
15390 setfacl -R -m u:$USER0:rwx $ffid ||
15391 error "setfacl $ffid failed"
15392 echo "getfacl fid $fid"
15393 getfacl $ffid || error "getfacl $ffid failed."
15395 echo "unlink fid $fid"
15396 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15397 echo "mknod fid $fid"
15398 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15400 fid=[0xf00000400:0x1:0x0]
15401 ffid=$MOUNT/.lustre/fid/$fid
15403 echo "stat non-exist fid $fid"
15404 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15405 echo "write to non-exist fid $fid"
15406 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15407 echo "link new fid $fid"
15408 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15410 mkdir -p $test_dir/$tdir
15411 touch $test_dir/$tdir/$tfile
15412 fid=$($LFS path2fid $test_dir/$tdir)
15415 error "error: could not get fid for $test_dir/$dir/$tfile."
15417 ffid=$MOUNT/.lustre/fid/$fid
15420 ls $ffid || error "ls $ffid failed."
15421 echo "touch $fid/$tfile.1"
15422 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15424 echo "touch $MOUNT/.lustre/fid/$tfile"
15425 touch $MOUNT/.lustre/fid/$tfile && \
15426 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15428 echo "setxattr to $MOUNT/.lustre/fid"
15429 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15431 echo "listxattr for $MOUNT/.lustre/fid"
15432 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15434 echo "delxattr from $MOUNT/.lustre/fid"
15435 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15437 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15438 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15439 error "touch invalid fid should fail."
15441 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15442 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15443 error "touch non-normal fid should fail."
15445 echo "rename $tdir to $MOUNT/.lustre/fid"
15446 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15447 error "rename to $MOUNT/.lustre/fid should fail."
15449 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15451 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15452 local new_obf_mode=777
15454 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15455 chmod $new_obf_mode $DIR/.lustre/fid ||
15456 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15458 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15459 [ $obf_mode -eq $new_obf_mode ] ||
15460 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15462 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15463 chmod $old_obf_mode $DIR/.lustre/fid ||
15464 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15467 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15468 fid=$($LFS path2fid $test_dir/$tfile-2)
15470 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15472 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15473 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15474 error "create lov data thru .lustre failed"
15476 echo "cp /etc/passwd $test_dir/$tfile-2"
15477 cp /etc/passwd $test_dir/$tfile-2 ||
15478 error "copy to $test_dir/$tfile-2 failed."
15479 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15480 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15481 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15483 rm -rf $test_dir/tfile.lnk
15484 rm -rf $test_dir/$tfile-2
15488 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15489 skip "Need MDS version at least 2.4.1"
15491 local tf=$DIR/$tfile
15494 local fid=$($LFS path2fid $tf)
15495 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15497 # check that we get the same pathname back
15500 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15501 echo "$rootpath $fid"
15502 found=$($LFS fid2path $rootpath "$fid")
15503 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15504 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15507 # check wrong root path format
15508 rootpath=$MOUNT"_wrong"
15509 found=$($LFS fid2path $rootpath "$fid")
15510 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15512 run_test 154A "lfs path2fid and fid2path basic checks"
15515 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15516 skip "Need MDS version at least 2.4.1"
15518 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15519 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15520 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15521 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15523 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15524 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15526 # check that we get the same pathname
15527 echo "PFID: $PFID, name: $name"
15528 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15529 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15530 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15531 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15533 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15535 run_test 154B "verify the ll_decode_linkea tool"
15538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15539 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15540 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
15541 skip "Need MDS version at least 2.2.51"
15542 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15544 cp /etc/hosts $DIR/$tfile
15546 fid=$($LFS path2fid $DIR/$tfile)
15548 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15550 dot_lustre_fid_permission_check "$fid" $DIR ||
15551 error "dot lustre permission check $fid failed"
15553 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15555 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15557 touch $MOUNT/.lustre/file &&
15558 error "creation is not allowed under .lustre"
15560 mkdir $MOUNT/.lustre/dir &&
15561 error "mkdir is not allowed under .lustre"
15565 run_test 154a "Open-by-FID"
15568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15569 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15570 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15571 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15572 skip "Need MDS version at least 2.2.51"
15574 local remote_dir=$DIR/$tdir/remote_dir
15578 mkdir -p $DIR/$tdir
15579 $LFS mkdir -i $MDTIDX $remote_dir ||
15580 error "create remote directory failed"
15582 cp /etc/hosts $remote_dir/$tfile
15584 fid=$($LFS path2fid $remote_dir/$tfile)
15586 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15588 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15589 error "dot lustre permission check $fid failed"
15592 run_test 154b "Open-by-FID for remote directory"
15595 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15596 skip "Need MDS version at least 2.4.1"
15598 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15599 local FID1=$($LFS path2fid $DIR/$tfile.1)
15600 local FID2=$($LFS path2fid $DIR/$tfile.2)
15601 local FID3=$($LFS path2fid $DIR/$tfile.3)
15604 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15605 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15606 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15608 [ "$FID" = "${!want}" ] ||
15609 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15613 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15615 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15616 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15620 run_test 154c "lfs path2fid and fid2path multiple arguments"
15623 remote_mds_nodsh && skip "remote MDS with nodsh"
15624 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15625 skip "Need MDS version at least 2.5.53"
15627 if remote_mds; then
15628 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15632 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15639 local fid=$($LFS path2fid $DIR/$tfile)
15642 cmd="exec $fd<$DIR/$tfile"
15644 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15645 echo "$fid_list" | grep "$fid"
15648 cmd="exec $fd>/dev/null"
15650 if [ $rc -ne 0 ]; then
15651 error "FID $fid not found in open files list $fid_list"
15654 run_test 154d "Verify open file fid"
15658 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15659 skip "Need MDS version at least 2.6.50"
15661 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15662 error ".lustre returned by readdir"
15665 run_test 154e ".lustre is not returned by readdir"
15668 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15670 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15671 mkdir_on_mdt0 $DIR/$tdir
15672 # test dirs inherit from its stripe
15673 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15674 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15675 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15676 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15679 # get fid of parents
15680 local FID0=$($LFS path2fid $DIR/$tdir)
15681 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15682 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15683 local FID3=$($LFS path2fid $DIR)
15685 # check that path2fid --parents returns expected <parent_fid>/name
15686 # 1) test for a directory (single parent)
15687 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15688 [ "$parent" == "$FID0/foo1" ] ||
15689 error "expected parent: $FID0/foo1, got: $parent"
15691 # 2) test for a file with nlink > 1 (multiple parents)
15692 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
15693 echo "$parent" | grep -F "$FID1/$tfile" ||
15694 error "$FID1/$tfile not returned in parent list"
15695 echo "$parent" | grep -F "$FID2/link" ||
15696 error "$FID2/link not returned in parent list"
15698 # 3) get parent by fid
15699 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15700 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15701 echo "$parent" | grep -F "$FID1/$tfile" ||
15702 error "$FID1/$tfile not returned in parent list (by fid)"
15703 echo "$parent" | grep -F "$FID2/link" ||
15704 error "$FID2/link not returned in parent list (by fid)"
15706 # 4) test for entry in root directory
15707 parent=$($LFS path2fid --parents $DIR/f)
15708 echo "$parent" | grep -F "$FID3/f" ||
15709 error "$FID3/f not returned in parent list"
15711 # 5) test it on root directory
15712 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15713 error "$MOUNT should not have parents"
15715 # enable xattr caching and check that linkea is correctly updated
15716 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15717 save_lustre_params client "llite.*.xattr_cache" > $save
15718 lctl set_param llite.*.xattr_cache 1
15720 # 6.1) linkea update on rename
15721 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15723 # get parents by fid
15724 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15725 # foo1 should no longer be returned in parent list
15726 echo "$parent" | grep -F "$FID1" &&
15727 error "$FID1 should no longer be in parent list"
15728 # the new path should appear
15729 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15730 error "$FID2/$tfile.moved is not in parent list"
15732 # 6.2) linkea update on unlink
15733 rm -f $DIR/$tdir/foo2/link
15734 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15735 # foo2/link should no longer be returned in parent list
15736 echo "$parent" | grep -F "$FID2/link" &&
15737 error "$FID2/link should no longer be in parent list"
15741 restore_lustre_params < $save
15744 run_test 154f "get parent fids by reading link ea"
15748 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15749 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15750 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15751 skip "Need MDS version at least 2.6.92"
15753 mkdir_on_mdt0 $DIR/$tdir
15754 llapi_fid_test -d $DIR/$tdir
15756 run_test 154g "various llapi FID tests"
15758 test_155_small_load() {
15759 local temp=$TMP/$tfile
15760 local file=$DIR/$tfile
15762 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15763 error "dd of=$temp bs=6096 count=1 failed"
15765 cancel_lru_locks $OSC
15766 cmp $temp $file || error "$temp $file differ"
15768 $TRUNCATE $temp 6000
15769 $TRUNCATE $file 6000
15770 cmp $temp $file || error "$temp $file differ (truncate1)"
15772 echo "12345" >>$temp
15773 echo "12345" >>$file
15774 cmp $temp $file || error "$temp $file differ (append1)"
15776 echo "12345" >>$temp
15777 echo "12345" >>$file
15778 cmp $temp $file || error "$temp $file differ (append2)"
15784 test_155_big_load() {
15785 remote_ost_nodsh && skip "remote OST with nodsh"
15787 local temp=$TMP/$tfile
15788 local file=$DIR/$tfile
15791 local cache_size=$(do_facet ost$((MAXI+1)) \
15792 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15794 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
15796 if [ -z "$cache_size" ]; then
15799 local large_file_size=$((cache_size * 2))
15801 echo "OSS cache size: $cache_size KB"
15802 echo "Large file size: $large_file_size KB"
15804 [ $MAXV -le $large_file_size ] &&
15805 skip_env "max available OST size needs > $large_file_size KB"
15807 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15809 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15810 error "dd of=$temp bs=$large_file_size count=1k failed"
15813 cancel_lru_locks osc
15814 cmp $temp $file || error "$temp $file differ"
15820 save_writethrough() {
15821 local facets=$(get_facets OST)
15823 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15827 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15829 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15831 save_writethrough $p
15834 set_cache writethrough on
15835 test_155_small_load
15836 restore_lustre_params < $p
15839 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15844 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15846 save_writethrough $p
15849 set_cache writethrough off
15850 test_155_small_load
15851 restore_lustre_params < $p
15854 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15859 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15861 save_writethrough $p
15864 set_cache writethrough on
15865 test_155_small_load
15866 restore_lustre_params < $p
15869 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15874 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15876 save_writethrough $p
15879 set_cache writethrough off
15880 test_155_small_load
15881 restore_lustre_params < $p
15884 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15889 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15891 save_writethrough $p
15894 set_cache writethrough on
15896 restore_lustre_params < $p
15899 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15904 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15906 save_writethrough $p
15909 set_cache writethrough off
15911 restore_lustre_params < $p
15914 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15919 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15921 save_writethrough $p
15924 set_cache writethrough on
15926 restore_lustre_params < $p
15929 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15934 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15936 save_writethrough $p
15939 set_cache writethrough off
15941 restore_lustre_params < $p
15944 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15947 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15948 remote_ost_nodsh && skip "remote OST with nodsh"
15949 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15950 skip "stats not implemented on old servers"
15951 [ "$ost1_FSTYPE" = "zfs" ] &&
15952 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
15957 local file="$DIR/$tfile"
15958 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15960 save_writethrough $p
15963 log "Turn on read and write cache"
15965 set_cache writethrough on
15967 log "Write data and read it back."
15968 log "Read should be satisfied from the cache."
15969 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15971 cancel_lru_locks osc
15972 cat $file >/dev/null
15974 if ! let "AFTER - BEFORE == CPAGES"; then
15975 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
15977 log "cache hits: before: $BEFORE, after: $AFTER"
15980 log "Read again; it should be satisfied from the cache."
15982 cancel_lru_locks osc
15983 cat $file >/dev/null
15985 if ! let "AFTER - BEFORE == CPAGES"; then
15986 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
15988 log "cache hits:: before: $BEFORE, after: $AFTER"
15991 log "Turn off the read cache and turn on the write cache"
15993 set_cache writethrough on
15995 log "Read again; it should be satisfied from the cache."
15997 cancel_lru_locks osc
15998 cat $file >/dev/null
16000 if ! let "AFTER - BEFORE == CPAGES"; then
16001 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
16003 log "cache hits:: before: $BEFORE, after: $AFTER"
16006 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16007 # > 2.12.56 uses pagecache if cached
16008 log "Read again; it should not be satisfied from the cache."
16010 cancel_lru_locks osc
16011 cat $file >/dev/null
16013 if ! let "AFTER - BEFORE == 0"; then
16014 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
16016 log "cache hits:: before: $BEFORE, after: $AFTER"
16020 log "Write data and read it back."
16021 log "Read should be satisfied from the cache."
16022 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16024 cancel_lru_locks osc
16025 cat $file >/dev/null
16027 if ! let "AFTER - BEFORE == CPAGES"; then
16028 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
16030 log "cache hits:: before: $BEFORE, after: $AFTER"
16033 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16034 # > 2.12.56 uses pagecache if cached
16035 log "Read again; it should not be satisfied from the cache."
16037 cancel_lru_locks osc
16038 cat $file >/dev/null
16040 if ! let "AFTER - BEFORE == 0"; then
16041 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
16043 log "cache hits:: before: $BEFORE, after: $AFTER"
16047 log "Turn off read and write cache"
16049 set_cache writethrough off
16051 log "Write data and read it back"
16052 log "It should not be satisfied from the cache."
16054 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16055 cancel_lru_locks osc
16057 cat $file >/dev/null
16059 if ! let "AFTER - BEFORE == 0"; then
16060 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
16062 log "cache hits:: before: $BEFORE, after: $AFTER"
16065 log "Turn on the read cache and turn off the write cache"
16067 set_cache writethrough off
16069 log "Write data and read it back"
16070 log "It should not be satisfied from the cache."
16072 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16074 cancel_lru_locks osc
16075 cat $file >/dev/null
16077 if ! let "AFTER - BEFORE == 0"; then
16078 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
16080 log "cache hits:: before: $BEFORE, after: $AFTER"
16083 log "Read again; it should be satisfied from the cache."
16085 cancel_lru_locks osc
16086 cat $file >/dev/null
16088 if ! let "AFTER - BEFORE == CPAGES"; then
16089 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
16091 log "cache hits:: before: $BEFORE, after: $AFTER"
16094 restore_lustre_params < $p
16097 run_test 156 "Verification of tunables"
16100 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16101 remote_mds_nodsh && skip "remote MDS with nodsh"
16102 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16103 skip "Need MDS version at least 2.2.0"
16105 changelog_register || error "changelog_register failed"
16106 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16107 changelog_users $SINGLEMDS | grep -q $cl_user ||
16108 error "User $cl_user not found in changelog_users"
16110 mkdir_on_mdt0 $DIR/$tdir
16113 test_mkdir -p $DIR/$tdir/pics/2008/zachy
16114 changelog_clear 0 || error "changelog_clear failed"
16115 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
16116 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
16117 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16118 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16119 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16120 rm $DIR/$tdir/pics/desktop.jpg
16122 echo "verifying changelog mask"
16123 changelog_chmask "-MKDIR"
16124 changelog_chmask "-CLOSE"
16126 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
16127 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
16129 changelog_chmask "+MKDIR"
16130 changelog_chmask "+CLOSE"
16132 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
16133 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
16135 MKDIRS=$(changelog_dump | grep -c "MKDIR")
16136 CLOSES=$(changelog_dump | grep -c "CLOSE")
16137 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
16138 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
16141 echo "verifying target fid"
16142 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
16143 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
16144 [ "$fidc" == "$fidf" ] ||
16145 error "changelog '$tfile' fid $fidc != file fid $fidf"
16146 echo "verifying parent fid"
16147 # The FID returned from the Changelog may be the directory shard on
16148 # a different MDT, and not the FID returned by path2fid on the parent.
16149 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
16150 # since this is what will matter when recreating this file in the tree.
16151 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
16152 local pathp=$($LFS fid2path $MOUNT "$fidp")
16153 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
16154 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
16156 echo "getting records for $cl_user"
16157 changelog_users $SINGLEMDS
16158 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
16160 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
16161 error "changelog_clear failed"
16162 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
16163 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
16164 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
16165 error "user index expect $user_rec1 + $nclr != $user_rec2"
16167 local min0_rec=$(changelog_users $SINGLEMDS |
16168 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
16169 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
16170 awk '{ print $1; exit; }')
16172 changelog_dump | tail -n 5
16173 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
16174 [ $first_rec == $((min0_rec + 1)) ] ||
16175 error "first index should be $min0_rec + 1 not $first_rec"
16177 # LU-3446 changelog index reset on MDT restart
16178 local cur_rec1=$(changelog_users $SINGLEMDS |
16179 awk '/^current.index:/ { print $NF }')
16180 changelog_clear 0 ||
16181 error "clear all changelog records for $cl_user failed"
16182 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
16183 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
16184 error "Fail to start $SINGLEMDS"
16185 local cur_rec2=$(changelog_users $SINGLEMDS |
16186 awk '/^current.index:/ { print $NF }')
16187 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
16188 [ $cur_rec1 == $cur_rec2 ] ||
16189 error "current index should be $cur_rec1 not $cur_rec2"
16191 echo "verifying users from this test are deregistered"
16192 changelog_deregister || error "changelog_deregister failed"
16193 changelog_users $SINGLEMDS | grep -q $cl_user &&
16194 error "User '$cl_user' still in changelog_users"
16196 # lctl get_param -n mdd.*.changelog_users
16197 # current_index: 144
16198 # ID index (idle seconds)
16199 # cl3 144 (2) mask=<list>
16200 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
16201 # this is the normal case where all users were deregistered
16202 # make sure no new records are added when no users are present
16203 local last_rec1=$(changelog_users $SINGLEMDS |
16204 awk '/^current.index:/ { print $NF }')
16205 touch $DIR/$tdir/chloe
16206 local last_rec2=$(changelog_users $SINGLEMDS |
16207 awk '/^current.index:/ { print $NF }')
16208 echo "verify changelogs are off: $last_rec1 == $last_rec2"
16209 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
16211 # any changelog users must be leftovers from a previous test
16212 changelog_users $SINGLEMDS
16213 echo "other changelog users; can't verify off"
16216 run_test 160a "changelog sanity"
16218 test_160b() { # LU-3587
16219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16220 remote_mds_nodsh && skip "remote MDS with nodsh"
16221 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16222 skip "Need MDS version at least 2.2.0"
16224 changelog_register || error "changelog_register failed"
16225 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16226 changelog_users $SINGLEMDS | grep -q $cl_user ||
16227 error "User '$cl_user' not found in changelog_users"
16229 local longname1=$(str_repeat a 255)
16230 local longname2=$(str_repeat b 255)
16233 echo "creating very long named file"
16234 touch $longname1 || error "create of '$longname1' failed"
16235 echo "renaming very long named file"
16236 mv $longname1 $longname2
16238 changelog_dump | grep RENME | tail -n 5
16241 run_test 160b "Verify that very long rename doesn't crash in changelog"
16244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16245 remote_mds_nodsh && skip "remote MDS with nodsh"
16247 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16248 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16249 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16250 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16254 # Registration step
16255 changelog_register || error "changelog_register failed"
16258 mkdir -p $DIR/$tdir
16259 $MCREATE $DIR/$tdir/foo_160c
16260 changelog_chmask "-TRUNC"
16261 $TRUNCATE $DIR/$tdir/foo_160c 200
16262 changelog_chmask "+TRUNC"
16263 $TRUNCATE $DIR/$tdir/foo_160c 199
16264 changelog_dump | tail -n 5
16265 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
16266 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
16268 run_test 160c "verify that changelog log catch the truncate event"
16271 remote_mds_nodsh && skip "remote MDS with nodsh"
16272 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16273 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16274 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
16275 skip "Need MDS version at least 2.7.60"
16277 # Registration step
16278 changelog_register || error "changelog_register failed"
16280 mkdir -p $DIR/$tdir/migrate_dir
16281 changelog_clear 0 || error "changelog_clear failed"
16283 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
16284 changelog_dump | tail -n 5
16285 local migrates=$(changelog_dump | grep -c "MIGRT")
16286 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
16288 run_test 160d "verify that changelog log catch the migrate event"
16291 remote_mds_nodsh && skip "remote MDS with nodsh"
16294 changelog_register || error "changelog_register failed"
16296 local MDT0=$(facet_svc $SINGLEMDS)
16299 # No user (expect fail)
16300 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
16302 if [ $rc -eq 0 ]; then
16303 error "Should fail without user"
16304 elif [ $rc -ne 4 ]; then
16305 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16308 # Delete a future user (expect fail)
16309 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16311 if [ $rc -eq 0 ]; then
16312 error "Deleted non-existant user cl77"
16313 elif [ $rc -ne 2 ]; then
16314 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16317 # Clear to a bad index (1 billion should be safe)
16318 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16321 if [ $rc -eq 0 ]; then
16322 error "Successfully cleared to invalid CL index"
16323 elif [ $rc -ne 22 ]; then
16324 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16327 run_test 160e "changelog negative testing (should return errors)"
16330 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16331 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16332 skip "Need MDS version at least 2.10.56"
16334 local mdts=$(comma_list $(mdts_nodes))
16337 changelog_register || error "first changelog_register failed"
16338 changelog_register || error "second changelog_register failed"
16340 declare -A cl_user1
16341 declare -A cl_user2
16346 # generate some changelog records to accumulate on each MDT
16347 # use all_char because created files should be evenly distributed
16348 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16349 error "test_mkdir $tdir failed"
16350 log "$(date +%s): creating first files"
16351 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16352 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16353 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16356 # check changelogs have been generated
16357 local start=$SECONDS
16358 local idle_time=$((MDSCOUNT * 5 + 5))
16359 local nbcl=$(changelog_dump | wc -l)
16360 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16362 for param in "changelog_max_idle_time=$idle_time" \
16364 "changelog_min_gc_interval=2" \
16365 "changelog_min_free_cat_entries=3"; do
16366 local MDT0=$(facet_svc $SINGLEMDS)
16367 local var="${param%=*}"
16368 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16370 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16371 do_nodes $mdts $LCTL set_param mdd.*.$param
16374 # force cl_user2 to be idle (1st part), but also cancel the
16375 # cl_user1 records so that it is not evicted later in the test.
16376 local sleep1=$((idle_time / 2))
16377 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16380 # simulate changelog catalog almost full
16381 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16382 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16384 for i in $(seq $MDSCOUNT); do
16385 cl_users=(${CL_USERS[mds$i]})
16386 cl_user1[mds$i]="${cl_users[0]}"
16387 cl_user2[mds$i]="${cl_users[1]}"
16389 [ -n "${cl_user1[mds$i]}" ] ||
16390 error "mds$i: no user registered"
16391 [ -n "${cl_user2[mds$i]}" ] ||
16392 error "mds$i: only ${cl_user2[mds$i]} is registered"
16394 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16395 [ -n "$user_rec1" ] ||
16396 error "mds$i: User ${cl_user1[mds$i]} not registered"
16397 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16398 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16399 [ -n "$user_rec2" ] ||
16400 error "mds$i: User ${cl_user1[mds$i]} not registered"
16401 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16402 "$user_rec1 + 2 == $user_rec2"
16403 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16404 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16405 "$user_rec1 + 2, but is $user_rec2"
16406 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16407 [ -n "$user_rec2" ] ||
16408 error "mds$i: User ${cl_user2[mds$i]} not registered"
16409 [ $user_rec1 == $user_rec2 ] ||
16410 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16411 "$user_rec1, but is $user_rec2"
16414 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16415 local sleep2=$((idle_time - (SECONDS - start) + 1))
16416 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16419 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16420 # cl_user1 should be OK because it recently processed records.
16421 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16422 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16423 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16424 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16427 # ensure gc thread is done
16428 for i in $(mdts_nodes); do
16429 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16430 error "$i: GC-thread not done"
16434 for (( i = 1; i <= MDSCOUNT; i++ )); do
16435 # check cl_user1 still registered
16436 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16437 error "mds$i: User ${cl_user1[mds$i]} not registered"
16438 # check cl_user2 unregistered
16439 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16440 error "mds$i: User ${cl_user2[mds$i]} still registered"
16442 # check changelogs are present and starting at $user_rec1 + 1
16443 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16444 [ -n "$user_rec1" ] ||
16445 error "mds$i: User ${cl_user1[mds$i]} not registered"
16446 first_rec=$($LFS changelog $(facet_svc mds$i) |
16447 awk '{ print $1; exit; }')
16449 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16450 [ $((user_rec1 + 1)) == $first_rec ] ||
16451 error "mds$i: rec $first_rec != $user_rec1 + 1"
16454 run_test 160f "changelog garbage collect (timestamped users)"
16457 remote_mds_nodsh && skip "remote MDS with nodsh"
16458 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16459 skip "Need MDS version at least 2.14.55"
16461 local mdts=$(comma_list $(mdts_nodes))
16464 changelog_register || error "first changelog_register failed"
16465 changelog_register || error "second changelog_register failed"
16467 declare -A cl_user1
16468 declare -A cl_user2
16473 # generate some changelog records to accumulate on each MDT
16474 # use all_char because created files should be evenly distributed
16475 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16476 error "test_mkdir $tdir failed"
16477 for ((i = 0; i < MDSCOUNT; i++)); do
16478 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16479 error "create $DIR/$tdir/d$i.1 failed"
16482 # check changelogs have been generated
16483 local nbcl=$(changelog_dump | wc -l)
16484 (( $nbcl > 0 )) || error "no changelogs found"
16486 # reduce the max_idle_indexes value to make sure we exceed it
16487 for param in "changelog_max_idle_indexes=2" \
16489 "changelog_min_gc_interval=2"; do
16490 local MDT0=$(facet_svc $SINGLEMDS)
16491 local var="${param%=*}"
16492 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16494 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16495 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16496 error "unable to set mdd.*.$param"
16499 local start=$SECONDS
16500 for i in $(seq $MDSCOUNT); do
16501 cl_users=(${CL_USERS[mds$i]})
16502 cl_user1[mds$i]="${cl_users[0]}"
16503 cl_user2[mds$i]="${cl_users[1]}"
16505 [ -n "${cl_user1[mds$i]}" ] ||
16506 error "mds$i: user1 is not registered"
16507 [ -n "${cl_user2[mds$i]}" ] ||
16508 error "mds$i: only ${cl_user1[mds$i]} is registered"
16510 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16511 [ -n "$user_rec1" ] ||
16512 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16513 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16514 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16515 [ -n "$user_rec2" ] ||
16516 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16517 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16518 "$user_rec1 + 2 == $user_rec2"
16519 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16520 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16521 "expected $user_rec1 + 2, but is $user_rec2"
16522 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16523 [ -n "$user_rec2" ] ||
16524 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16525 [ $user_rec1 == $user_rec2 ] ||
16526 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16527 "expected $user_rec1, but is $user_rec2"
16530 # ensure we are past the previous changelog_min_gc_interval set above
16531 local sleep2=$((start + 2 - SECONDS))
16532 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16533 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16534 # cl_user1 should be OK because it recently processed records.
16535 for ((i = 0; i < MDSCOUNT; i++)); do
16536 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16537 error "create $DIR/$tdir/d$i.3 failed"
16540 # ensure gc thread is done
16541 for i in $(mdts_nodes); do
16542 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16543 error "$i: GC-thread not done"
16547 for (( i = 1; i <= MDSCOUNT; i++ )); do
16548 # check cl_user1 still registered
16549 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16550 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16551 # check cl_user2 unregistered
16552 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16553 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16555 # check changelogs are present and starting at $user_rec1 + 1
16556 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16557 [ -n "$user_rec1" ] ||
16558 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16559 first_rec=$($LFS changelog $(facet_svc mds$i) |
16560 awk '{ print $1; exit; }')
16562 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16563 [ $((user_rec1 + 1)) == $first_rec ] ||
16564 error "mds$i: rec $first_rec != $user_rec1 + 1"
16567 run_test 160g "changelog garbage collect on idle records"
16570 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16571 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16572 skip "Need MDS version at least 2.10.56"
16574 local mdts=$(comma_list $(mdts_nodes))
16577 changelog_register || error "first changelog_register failed"
16578 changelog_register || error "second changelog_register failed"
16580 declare -A cl_user1
16581 declare -A cl_user2
16586 # generate some changelog records to accumulate on each MDT
16587 # use all_char because created files should be evenly distributed
16588 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16589 error "test_mkdir $tdir failed"
16590 for ((i = 0; i < MDSCOUNT; i++)); do
16591 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16592 error "create $DIR/$tdir/d$i.1 failed"
16595 # check changelogs have been generated
16596 local nbcl=$(changelog_dump | wc -l)
16597 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16599 for param in "changelog_max_idle_time=10" \
16601 "changelog_min_gc_interval=2"; do
16602 local MDT0=$(facet_svc $SINGLEMDS)
16603 local var="${param%=*}"
16604 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16606 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16607 do_nodes $mdts $LCTL set_param mdd.*.$param
16610 # force cl_user2 to be idle (1st part)
16613 for i in $(seq $MDSCOUNT); do
16614 cl_users=(${CL_USERS[mds$i]})
16615 cl_user1[mds$i]="${cl_users[0]}"
16616 cl_user2[mds$i]="${cl_users[1]}"
16618 [ -n "${cl_user1[mds$i]}" ] ||
16619 error "mds$i: no user registered"
16620 [ -n "${cl_user2[mds$i]}" ] ||
16621 error "mds$i: only ${cl_user2[mds$i]} is registered"
16623 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16624 [ -n "$user_rec1" ] ||
16625 error "mds$i: User ${cl_user1[mds$i]} not registered"
16626 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16627 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16628 [ -n "$user_rec2" ] ||
16629 error "mds$i: User ${cl_user1[mds$i]} not registered"
16630 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16631 "$user_rec1 + 2 == $user_rec2"
16632 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16633 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16634 "$user_rec1 + 2, but is $user_rec2"
16635 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16636 [ -n "$user_rec2" ] ||
16637 error "mds$i: User ${cl_user2[mds$i]} not registered"
16638 [ $user_rec1 == $user_rec2 ] ||
16639 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16640 "$user_rec1, but is $user_rec2"
16643 # force cl_user2 to be idle (2nd part) and to reach
16644 # changelog_max_idle_time
16647 # force each GC-thread start and block then
16648 # one per MDT/MDD, set fail_val accordingly
16649 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16650 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16652 # generate more changelogs to trigger fail_loc
16653 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16654 error "create $DIR/$tdir/${tfile}bis failed"
16656 # stop MDT to stop GC-thread, should be done in back-ground as it will
16657 # block waiting for the thread to be released and exit
16658 declare -A stop_pids
16659 for i in $(seq $MDSCOUNT); do
16661 stop_pids[mds$i]=$!
16664 for i in $(mdts_nodes); do
16667 local facets=$(facets_up_on_host $i)
16669 for facet in ${facets//,/ }; do
16670 if [[ $facet == mds* ]]; then
16674 # ensure each MDS's gc threads are still present and all in "R"
16675 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16676 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16677 error "$i: expected $nb GC-thread"
16679 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16681 error "$i: GC-thread not found in R-state"
16682 # check umounts of each MDT on MDS have reached kthread_stop()
16683 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16684 error "$i: expected $nb umount"
16686 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16687 error "$i: umount not found in D-state"
16690 # release all GC-threads
16691 do_nodes $mdts $LCTL set_param fail_loc=0
16693 # wait for MDT stop to complete
16694 for i in $(seq $MDSCOUNT); do
16695 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16699 # may try to check if any orphan changelog records are present
16700 # via ldiskfs/zfs and llog_reader...
16702 # re-start/mount MDTs
16703 for i in $(seq $MDSCOUNT); do
16704 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16705 error "Fail to start mds$i"
16709 for i in $(seq $MDSCOUNT); do
16710 # check cl_user1 still registered
16711 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16712 error "mds$i: User ${cl_user1[mds$i]} not registered"
16713 # check cl_user2 unregistered
16714 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16715 error "mds$i: User ${cl_user2[mds$i]} still registered"
16717 # check changelogs are present and starting at $user_rec1 + 1
16718 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16719 [ -n "$user_rec1" ] ||
16720 error "mds$i: User ${cl_user1[mds$i]} not registered"
16721 first_rec=$($LFS changelog $(facet_svc mds$i) |
16722 awk '{ print $1; exit; }')
16724 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16725 [ $((user_rec1 + 1)) == $first_rec ] ||
16726 error "mds$i: first index should be $user_rec1 + 1, " \
16727 "but is $first_rec"
16730 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16735 local mdts=$(comma_list $(mdts_nodes))
16737 changelog_register || error "first changelog_register failed"
16739 # generate some changelog records to accumulate on each MDT
16740 # use all_char because created files should be evenly distributed
16741 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16742 error "test_mkdir $tdir failed"
16743 for ((i = 0; i < MDSCOUNT; i++)); do
16744 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16745 error "create $DIR/$tdir/d$i.1 failed"
16748 # check changelogs have been generated
16749 local nbcl=$(changelog_dump | wc -l)
16750 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16752 # simulate race between register and unregister
16753 # XXX as fail_loc is set per-MDS, with DNE configs the race
16754 # simulation will only occur for one MDT per MDS and for the
16755 # others the normal race scenario will take place
16756 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16757 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16758 do_nodes $mdts $LCTL set_param fail_val=1
16760 # unregister 1st user
16761 changelog_deregister &
16763 # wait some time for deregister work to reach race rdv
16765 # register 2nd user
16766 changelog_register || error "2nd user register failed"
16768 wait $pid1 || error "1st user deregister failed"
16772 declare -A LAST_REC
16773 for i in $(seq $MDSCOUNT); do
16774 if changelog_users mds$i | grep "^cl"; then
16775 # make sure new records are added with one user present
16776 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16777 awk '/^current.index:/ { print $NF }')
16779 error "mds$i has no user registered"
16783 # generate more changelog records to accumulate on each MDT
16784 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16785 error "create $DIR/$tdir/${tfile}bis failed"
16787 for i in $(seq $MDSCOUNT); do
16788 last_rec=$(changelog_users $SINGLEMDS |
16789 awk '/^current.index:/ { print $NF }')
16790 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16791 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16792 error "changelogs are off on mds$i"
16795 run_test 160i "changelog user register/unregister race"
16798 remote_mds_nodsh && skip "remote MDS with nodsh"
16799 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16800 skip "Need MDS version at least 2.12.56"
16802 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16803 stack_trap "umount $MOUNT2" EXIT
16805 changelog_register || error "first changelog_register failed"
16806 stack_trap "changelog_deregister" EXIT
16808 # generate some changelog
16809 # use all_char because created files should be evenly distributed
16810 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16811 error "mkdir $tdir failed"
16812 for ((i = 0; i < MDSCOUNT; i++)); do
16813 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16814 error "create $DIR/$tdir/d$i.1 failed"
16817 # open the changelog device
16818 exec 3>/dev/changelog-$FSNAME-MDT0000
16819 stack_trap "exec 3>&-" EXIT
16820 exec 4</dev/changelog-$FSNAME-MDT0000
16821 stack_trap "exec 4<&-" EXIT
16823 # umount the first lustre mount
16825 stack_trap "mount_client $MOUNT" EXIT
16827 # read changelog, which may or may not fail, but should not crash
16831 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16832 changelog_users $SINGLEMDS | grep -q $cl_user ||
16833 error "User $cl_user not found in changelog_users"
16835 printf 'clear:'$cl_user':0' >&3
16837 run_test 160j "client can be umounted while its chanangelog is being used"
16840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16841 remote_mds_nodsh && skip "remote MDS with nodsh"
16843 mkdir -p $DIR/$tdir/1/1
16845 changelog_register || error "changelog_register failed"
16846 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16848 changelog_users $SINGLEMDS | grep -q $cl_user ||
16849 error "User '$cl_user' not found in changelog_users"
16850 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16851 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16852 rmdir $DIR/$tdir/1/1 & sleep 1
16854 touch $DIR/$tdir/2/2
16855 rm -rf $DIR/$tdir/2
16860 changelog_dump | grep rmdir || error "rmdir not recorded"
16862 run_test 160k "Verify that changelog records are not lost"
16864 # Verifies that a file passed as a parameter has recently had an operation
16865 # performed on it that has generated an MTIME changelog which contains the
16866 # correct parent FID. As files might reside on a different MDT from the
16867 # parent directory in DNE configurations, the FIDs are translated to paths
16868 # before being compared, which should be identical
16869 compare_mtime_changelog() {
16877 mdtidx=$($LFS getstripe --mdt-index $file)
16878 mdtidx=$(printf "%04x" $mdtidx)
16880 # Obtain the parent FID from the MTIME changelog
16881 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16882 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16884 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16885 [ -z "$cl_fid" ] && error "parent FID not present"
16887 # Verify that the path for the parent FID is the same as the path for
16888 # the test directory
16889 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16893 [[ "${pdir%/}" == "$dir" ]] ||
16894 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16900 remote_mds_nodsh && skip "remote MDS with nodsh"
16901 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16902 skip "Need MDS version at least 2.13.55"
16906 changelog_register || error "changelog_register failed"
16907 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16909 changelog_users $SINGLEMDS | grep -q $cl_user ||
16910 error "User '$cl_user' not found in changelog_users"
16912 # Clear some types so that MTIME changelogs are generated
16913 changelog_chmask "-CREAT"
16914 changelog_chmask "-CLOSE"
16916 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16918 # Test CL_MTIME during setattr
16919 touch $DIR/$tdir/$tfile
16920 compare_mtime_changelog $DIR/$tdir/$tfile
16922 # Test CL_MTIME during close
16923 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16924 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16926 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16929 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16930 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16931 skip "Need MDS version at least 2.14.51"
16938 changelog_register || error "first changelog_register failed"
16939 changelog_register || error "second changelog_register failed"
16941 cl_users=(${CL_USERS[mds1]})
16942 cl_user1="${cl_users[0]}"
16943 cl_user2="${cl_users[1]}"
16944 # generate some changelog records to accumulate on MDT0
16945 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16946 createmany -m $DIR/$tdir/$tfile 50 ||
16947 error "create $DIR/$tdir/$tfile failed"
16948 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16951 # check changelogs have been generated
16952 local nbcl=$(changelog_dump | wc -l)
16953 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16955 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
16956 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
16958 __changelog_clear mds1 $cl_user1 +10
16959 __changelog_clear mds1 $cl_user2 0 &
16962 __changelog_clear mds1 $cl_user1 0 ||
16963 error "fail to cancel record for $cl_user1"
16965 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16967 run_test 160m "Changelog clear race"
16970 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16971 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16972 skip "Need MDS version at least 2.14.51"
16981 changelog_register || error "first changelog_register failed"
16983 cl_users=(${CL_USERS[mds1]})
16984 cl_user1="${cl_users[0]}"
16986 # generate some changelog records to accumulate on MDT0
16987 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16988 first_rec=$(changelog_users $SINGLEMDS |
16989 awk '/^current.index:/ { print $NF }')
16990 while (( last_rec < (( first_rec + 65000)) )); do
16991 createmany -m $DIR/$tdir/$tfile 10000 ||
16992 error "create $DIR/$tdir/$tfile failed"
16994 for i in $(seq 0 10000); do
16995 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
16999 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
17000 error "unlinkmany failed unlink"
17001 last_rec=$(changelog_users $SINGLEMDS |
17002 awk '/^current.index:/ { print $NF }')
17003 echo last record $last_rec
17004 (( last_rec == 0 )) && error "no changelog found"
17007 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
17008 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
17010 __changelog_clear mds1 $cl_user1 0 &
17013 __changelog_clear mds1 $cl_user1 0 ||
17014 error "fail to cancel record for $cl_user1"
17016 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17018 run_test 160n "Changelog destroy race"
17021 local mdt="$(facet_svc $SINGLEMDS)"
17023 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17024 remote_mds_nodsh && skip "remote MDS with nodsh"
17025 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
17026 skip "Need MDS version at least 2.14.52"
17028 changelog_register --user test_160o -m unlnk+close+open ||
17029 error "changelog_register failed"
17031 do_facet $SINGLEMDS $LCTL --device $mdt \
17032 changelog_register -u "Tt3_-#" &&
17033 error "bad symbols in name should fail"
17035 do_facet $SINGLEMDS $LCTL --device $mdt \
17036 changelog_register -u test_160o &&
17037 error "the same name registration should fail"
17039 do_facet $SINGLEMDS $LCTL --device $mdt \
17040 changelog_register -u test_160toolongname &&
17041 error "too long name registration should fail"
17043 changelog_chmask "MARK+HSM"
17044 lctl get_param mdd.*.changelog*mask
17045 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17046 changelog_users $SINGLEMDS | grep -q $cl_user ||
17047 error "User $cl_user not found in changelog_users"
17049 echo $cl_user | grep -q test_160o ||
17050 error "User $cl_user has no specific name 'test160o'"
17053 changelog_clear 0 || error "changelog_clear failed"
17054 # generate some changelog records to accumulate on MDT0
17055 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17056 touch $DIR/$tdir/$tfile # open 1
17058 OPENS=$(changelog_dump | grep -c "OPEN")
17059 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
17061 # must be no MKDIR it wasn't set as user mask
17062 MKDIR=$(changelog_dump | grep -c "MKDIR")
17063 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
17065 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
17066 mdd.$mdt.changelog_current_mask -n)
17067 # register maskless user
17068 changelog_register || error "changelog_register failed"
17069 # effective mask should be not changed because it is not minimal
17070 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17071 mdd.$mdt.changelog_current_mask -n)
17072 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
17073 # set server mask to minimal value
17074 changelog_chmask "MARK"
17075 # check effective mask again, should be treated as DEFMASK now
17076 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17077 mdd.$mdt.changelog_current_mask -n)
17078 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17080 do_facet $SINGLEMDS $LCTL --device $mdt \
17081 changelog_deregister -u test_160o ||
17082 error "cannot deregister by name"
17084 run_test 160o "changelog user name and mask"
17087 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17088 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17089 skip "Need MDS version at least 2.14.51"
17090 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
17096 changelog_register || error "first changelog_register failed"
17098 cl_users=(${CL_USERS[mds1]})
17099 cl_user1="${cl_users[0]}"
17101 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17102 createmany -m $DIR/$tdir/$tfile 50 ||
17103 error "create $DIR/$tdir/$tfile failed"
17104 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17107 # check changelogs have been generated
17108 entry_count=$(changelog_dump | wc -l)
17109 ((entry_count != 0)) || error "no changelog entries found"
17111 # remove changelog_users and check that orphan entries are removed
17113 local dev=$(mdsdevname 1)
17114 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
17115 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
17116 entry_count=$(changelog_dump | wc -l)
17117 ((entry_count == 0)) ||
17118 error "found $entry_count changelog entries, expected none"
17120 run_test 160p "Changelog orphan cleanup with no users"
17123 local mdt="$(facet_svc $SINGLEMDS)"
17126 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17127 remote_mds_nodsh && skip "remote MDS with nodsh"
17128 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
17129 skip "Need MDS version at least 2.14.54"
17131 # set server mask to minimal value like server init does
17132 changelog_chmask "MARK"
17133 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
17134 error "changelog_register failed"
17135 # check effective mask again, should be treated as DEFMASK now
17136 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17137 mdd.$mdt.changelog_current_mask -n)
17138 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
17139 error "changelog_deregister failed"
17140 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17142 run_test 160q "changelog effective mask is DEFMASK if not set"
17145 remote_mds_nodsh && skip "remote MDS with nodsh"
17146 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
17147 skip "Need MDS version at least 2.14.55"
17149 local mdts=$(comma_list $(mdts_nodes))
17151 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
17152 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
17153 fail_val=$((24 * 3600 * 10))
17155 # Create a user which is 10 days old
17156 changelog_register || error "first changelog_register failed"
17158 declare -A cl_user1
17161 # generate some changelog records to accumulate on each MDT
17162 # use all_char because created files should be evenly distributed
17163 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17164 error "test_mkdir $tdir failed"
17165 for ((i = 0; i < MDSCOUNT; i++)); do
17166 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17167 error "create $DIR/$tdir/d$i.1 failed"
17170 # check changelogs have been generated
17171 local nbcl=$(changelog_dump | wc -l)
17172 (( nbcl > 0 )) || error "no changelogs found"
17174 # reduce the max_idle_indexes value to make sure we exceed it
17175 for param in "changelog_max_idle_indexes=2097446912" \
17176 "changelog_max_idle_time=2592000" \
17178 "changelog_min_gc_interval=2"; do
17179 local MDT0=$(facet_svc $SINGLEMDS)
17180 local var="${param%=*}"
17181 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17183 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17184 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17185 error "unable to set mdd.*.$param"
17188 local start=$SECONDS
17189 for i in $(seq $MDSCOUNT); do
17190 cl_users=(${CL_USERS[mds$i]})
17191 cl_user1[mds$i]="${cl_users[0]}"
17193 [[ -n "${cl_user1[mds$i]}" ]] ||
17194 error "mds$i: no user registered"
17197 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
17198 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
17200 # ensure we are past the previous changelog_min_gc_interval set above
17201 local sleep2=$((start + 2 - SECONDS))
17202 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17204 # Generate one more changelog to trigger GC
17205 for ((i = 0; i < MDSCOUNT; i++)); do
17206 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
17207 error "create $DIR/$tdir/d$i.3 failed"
17210 # ensure gc thread is done
17211 for node in $(mdts_nodes); do
17212 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
17213 error "$node: GC-thread not done"
17216 do_nodes $mdts $LCTL set_param fail_loc=0
17218 for (( i = 1; i <= MDSCOUNT; i++ )); do
17219 # check cl_user1 is purged
17220 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
17221 error "mds$i: User ${cl_user1[mds$i]} is registered"
17225 run_test 160s "changelog garbage collect on idle records * time"
17228 remote_mds_nodsh && skip "remote MDS with nodsh"
17229 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
17230 skip "Need MDS version at least 2.15.50"
17232 local MDT0=$(facet_svc $SINGLEMDS)
17238 changelog_register --user user1 -m all ||
17239 error "user1 failed to register"
17241 mkdir_on_mdt0 $DIR/$tdir
17242 # create default overstripe to maximize changelog size
17243 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
17244 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
17245 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17247 # user2 consumes less records so less space
17248 changelog_register --user user2 || error "user2 failed to register"
17249 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
17250 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17252 # check changelogs have been generated
17253 local nbcl=$(changelog_dump | wc -l)
17254 (( nbcl > 0 )) || error "no changelogs found"
17256 # reduce the changelog_min_gc_interval to force check
17257 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
17258 local var="${param%=*}"
17259 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17261 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
17262 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
17263 error "unable to set mdd.*.$param"
17267 cl_users=(${CL_USERS[mds1]})
17268 cl_user1="${cl_users[0]}"
17269 cl_user2="${cl_users[1]}"
17271 [[ -n $cl_user1 ]] ||
17272 error "mds1: user #1 isn't registered"
17273 [[ -n $cl_user2 ]] ||
17274 error "mds1: user #2 isn't registered"
17276 # ensure we are past the previous changelog_min_gc_interval set above
17277 local sleep2=$((start + 2 - SECONDS))
17278 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17280 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
17281 do_facet mds1 $LCTL set_param fail_loc=0x018c \
17282 fail_val=$(((llog_size1 + llog_size2) / 2))
17284 # Generate more changelog to trigger GC
17285 createmany -o $DIR/$tdir/u3_ 4 ||
17286 error "create failed for more files"
17288 # ensure gc thread is done
17289 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
17290 error "mds1: GC-thread not done"
17292 do_facet mds1 $LCTL set_param fail_loc=0
17294 # check cl_user1 is purged
17295 changelog_users mds1 | grep -q "$cl_user1" &&
17296 error "User $cl_user1 is registered"
17297 # check cl_user2 is not purged
17298 changelog_users mds1 | grep -q "$cl_user2" ||
17299 error "User $cl_user2 is not registered"
17301 run_test 160t "changelog garbage collect on lack of space"
17304 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17306 test_mkdir -c1 $DIR/$tdir
17307 cp /etc/hosts $DIR/$tdir/$tfile
17308 test_mkdir -c1 $DIR/$tdir/foo1
17309 test_mkdir -c1 $DIR/$tdir/foo2
17310 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
17311 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
17312 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
17313 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
17314 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
17315 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17316 $LFS fid2path $DIR $FID
17317 error "bad link ea"
17320 rm $DIR/$tdir/foo2/zachary
17322 rm $DIR/$tdir/foo2/thor
17324 rm $DIR/$tdir/$tfile
17326 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
17327 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
17328 { $LFS fid2path $DIR $FID; error "bad link rename"; }
17329 rm $DIR/$tdir/foo2/maggie
17332 local longname=$tfile.avg_len_is_thirty_two_
17333 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
17334 error_noexit 'failed to unlink many hardlinks'" EXIT
17335 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
17336 error "failed to hardlink many files"
17337 links=$($LFS fid2path $DIR $FID | wc -l)
17338 echo -n "${links}/1000 links in link EA"
17339 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
17341 run_test 161a "link ea sanity"
17344 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17345 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
17348 local remote_dir=$DIR/$tdir/remote_dir
17350 mkdir -p $DIR/$tdir
17351 $LFS mkdir -i $MDTIDX $remote_dir ||
17352 error "create remote directory failed"
17354 cp /etc/hosts $remote_dir/$tfile
17355 mkdir -p $remote_dir/foo1
17356 mkdir -p $remote_dir/foo2
17357 ln $remote_dir/$tfile $remote_dir/foo1/sofia
17358 ln $remote_dir/$tfile $remote_dir/foo2/zachary
17359 ln $remote_dir/$tfile $remote_dir/foo1/luna
17360 ln $remote_dir/$tfile $remote_dir/foo2/thor
17362 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
17364 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17365 $LFS fid2path $DIR $FID
17366 error "bad link ea"
17369 rm $remote_dir/foo2/zachary
17371 rm $remote_dir/foo2/thor
17373 rm $remote_dir/$tfile
17375 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
17376 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
17377 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
17378 $LFS fid2path $DIR $FID
17379 error "bad link rename"
17381 rm $remote_dir/foo2/maggie
17384 local longname=filename_avg_len_is_thirty_two_
17385 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17386 error "failed to hardlink many files"
17387 links=$($LFS fid2path $DIR $FID | wc -l)
17388 echo -n "${links}/1000 links in link EA"
17389 [[ ${links} -gt 60 ]] ||
17390 error "expected at least 60 links in link EA"
17391 unlinkmany $remote_dir/foo2/$longname 1000 ||
17392 error "failed to unlink many hardlinks"
17394 run_test 161b "link ea sanity under remote directory"
17397 remote_mds_nodsh && skip "remote MDS with nodsh"
17398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17399 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17400 skip "Need MDS version at least 2.1.5"
17402 # define CLF_RENAME_LAST 0x0001
17403 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17404 changelog_register || error "changelog_register failed"
17407 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17408 touch $DIR/$tdir/foo_161c
17409 touch $DIR/$tdir/bar_161c
17410 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17411 changelog_dump | grep RENME | tail -n 5
17412 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17413 changelog_clear 0 || error "changelog_clear failed"
17414 if [ x$flags != "x0x1" ]; then
17415 error "flag $flags is not 0x1"
17418 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17419 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17420 touch $DIR/$tdir/foo_161c
17421 touch $DIR/$tdir/bar_161c
17422 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17423 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17424 changelog_dump | grep RENME | tail -n 5
17425 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17426 changelog_clear 0 || error "changelog_clear failed"
17427 if [ x$flags != "x0x0" ]; then
17428 error "flag $flags is not 0x0"
17430 echo "rename overwrite a target having nlink > 1," \
17431 "changelog record has flags of $flags"
17433 # rename doesn't overwrite a target (changelog flag 0x0)
17434 touch $DIR/$tdir/foo_161c
17435 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17436 changelog_dump | grep RENME | tail -n 5
17437 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17438 changelog_clear 0 || error "changelog_clear failed"
17439 if [ x$flags != "x0x0" ]; then
17440 error "flag $flags is not 0x0"
17442 echo "rename doesn't overwrite a target," \
17443 "changelog record has flags of $flags"
17445 # define CLF_UNLINK_LAST 0x0001
17446 # unlink a file having nlink = 1 (changelog flag 0x1)
17447 rm -f $DIR/$tdir/foo2_161c
17448 changelog_dump | grep UNLNK | tail -n 5
17449 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17450 changelog_clear 0 || error "changelog_clear failed"
17451 if [ x$flags != "x0x1" ]; then
17452 error "flag $flags is not 0x1"
17454 echo "unlink a file having nlink = 1," \
17455 "changelog record has flags of $flags"
17457 # unlink a file having nlink > 1 (changelog flag 0x0)
17458 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17459 rm -f $DIR/$tdir/foobar_161c
17460 changelog_dump | grep UNLNK | tail -n 5
17461 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17462 changelog_clear 0 || error "changelog_clear failed"
17463 if [ x$flags != "x0x0" ]; then
17464 error "flag $flags is not 0x0"
17466 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17468 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17471 remote_mds_nodsh && skip "remote MDS with nodsh"
17472 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17477 changelog_register || error "changelog_register failed"
17479 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17480 # interfer with $MOUNT/.lustre/fid/ access
17482 [[ $? -eq 0 ]] || error "mkdir failed"
17484 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17485 $LCTL set_param fail_loc=0x8000140c
17487 $LCTL set_param fail_val=5
17490 echo foofoo > $DIR/$tdir/$tfile &
17493 # wait for create to be delayed
17497 [[ $? -eq 0 ]] || error "create should be blocked"
17499 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17500 stack_trap "rm -f $tempfile"
17501 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17502 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17503 # some delay may occur during ChangeLog publishing and file read just
17504 # above, that could allow file write to happen finally
17505 [[ -s $tempfile ]] && echo "file should be empty"
17507 $LCTL set_param fail_loc=0
17510 [[ $? -eq 0 ]] || error "create failed"
17512 run_test 161d "create with concurrent .lustre/fid access"
17515 local expected="$1"
17520 path=$($LFS fid2path "$@")
17523 if [ $rc -ne 0 ]; then
17524 error "path looked up of '$expected' failed: rc=$rc"
17525 elif [ "$path" != "$expected" ]; then
17526 error "path looked up '$path' instead of '$expected'"
17528 echo "FID '$fid' resolves to path '$path' as expected"
17532 test_162a() { # was test_162
17533 test_mkdir -p -c1 $DIR/$tdir/d2
17534 touch $DIR/$tdir/d2/$tfile
17535 touch $DIR/$tdir/d2/x1
17536 touch $DIR/$tdir/d2/x2
17537 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17538 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17540 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17541 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17544 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17545 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17546 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17548 # softlink to wrong file
17549 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17550 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17551 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17554 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17555 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17556 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17557 # fid2path dir/fsname should both work
17558 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17559 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17561 # hardlink count: check that there are 2 links
17562 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17563 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17565 # hardlink indexing: remove the first link
17566 rm $DIR/$tdir/d2/p/q/r/hlink
17567 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17569 run_test 162a "path lookup sanity"
17572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17573 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17576 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17577 error "create striped dir failed"
17579 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17580 tail -n 1 | awk '{print $2}')
17581 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17583 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17584 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17587 for ((i=0;i<5;i++)); do
17588 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17589 error "get fid for f$i failed"
17590 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17592 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17593 error "get fid for d$i failed"
17594 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17599 run_test 162b "striped directory path lookup sanity"
17601 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17603 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17604 skip "Need MDS version at least 2.7.51"
17606 local lpath=$tdir.local
17607 local rpath=$tdir.remote
17609 test_mkdir $DIR/$lpath
17610 test_mkdir $DIR/$rpath
17612 for ((i = 0; i <= 101; i++)); do
17615 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17616 error "get fid for local directory $DIR/$lpath failed"
17617 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17620 test_mkdir $DIR/$rpath
17621 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17622 error "get fid for remote directory $DIR/$rpath failed"
17623 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17628 run_test 162c "fid2path works with paths 100 or more directories deep"
17630 oalr_event_count() {
17634 awk -v name="${FSNAME}-OST0000" \
17635 -v event="${event}" \
17636 '$1 == "TRACE" && $2 == event && $3 == name' \
17641 oalr_expect_event_count() {
17644 local expect="${3}"
17647 count=$(oalr_event_count "${event}" "${trace}")
17648 if ((count == expect)); then
17652 error_noexit "${event} event count was '${count}', expected ${expect}"
17658 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17660 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17664 sync # Flush previous IOs so we can count log entries.
17665 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17666 stack_trap cleanup_165 EXIT
17670 local trace="/tmp/${tfile}.trace"
17674 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17675 skip "OFD access log unsupported"
17678 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17681 do_facet ost1 ofd_access_log_reader --list
17684 do_facet ost1 killall -TERM ofd_access_log_reader
17688 if ((rc != 0)); then
17689 error "ofd_access_log_reader exited with rc = '${rc}'"
17692 # Parse trace file for discovery events:
17693 oalr_expect_event_count alr_log_add "${trace}" 1
17694 oalr_expect_event_count alr_log_eof "${trace}" 1
17695 oalr_expect_event_count alr_log_free "${trace}" 1
17697 run_test 165a "ofd access log discovery"
17700 local trace="/tmp/${tfile}.trace"
17701 local file="${DIR}/${tfile}"
17710 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17711 skip "OFD access log unsupported"
17714 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17717 do_facet ost1 ofd_access_log_reader --list
17719 lfs setstripe -c 1 -i 0 "${file}"
17720 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17721 error "cannot create '${file}'"
17724 do_facet ost1 killall -TERM ofd_access_log_reader
17728 if ((rc != 0)); then
17729 error "ofd_access_log_reader exited with rc = '${rc}'"
17732 oalr_expect_event_count alr_log_entry "${trace}" 1
17734 pfid1=$($LFS path2fid "${file}")
17736 # 1 2 3 4 5 6 7 8 9 10
17737 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
17738 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17740 echo "entry = '${entry[*]}'" >&2
17743 if [[ "${pfid1}" != "${pfid2}" ]]; then
17744 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17748 if ((size != 1048576)); then
17749 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
17753 if [[ "${flags}" != "w" ]]; then
17754 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
17757 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17760 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
17761 error "cannot read '${file}'"
17764 do_facet ost1 killall -TERM ofd_access_log_reader
17768 if ((rc != 0)); then
17769 error "ofd_access_log_reader exited with rc = '${rc}'"
17772 oalr_expect_event_count alr_log_entry "${trace}" 1
17774 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17775 echo "entry = '${entry[*]}'" >&2
17778 if [[ "${pfid1}" != "${pfid2}" ]]; then
17779 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17783 if ((size != 524288)); then
17784 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
17788 if [[ "${flags}" != "r" ]]; then
17789 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
17792 run_test 165b "ofd access log entries are produced and consumed"
17795 local trace="/tmp/${tfile}.trace"
17796 local file="${DIR}/${tdir}/${tfile}"
17798 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17799 skip "OFD access log unsupported"
17801 test_mkdir "${DIR}/${tdir}"
17804 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17807 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
17809 # 4096 / 64 = 64. Create twice as many entries.
17810 for ((i = 0; i < 128; i++)); do
17811 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
17812 error "cannot create file"
17817 do_facet ost1 killall -TERM ofd_access_log_reader
17820 if ((rc != 0)); then
17821 error "ofd_access_log_reader exited with rc = '${rc}'"
17824 unlinkmany "${file}-%d" 128
17826 run_test 165c "full ofd access logs do not block IOs"
17828 oal_get_read_count() {
17831 # STATS lustre-OST0001 alr_read_count 1
17833 do_facet ost1 cat "${stats}" |
17834 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
17835 END { print count; }'
17838 oal_expect_read_count() {
17843 # Ask ofd_access_log_reader to write stats.
17844 do_facet ost1 killall -USR1 ofd_access_log_reader
17846 # Allow some time for things to happen.
17849 count=$(oal_get_read_count "${stats}")
17850 if ((count == expect)); then
17854 error_noexit "bad read count, got ${count}, expected ${expect}"
17855 do_facet ost1 cat "${stats}" >&2
17860 local stats="/tmp/${tfile}.stats"
17861 local file="${DIR}/${tdir}/${tfile}"
17862 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
17864 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17865 skip "OFD access log unsupported"
17867 test_mkdir "${DIR}/${tdir}"
17870 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
17873 lfs setstripe -c 1 -i 0 "${file}"
17875 do_facet ost1 lctl set_param "${param}=rw"
17876 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17877 error "cannot create '${file}'"
17878 oal_expect_read_count "${stats}" 1
17880 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17881 error "cannot read '${file}'"
17882 oal_expect_read_count "${stats}" 2
17884 do_facet ost1 lctl set_param "${param}=r"
17885 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17886 error "cannot create '${file}'"
17887 oal_expect_read_count "${stats}" 2
17889 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17890 error "cannot read '${file}'"
17891 oal_expect_read_count "${stats}" 3
17893 do_facet ost1 lctl set_param "${param}=w"
17894 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17895 error "cannot create '${file}'"
17896 oal_expect_read_count "${stats}" 4
17898 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17899 error "cannot read '${file}'"
17900 oal_expect_read_count "${stats}" 4
17902 do_facet ost1 lctl set_param "${param}=0"
17903 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17904 error "cannot create '${file}'"
17905 oal_expect_read_count "${stats}" 4
17907 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17908 error "cannot read '${file}'"
17909 oal_expect_read_count "${stats}" 4
17911 do_facet ost1 killall -TERM ofd_access_log_reader
17914 if ((rc != 0)); then
17915 error "ofd_access_log_reader exited with rc = '${rc}'"
17918 run_test 165d "ofd_access_log mask works"
17921 local stats="/tmp/${tfile}.stats"
17922 local file0="${DIR}/${tdir}-0/${tfile}"
17923 local file1="${DIR}/${tdir}-1/${tfile}"
17925 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17926 skip "OFD access log unsupported"
17928 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
17930 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
17931 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
17933 lfs setstripe -c 1 -i 0 "${file0}"
17934 lfs setstripe -c 1 -i 0 "${file1}"
17937 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
17940 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
17941 error "cannot create '${file0}'"
17943 oal_expect_read_count "${stats}" 0
17945 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17946 error "cannot create '${file1}'"
17948 oal_expect_read_count "${stats}" 1
17950 do_facet ost1 killall -TERM ofd_access_log_reader
17953 if ((rc != 0)); then
17954 error "ofd_access_log_reader exited with rc = '${rc}'"
17957 run_test 165e "ofd_access_log MDT index filter works"
17960 local trace="/tmp/${tfile}.trace"
17965 do_facet ost1 timeout 60 ofd_access_log_reader \
17966 --exit-on-close --debug=- --trace=- > "${trace}" &
17973 if ((rc != 0)); then
17974 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
17979 run_test 165f "ofd_access_log_reader --exit-on-close works"
17982 # do directio so as not to populate the page cache
17983 log "creating a 10 Mb file"
17984 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
17985 error "multiop failed while creating a file"
17986 log "starting reads"
17987 dd if=$DIR/$tfile of=/dev/null bs=4096 &
17988 log "truncating the file"
17989 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
17990 error "multiop failed while truncating the file"
17992 kill %+ || true # reads might have finished
17993 echo "wait until dd is finished"
17995 log "removing the temporary file"
17996 rm -rf $DIR/$tfile || error "tmp file removal failed"
17998 run_test 169 "parallel read and truncate should not deadlock"
18001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18003 $LCTL clear # bug 18514
18004 $LCTL debug_daemon start $TMP/${tfile}_log_good
18006 $LCTL debug_daemon stop
18007 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
18008 error "sed failed to read log_good"
18010 $LCTL debug_daemon start $TMP/${tfile}_log_good
18012 $LCTL debug_daemon stop
18014 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
18015 error "lctl df log_bad failed"
18017 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18018 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18020 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
18021 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
18023 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
18024 error "bad_line good_line1 good_line2 are empty"
18026 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18027 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
18028 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18030 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
18031 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18032 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18034 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
18035 error "bad_line_new good_line_new are empty"
18037 local expected_good=$((good_line1 + good_line2*2))
18039 rm -f $TMP/${tfile}*
18040 # LU-231, short malformed line may not be counted into bad lines
18041 if [ $bad_line -ne $bad_line_new ] &&
18042 [ $bad_line -ne $((bad_line_new - 1)) ]; then
18043 error "expected $bad_line bad lines, but got $bad_line_new"
18047 if [ $expected_good -ne $good_line_new ]; then
18048 error "expected $expected_good good lines, but got $good_line_new"
18053 run_test 170 "test lctl df to handle corrupted log ====================="
18055 test_171() { # bug20592
18056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18058 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
18059 $LCTL set_param fail_loc=0x50e
18060 $LCTL set_param fail_val=3000
18061 multiop_bg_pause $DIR/$tfile O_s || true
18063 kill -USR1 $MULTIPID
18067 if dmesg | grep "recursive fault"; then
18068 error "caught a recursive fault"
18070 $LCTL set_param fail_loc=0
18073 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
18077 #define OBD_FAIL_OBD_CLEANUP 0x60e
18078 $LCTL set_param fail_loc=0x60e
18079 umount $MOUNT || error "umount $MOUNT failed"
18080 stack_trap "mount_client $MOUNT"
18082 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
18083 error "no client OBDs are remained"
18085 $LCTL dl | while read devno state type name foo; do
18088 $LCTL --device $name cleanup
18089 $LCTL --device $name detach
18092 # skip server devices
18097 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
18098 $LCTL dl | egrep " osc | lov | lmv | mdc "
18099 error "some client OBDs are still remained"
18103 run_test 172 "manual device removal with lctl cleanup/detach ======"
18105 # it would be good to share it with obdfilter-survey/iokit-libecho code
18106 setup_obdecho_osc () {
18109 local obdfilter_name=$2
18110 echo "Creating new osc for $obdfilter_name on $ost_nid"
18111 # make sure we can find loopback nid
18112 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
18114 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
18115 ${obdfilter_name}_osc_UUID || rc=2; }
18116 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
18117 ${obdfilter_name}_UUID $ost_nid || rc=3; }
18121 cleanup_obdecho_osc () {
18122 local obdfilter_name=$1
18123 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
18124 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
18131 local pages=${3:-64}
18136 local obd_size=$(get_obd_size $node $OBD)
18137 local page_size=$(get_page_size $node)
18138 if [[ -n "$obd_size" ]]; then
18139 local new_count=$((obd_size / (pages * page_size / 1024)))
18140 [[ $new_count -ge $count ]] || count=$new_count
18143 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
18144 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
18146 if [ $rc -eq 0 ]; then
18147 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
18148 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
18150 echo "New object id is $id"
18151 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
18153 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
18154 "test_brw $count w v $pages $id" || rc=4; }
18155 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
18157 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
18158 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
18159 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
18160 { do_facet $node "$LCTL --device ec detach" || rc=6; }
18161 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
18166 skip "obdecho on osc is no longer supported"
18168 run_test 180a "test obdecho on osc"
18171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18172 remote_ost_nodsh && skip "remote OST with nodsh"
18174 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18175 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18176 error "failed to load module obdecho"
18178 local target=$(do_facet ost1 $LCTL dl |
18179 awk '/obdfilter/ { print $4; exit; }')
18181 if [ -n "$target" ]; then
18182 obdecho_test $target ost1 || error "obdecho_test failed with $?"
18184 do_facet ost1 $LCTL dl
18185 error "there is no obdfilter target on ost1"
18188 run_test 180b "test obdecho directly on obdfilter"
18190 test_180c() { # LU-2598
18191 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18192 remote_ost_nodsh && skip "remote OST with nodsh"
18193 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
18194 skip "Need MDS version at least 2.4.0"
18196 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18197 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18198 error "failed to load module obdecho"
18200 local target=$(do_facet ost1 $LCTL dl |
18201 awk '/obdfilter/ { print $4; exit; }')
18203 if [ -n "$target" ]; then
18204 local pages=16384 # 64MB bulk I/O RPC size
18206 obdecho_test "$target" ost1 "$pages" ||
18207 error "obdecho_test with pages=$pages failed with $?"
18209 do_facet ost1 $LCTL dl
18210 error "there is no obdfilter target on ost1"
18213 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
18215 test_181() { # bug 22177
18216 test_mkdir $DIR/$tdir
18217 # create enough files to index the directory
18218 createmany -o $DIR/$tdir/foobar 4000
18219 # print attributes for debug purpose
18222 multiop_bg_pause $DIR/$tdir D_Sc || return 1
18224 # remove the files & current working dir
18225 unlinkmany $DIR/$tdir/foobar 4000
18227 kill -USR1 $MULTIPID
18229 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
18232 run_test 181 "Test open-unlinked dir ========================"
18238 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18240 $LCTL set_param mdc.*.rpc_stats=clear
18242 for (( i = 0; i < $tcount; i++ )) ; do
18243 mkdir $DIR/$tdir/$i
18246 for (( i = 0; i < $tcount; i++ )) ; do
18247 createmany -o $DIR/$tdir/$i/f- $fcount &
18251 for (( i = 0; i < $tcount; i++ )) ; do
18252 unlinkmany $DIR/$tdir/$i/f- $fcount &
18256 $LCTL get_param mdc.*.rpc_stats
18260 run_test 182a "Test parallel modify metadata operations from mdc"
18263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18264 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18271 do_facet mds1 $LCTL list_param \
18272 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
18273 skip "MDS lacks parallel RPC handling"
18275 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18277 rpc_count=$(do_facet mds1 $LCTL get_param -n \
18278 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
18281 createmany -i 0 -d $DIR/$tdir/t- $tcount
18283 for (( i = 0; i < $tcount; i++ )) ; do
18284 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18288 delta=$((etime - stime))
18289 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
18292 for (( i = 0; i < $tcount; i++ )) ; do
18293 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
18297 delta=$((etime - stime))
18298 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
18302 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18304 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
18307 createmany -i 0 -d $DIR/$tdir/t- $tcount
18309 for (( i = 0; i < $tcount; i++ )) ; do
18310 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18314 delta=$((etime - stime))
18315 echo "Time for file creation $delta sec for 1 RPC sent at a time"
18318 for (( i = 0; i < $tcount; i++ )) ; do
18319 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
18323 delta=$((etime - stime))
18324 echo "Time for file removal $delta sec for 1 RPC sent at a time"
18326 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
18328 run_test 182b "Test parallel modify metadata operations from osp"
18330 test_183() { # LU-2275
18331 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18332 remote_mds_nodsh && skip "remote MDS with nodsh"
18333 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
18334 skip "Need MDS version at least 2.3.56"
18336 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18337 echo aaa > $DIR/$tdir/$tfile
18339 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
18340 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
18342 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
18343 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
18345 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18347 # Flush negative dentry cache
18348 touch $DIR/$tdir/$tfile
18350 # We are not checking for any leaked references here, they'll
18351 # become evident next time we do cleanup with module unload.
18354 run_test 183 "No crash or request leak in case of strange dispositions ========"
18356 # test suite 184 is for LU-2016, LU-2017
18358 check_swap_layouts_support
18360 dir0=$DIR/$tdir/$testnum
18361 test_mkdir -p -c1 $dir0
18366 $LFS setstripe -c1 $file1
18368 $LFS setstripe -c2 $file2
18370 gen1=$($LFS getstripe -g $file1)
18371 gen2=$($LFS getstripe -g $file2)
18373 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
18374 gen=$($LFS getstripe -g $file1)
18375 [[ $gen1 != $gen ]] ||
18376 error "Layout generation on $file1 does not change"
18377 gen=$($LFS getstripe -g $file2)
18378 [[ $gen2 != $gen ]] ||
18379 error "Layout generation on $file2 does not change"
18381 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
18382 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18384 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
18386 run_test 184a "Basic layout swap"
18389 check_swap_layouts_support
18391 dir0=$DIR/$tdir/$testnum
18392 mkdir -p $dir0 || error "creating dir $dir0"
18399 $LFS setstripe -c1 $file1
18400 $LFS setstripe -c2 $file2
18401 $LFS setstripe -c1 $file3
18402 chown $RUNAS_ID $file3
18403 gen1=$($LFS getstripe -g $file1)
18404 gen2=$($LFS getstripe -g $file2)
18406 $LFS swap_layouts $dir1 $dir2 &&
18407 error "swap of directories layouts should fail"
18408 $LFS swap_layouts $dir1 $file1 &&
18409 error "swap of directory and file layouts should fail"
18410 $RUNAS $LFS swap_layouts $file1 $file2 &&
18411 error "swap of file we cannot write should fail"
18412 $LFS swap_layouts $file1 $file3 &&
18413 error "swap of file with different owner should fail"
18414 /bin/true # to clear error code
18416 run_test 184b "Forbidden layout swap (will generate errors)"
18419 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18420 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18421 check_swap_layouts_support
18422 check_swap_layout_no_dom $DIR
18424 local dir0=$DIR/$tdir/$testnum
18425 mkdir -p $dir0 || error "creating dir $dir0"
18427 local ref1=$dir0/ref1
18428 local ref2=$dir0/ref2
18429 local file1=$dir0/file1
18430 local file2=$dir0/file2
18431 # create a file large enough for the concurrent test
18432 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18433 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18434 echo "ref file size: ref1($(stat -c %s $ref1))," \
18435 "ref2($(stat -c %s $ref2))"
18438 dd if=$ref1 of=$file1 bs=16k &
18441 # Make sure dd starts to copy file, but wait at most 5 seconds
18443 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18445 $LFS swap_layouts $file1 $file2
18448 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18449 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18451 # how many bytes copied before swapping layout
18452 local copied=$(stat -c %s $file2)
18453 local remaining=$(stat -c %s $ref1)
18454 remaining=$((remaining - copied))
18455 echo "Copied $copied bytes before swapping layout..."
18457 cmp -n $copied $file1 $ref2 | grep differ &&
18458 error "Content mismatch [0, $copied) of ref2 and file1"
18459 cmp -n $copied $file2 $ref1 ||
18460 error "Content mismatch [0, $copied) of ref1 and file2"
18461 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18462 error "Content mismatch [$copied, EOF) of ref1 and file1"
18465 rm -f $ref1 $ref2 $file1 $file2
18467 run_test 184c "Concurrent write and layout swap"
18470 check_swap_layouts_support
18471 check_swap_layout_no_dom $DIR
18472 [ -z "$(which getfattr 2>/dev/null)" ] &&
18473 skip_env "no getfattr command"
18475 local file1=$DIR/$tdir/$tfile-1
18476 local file2=$DIR/$tdir/$tfile-2
18477 local file3=$DIR/$tdir/$tfile-3
18481 mkdir -p $DIR/$tdir
18482 touch $file1 || error "create $file1 failed"
18483 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18484 error "create $file2 failed"
18485 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18486 error "create $file3 failed"
18487 lovea1=$(get_layout_param $file1)
18489 $LFS swap_layouts $file2 $file3 ||
18490 error "swap $file2 $file3 layouts failed"
18491 $LFS swap_layouts $file1 $file2 ||
18492 error "swap $file1 $file2 layouts failed"
18494 lovea2=$(get_layout_param $file2)
18497 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18499 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18500 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18502 run_test 184d "allow stripeless layouts swap"
18505 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18506 skip "Need MDS version at least 2.6.94"
18507 check_swap_layouts_support
18508 check_swap_layout_no_dom $DIR
18509 [ -z "$(which getfattr 2>/dev/null)" ] &&
18510 skip_env "no getfattr command"
18512 local file1=$DIR/$tdir/$tfile-1
18513 local file2=$DIR/$tdir/$tfile-2
18514 local file3=$DIR/$tdir/$tfile-3
18517 mkdir -p $DIR/$tdir
18518 touch $file1 || error "create $file1 failed"
18519 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18520 error "create $file2 failed"
18521 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18522 error "create $file3 failed"
18524 $LFS swap_layouts $file1 $file2 ||
18525 error "swap $file1 $file2 layouts failed"
18527 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18528 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18530 echo 123 > $file1 || error "Should be able to write into $file1"
18532 $LFS swap_layouts $file1 $file3 ||
18533 error "swap $file1 $file3 layouts failed"
18535 echo 123 > $file1 || error "Should be able to write into $file1"
18537 rm -rf $file1 $file2 $file3
18539 run_test 184e "Recreate layout after stripeless layout swaps"
18542 # Create a file with name longer than sizeof(struct stat) ==
18543 # 144 to see if we can get chars from the file name to appear
18544 # in the returned striping. Note that 'f' == 0x66.
18545 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18547 mkdir -p $DIR/$tdir
18548 mcreate $DIR/$tdir/$file
18549 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18550 error "IOC_MDC_GETFILEINFO returned garbage striping"
18553 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18555 test_185() { # LU-2441
18556 # LU-3553 - no volatile file support in old servers
18557 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18558 skip "Need MDS version at least 2.3.60"
18560 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18561 touch $DIR/$tdir/spoo
18562 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18563 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18564 error "cannot create/write a volatile file"
18565 [ "$FILESET" == "" ] &&
18566 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18567 error "FID is still valid after close"
18569 multiop_bg_pause $DIR/$tdir vVw4096_c
18576 # assume that the next FID for this client is sequential, since stdout
18577 # is unfortunately eaten by multiop_bg_pause
18578 local n=$((${fidv[1]} + 1))
18579 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18580 if [ "$FILESET" == "" ]; then
18581 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18582 error "FID is missing before close"
18584 kill -USR1 $multi_pid
18585 # 1 second delay, so if mtime change we will see it
18587 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18588 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18590 run_test 185 "Volatile file support"
18592 function create_check_volatile() {
18596 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18599 local FID=$(cat /tmp/${tfile}.fid)
18600 [ "$FID" == "" ] && error "can't get FID for volatile"
18601 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18602 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18603 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18607 cancel_lru_locks mdc # flush opencache
18608 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18613 # LU-12516 - volatile creation via .lustre
18614 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18615 skip "Need MDS version at least 2.3.55"
18617 create_check_volatile 0
18618 [ $MDSCOUNT -lt 2 ] && return 0
18621 create_check_volatile 1
18625 run_test 185a "Volatile file creation in .lustre/fid/"
18628 remote_mds_nodsh && skip "remote MDS with nodsh"
18629 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18630 skip "Need MDS version at least 2.3.0"
18632 local dir0=$DIR/$tdir/$testnum
18633 mkdir -p $dir0 || error "creating dir $dir0"
18635 local file=$dir0/file1
18636 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18637 local dv1=$($LFS data_version $file)
18638 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18639 local dv2=$($LFS data_version $file)
18640 [[ $dv1 != $dv2 ]] ||
18641 error "data version did not change on write $dv1 == $dv2"
18646 run_test 187a "Test data version change"
18649 remote_mds_nodsh && skip "remote MDS with nodsh"
18650 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18651 skip "Need MDS version at least 2.3.0"
18653 local dir0=$DIR/$tdir/$testnum
18654 mkdir -p $dir0 || error "creating dir $dir0"
18656 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18657 [[ ${DV[0]} != ${DV[1]} ]] ||
18658 error "data version did not change on write"\
18659 " ${DV[0]} == ${DV[1]}"
18664 run_test 187b "Test data version change on volatile file"
18667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18668 remote_mgs_nodsh && skip "remote MGS with nodsh"
18669 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18671 local POOL=${POOL:-cea1}
18672 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18673 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18676 local last_ost=$(($OSTCOUNT - 1))
18678 local ost_list=$(seq $first_ost $ost_step $last_ost)
18679 local ost_range="$first_ost $last_ost $ost_step"
18680 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18681 local file_dir=$POOL_ROOT/file_tst
18682 local subdir=$test_path/subdir
18686 # former test_200a test_200b
18687 pool_add $POOL || { rc=$? ; break; }
18688 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
18689 # former test_200c test_200d
18690 mkdir -p $test_path
18691 pool_set_dir $POOL $test_path || { rc=$? ; break; }
18692 pool_check_dir $POOL $test_path || { rc=$? ; break; }
18694 pool_check_dir $POOL $subdir || { rc=$? ; break; }
18695 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
18696 || { rc=$? ; break; }
18697 # former test_200e test_200f
18698 local files=$((OSTCOUNT*3))
18699 pool_alloc_files $POOL $test_path $files "$ost_list" \
18700 || { rc=$? ; break; }
18701 pool_create_files $POOL $file_dir $files "$ost_list" \
18702 || { rc=$? ; break; }
18703 # former test_200g test_200h
18704 pool_lfs_df $POOL || { rc=$? ; break; }
18705 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
18707 # former test_201a test_201b test_201c
18708 pool_remove_first_target $POOL || { rc=$? ; break; }
18710 local f=$test_path/$tfile
18711 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
18712 pool_remove $POOL $f || { rc=$? ; break; }
18720 run_test 200 "OST pools"
18722 # usage: default_attr <count | size | offset>
18724 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
18727 # usage: check_default_stripe_attr
18728 check_default_stripe_attr() {
18729 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
18732 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
18734 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
18738 error "unknown getstripe attr '$1'"
18741 [ $ACTUAL == $EXPECTED ] ||
18742 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
18746 test_mkdir $DIR/$tdir
18747 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
18749 check_default_stripe_attr --stripe-count
18750 check_default_stripe_attr --stripe-size
18751 check_default_stripe_attr --stripe-index
18753 run_test 204a "Print default stripe attributes"
18756 test_mkdir $DIR/$tdir
18757 $LFS setstripe --stripe-count 1 $DIR/$tdir
18759 check_default_stripe_attr --stripe-size
18760 check_default_stripe_attr --stripe-index
18762 run_test 204b "Print default stripe size and offset"
18765 test_mkdir $DIR/$tdir
18766 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18768 check_default_stripe_attr --stripe-count
18769 check_default_stripe_attr --stripe-index
18771 run_test 204c "Print default stripe count and offset"
18774 test_mkdir $DIR/$tdir
18775 $LFS setstripe --stripe-index 0 $DIR/$tdir
18777 check_default_stripe_attr --stripe-count
18778 check_default_stripe_attr --stripe-size
18780 run_test 204d "Print default stripe count and size"
18783 test_mkdir $DIR/$tdir
18784 $LFS setstripe -d $DIR/$tdir
18786 check_default_stripe_attr --stripe-count --raw
18787 check_default_stripe_attr --stripe-size --raw
18788 check_default_stripe_attr --stripe-index --raw
18790 run_test 204e "Print raw stripe attributes"
18793 test_mkdir $DIR/$tdir
18794 $LFS setstripe --stripe-count 1 $DIR/$tdir
18796 check_default_stripe_attr --stripe-size --raw
18797 check_default_stripe_attr --stripe-index --raw
18799 run_test 204f "Print raw stripe size and offset"
18802 test_mkdir $DIR/$tdir
18803 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18805 check_default_stripe_attr --stripe-count --raw
18806 check_default_stripe_attr --stripe-index --raw
18808 run_test 204g "Print raw stripe count and offset"
18811 test_mkdir $DIR/$tdir
18812 $LFS setstripe --stripe-index 0 $DIR/$tdir
18814 check_default_stripe_attr --stripe-count --raw
18815 check_default_stripe_attr --stripe-size --raw
18817 run_test 204h "Print raw stripe count and size"
18819 # Figure out which job scheduler is being used, if any,
18820 # or use a fake one
18821 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
18822 JOBENV=SLURM_JOB_ID
18823 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
18825 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
18827 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
18828 JOBENV=LOADL_STEP_ID
18829 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
18832 $LCTL list_param jobid_name > /dev/null 2>&1
18833 if [ $? -eq 0 ]; then
18839 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
18841 verify_jobstats() {
18846 # we don't really need to clear the stats for this test to work, since each
18847 # command has a unique jobid, but it makes debugging easier if needed.
18848 # for facet in $facets; do
18849 # local dev=$(convert_facet2label $facet)
18850 # # clear old jobstats
18851 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
18854 # use a new JobID for each test, or we might see an old one
18855 [ "$JOBENV" = "FAKE_JOBID" ] &&
18856 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
18858 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
18860 [ "$JOBENV" = "nodelocal" ] && {
18861 FAKE_JOBID=id.$testnum.%e.$RANDOM
18862 $LCTL set_param jobid_name=$FAKE_JOBID
18863 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
18866 log "Test: ${cmd[*]}"
18867 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
18869 if [ $JOBENV = "FAKE_JOBID" ]; then
18870 FAKE_JOBID=$JOBVAL ${cmd[*]}
18875 # all files are created on OST0000
18876 for facet in $facets; do
18877 local stats="*.$(convert_facet2label $facet).job_stats"
18879 # strip out libtool wrappers for in-tree executables
18880 if (( $(do_facet $facet lctl get_param $stats |
18881 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
18882 do_facet $facet lctl get_param $stats
18883 error "No jobstats for $JOBVAL found on $facet::$stats"
18889 local new_jobenv=$1
18891 set_persistent_param_and_check client "jobid_var" \
18892 "$FSNAME.sys.jobid_var" $new_jobenv
18895 test_205a() { # Job stats
18896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18897 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
18898 skip "Need MDS version with at least 2.7.1"
18899 remote_mgs_nodsh && skip "remote MGS with nodsh"
18900 remote_mds_nodsh && skip "remote MDS with nodsh"
18901 remote_ost_nodsh && skip "remote OST with nodsh"
18902 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
18903 skip "Server doesn't support jobstats"
18904 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
18906 local old_jobenv=$($LCTL get_param -n jobid_var)
18907 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
18909 if [[ $PERM_CMD == *"set_param -P"* ]]; then
18910 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
18912 stack_trap "do_facet mgs $PERM_CMD \
18913 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
18917 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
18918 mdt.*.job_cleanup_interval | head -n 1)
18919 local new_interval=5
18920 do_facet $SINGLEMDS \
18921 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
18922 stack_trap "do_facet $SINGLEMDS \
18923 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
18924 local start=$SECONDS
18928 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
18929 verify_jobstats "$cmd" "$SINGLEMDS"
18931 cmd="rmdir $DIR/$tdir"
18932 verify_jobstats "$cmd" "$SINGLEMDS"
18933 # mkdir on secondary MDT
18934 if [ $MDSCOUNT -gt 1 ]; then
18935 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
18936 verify_jobstats "$cmd" "mds2"
18939 cmd="mknod $DIR/$tfile c 1 3"
18940 verify_jobstats "$cmd" "$SINGLEMDS"
18942 cmd="rm -f $DIR/$tfile"
18943 verify_jobstats "$cmd" "$SINGLEMDS"
18944 # create all files on OST0000 so verify_jobstats can find OST stats
18946 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
18947 verify_jobstats "$cmd" "$SINGLEMDS"
18949 cmd="touch $DIR/$tfile"
18950 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18952 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
18953 verify_jobstats "$cmd" "ost1"
18955 cancel_lru_locks osc
18956 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
18957 verify_jobstats "$cmd" "ost1"
18959 cmd="$TRUNCATE $DIR/$tfile 0"
18960 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18962 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
18963 verify_jobstats "$cmd" "$SINGLEMDS"
18964 # jobstats expiry - sleep until old stats should be expired
18965 local left=$((new_interval + 5 - (SECONDS - start)))
18966 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
18967 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
18969 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
18970 verify_jobstats "$cmd" "$SINGLEMDS"
18971 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
18972 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
18974 # Ensure that jobid are present in changelog (if supported by MDS)
18975 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
18976 changelog_dump | tail -10
18977 jobids=$(changelog_dump | tail -9 | grep -c "j=")
18978 [ $jobids -eq 9 ] ||
18979 error "Wrong changelog jobid count $jobids != 9"
18983 jobstats_set $JOBENV
18985 changelog_dump | grep $tfile
18986 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
18987 [ $jobids -eq 0 ] ||
18988 error "Unexpected jobids when jobid_var=$JOBENV"
18991 # test '%j' access to environment variable - if supported
18992 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
18993 JOBENV="JOBCOMPLEX"
18994 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18996 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18999 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
19000 JOBENV="JOBCOMPLEX"
19001 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
19003 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19006 # test '%j' access to per-session jobid - if supported
19007 if lctl list_param jobid_this_session > /dev/null 2>&1
19009 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
19010 lctl set_param jobid_this_session=$USER
19012 JOBENV="JOBCOMPLEX"
19013 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19015 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19018 run_test 205a "Verify job stats"
19020 # LU-13117, LU-13597
19022 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
19023 skip "Need MDS version at least 2.13.54.91"
19025 local job_stats="mdt.*.job_stats"
19026 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
19028 do_facet mds1 $LCTL set_param $job_stats=clear
19030 # Setting jobid_var to USER might not be supported
19031 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
19032 $LCTL set_param jobid_var=USER || true
19033 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
19034 $LCTL set_param jobid_name="%j.%e.%u"
19036 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
19037 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
19038 { do_facet mds1 $LCTL get_param $job_stats;
19039 error "Unexpected jobid found"; }
19040 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
19041 { do_facet mds1 $LCTL get_param $job_stats;
19042 error "wrong job_stats format found"; }
19044 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
19045 echo "MDS does not yet escape jobid" && return 0
19046 $LCTL set_param jobid_var=TEST205b
19047 env -i TEST205b="has sp" touch $DIR/$tfile.2
19048 do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
19049 { do_facet mds1 $LCTL get_param $job_stats;
19050 error "jobid not escaped"; }
19052 run_test 205b "Verify job stats jobid and output format"
19056 $LCTL set_param llite.*.stats=0
19057 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
19058 $LCTL get_param llite.*.stats
19059 $LCTL get_param llite.*.stats | grep \
19060 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
19061 error "wrong client stats format found"
19063 run_test 205c "Verify client stats format"
19065 # LU-1480, LU-1773 and LU-1657
19067 mkdir -p $DIR/$tdir
19068 $LFS setstripe -c -1 $DIR/$tdir
19069 #define OBD_FAIL_LOV_INIT 0x1403
19070 $LCTL set_param fail_loc=0xa0001403
19071 $LCTL set_param fail_val=1
19072 touch $DIR/$tdir/$tfile || true
19074 run_test 206 "fail lov_init_raid0() doesn't lbug"
19077 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19078 local fsz=`stat -c %s $DIR/$tfile`
19079 cancel_lru_locks mdc
19081 # do not return layout in getattr intent
19082 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
19083 $LCTL set_param fail_loc=0x170
19084 local sz=`stat -c %s $DIR/$tfile`
19086 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
19090 run_test 207a "can refresh layout at glimpse"
19093 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19094 local cksum=`md5sum $DIR/$tfile`
19095 local fsz=`stat -c %s $DIR/$tfile`
19096 cancel_lru_locks mdc
19097 cancel_lru_locks osc
19099 # do not return layout in getattr intent
19100 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
19101 $LCTL set_param fail_loc=0x171
19103 # it will refresh layout after the file is opened but before read issues
19104 echo checksum is "$cksum"
19105 echo "$cksum" |md5sum -c --quiet || error "file differs"
19109 run_test 207b "can refresh layout at open"
19112 # FIXME: in this test suite, only RD lease is used. This is okay
19113 # for now as only exclusive open is supported. After generic lease
19114 # is done, this test suite should be revised. - Jinshan
19116 remote_mds_nodsh && skip "remote MDS with nodsh"
19117 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
19118 skip "Need MDS version at least 2.4.52"
19120 echo "==== test 1: verify get lease work"
19121 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
19123 echo "==== test 2: verify lease can be broken by upcoming open"
19124 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19128 $MULTIOP $DIR/$tfile oO_RDWR:c
19129 kill -USR1 $PID && wait $PID || error "break lease error"
19131 echo "==== test 3: verify lease can't be granted if an open already exists"
19132 $MULTIOP $DIR/$tfile oO_RDWR:_c &
19136 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
19137 kill -USR1 $PID && wait $PID || error "open file error"
19139 echo "==== test 4: lease can sustain over recovery"
19140 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
19146 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
19148 echo "==== test 5: lease broken can't be regained by replay"
19149 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19153 # open file to break lease and then recovery
19154 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
19157 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
19161 run_test 208 "Exclusive open"
19164 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
19165 skip_env "must have disp_stripe"
19168 sync; sleep 5; sync;
19170 echo 3 > /proc/sys/vm/drop_caches
19171 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19172 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19173 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19175 # open/close 500 times
19176 for i in $(seq 500); do
19180 echo 3 > /proc/sys/vm/drop_caches
19181 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19182 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19183 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19185 echo "before: $req_before, after: $req_after"
19186 [ $((req_after - req_before)) -ge 300 ] &&
19187 error "open/close requests are not freed"
19190 run_test 209 "read-only open/close requests should be freed promptly"
19195 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
19199 $LFS getstripe $DIR/$tfile
19201 wait $pid || error "multiop failed"
19203 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
19207 $LFS getstripe $DIR/$tfile
19209 wait $pid || error "multiop failed"
19211 run_test 210 "lfs getstripe does not break leases"
19215 size=$((size % 8192 + 1))
19216 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
19217 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
19218 rm -f $DIR/f212 $DIR/f212.xyz
19220 run_test 212 "Sendfile test ============================================"
19223 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
19224 cancel_lru_locks osc
19225 lctl set_param fail_loc=0x8000040f
19226 # generate a read lock
19227 cat $DIR/$tfile > /dev/null
19228 # write to the file, it will try to cancel the above read lock.
19229 cat /etc/hosts >> $DIR/$tfile
19231 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
19233 test_214() { # for bug 20133
19234 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
19235 for (( i=0; i < 340; i++ )) ; do
19236 touch $DIR/$tdir/d214c/a$i
19239 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
19240 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
19241 ls $DIR/d214c || error "ls $DIR/d214c failed"
19242 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
19243 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
19245 run_test 214 "hash-indexed directory test - bug 20133"
19247 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
19248 create_lnet_proc_files() {
19249 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
19252 # counterpart of create_lnet_proc_files
19253 remove_lnet_proc_files() {
19254 rm -f $TMP/lnet_$1.sys
19257 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19258 # 3rd arg as regexp for body
19259 check_lnet_proc_stats() {
19260 local l=$(cat "$TMP/lnet_$1" |wc -l)
19261 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
19263 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
19266 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19267 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
19268 # optional and can be regexp for 2nd line (lnet.routes case)
19269 check_lnet_proc_entry() {
19270 local blp=2 # blp stands for 'position of 1st line of body'
19271 [ -z "$5" ] || blp=3 # lnet.routes case
19273 local l=$(cat "$TMP/lnet_$1" |wc -l)
19274 # subtracting one from $blp because the body can be empty
19275 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
19277 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
19278 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
19280 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
19281 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
19283 # bail out if any unexpected line happened
19284 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
19285 [ "$?" != 0 ] || error "$2 misformatted"
19288 test_215() { # for bugs 18102, 21079, 21517
19289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19291 local N='(0|[1-9][0-9]*)' # non-negative numeric
19292 local P='[1-9][0-9]*' # positive numeric
19293 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
19294 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
19295 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
19296 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
19298 local L1 # regexp for 1st line
19299 local L2 # regexp for 2nd line (optional)
19300 local BR # regexp for the rest (body)
19302 # lnet.stats should look as 11 space-separated non-negative numerics
19303 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
19304 create_lnet_proc_files "stats"
19305 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
19306 remove_lnet_proc_files "stats"
19308 # lnet.routes should look like this:
19309 # Routing disabled/enabled
19310 # net hops priority state router
19311 # where net is a string like tcp0, hops > 0, priority >= 0,
19312 # state is up/down,
19313 # router is a string like 192.168.1.1@tcp2
19314 L1="^Routing (disabled|enabled)$"
19315 L2="^net +hops +priority +state +router$"
19316 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
19317 create_lnet_proc_files "routes"
19318 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
19319 remove_lnet_proc_files "routes"
19321 # lnet.routers should look like this:
19322 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
19323 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
19324 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
19325 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
19326 L1="^ref +rtr_ref +alive +router$"
19327 BR="^$P +$P +(up|down) +$NID$"
19328 create_lnet_proc_files "routers"
19329 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
19330 remove_lnet_proc_files "routers"
19332 # lnet.peers should look like this:
19333 # nid refs state last max rtr min tx min queue
19334 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
19335 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
19336 # numeric (0 or >0 or <0), queue >= 0.
19337 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
19338 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
19339 create_lnet_proc_files "peers"
19340 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
19341 remove_lnet_proc_files "peers"
19343 # lnet.buffers should look like this:
19344 # pages count credits min
19345 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
19346 L1="^pages +count +credits +min$"
19347 BR="^ +$N +$N +$I +$I$"
19348 create_lnet_proc_files "buffers"
19349 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
19350 remove_lnet_proc_files "buffers"
19352 # lnet.nis should look like this:
19353 # nid status alive refs peer rtr max tx min
19354 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
19355 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
19356 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
19357 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
19358 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
19359 create_lnet_proc_files "nis"
19360 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
19361 remove_lnet_proc_files "nis"
19363 # can we successfully write to lnet.stats?
19364 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
19366 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
19368 test_216() { # bug 20317
19369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19370 remote_ost_nodsh && skip "remote OST with nodsh"
19373 local facets=$(get_facets OST)
19374 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19376 save_lustre_params client "osc.*.contention_seconds" > $p
19377 save_lustre_params $facets \
19378 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
19379 save_lustre_params $facets \
19380 "ldlm.namespaces.filter-*.contended_locks" >> $p
19381 save_lustre_params $facets \
19382 "ldlm.namespaces.filter-*.contention_seconds" >> $p
19383 clear_stats osc.*.osc_stats
19385 # agressive lockless i/o settings
19386 do_nodes $(comma_list $(osts_nodes)) \
19387 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
19388 ldlm.namespaces.filter-*.contended_locks=0 \
19389 ldlm.namespaces.filter-*.contention_seconds=60"
19390 lctl set_param -n osc.*.contention_seconds=60
19392 $DIRECTIO write $DIR/$tfile 0 10 4096
19393 $CHECKSTAT -s 40960 $DIR/$tfile
19395 # disable lockless i/o
19396 do_nodes $(comma_list $(osts_nodes)) \
19397 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
19398 ldlm.namespaces.filter-*.contended_locks=32 \
19399 ldlm.namespaces.filter-*.contention_seconds=0"
19400 lctl set_param -n osc.*.contention_seconds=0
19401 clear_stats osc.*.osc_stats
19403 dd if=/dev/zero of=$DIR/$tfile count=0
19404 $CHECKSTAT -s 0 $DIR/$tfile
19406 restore_lustre_params <$p
19410 run_test 216 "check lockless direct write updates file size and kms correctly"
19412 test_217() { # bug 22430
19413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19418 for node in $(nodes_list); do
19419 nid=$(host_nids_address $node $NETTYPE)
19420 if [[ $nid = *-* ]] ; then
19421 echo "lctl ping $(h2nettype $nid)"
19422 lctl ping $(h2nettype $nid)
19424 echo "skipping $node (no hyphen detected)"
19428 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19431 # do directio so as not to populate the page cache
19432 log "creating a 10 Mb file"
19433 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19434 log "starting reads"
19435 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19436 log "truncating the file"
19437 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19439 kill %+ || true # reads might have finished
19440 echo "wait until dd is finished"
19442 log "removing the temporary file"
19443 rm -rf $DIR/$tfile || error "tmp file removal failed"
19445 run_test 218 "parallel read and truncate should not deadlock"
19448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19450 # write one partial page
19451 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19452 # set no grant so vvp_io_commit_write will do sync write
19453 $LCTL set_param fail_loc=0x411
19454 # write a full page at the end of file
19455 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19457 $LCTL set_param fail_loc=0
19458 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19459 $LCTL set_param fail_loc=0x411
19460 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19463 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19464 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19466 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19468 test_220() { #LU-325
19469 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19470 remote_ost_nodsh && skip "remote OST with nodsh"
19471 remote_mds_nodsh && skip "remote MDS with nodsh"
19472 remote_mgs_nodsh && skip "remote MGS with nodsh"
19476 # create on MDT0000 so the last_id and next_id are correct
19477 mkdir_on_mdt0 $DIR/$tdir
19478 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19482 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19483 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19484 osp.$mdtosc_proc1.prealloc_last_id)
19485 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19486 osp.$mdtosc_proc1.prealloc_next_id)
19490 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19491 #define OBD_FAIL_OST_ENOINO 0x229
19492 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19493 create_pool $FSNAME.$TESTNAME || return 1
19494 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19496 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19498 MDSOBJS=$((last_id - next_id))
19499 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19501 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19502 echo "OST still has $count kbytes free"
19504 echo "create $MDSOBJS files @next_id..."
19505 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19507 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19508 osp.$mdtosc_proc1.prealloc_last_id)
19509 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19510 osp.$mdtosc_proc1.prealloc_next_id)
19512 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19517 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19518 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19520 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19521 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19522 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19523 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19524 echo "unlink $MDSOBJS files @$next_id..."
19525 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19527 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19532 dd if=`which date` of=$MOUNT/date oflag=sync
19533 chmod +x $MOUNT/date
19535 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19536 $LCTL set_param fail_loc=0x80001401
19538 $MOUNT/date > /dev/null
19541 run_test 221 "make sure fault and truncate race to not cause OOM"
19544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19547 test_mkdir $DIR/$tdir
19548 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19549 createmany -o $DIR/$tdir/$tfile 10
19550 cancel_lru_locks mdc
19551 cancel_lru_locks osc
19552 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19553 $LCTL set_param fail_loc=0x31a
19554 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19555 $LCTL set_param fail_loc=0
19558 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19564 test_mkdir $DIR/$tdir
19565 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19566 createmany -o $DIR/$tdir/$tfile 10
19567 cancel_lru_locks mdc
19568 cancel_lru_locks osc
19569 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19570 $LCTL set_param fail_loc=0x31a
19571 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19572 $LCTL set_param fail_loc=0
19574 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
19577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19580 test_mkdir $DIR/$tdir
19581 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19582 createmany -o $DIR/$tdir/$tfile 10
19583 cancel_lru_locks mdc
19584 cancel_lru_locks osc
19585 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
19586 $LCTL set_param fail_loc=0x31b
19587 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
19588 $LCTL set_param fail_loc=0
19591 run_test 223 "osc reenqueue if without AGL lock granted ======================="
19593 test_224a() { # LU-1039, MRP-303
19594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19595 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
19596 $LCTL set_param fail_loc=0x508
19597 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
19598 $LCTL set_param fail_loc=0
19601 run_test 224a "Don't panic on bulk IO failure"
19603 test_224bd_sub() { # LU-1039, MRP-303
19604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19608 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
19610 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19612 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
19613 cancel_lru_locks osc
19615 stack_trap "set_checksums $ORIG_CSUM" EXIT
19616 local at_max_saved=0
19618 # adaptive timeouts may prevent seeing the issue
19619 if at_is_enabled; then
19620 at_max_saved=$(at_max_get mds)
19621 at_max_set 0 mds client
19622 stack_trap "at_max_set $at_max_saved mds client" EXIT
19625 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
19626 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
19627 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
19629 do_facet ost1 $LCTL set_param fail_loc=0
19630 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
19635 test_224bd_sub 3 error "dd failed"
19637 run_test 224b "Don't panic on bulk IO failure"
19639 test_224c() { # LU-6441
19640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19641 remote_mds_nodsh && skip "remote MDS with nodsh"
19643 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19644 save_writethrough $p
19645 set_cache writethrough on
19647 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
19648 local at_max=$($LCTL get_param -n at_max)
19649 local timeout=$($LCTL get_param -n timeout)
19650 local test_at="at_max"
19651 local param_at="$FSNAME.sys.at_max"
19652 local test_timeout="timeout"
19653 local param_timeout="$FSNAME.sys.timeout"
19655 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
19657 set_persistent_param_and_check client "$test_at" "$param_at" 0
19658 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
19660 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
19661 do_facet ost1 "$LCTL set_param fail_loc=0x520"
19662 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19663 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
19665 do_facet ost1 "$LCTL set_param fail_loc=0"
19667 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
19668 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
19671 $LCTL set_param -n $pages_per_rpc
19672 restore_lustre_params < $p
19675 run_test 224c "Don't hang if one of md lost during large bulk RPC"
19677 test_224d() { # LU-11169
19678 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
19680 run_test 224d "Don't corrupt data on bulk IO timeout"
19682 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
19684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19685 if [ -z ${MDSSURVEY} ]; then
19686 skip_env "mds-survey not found"
19688 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19689 skip "Need MDS version at least 2.2.51"
19691 local mds=$(facet_host $SINGLEMDS)
19692 local target=$(do_nodes $mds 'lctl dl' |
19693 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19695 local cmd1="file_count=1000 thrhi=4"
19696 local cmd2="dir_count=2 layer=mdd stripe_count=0"
19697 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19698 local cmd="$cmd1 $cmd2 $cmd3"
19700 rm -f ${TMP}/mds_survey*
19702 eval $cmd || error "mds-survey with zero-stripe failed"
19703 cat ${TMP}/mds_survey*
19704 rm -f ${TMP}/mds_survey*
19706 run_test 225a "Metadata survey sanity with zero-stripe"
19709 if [ -z ${MDSSURVEY} ]; then
19710 skip_env "mds-survey not found"
19712 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19713 skip "Need MDS version at least 2.2.51"
19714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19715 remote_mds_nodsh && skip "remote MDS with nodsh"
19716 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
19717 skip_env "Need to mount OST to test"
19720 local mds=$(facet_host $SINGLEMDS)
19721 local target=$(do_nodes $mds 'lctl dl' |
19722 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19724 local cmd1="file_count=1000 thrhi=4"
19725 local cmd2="dir_count=2 layer=mdd stripe_count=1"
19726 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19727 local cmd="$cmd1 $cmd2 $cmd3"
19729 rm -f ${TMP}/mds_survey*
19731 eval $cmd || error "mds-survey with stripe_count failed"
19732 cat ${TMP}/mds_survey*
19733 rm -f ${TMP}/mds_survey*
19735 run_test 225b "Metadata survey sanity with stripe_count = 1"
19737 mcreate_path2fid () {
19743 local path=$DIR/$tdir/$name
19748 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
19749 error "cannot create $desc"
19751 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
19753 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
19755 fid_path=$($LFS fid2path $MOUNT $fid)
19757 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
19759 [ "$path" == "$fid_path" ] ||
19760 error "fid2path returned $fid_path, expected $path"
19762 echo "pass with $path and $fid"
19767 mkdir -p $DIR/$tdir
19769 mcreate_path2fid 0010666 0 0 fifo "FIFO"
19770 mcreate_path2fid 0020666 1 3 null "character special file (null)"
19771 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
19772 mcreate_path2fid 0040666 0 0 dir "directory"
19773 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
19774 mcreate_path2fid 0100666 0 0 file "regular file"
19775 mcreate_path2fid 0120666 0 0 link "symbolic link"
19776 mcreate_path2fid 0140666 0 0 sock "socket"
19778 run_test 226a "call path2fid and fid2path on files of all type"
19781 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19786 mkdir -p $DIR/$tdir
19787 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
19788 error "create remote directory failed"
19789 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
19790 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
19791 "character special file (null)"
19792 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
19793 "character special file (no device)"
19794 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
19795 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
19796 "block special file (loop)"
19797 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
19798 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
19799 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
19801 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
19804 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19805 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
19806 skip "Need MDS version at least 2.13.55"
19808 local submnt=/mnt/submnt
19809 local srcfile=/etc/passwd
19810 local dstfile=$submnt/passwd
19816 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
19817 error "create remote directory failed"
19818 mkdir -p $submnt || error "create $submnt failed"
19819 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
19820 error "mount $submnt failed"
19821 stack_trap "umount $submnt" EXIT
19823 cp $srcfile $dstfile
19824 fid=$($LFS path2fid $dstfile)
19825 path=$($LFS fid2path $submnt "$fid")
19826 [ "$path" = "$dstfile" ] ||
19827 error "fid2path $submnt $fid failed ($path != $dstfile)"
19829 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
19831 # LU-1299 Executing or running ldd on a truncated executable does not
19832 # cause an out-of-memory condition.
19834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19835 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
19837 dd if=$(which date) of=$MOUNT/date bs=1k count=1
19838 chmod +x $MOUNT/date
19840 $MOUNT/date > /dev/null
19841 ldd $MOUNT/date > /dev/null
19844 run_test 227 "running truncated executable does not cause OOM"
19846 # LU-1512 try to reuse idle OI blocks
19848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19849 remote_mds_nodsh && skip "remote MDS with nodsh"
19850 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19852 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19853 local myDIR=$DIR/$tdir
19856 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19857 $LCTL set_param fail_loc=0x80001002
19858 createmany -o $myDIR/t- 10000
19859 $LCTL set_param fail_loc=0
19860 # The guard is current the largest FID holder
19862 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19864 local IDX=$(($SEQ % 64))
19866 do_facet $SINGLEMDS sync
19867 # Make sure journal flushed.
19869 local blk1=$(do_facet $SINGLEMDS \
19870 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19871 grep Blockcount | awk '{print $4}')
19873 # Remove old files, some OI blocks will become idle.
19874 unlinkmany $myDIR/t- 10000
19875 # Create new files, idle OI blocks should be reused.
19876 createmany -o $myDIR/t- 2000
19877 do_facet $SINGLEMDS sync
19878 # Make sure journal flushed.
19880 local blk2=$(do_facet $SINGLEMDS \
19881 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19882 grep Blockcount | awk '{print $4}')
19884 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19886 run_test 228a "try to reuse idle OI blocks"
19889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19890 remote_mds_nodsh && skip "remote MDS with nodsh"
19891 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19893 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19894 local myDIR=$DIR/$tdir
19897 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19898 $LCTL set_param fail_loc=0x80001002
19899 createmany -o $myDIR/t- 10000
19900 $LCTL set_param fail_loc=0
19901 # The guard is current the largest FID holder
19903 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19905 local IDX=$(($SEQ % 64))
19907 do_facet $SINGLEMDS sync
19908 # Make sure journal flushed.
19910 local blk1=$(do_facet $SINGLEMDS \
19911 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19912 grep Blockcount | awk '{print $4}')
19914 # Remove old files, some OI blocks will become idle.
19915 unlinkmany $myDIR/t- 10000
19918 stop $SINGLEMDS || error "Fail to stop MDT."
19920 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
19921 error "Fail to start MDT."
19923 df $MOUNT || error "Fail to df."
19924 # Create new files, idle OI blocks should be reused.
19925 createmany -o $myDIR/t- 2000
19926 do_facet $SINGLEMDS sync
19927 # Make sure journal flushed.
19929 local blk2=$(do_facet $SINGLEMDS \
19930 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19931 grep Blockcount | awk '{print $4}')
19933 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19935 run_test 228b "idle OI blocks can be reused after MDT restart"
19939 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19940 remote_mds_nodsh && skip "remote MDS with nodsh"
19941 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19943 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19944 local myDIR=$DIR/$tdir
19947 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19948 $LCTL set_param fail_loc=0x80001002
19949 # 20000 files can guarantee there are index nodes in the OI file
19950 createmany -o $myDIR/t- 20000
19951 $LCTL set_param fail_loc=0
19952 # The guard is current the largest FID holder
19954 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19956 local IDX=$(($SEQ % 64))
19958 do_facet $SINGLEMDS sync
19959 # Make sure journal flushed.
19961 local blk1=$(do_facet $SINGLEMDS \
19962 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19963 grep Blockcount | awk '{print $4}')
19965 # Remove old files, some OI blocks will become idle.
19966 unlinkmany $myDIR/t- 20000
19968 # The OI file should become empty now
19970 # Create new files, idle OI blocks should be reused.
19971 createmany -o $myDIR/t- 2000
19972 do_facet $SINGLEMDS sync
19973 # Make sure journal flushed.
19975 local blk2=$(do_facet $SINGLEMDS \
19976 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19977 grep Blockcount | awk '{print $4}')
19979 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19981 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
19983 test_229() { # LU-2482, LU-3448
19984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19985 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19986 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
19987 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
19991 # Create a file with a released layout and stripe count 2.
19992 $MULTIOP $DIR/$tfile H2c ||
19993 error "failed to create file with released layout"
19995 $LFS getstripe -v $DIR/$tfile
19997 local pattern=$($LFS getstripe -L $DIR/$tfile)
19998 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
20000 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
20002 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
20003 stat $DIR/$tfile || error "failed to stat released file"
20005 chown $RUNAS_ID $DIR/$tfile ||
20006 error "chown $RUNAS_ID $DIR/$tfile failed"
20008 chgrp $RUNAS_ID $DIR/$tfile ||
20009 error "chgrp $RUNAS_ID $DIR/$tfile failed"
20011 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
20012 rm $DIR/$tfile || error "failed to remove released file"
20014 run_test 229 "getstripe/stat/rm/attr changes work on released files"
20017 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20018 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20019 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20020 skip "Need MDS version at least 2.11.52"
20024 test_mkdir $DIR/$tdir
20025 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
20026 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
20027 [ $mdt_idx -ne 0 ] &&
20028 error "create local directory on wrong MDT $mdt_idx"
20030 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
20031 error "create remote directory failed"
20032 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
20033 [ $mdt_idx -ne $MDTIDX ] &&
20034 error "create remote directory on wrong MDT $mdt_idx"
20036 createmany -o $DIR/$tdir/test_230/t- 10 ||
20037 error "create files on remote directory failed"
20038 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
20039 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
20040 rm -r $DIR/$tdir || error "unlink remote directory failed"
20042 run_test 230a "Create remote directory and files under the remote directory"
20045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20046 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20047 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20048 skip "Need MDS version at least 2.11.52"
20056 local migrate_dir=$DIR/$tdir/migrate_dir
20057 local other_dir=$DIR/$tdir/other_dir
20059 test_mkdir $DIR/$tdir
20060 test_mkdir -i0 -c1 $migrate_dir
20061 test_mkdir -i0 -c1 $other_dir
20062 for ((i=0; i<10; i++)); do
20063 mkdir -p $migrate_dir/dir_${i}
20064 createmany -o $migrate_dir/dir_${i}/f 10 ||
20065 error "create files under remote dir failed $i"
20068 cp /etc/passwd $migrate_dir/$tfile
20069 cp /etc/passwd $other_dir/$tfile
20070 chattr +SAD $migrate_dir
20071 chattr +SAD $migrate_dir/$tfile
20073 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20074 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20075 local old_dir_mode=$(stat -c%f $migrate_dir)
20076 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
20078 mkdir -p $migrate_dir/dir_default_stripe2
20079 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
20080 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
20082 mkdir -p $other_dir
20083 ln $migrate_dir/$tfile $other_dir/luna
20084 ln $migrate_dir/$tfile $migrate_dir/sofia
20085 ln $other_dir/$tfile $migrate_dir/david
20086 ln -s $migrate_dir/$tfile $other_dir/zachary
20087 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
20088 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
20094 for len in 58 59 60; do
20095 lnktgt=$(str_repeat 'l' $len)
20096 touch $migrate_dir/$lnktgt
20097 ln -s $lnktgt $migrate_dir/${len}char_ln
20101 for len in 4094 4095; do
20102 lnktgt=$(str_repeat 'l' $len)
20103 ln -s $lnktgt $migrate_dir/${len}char_ln
20107 for len in 254 255; do
20108 touch $migrate_dir/$(str_repeat 'l' $len)
20111 $LFS migrate -m $MDTIDX $migrate_dir ||
20112 error "fails on migrating remote dir to MDT1"
20114 echo "migratate to MDT1, then checking.."
20115 for ((i = 0; i < 10; i++)); do
20116 for file in $(find $migrate_dir/dir_${i}); do
20117 mdt_index=$($LFS getstripe -m $file)
20118 # broken symlink getstripe will fail
20119 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20120 error "$file is not on MDT${MDTIDX}"
20124 # the multiple link file should still in MDT0
20125 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
20126 [ $mdt_index == 0 ] ||
20127 error "$file is not on MDT${MDTIDX}"
20129 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20130 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20131 error " expect $old_dir_flag get $new_dir_flag"
20133 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20134 [ "$old_file_flag" = "$new_file_flag" ] ||
20135 error " expect $old_file_flag get $new_file_flag"
20137 local new_dir_mode=$(stat -c%f $migrate_dir)
20138 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20139 error "expect mode $old_dir_mode get $new_dir_mode"
20141 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20142 [ "$old_file_mode" = "$new_file_mode" ] ||
20143 error "expect mode $old_file_mode get $new_file_mode"
20145 diff /etc/passwd $migrate_dir/$tfile ||
20146 error "$tfile different after migration"
20148 diff /etc/passwd $other_dir/luna ||
20149 error "luna different after migration"
20151 diff /etc/passwd $migrate_dir/sofia ||
20152 error "sofia different after migration"
20154 diff /etc/passwd $migrate_dir/david ||
20155 error "david different after migration"
20157 diff /etc/passwd $other_dir/zachary ||
20158 error "zachary different after migration"
20160 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20161 error "${tfile}_ln different after migration"
20163 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20164 error "${tfile}_ln_other different after migration"
20166 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
20167 [ $stripe_count = 2 ] ||
20168 error "dir strpe_count $d != 2 after migration."
20170 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
20171 [ $stripe_count = 2 ] ||
20172 error "file strpe_count $d != 2 after migration."
20174 #migrate back to MDT0
20177 $LFS migrate -m $MDTIDX $migrate_dir ||
20178 error "fails on migrating remote dir to MDT0"
20180 echo "migrate back to MDT0, checking.."
20181 for file in $(find $migrate_dir); do
20182 mdt_index=$($LFS getstripe -m $file)
20183 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20184 error "$file is not on MDT${MDTIDX}"
20187 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20188 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20189 error " expect $old_dir_flag get $new_dir_flag"
20191 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20192 [ "$old_file_flag" = "$new_file_flag" ] ||
20193 error " expect $old_file_flag get $new_file_flag"
20195 local new_dir_mode=$(stat -c%f $migrate_dir)
20196 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20197 error "expect mode $old_dir_mode get $new_dir_mode"
20199 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20200 [ "$old_file_mode" = "$new_file_mode" ] ||
20201 error "expect mode $old_file_mode get $new_file_mode"
20203 diff /etc/passwd ${migrate_dir}/$tfile ||
20204 error "$tfile different after migration"
20206 diff /etc/passwd ${other_dir}/luna ||
20207 error "luna different after migration"
20209 diff /etc/passwd ${migrate_dir}/sofia ||
20210 error "sofia different after migration"
20212 diff /etc/passwd ${other_dir}/zachary ||
20213 error "zachary different after migration"
20215 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20216 error "${tfile}_ln different after migration"
20218 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20219 error "${tfile}_ln_other different after migration"
20221 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
20222 [ $stripe_count = 2 ] ||
20223 error "dir strpe_count $d != 2 after migration."
20225 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
20226 [ $stripe_count = 2 ] ||
20227 error "file strpe_count $d != 2 after migration."
20229 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20231 run_test 230b "migrate directory"
20234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20235 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20236 remote_mds_nodsh && skip "remote MDS with nodsh"
20237 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20238 skip "Need MDS version at least 2.11.52"
20244 local migrate_dir=$DIR/$tdir/migrate_dir
20246 #If migrating directory fails in the middle, all entries of
20247 #the directory is still accessiable.
20248 test_mkdir $DIR/$tdir
20249 test_mkdir -i0 -c1 $migrate_dir
20250 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
20252 createmany -o $migrate_dir/f $total ||
20253 error "create files under ${migrate_dir} failed"
20255 # fail after migrating top dir, and this will fail only once, so the
20256 # first sub file migration will fail (currently f3), others succeed.
20257 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
20258 do_facet mds1 lctl set_param fail_loc=0x1801
20259 local t=$(ls $migrate_dir | wc -l)
20260 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
20261 error "migrate should fail"
20262 local u=$(ls $migrate_dir | wc -l)
20263 [ "$u" == "$t" ] || error "$u != $t during migration"
20265 # add new dir/file should succeed
20266 mkdir $migrate_dir/dir ||
20267 error "mkdir failed under migrating directory"
20268 touch $migrate_dir/file ||
20269 error "create file failed under migrating directory"
20271 # add file with existing name should fail
20272 for file in $migrate_dir/f*; do
20273 stat $file > /dev/null || error "stat $file failed"
20274 $OPENFILE -f O_CREAT:O_EXCL $file &&
20275 error "open(O_CREAT|O_EXCL) $file should fail"
20276 $MULTIOP $file m && error "create $file should fail"
20277 touch $DIR/$tdir/remote_dir/$tfile ||
20278 error "touch $tfile failed"
20279 ln $DIR/$tdir/remote_dir/$tfile $file &&
20280 error "link $file should fail"
20281 mdt_index=$($LFS getstripe -m $file)
20282 if [ $mdt_index == 0 ]; then
20283 # file failed to migrate is not allowed to rename to
20284 mv $DIR/$tdir/remote_dir/$tfile $file &&
20285 error "rename to $file should fail"
20287 mv $DIR/$tdir/remote_dir/$tfile $file ||
20288 error "rename to $file failed"
20290 echo hello >> $file || error "write $file failed"
20293 # resume migration with different options should fail
20294 $LFS migrate -m 0 $migrate_dir &&
20295 error "migrate -m 0 $migrate_dir should fail"
20297 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
20298 error "migrate -c 2 $migrate_dir should fail"
20300 # resume migration should succeed
20301 $LFS migrate -m $MDTIDX $migrate_dir ||
20302 error "migrate $migrate_dir failed"
20304 echo "Finish migration, then checking.."
20305 for file in $(find $migrate_dir); do
20306 mdt_index=$($LFS getstripe -m $file)
20307 [ $mdt_index == $MDTIDX ] ||
20308 error "$file is not on MDT${MDTIDX}"
20311 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20313 run_test 230c "check directory accessiblity if migration failed"
20316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20317 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20318 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20319 skip "Need MDS version at least 2.11.52"
20321 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
20323 local migrate_dir=$DIR/$tdir/migrate_dir
20333 old_index=$((RANDOM % MDSCOUNT))
20334 old_count=$((MDSCOUNT - old_index))
20335 new_index=$((RANDOM % MDSCOUNT))
20336 new_count=$((MDSCOUNT - new_index))
20337 new_hash=1 # for all_char
20339 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
20340 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
20342 test_mkdir $DIR/$tdir
20343 test_mkdir -i $old_index -c $old_count $migrate_dir
20345 for ((i=0; i<100; i++)); do
20346 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
20347 createmany -o $migrate_dir/dir_${i}/f 100 ||
20348 error "create files under remote dir failed $i"
20351 echo -n "Migrate from MDT$old_index "
20352 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
20353 echo -n "to MDT$new_index"
20354 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
20357 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
20358 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
20359 error "migrate remote dir error"
20361 echo "Finish migration, then checking.."
20362 for file in $(find $migrate_dir -maxdepth 1); do
20363 mdt_index=$($LFS getstripe -m $file)
20364 if [ $mdt_index -lt $new_index ] ||
20365 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
20366 error "$file is on MDT$mdt_index"
20370 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20372 run_test 230d "check migrate big directory"
20375 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20376 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20377 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20378 skip "Need MDS version at least 2.11.52"
20385 mkdir_on_mdt0 $DIR/$tdir
20386 mkdir $DIR/$tdir/migrate_dir
20387 mkdir $DIR/$tdir/other_dir
20388 touch $DIR/$tdir/migrate_dir/a
20389 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
20390 ls $DIR/$tdir/other_dir
20392 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20393 error "migrate dir fails"
20395 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20396 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20398 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20399 [ $mdt_index == 0 ] || error "a is not on MDT0"
20401 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20402 error "migrate dir fails"
20404 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20405 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20407 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20408 [ $mdt_index == 1 ] || error "a is not on MDT1"
20410 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20411 [ $mdt_index == 1 ] || error "b is not on MDT1"
20413 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20414 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20416 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20418 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20420 run_test 230e "migrate mulitple local link files"
20423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20424 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20425 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20426 skip "Need MDS version at least 2.11.52"
20431 mkdir -p $DIR/$tdir
20432 mkdir $DIR/$tdir/migrate_dir
20433 $LFS mkdir -i1 $DIR/$tdir/other_dir
20434 touch $DIR/$tdir/migrate_dir/a
20435 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20436 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20437 ls $DIR/$tdir/other_dir
20439 # a should be migrated to MDT1, since no other links on MDT0
20440 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20441 error "#1 migrate dir fails"
20442 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20443 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20444 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20445 [ $mdt_index == 1 ] || error "a is not on MDT1"
20447 # a should stay on MDT1, because it is a mulitple link file
20448 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20449 error "#2 migrate dir fails"
20450 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20451 [ $mdt_index == 1 ] || error "a is not on MDT1"
20453 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20454 error "#3 migrate dir fails"
20456 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20457 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20458 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20460 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20461 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20463 # a should be migrated to MDT0, since no other links on MDT1
20464 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20465 error "#4 migrate dir fails"
20466 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20467 [ $mdt_index == 0 ] || error "a is not on MDT0"
20469 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20471 run_test 230f "migrate mulitple remote link files"
20474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20475 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20476 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20477 skip "Need MDS version at least 2.11.52"
20479 mkdir -p $DIR/$tdir/migrate_dir
20481 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20482 error "migrating dir to non-exist MDT succeeds"
20485 run_test 230g "migrate dir to non-exist MDT"
20488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20489 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20490 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20491 skip "Need MDS version at least 2.11.52"
20495 mkdir -p $DIR/$tdir/migrate_dir
20497 $LFS migrate -m1 $DIR &&
20498 error "migrating mountpoint1 should fail"
20500 $LFS migrate -m1 $DIR/$tdir/.. &&
20501 error "migrating mountpoint2 should fail"
20504 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20505 error "migrating $tdir/migrate_dir/.. should fail"
20509 run_test 230h "migrate .. and root"
20512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20513 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20514 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20515 skip "Need MDS version at least 2.11.52"
20517 mkdir -p $DIR/$tdir/migrate_dir
20519 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20520 error "migration fails with a tailing slash"
20522 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20523 error "migration fails with two tailing slashes"
20525 run_test 230i "lfs migrate -m tolerates trailing slashes"
20528 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20529 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20530 skip "Need MDS version at least 2.11.52"
20532 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20533 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20534 error "create $tfile failed"
20535 cat /etc/passwd > $DIR/$tdir/$tfile
20537 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20539 cmp /etc/passwd $DIR/$tdir/$tfile ||
20540 error "DoM file mismatch after migration"
20542 run_test 230j "DoM file data not changed after dir migration"
20545 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20546 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20547 skip "Need MDS version at least 2.11.56"
20550 local files_on_starting_mdt=0
20552 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20553 $LFS getdirstripe $DIR/$tdir
20554 for i in $(seq $total); do
20555 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20556 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20557 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20560 echo "$files_on_starting_mdt files on MDT0"
20562 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20563 $LFS getdirstripe $DIR/$tdir
20565 files_on_starting_mdt=0
20566 for i in $(seq $total); do
20567 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20568 error "file $tfile.$i mismatch after migration"
20569 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20570 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20573 echo "$files_on_starting_mdt files on MDT1 after migration"
20574 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20576 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20577 $LFS getdirstripe $DIR/$tdir
20579 files_on_starting_mdt=0
20580 for i in $(seq $total); do
20581 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20582 error "file $tfile.$i mismatch after 2nd migration"
20583 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20584 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20587 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
20588 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
20592 run_test 230k "file data not changed after dir migration"
20595 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20596 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20597 skip "Need MDS version at least 2.11.56"
20599 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
20600 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
20601 error "create files under remote dir failed $i"
20602 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20604 run_test 230l "readdir between MDTs won't crash"
20607 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20608 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20609 skip "Need MDS version at least 2.11.56"
20612 local mig_dir=$DIR/$tdir/migrate_dir
20613 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20617 echo "Creating files and dirs with xattrs"
20618 test_mkdir $DIR/$tdir
20619 test_mkdir -i0 -c1 $mig_dir
20621 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
20622 error "cannot set xattr attr1 on dir"
20623 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
20624 error "cannot set xattr attr2 on dir"
20625 touch $mig_dir/dir/f0
20626 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
20627 error "cannot set xattr attr1 on file"
20628 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
20629 error "cannot set xattr attr2 on file"
20630 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20631 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20632 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
20633 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20634 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
20635 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20636 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
20637 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20638 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
20640 echo "Migrating to MDT1"
20641 $LFS migrate -m $MDTIDX $mig_dir ||
20642 error "fails on migrating dir to MDT1"
20644 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20645 echo "Checking xattrs"
20646 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20647 [ "$val" = $longstr ] ||
20648 error "expecting xattr1 $longstr on dir, found $val"
20649 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20650 [ "$val" = $shortstr ] ||
20651 error "expecting xattr2 $shortstr on dir, found $val"
20652 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20653 [ "$val" = $longstr ] ||
20654 error "expecting xattr1 $longstr on file, found $val"
20655 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20656 [ "$val" = $shortstr ] ||
20657 error "expecting xattr2 $shortstr on file, found $val"
20659 run_test 230m "xattrs not changed after dir migration"
20662 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20663 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
20664 skip "Need MDS version at least 2.13.53"
20666 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
20667 cat /etc/hosts > $DIR/$tdir/$tfile
20668 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
20669 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
20671 cmp /etc/hosts $DIR/$tdir/$tfile ||
20672 error "File data mismatch after migration"
20674 run_test 230n "Dir migration with mirrored file"
20677 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
20678 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
20679 skip "Need MDS version at least 2.13.52"
20681 local mdts=$(comma_list $(mdts_nodes))
20683 local restripe_status
20687 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20689 # in case "crush" hash type is not set
20690 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20692 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20693 mdt.*MDT0000.enable_dir_restripe)
20694 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20695 stack_trap "do_nodes $mdts $LCTL set_param \
20696 mdt.*.enable_dir_restripe=$restripe_status"
20699 createmany -m $DIR/$tdir/f 100 ||
20700 error "create files under remote dir failed $i"
20701 createmany -d $DIR/$tdir/d 100 ||
20702 error "create dirs under remote dir failed $i"
20704 for i in $(seq 2 $MDSCOUNT); do
20705 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20706 $LFS setdirstripe -c $i $DIR/$tdir ||
20707 error "split -c $i $tdir failed"
20708 wait_update $HOSTNAME \
20709 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
20710 error "dir split not finished"
20711 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20712 awk '/migrate/ {sum += $2} END { print sum }')
20713 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
20714 # delta is around total_files/stripe_count
20715 (( $delta < 200 / (i - 1) + 4 )) ||
20716 error "$delta files migrated >= $((200 / (i - 1) + 4))"
20719 run_test 230o "dir split"
20722 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20723 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20724 skip "Need MDS version at least 2.13.52"
20726 local mdts=$(comma_list $(mdts_nodes))
20728 local restripe_status
20732 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20734 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20736 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20737 mdt.*MDT0000.enable_dir_restripe)
20738 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20739 stack_trap "do_nodes $mdts $LCTL set_param \
20740 mdt.*.enable_dir_restripe=$restripe_status"
20742 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
20743 createmany -m $DIR/$tdir/f 100 ||
20744 error "create files under remote dir failed"
20745 createmany -d $DIR/$tdir/d 100 ||
20746 error "create dirs under remote dir failed"
20748 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
20749 local mdt_hash="crush"
20751 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20752 $LFS setdirstripe -c $c $DIR/$tdir ||
20753 error "split -c $c $tdir failed"
20754 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
20755 mdt_hash="$mdt_hash,fixed"
20756 elif [ $c -eq 1 ]; then
20759 wait_update $HOSTNAME \
20760 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
20761 error "dir merge not finished"
20762 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20763 awk '/migrate/ {sum += $2} END { print sum }')
20764 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
20765 # delta is around total_files/stripe_count
20766 (( delta < 200 / c + 4 )) ||
20767 error "$delta files migrated >= $((200 / c + 4))"
20770 run_test 230p "dir merge"
20773 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
20774 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20775 skip "Need MDS version at least 2.13.52"
20777 local mdts=$(comma_list $(mdts_nodes))
20778 local saved_threshold=$(do_facet mds1 \
20779 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
20780 local saved_delta=$(do_facet mds1 \
20781 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
20782 local threshold=100
20785 local stripe_count=0
20790 # test with fewer files on ZFS
20791 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
20793 stack_trap "do_nodes $mdts $LCTL set_param \
20794 mdt.*.dir_split_count=$saved_threshold"
20795 stack_trap "do_nodes $mdts $LCTL set_param \
20796 mdt.*.dir_split_delta=$saved_delta"
20797 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
20798 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
20799 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
20800 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
20801 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
20802 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20804 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20805 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20807 create=$((threshold * 3 / 2))
20808 while [ $stripe_count -lt $MDSCOUNT ]; do
20809 createmany -m $DIR/$tdir/f $total $create ||
20810 error "create sub files failed"
20811 stat $DIR/$tdir > /dev/null
20812 total=$((total + create))
20813 stripe_count=$((stripe_count + delta))
20814 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
20816 wait_update $HOSTNAME \
20817 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
20818 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
20820 wait_update $HOSTNAME \
20821 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
20822 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
20824 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
20825 echo "$nr_files/$total files on MDT$stripe_index after split"
20826 # allow 10% margin of imbalance with crush hash
20827 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
20828 error "$nr_files files on MDT$stripe_index after split"
20830 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
20831 [ $nr_files -eq $total ] ||
20832 error "total sub files $nr_files != $total"
20835 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
20837 echo "fixed layout directory won't auto split"
20838 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
20839 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
20840 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
20841 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
20842 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
20844 run_test 230q "dir auto split"
20847 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
20848 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20849 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
20850 skip "Need MDS version at least 2.13.54"
20852 # maximum amount of local locks:
20853 # parent striped dir - 2 locks
20854 # new stripe in parent to migrate to - 1 lock
20855 # source and target - 2 locks
20856 # Total 5 locks for regular file
20857 mkdir -p $DIR/$tdir
20858 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
20859 touch $DIR/$tdir/dir1/eee
20861 # create 4 hardlink for 4 more locks
20862 # Total: 9 locks > RS_MAX_LOCKS (8)
20863 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
20864 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
20865 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
20866 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
20867 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
20868 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
20869 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
20870 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
20872 cancel_lru_locks mdc
20874 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
20875 error "migrate dir fails"
20877 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20879 run_test 230r "migrate with too many local locks"
20882 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
20883 skip "Need MDS version at least 2.14.52"
20885 local mdts=$(comma_list $(mdts_nodes))
20886 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
20887 mdt.*MDT0000.enable_dir_restripe)
20889 stack_trap "do_nodes $mdts $LCTL set_param \
20890 mdt.*.enable_dir_restripe=$restripe_status"
20894 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
20895 test_mkdir $DIR/$tdir
20896 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
20897 error "$LFS mkdir should return EEXIST if target exists"
20901 run_test 230s "lfs mkdir should return -EEXIST if target exists"
20905 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20906 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
20907 skip "Need MDS version at least 2.14.50"
20909 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
20910 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
20911 $LFS project -p 1 -s $DIR/$tdir ||
20912 error "set $tdir project id failed"
20913 $LFS project -p 2 -s $DIR/$tdir/subdir ||
20914 error "set subdir project id failed"
20915 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
20917 run_test 230t "migrate directory with project ID set"
20921 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20922 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20923 skip "Need MDS version at least 2.14.53"
20927 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20928 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20929 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
20930 for i in $(seq 0 $((MDSCOUNT - 1))); do
20931 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20932 echo "$count dirs migrated to MDT$i"
20934 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20935 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
20937 run_test 230u "migrate directory by QOS"
20941 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20942 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20943 skip "Need MDS version at least 2.14.53"
20947 mkdir $DIR/$tdir || error "mkdir $tdir failed"
20948 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20949 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
20950 for i in $(seq 0 $((MDSCOUNT - 1))); do
20951 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20952 echo "$count subdirs migrated to MDT$i"
20953 (( i == 3 )) && (( count > 0 )) &&
20954 error "subdir shouldn't be migrated to MDT3"
20956 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20957 (( count == 3 )) || error "dirs migrated to $count MDTs"
20959 run_test 230v "subdir migrated to the MDT where its parent is located"
20962 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20963 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
20964 skip "Need MDS version at least 2.15.0"
20966 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
20967 createmany -o $DIR/$tdir/f 10 || error "create files failed"
20968 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
20970 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
20971 error "migrate failed"
20973 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
20974 error "$tdir stripe count mismatch"
20976 for i in $(seq 0 9); do
20977 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
20978 error "d$i is striped"
20981 run_test 230w "non-recursive mode dir migration"
20985 # For simplicity this test assumes that max_pages_per_rpc
20986 # is the same across all OSCs
20987 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
20988 local bulk_size=$((max_pages * PAGE_SIZE))
20989 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
20992 mkdir -p $DIR/$tdir
20993 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
20994 error "failed to set stripe with -S ${brw_size}M option"
20996 # clear the OSC stats
20997 $LCTL set_param osc.*.stats=0 &>/dev/null
21000 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
21001 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
21002 oflag=direct &>/dev/null || error "dd failed"
21004 sync; sleep 1; sync # just to be safe
21005 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
21006 if [ x$nrpcs != "x1" ]; then
21007 $LCTL get_param osc.*.stats
21008 error "found $nrpcs ost_write RPCs, not 1 as expected"
21012 # Drop the OSC cache, otherwise we will read from it
21013 cancel_lru_locks osc
21015 # clear the OSC stats
21016 $LCTL set_param osc.*.stats=0 &>/dev/null
21018 # Client reads $bulk_size.
21019 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
21020 iflag=direct &>/dev/null || error "dd failed"
21022 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
21023 if [ x$nrpcs != "x1" ]; then
21024 $LCTL get_param osc.*.stats
21025 error "found $nrpcs ost_read RPCs, not 1 as expected"
21028 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
21031 mkdir -p $DIR/$tdir
21033 for i in {0..1023}; do
21034 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
21035 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
21036 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
21040 run_test 231b "must not assert on fully utilized OST request buffer"
21043 mkdir -p $DIR/$tdir
21044 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21046 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21047 do_facet ost1 $LCTL set_param fail_loc=0x31c
21049 # ignore dd failure
21050 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
21052 do_facet ost1 $LCTL set_param fail_loc=0
21053 umount_client $MOUNT || error "umount failed"
21054 mount_client $MOUNT || error "mount failed"
21055 stop ost1 || error "cannot stop ost1"
21056 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21058 run_test 232a "failed lock should not block umount"
21061 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
21062 skip "Need MDS version at least 2.10.58"
21064 mkdir -p $DIR/$tdir
21065 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21066 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
21068 cancel_lru_locks osc
21070 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21071 do_facet ost1 $LCTL set_param fail_loc=0x31c
21074 $LFS data_version $DIR/$tdir/$tfile || true
21076 do_facet ost1 $LCTL set_param fail_loc=0
21077 umount_client $MOUNT || error "umount failed"
21078 mount_client $MOUNT || error "mount failed"
21079 stop ost1 || error "cannot stop ost1"
21080 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21082 run_test 232b "failed data version lock should not block umount"
21085 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
21086 skip "Need MDS version at least 2.3.64"
21087 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21089 local fid=$($LFS path2fid $MOUNT)
21091 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21092 error "cannot access $MOUNT using its FID '$fid'"
21094 run_test 233a "checking that OBF of the FS root succeeds"
21097 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
21098 skip "Need MDS version at least 2.5.90"
21099 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21101 local fid=$($LFS path2fid $MOUNT/.lustre)
21103 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21104 error "cannot access $MOUNT/.lustre using its FID '$fid'"
21106 fid=$($LFS path2fid $MOUNT/.lustre/fid)
21107 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21108 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
21110 run_test 233b "checking that OBF of the FS .lustre succeeds"
21113 local p="$TMP/sanityN-$TESTNAME.parameters"
21114 save_lustre_params client "llite.*.xattr_cache" > $p
21115 lctl set_param llite.*.xattr_cache 1 ||
21116 skip_env "xattr cache is not supported"
21118 mkdir -p $DIR/$tdir || error "mkdir failed"
21119 touch $DIR/$tdir/$tfile || error "touch failed"
21120 # OBD_FAIL_LLITE_XATTR_ENOMEM
21121 $LCTL set_param fail_loc=0x1405
21122 getfattr -n user.attr $DIR/$tdir/$tfile &&
21123 error "getfattr should have failed with ENOMEM"
21124 $LCTL set_param fail_loc=0x0
21127 restore_lustre_params < $p
21130 run_test 234 "xattr cache should not crash on ENOMEM"
21133 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
21134 skip "Need MDS version at least 2.4.52"
21136 flock_deadlock $DIR/$tfile
21141 124) error "process hangs on a deadlock"
21143 *) error "error executing flock_deadlock $DIR/$tfile"
21147 run_test 235 "LU-1715: flock deadlock detection does not work properly"
21151 check_swap_layouts_support
21153 local ref1=/etc/passwd
21154 local ref2=/etc/group
21155 local file1=$DIR/$tdir/f1
21156 local file2=$DIR/$tdir/f2
21158 test_mkdir -c1 $DIR/$tdir
21159 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
21160 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
21161 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
21162 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
21163 local fd=$(free_fd)
21164 local cmd="exec $fd<>$file2"
21167 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
21168 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
21171 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
21176 run_test 236 "Layout swap on open unlinked file"
21178 # LU-4659 linkea consistency
21180 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
21181 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
21182 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
21183 skip "Need MDS version at least 2.5.58 or 2.5.2+"
21186 ln $DIR/$tfile $DIR/$tfile.lnk
21187 touch $DIR/$tfile.new
21188 mv $DIR/$tfile.new $DIR/$tfile
21189 local fid1=$($LFS path2fid $DIR/$tfile)
21190 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
21191 local path1=$($LFS fid2path $FSNAME "$fid1")
21192 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
21193 local path2=$($LFS fid2path $FSNAME "$fid2")
21194 [ $tfile.lnk == $path2 ] ||
21195 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
21198 run_test 238 "Verify linkea consistency"
21200 test_239A() { # was test_239
21201 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
21202 skip "Need MDS version at least 2.5.60"
21204 local list=$(comma_list $(mdts_nodes))
21206 mkdir -p $DIR/$tdir
21207 createmany -o $DIR/$tdir/f- 5000
21208 unlinkmany $DIR/$tdir/f- 5000
21209 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
21210 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
21211 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
21212 osp.*MDT*.sync_in_flight" | calc_sum)
21213 [ "$changes" -eq 0 ] || error "$changes not synced"
21215 run_test 239A "osp_sync test"
21217 test_239a() { #LU-5297
21218 remote_mds_nodsh && skip "remote MDS with nodsh"
21221 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
21222 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
21223 chgrp $RUNAS_GID $DIR/$tfile
21224 wait_delete_completed
21226 run_test 239a "process invalid osp sync record correctly"
21228 test_239b() { #LU-5297
21229 remote_mds_nodsh && skip "remote MDS with nodsh"
21232 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
21233 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
21234 chgrp $RUNAS_GID $DIR/$tfile1
21235 wait_delete_completed
21236 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21238 chgrp $RUNAS_GID $DIR/$tfile2
21239 wait_delete_completed
21241 run_test 239b "process osp sync record with ENOMEM error correctly"
21244 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21245 remote_mds_nodsh && skip "remote MDS with nodsh"
21247 mkdir -p $DIR/$tdir
21249 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
21250 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
21251 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
21252 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
21254 umount_client $MOUNT || error "umount failed"
21255 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
21256 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
21257 mount_client $MOUNT || error "failed to mount client"
21259 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
21260 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
21262 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
21268 for LOOP in $(seq $count); do
21269 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
21270 cancel_lru_locks $OSC || true
21278 for LOOP in $(seq $1); do
21279 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
21284 test_241a() { # was test_241
21285 local bsize=$PAGE_SIZE
21287 (( bsize < 40960 )) && bsize=40960
21288 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21290 cancel_lru_locks $OSC
21291 test_241_bio 1000 $bsize &
21293 test_241_dio 1000 $bsize
21296 run_test 241a "bio vs dio"
21299 local bsize=$PAGE_SIZE
21301 (( bsize < 40960 )) && bsize=40960
21302 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21304 test_241_dio 1000 $bsize &
21306 test_241_dio 1000 $bsize
21309 run_test 241b "dio vs dio"
21312 remote_mds_nodsh && skip "remote MDS with nodsh"
21314 mkdir_on_mdt0 $DIR/$tdir
21315 touch $DIR/$tdir/$tfile
21317 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
21318 do_facet mds1 lctl set_param fail_loc=0x105
21319 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
21321 do_facet mds1 lctl set_param fail_loc=0
21322 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
21324 run_test 242 "mdt_readpage failure should not cause directory unreadable"
21328 test_mkdir $DIR/$tdir
21329 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
21331 run_test 243 "various group lock tests"
21335 test_mkdir $DIR/$tdir
21336 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
21337 sendfile_grouplock $DIR/$tdir/$tfile || \
21338 error "sendfile+grouplock failed"
21341 run_test 244a "sendfile with group lock tests"
21345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
21348 local size=$((1024*1024))
21350 test_mkdir $DIR/$tdir
21351 for i in $(seq 1 $threads); do
21352 local file=$DIR/$tdir/file_$((i / 10))
21353 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
21356 for i in $(seq 1 $threads); do
21360 run_test 244b "multi-threaded write with group lock"
21363 local flagname="multi_mod_rpcs"
21364 local connect_data_name="max_mod_rpcs"
21367 # check if multiple modify RPCs flag is set
21368 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
21369 grep "connect_flags:")
21372 echo "$out" | grep -qw $flagname
21373 if [ $? -ne 0 ]; then
21374 echo "connect flag $flagname is not set"
21378 # check if multiple modify RPCs data is set
21379 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
21382 echo "$out" | grep -qw $connect_data_name ||
21383 error "import should have connect data $connect_data_name"
21385 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
21388 local flagname="multi_mod_rpcs"
21389 local connect_data_name="max_mod_rpcs"
21392 remote_mds_nodsh && skip "remote MDS with nodsh"
21393 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
21395 # check if multiple modify RPCs flag is set
21396 out=$(do_facet mds1 \
21397 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
21398 grep "connect_flags:")
21401 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
21403 # check if multiple modify RPCs data is set
21404 out=$(do_facet mds1 \
21405 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21407 [[ "$out" =~ $connect_data_name ]] ||
21410 error "missing connect data $connect_data_name"
21413 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21419 umount_client $submount
21424 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21426 skip_env "Fileset feature is not supported"
21428 local submount=${MOUNT}_$tdir
21431 mkdir -p $submount || error "mkdir $submount failed"
21432 FILESET="$FILESET/$tdir" mount_client $submount ||
21433 error "mount $submount failed"
21434 trap "cleanup_247 $submount" EXIT
21435 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21436 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21437 error "read $MOUNT/$tdir/$tfile failed"
21438 cleanup_247 $submount
21440 run_test 247a "mount subdir as fileset"
21443 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21444 skip_env "Fileset feature is not supported"
21446 local submount=${MOUNT}_$tdir
21448 rm -rf $MOUNT/$tdir
21449 mkdir -p $submount || error "mkdir $submount failed"
21451 FILESET="$FILESET/$tdir" mount_client $submount &&
21452 error "mount $submount should fail"
21455 run_test 247b "mount subdir that dose not exist"
21458 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21459 skip_env "Fileset feature is not supported"
21461 local submount=${MOUNT}_$tdir
21463 mkdir -p $MOUNT/$tdir/dir1
21464 mkdir -p $submount || error "mkdir $submount failed"
21465 trap "cleanup_247 $submount" EXIT
21466 FILESET="$FILESET/$tdir" mount_client $submount ||
21467 error "mount $submount failed"
21468 local fid=$($LFS path2fid $MOUNT/)
21469 $LFS fid2path $submount $fid && error "fid2path should fail"
21470 cleanup_247 $submount
21472 run_test 247c "running fid2path outside subdirectory root"
21475 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21476 skip "Fileset feature is not supported"
21478 local submount=${MOUNT}_$tdir
21480 mkdir -p $MOUNT/$tdir/dir1
21481 mkdir -p $submount || error "mkdir $submount failed"
21482 FILESET="$FILESET/$tdir" mount_client $submount ||
21483 error "mount $submount failed"
21484 trap "cleanup_247 $submount" EXIT
21486 local td=$submount/dir1
21487 local fid=$($LFS path2fid $td)
21488 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21490 # check that we get the same pathname back
21493 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21494 echo "$rootpath $fid"
21495 found=$($LFS fid2path $rootpath "$fid")
21496 [ -n "$found" ] || error "fid2path should succeed"
21497 [ "$found" == "$td" ] || error "fid2path $found != $td"
21499 # check wrong root path format
21500 rootpath=$submount"_wrong"
21501 found=$($LFS fid2path $rootpath "$fid")
21502 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21504 cleanup_247 $submount
21506 run_test 247d "running fid2path inside subdirectory root"
21510 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21512 skip "Fileset feature is not supported"
21514 local submount=${MOUNT}_$tdir
21517 mkdir -p $submount || error "mkdir $submount failed"
21518 FILESET="$FILESET/.." mount_client $submount &&
21519 error "mount $submount should fail"
21522 run_test 247e "mount .. as fileset"
21525 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21526 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
21527 skip "Need at least version 2.13.52"
21528 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21529 skip "Need at least version 2.14.50"
21530 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21532 skip "Fileset feature is not supported"
21534 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21535 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21536 error "mkdir remote failed"
21537 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21538 error "mkdir remote/subdir failed"
21539 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21540 error "mkdir striped failed"
21541 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
21543 local submount=${MOUNT}_$tdir
21545 mkdir -p $submount || error "mkdir $submount failed"
21546 stack_trap "rmdir $submount"
21550 local fileset=$FILESET
21551 local mdts=$(comma_list $(mdts_nodes))
21553 stat=$(do_facet mds1 $LCTL get_param -n \
21554 mdt.*MDT0000.enable_remote_subdir_mount)
21555 stack_trap "do_nodes $mdts $LCTL set_param \
21556 mdt.*.enable_remote_subdir_mount=$stat"
21558 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
21559 stack_trap "umount_client $submount"
21560 FILESET="$fileset/$tdir/remote" mount_client $submount &&
21561 error "mount remote dir $dir should fail"
21563 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
21564 $tdir/striped/. ; do
21565 FILESET="$fileset/$dir" mount_client $submount ||
21566 error "mount $dir failed"
21567 umount_client $submount
21570 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
21571 FILESET="$fileset/$tdir/remote" mount_client $submount ||
21572 error "mount $tdir/remote failed"
21574 run_test 247f "mount striped or remote directory as fileset"
21577 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
21578 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21579 skip "Need at least version 2.14.50"
21581 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
21582 error "mkdir $tdir failed"
21583 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
21585 local submount=${MOUNT}_$tdir
21587 mkdir -p $submount || error "mkdir $submount failed"
21588 stack_trap "rmdir $submount"
21590 FILESET="$fileset/$tdir" mount_client $submount ||
21591 error "mount $dir failed"
21592 stack_trap "umount $submount"
21594 local mdts=$(comma_list $(mdts_nodes))
21598 stat $submount > /dev/null
21599 cancel_lru_locks $MDC
21600 stat $submount > /dev/null
21601 stat $submount/$tfile > /dev/null
21602 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
21603 stat $submount/$tfile > /dev/null
21604 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
21605 awk '/getattr/ {sum += $2} END {print sum}')
21607 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
21609 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
21612 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
21613 [ -z "$fast_read_sav" ] && skip "no fast read support"
21615 # create a large file for fast read verification
21616 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
21618 # make sure the file is created correctly
21619 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
21620 { rm -f $DIR/$tfile; skip "file creation error"; }
21622 echo "Test 1: verify that fast read is 4 times faster on cache read"
21624 # small read with fast read enabled
21625 $LCTL set_param -n llite.*.fast_read=1
21626 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21627 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21628 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21629 # small read with fast read disabled
21630 $LCTL set_param -n llite.*.fast_read=0
21631 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21632 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21633 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21635 # verify that fast read is 4 times faster for cache read
21636 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
21637 error_not_in_vm "fast read was not 4 times faster: " \
21638 "$t_fast vs $t_slow"
21640 echo "Test 2: verify the performance between big and small read"
21641 $LCTL set_param -n llite.*.fast_read=1
21643 # 1k non-cache read
21644 cancel_lru_locks osc
21645 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21646 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21647 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21649 # 1M non-cache read
21650 cancel_lru_locks osc
21651 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21652 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21653 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21655 # verify that big IO is not 4 times faster than small IO
21656 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
21657 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
21659 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
21662 run_test 248a "fast read verification"
21665 # Default short_io_bytes=16384, try both smaller and larger sizes.
21666 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
21667 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
21668 echo "bs=53248 count=113 normal buffered write"
21669 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
21670 error "dd of initial data file failed"
21671 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
21673 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
21674 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
21675 error "dd with sync normal writes failed"
21676 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
21678 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
21679 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
21680 error "dd with sync small writes failed"
21681 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
21683 cancel_lru_locks osc
21685 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
21686 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
21687 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
21688 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
21689 iflag=direct || error "dd with O_DIRECT small read failed"
21690 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
21691 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
21692 error "compare $TMP/$tfile.1 failed"
21694 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
21695 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
21697 # just to see what the maximum tunable value is, and test parsing
21698 echo "test invalid parameter 2MB"
21699 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
21700 error "too-large short_io_bytes allowed"
21701 echo "test maximum parameter 512KB"
21702 # if we can set a larger short_io_bytes, run test regardless of version
21703 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
21704 # older clients may not allow setting it this large, that's OK
21705 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
21706 skip "Need at least client version 2.13.50"
21707 error "medium short_io_bytes failed"
21709 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21710 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
21712 echo "test large parameter 64KB"
21713 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
21714 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21716 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
21717 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
21718 error "dd with sync large writes failed"
21719 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
21721 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
21722 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
21723 num=$((113 * 4096 / PAGE_SIZE))
21724 echo "bs=$size count=$num oflag=direct large write $tfile.3"
21725 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
21726 error "dd with O_DIRECT large writes failed"
21727 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
21728 error "compare $DIR/$tfile.3 failed"
21730 cancel_lru_locks osc
21732 echo "bs=$size count=$num iflag=direct large read $tfile.2"
21733 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
21734 error "dd with O_DIRECT large read failed"
21735 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
21736 error "compare $TMP/$tfile.2 failed"
21738 echo "bs=$size count=$num iflag=direct large read $tfile.3"
21739 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
21740 error "dd with O_DIRECT large read failed"
21741 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
21742 error "compare $TMP/$tfile.3 failed"
21744 run_test 248b "test short_io read and write for both small and large sizes"
21746 test_249() { # LU-7890
21747 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
21748 skip "Need at least version 2.8.54"
21751 $LFS setstripe -c 1 $DIR/$tfile
21752 # Offset 2T == 4k * 512M
21753 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
21754 error "dd to 2T offset failed"
21756 run_test 249 "Write above 2T file size"
21759 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
21760 && skip "no 16TB file size limit on ZFS"
21762 $LFS setstripe -c 1 $DIR/$tfile
21763 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
21764 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
21765 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
21766 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
21767 conv=notrunc,fsync && error "append succeeded"
21770 run_test 250 "Write above 16T limit"
21773 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
21775 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
21776 #Skip once - writing the first stripe will succeed
21777 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21778 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
21779 error "short write happened"
21781 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21782 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
21783 error "short read happened"
21787 run_test 251 "Handling short read and write correctly"
21790 remote_mds_nodsh && skip "remote MDS with nodsh"
21791 remote_ost_nodsh && skip "remote OST with nodsh"
21792 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
21793 skip_env "ldiskfs only test"
21803 # check lr_reader on OST0000
21805 dev=$(facet_device $tgt)
21806 out=$(do_facet $tgt $LR_READER $dev)
21807 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21809 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
21810 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
21811 error "Invalid uuid returned by $LR_READER on target $tgt"
21812 echo -e "uuid returned by $LR_READER is '$uuid'\n"
21814 # check lr_reader -c on MDT0000
21816 dev=$(facet_device $tgt)
21817 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
21818 skip "$LR_READER does not support additional options"
21820 out=$(do_facet $tgt $LR_READER -c $dev)
21821 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21823 num=$(echo "$out" | grep -c "mdtlov")
21824 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
21825 error "Invalid number of mdtlov clients returned by $LR_READER"
21826 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
21828 # check lr_reader -cr on MDT0000
21829 out=$(do_facet $tgt $LR_READER -cr $dev)
21830 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21832 echo "$out" | grep -q "^reply_data:$" ||
21833 error "$LR_READER should have returned 'reply_data' section"
21834 num=$(echo "$out" | grep -c "client_generation")
21835 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
21837 run_test 252 "check lr_reader tool"
21840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21841 remote_mds_nodsh && skip "remote MDS with nodsh"
21842 remote_mgs_nodsh && skip "remote MGS with nodsh"
21846 local ost_name=$(ostname_from_index $ostidx)
21849 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
21850 do_facet $SINGLEMDS $LCTL get_param -n \
21851 osp.$mdtosc_proc1.reserved_mb_high ||
21852 skip "remote MDS does not support reserved_mb_high"
21856 wait_delete_completed
21859 pool_add $TESTNAME || error "Pool creation failed"
21860 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
21862 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
21863 error "Setstripe failed"
21865 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
21867 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
21869 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
21871 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21872 osp.$mdtosc_proc1.prealloc_status)
21873 echo "prealloc_status $oa_status"
21875 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
21876 error "File creation should fail"
21878 #object allocation was stopped, but we still able to append files
21879 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
21880 oflag=append || error "Append failed"
21882 rm -f $DIR/$tdir/$tfile.0
21884 # For this test, we want to delete the files we created to go out of
21885 # space but leave the watermark, so we remain nearly out of space
21886 ost_watermarks_enospc_delete_files $tfile $ostidx
21888 wait_delete_completed
21892 for i in $(seq 10 12); do
21893 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
21894 2>/dev/null || error "File creation failed after rm"
21897 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21898 osp.$mdtosc_proc1.prealloc_status)
21899 echo "prealloc_status $oa_status"
21901 if (( oa_status != 0 )); then
21902 error "Object allocation still disable after rm"
21905 run_test 253 "Check object allocation limit"
21908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21909 remote_mds_nodsh && skip "remote MDS with nodsh"
21911 local mdt=$(facet_svc $SINGLEMDS)
21913 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
21914 skip "MDS does not support changelog_size"
21918 changelog_register || error "changelog_register failed"
21920 changelog_clear 0 || error "changelog_clear failed"
21922 local size1=$(do_facet $SINGLEMDS \
21923 $LCTL get_param -n mdd.$mdt.changelog_size)
21924 echo "Changelog size $size1"
21927 $LFS mkdir -i 0 $DIR/$tdir
21929 mkdir -p $DIR/$tdir/pics/2008/zachy
21930 touch $DIR/$tdir/pics/2008/zachy/timestamp
21931 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
21932 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
21933 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
21934 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
21935 rm $DIR/$tdir/pics/desktop.jpg
21937 local size2=$(do_facet $SINGLEMDS \
21938 $LCTL get_param -n mdd.$mdt.changelog_size)
21939 echo "Changelog size after work $size2"
21941 (( $size2 > $size1 )) ||
21942 error "new Changelog size=$size2 less than old size=$size1"
21944 run_test 254 "Check changelog size"
21951 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
21952 awk -F: '{print $2}' | grep $type > /dev/null
21953 if [ $? -ne 0 ]; then
21963 lfs ladvise -a willread $file > /dev/null 2>&1
21964 if [ $? -eq 0 ]; then
21968 lfs ladvise -a willread $file 2>&1 |
21969 grep "Inappropriate ioctl for device" > /dev/null
21970 if [ $? -eq 0 ]; then
21977 bc <<<"scale=2; ($1 - $2) * 100 / $2"
21980 # run a random read IO workload
21981 # usage: random_read_iops <filename> <filesize> <iosize>
21982 random_read_iops() {
21985 local iosize=${3:-4096}
21987 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
21988 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
21991 drop_file_oss_cache() {
21995 $LFS ladvise -a dontneed $file 2>/dev/null ||
21996 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
21999 ladvise_willread_performance()
22002 local average_origin=0
22003 local average_cache=0
22004 local average_ladvise=0
22006 for ((i = 1; i <= $repeat; i++)); do
22007 echo "Iter $i/$repeat: reading without willread hint"
22008 cancel_lru_locks osc
22009 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22010 local speed_origin=$(random_read_iops $DIR/$tfile $size)
22011 echo "Iter $i/$repeat: uncached speed: $speed_origin"
22012 average_origin=$(bc <<<"$average_origin + $speed_origin")
22014 cancel_lru_locks osc
22015 local speed_cache=$(random_read_iops $DIR/$tfile $size)
22016 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
22017 average_cache=$(bc <<<"$average_cache + $speed_cache")
22019 cancel_lru_locks osc
22020 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22021 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
22022 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
22023 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
22024 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
22026 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
22027 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
22028 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
22030 speedup_cache=$(percent $average_cache $average_origin)
22031 speedup_ladvise=$(percent $average_ladvise $average_origin)
22033 echo "Average uncached read: $average_origin"
22034 echo "Average speedup with OSS cached read: " \
22035 "$average_cache = +$speedup_cache%"
22036 echo "Average speedup with ladvise willread: " \
22037 "$average_ladvise = +$speedup_ladvise%"
22039 local lowest_speedup=20
22040 if (( ${average_cache%.*} < $lowest_speedup )); then
22041 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
22042 " got $average_cache%. Skipping ladvise willread check."
22046 # the test won't work on ZFS until it supports 'ladvise dontneed', but
22047 # it is still good to run until then to exercise 'ladvise willread'
22048 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22049 [ "$ost1_FSTYPE" = "zfs" ] &&
22050 echo "osd-zfs does not support dontneed or drop_caches" &&
22053 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
22054 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
22055 error_not_in_vm "Speedup with willread is less than " \
22056 "$lowest_speedup%, got $average_ladvise%"
22060 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22061 skip "lustre < 2.8.54 does not support ladvise "
22062 remote_ost_nodsh && skip "remote OST with nodsh"
22064 stack_trap "rm -f $DIR/$tfile"
22065 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
22067 ladvise_no_type willread $DIR/$tfile &&
22068 skip "willread ladvise is not supported"
22070 ladvise_no_ioctl $DIR/$tfile &&
22071 skip "ladvise ioctl is not supported"
22074 local size=$((size_mb * 1048576))
22075 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22076 error "dd to $DIR/$tfile failed"
22078 lfs ladvise -a willread $DIR/$tfile ||
22079 error "Ladvise failed with no range argument"
22081 lfs ladvise -a willread -s 0 $DIR/$tfile ||
22082 error "Ladvise failed with no -l or -e argument"
22084 lfs ladvise -a willread -e 1 $DIR/$tfile ||
22085 error "Ladvise failed with only -e argument"
22087 lfs ladvise -a willread -l 1 $DIR/$tfile ||
22088 error "Ladvise failed with only -l argument"
22090 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
22091 error "End offset should not be smaller than start offset"
22093 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
22094 error "End offset should not be equal to start offset"
22096 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
22097 error "Ladvise failed with overflowing -s argument"
22099 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
22100 error "Ladvise failed with overflowing -e argument"
22102 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
22103 error "Ladvise failed with overflowing -l argument"
22105 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
22106 error "Ladvise succeeded with conflicting -l and -e arguments"
22108 echo "Synchronous ladvise should wait"
22110 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
22111 do_nodes $(comma_list $(osts_nodes)) \
22112 $LCTL set_param fail_val=$delay fail_loc=0x237
22114 local start_ts=$SECONDS
22115 lfs ladvise -a willread $DIR/$tfile ||
22116 error "Ladvise failed with no range argument"
22117 local end_ts=$SECONDS
22118 local inteval_ts=$((end_ts - start_ts))
22120 if [ $inteval_ts -lt $(($delay - 1)) ]; then
22121 error "Synchronous advice didn't wait reply"
22124 echo "Asynchronous ladvise shouldn't wait"
22125 local start_ts=$SECONDS
22126 lfs ladvise -a willread -b $DIR/$tfile ||
22127 error "Ladvise failed with no range argument"
22128 local end_ts=$SECONDS
22129 local inteval_ts=$((end_ts - start_ts))
22131 if [ $inteval_ts -gt $(($delay / 2)) ]; then
22132 error "Asynchronous advice blocked"
22135 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
22136 ladvise_willread_performance
22138 run_test 255a "check 'lfs ladvise -a willread'"
22144 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
22148 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22149 skip "lustre < 2.8.54 does not support ladvise "
22150 remote_ost_nodsh && skip "remote OST with nodsh"
22152 stack_trap "rm -f $DIR/$tfile"
22153 lfs setstripe -c 1 -i 0 $DIR/$tfile
22155 ladvise_no_type dontneed $DIR/$tfile &&
22156 skip "dontneed ladvise is not supported"
22158 ladvise_no_ioctl $DIR/$tfile &&
22159 skip "ladvise ioctl is not supported"
22161 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22162 [ "$ost1_FSTYPE" = "zfs" ] &&
22163 skip "zfs-osd does not support 'ladvise dontneed'"
22166 local size=$((size_mb * 1048576))
22167 # In order to prevent disturbance of other processes, only check 3/4
22168 # of the memory usage
22169 local kibibytes=$((size_mb * 1024 * 3 / 4))
22171 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22172 error "dd to $DIR/$tfile failed"
22174 #force write to complete before dropping OST cache & checking memory
22177 local total=$(facet_meminfo ost1 MemTotal)
22178 echo "Total memory: $total KiB"
22180 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
22181 local before_read=$(facet_meminfo ost1 Cached)
22182 echo "Cache used before read: $before_read KiB"
22184 lfs ladvise -a willread $DIR/$tfile ||
22185 error "Ladvise willread failed"
22186 local after_read=$(facet_meminfo ost1 Cached)
22187 echo "Cache used after read: $after_read KiB"
22189 lfs ladvise -a dontneed $DIR/$tfile ||
22190 error "Ladvise dontneed again failed"
22191 local no_read=$(facet_meminfo ost1 Cached)
22192 echo "Cache used after dontneed ladvise: $no_read KiB"
22194 if [ $total -lt $((before_read + kibibytes)) ]; then
22195 echo "Memory is too small, abort checking"
22199 if [ $((before_read + kibibytes)) -gt $after_read ]; then
22200 error "Ladvise willread should use more memory" \
22201 "than $kibibytes KiB"
22204 if [ $((no_read + kibibytes)) -gt $after_read ]; then
22205 error "Ladvise dontneed should release more memory" \
22206 "than $kibibytes KiB"
22209 run_test 255b "check 'lfs ladvise -a dontneed'"
22212 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
22213 skip "lustre < 2.10.50 does not support lockahead"
22215 local ost1_imp=$(get_osc_import_name client ost1)
22216 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22224 test_mkdir -p $DIR/$tdir
22225 $LFS setstripe -i 0 -c 1 $DIR/$tdir
22227 #test 10 returns only success/failure
22229 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22231 if [ $rc -eq 255 ]; then
22232 error "Ladvise test${i} failed, ${rc}"
22235 #test 11 counts lock enqueue requests, all others count new locks
22237 count=$(do_facet ost1 \
22238 $LCTL get_param -n ost.OSS.ost.stats)
22239 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
22241 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22243 if [ $rc -eq 255 ]; then
22244 error "Ladvise test${i} failed, ${rc}"
22247 new_count=$(do_facet ost1 \
22248 $LCTL get_param -n ost.OSS.ost.stats)
22249 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
22250 awk '{ print $2 }')
22252 difference="$((new_count - count))"
22253 if [ $difference -ne $rc ]; then
22254 error "Ladvise test${i}, bad enqueue count, returned " \
22255 "${rc}, actual ${difference}"
22258 for i in $(seq 12 21); do
22259 # If we do not do this, we run the risk of having too many
22260 # locks and starting lock cancellation while we are checking
22262 cancel_lru_locks osc
22264 count=$($LCTL get_param -n \
22265 ldlm.namespaces.$imp_name.lock_unused_count)
22267 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22269 if [ $rc -eq 255 ]; then
22270 error "Ladvise test ${i} failed, ${rc}"
22273 new_count=$($LCTL get_param -n \
22274 ldlm.namespaces.$imp_name.lock_unused_count)
22275 difference="$((new_count - count))"
22277 # Test 15 output is divided by 100 to map down to valid return
22278 if [ $i -eq 15 ]; then
22282 if [ $difference -ne $rc ]; then
22283 error "Ladvise test ${i}, bad lock count, returned " \
22284 "${rc}, actual ${difference}"
22288 #test 22 returns only success/failure
22290 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22292 if [ $rc -eq 255 ]; then
22293 error "Ladvise test${i} failed, ${rc}"
22296 run_test 255c "suite of ladvise lockahead tests"
22299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22300 remote_mds_nodsh && skip "remote MDS with nodsh"
22301 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22302 changelog_users $SINGLEMDS | grep "^cl" &&
22303 skip "active changelog user"
22309 mdt_dev=$(facet_device $SINGLEMDS)
22312 changelog_register || error "changelog_register failed"
22315 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
22317 changelog_clear 0 || error "changelog_clear failed"
22320 touch $DIR/$tdir/{1..10}
22323 stop $SINGLEMDS || error "Fail to stop MDT"
22326 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
22327 error "Fail to start MDT"
22329 #after mount new plainllog is used
22330 touch $DIR/$tdir/{11..19}
22331 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
22332 stack_trap "rm -f $tmpfile"
22333 cat_sl=$(do_facet $SINGLEMDS "sync; \
22334 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22335 llog_reader $tmpfile | grep -c type=1064553b")
22336 do_facet $SINGLEMDS llog_reader $tmpfile
22338 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
22340 changelog_clear 0 || error "changelog_clear failed"
22342 cat_sl=$(do_facet $SINGLEMDS "sync; \
22343 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22344 llog_reader $tmpfile | grep -c type=1064553b")
22346 if (( cat_sl == 2 )); then
22347 error "Empty plain llog was not deleted from changelog catalog"
22348 elif (( cat_sl != 1 )); then
22349 error "Active plain llog shouldn't be deleted from catalog"
22352 run_test 256 "Check llog delete for empty and not full state"
22355 remote_mds_nodsh && skip "remote MDS with nodsh"
22356 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22357 skip "Need MDS version at least 2.8.55"
22359 test_mkdir $DIR/$tdir
22361 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
22362 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
22365 #define OBD_FAIL_MDS_XATTR_REP 0x161
22366 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22367 local facet=mds$((mdtidx + 1))
22368 set_nodes_failloc $(facet_active_host $facet) 0x80000161
22369 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
22371 stop $facet || error "stop MDS failed"
22372 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
22373 error "start MDS fail"
22374 wait_recovery_complete $facet
22376 run_test 257 "xattr locks are not lost"
22378 # Verify we take the i_mutex when security requires it
22380 #define OBD_FAIL_IMUTEX_SEC 0x141c
22381 $LCTL set_param fail_loc=0x141c
22383 chmod u+s $DIR/$tfile
22384 chmod a+rwx $DIR/$tfile
22385 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22387 if [ $RC -ne 0 ]; then
22388 error "error, failed to take i_mutex, rc=$?"
22392 run_test 258a "verify i_mutex security behavior when suid attributes is set"
22394 # Verify we do NOT take the i_mutex in the normal case
22396 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
22397 $LCTL set_param fail_loc=0x141d
22400 chmod a+rw $DIR/$tfile
22401 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22403 if [ $RC -ne 0 ]; then
22404 error "error, took i_mutex unnecessarily, rc=$?"
22409 run_test 258b "verify i_mutex security behavior"
22412 local file=$DIR/$tfile
22416 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22418 stack_trap "rm -f $file" EXIT
22420 wait_delete_completed
22421 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22422 echo "before: $before"
22424 $LFS setstripe -i 0 -c 1 $file
22425 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22427 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22428 echo "after write: $after"
22430 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22431 do_facet ost1 $LCTL set_param fail_loc=0x2301
22433 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22434 echo "after truncate: $after"
22437 do_facet ost1 $LCTL set_param fail_loc=0
22438 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22440 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22441 echo "after restart: $after"
22442 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22443 error "missing truncate?"
22447 run_test 259 "crash at delayed truncate"
22450 #define OBD_FAIL_MDC_CLOSE 0x806
22451 $LCTL set_param fail_loc=0x80000806
22455 run_test 260 "Check mdc_close fail"
22457 ### Data-on-MDT sanity tests ###
22459 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22460 skip "Need MDS version at least 2.10.55 for DoM"
22463 local dom=$DIR/$tdir/dom_file
22464 local tmp=$DIR/$tdir/tmp_file
22466 mkdir_on_mdt0 $DIR/$tdir
22468 # basic checks for DoM component creation
22469 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22470 error "Can set MDT layout to non-first entry"
22472 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22473 error "Can define multiple entries as MDT layout"
22475 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22477 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22478 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22479 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22481 local mdtidx=$($LFS getstripe -m $dom)
22482 local mdtname=MDT$(printf %04x $mdtidx)
22483 local facet=mds$((mdtidx + 1))
22484 local space_check=1
22486 # Skip free space checks with ZFS
22487 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22491 local size_tmp=$((65536 * 3))
22492 local mdtfree1=$(do_facet $facet \
22493 lctl get_param -n osd*.*$mdtname.kbytesfree)
22495 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22496 # check also direct IO along write
22497 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22498 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22500 cmp $tmp $dom || error "file data is different"
22501 [ $(stat -c%s $dom) == $size_tmp ] ||
22502 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22503 if [ $space_check == 1 ]; then
22504 local mdtfree2=$(do_facet $facet \
22505 lctl get_param -n osd*.*$mdtname.kbytesfree)
22507 # increase in usage from by $size_tmp
22508 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22509 error "MDT free space wrong after write: " \
22510 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22514 local size_dom=10000
22516 $TRUNCATE $dom $size_dom
22517 [ $(stat -c%s $dom) == $size_dom ] ||
22518 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22519 if [ $space_check == 1 ]; then
22520 mdtfree1=$(do_facet $facet \
22521 lctl get_param -n osd*.*$mdtname.kbytesfree)
22522 # decrease in usage from $size_tmp to new $size_dom
22523 [ $(($mdtfree1 - $mdtfree2)) -ge \
22524 $(((size_tmp - size_dom) / 1024)) ] ||
22525 error "MDT free space is wrong after truncate: " \
22526 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22532 size_dom=$((size_dom + size_tmp))
22533 [ $(stat -c%s $dom) == $size_dom ] ||
22534 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22535 if [ $space_check == 1 ]; then
22536 mdtfree2=$(do_facet $facet \
22537 lctl get_param -n osd*.*$mdtname.kbytesfree)
22538 # increase in usage by $size_tmp from previous
22539 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22540 error "MDT free space is wrong after append: " \
22541 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22546 if [ $space_check == 1 ]; then
22547 mdtfree1=$(do_facet $facet \
22548 lctl get_param -n osd*.*$mdtname.kbytesfree)
22549 # decrease in usage by $size_dom from previous
22550 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
22551 error "MDT free space is wrong after removal: " \
22552 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
22555 # combined striping
22556 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
22557 error "Can't create DoM + OST striping"
22559 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
22560 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22561 # check also direct IO along write
22562 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22564 cmp $tmp $dom || error "file data is different"
22565 [ $(stat -c%s $dom) == $size_tmp ] ||
22566 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22571 run_test 270a "DoM: basic functionality tests"
22574 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22575 skip "Need MDS version at least 2.10.55"
22577 local dom=$DIR/$tdir/dom_file
22578 local max_size=1048576
22580 mkdir -p $DIR/$tdir
22581 $LFS setstripe -E $max_size -L mdt $dom
22583 # truncate over the limit
22584 $TRUNCATE $dom $(($max_size + 1)) &&
22585 error "successful truncate over the maximum size"
22586 # write over the limit
22587 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
22588 error "successful write over the maximum size"
22589 # append over the limit
22590 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
22591 echo "12345" >> $dom && error "successful append over the maximum size"
22596 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
22599 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22600 skip "Need MDS version at least 2.10.55"
22602 mkdir -p $DIR/$tdir
22603 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22605 # check files inherit DoM EA
22606 touch $DIR/$tdir/first
22607 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
22608 error "bad pattern"
22609 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
22610 error "bad stripe count"
22611 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
22612 error "bad stripe size"
22614 # check directory inherits DoM EA and uses it as default
22615 mkdir $DIR/$tdir/subdir
22616 touch $DIR/$tdir/subdir/second
22617 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
22618 error "bad pattern in sub-directory"
22619 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
22620 error "bad stripe count in sub-directory"
22621 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
22622 error "bad stripe size in sub-directory"
22625 run_test 270c "DoM: DoM EA inheritance tests"
22628 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22629 skip "Need MDS version at least 2.10.55"
22631 mkdir -p $DIR/$tdir
22632 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22634 # inherit default DoM striping
22635 mkdir $DIR/$tdir/subdir
22636 touch $DIR/$tdir/subdir/f1
22638 # change default directory striping
22639 $LFS setstripe -c 1 $DIR/$tdir/subdir
22640 touch $DIR/$tdir/subdir/f2
22641 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
22642 error "wrong default striping in file 2"
22643 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
22644 error "bad pattern in file 2"
22647 run_test 270d "DoM: change striping from DoM to RAID0"
22650 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22651 skip "Need MDS version at least 2.10.55"
22653 mkdir -p $DIR/$tdir/dom
22654 mkdir -p $DIR/$tdir/norm
22657 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
22658 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
22660 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
22661 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
22663 # find DoM files by layout
22664 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
22665 [ $NUM -eq $DOMFILES ] ||
22666 error "lfs find -L: found $NUM, expected $DOMFILES"
22667 echo "Test 1: lfs find 20 DOM files by layout: OK"
22669 # there should be 1 dir with default DOM striping
22670 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
22672 error "lfs find -L: found $NUM, expected 1 dir"
22673 echo "Test 2: lfs find 1 DOM dir by layout: OK"
22675 # find DoM files by stripe size
22676 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
22677 [ $NUM -eq $DOMFILES ] ||
22678 error "lfs find -S: found $NUM, expected $DOMFILES"
22679 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
22681 # find files by stripe offset except DoM files
22682 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
22683 [ $NUM -eq $NORMFILES ] ||
22684 error "lfs find -i: found $NUM, expected $NORMFILES"
22685 echo "Test 5: lfs find no DOM files by stripe index: OK"
22688 run_test 270e "DoM: lfs find with DoM files test"
22691 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22692 skip "Need MDS version at least 2.10.55"
22694 local mdtname=${FSNAME}-MDT0000-mdtlov
22695 local dom=$DIR/$tdir/dom_file
22696 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
22697 lod.$mdtname.dom_stripesize)
22698 local dom_limit=131072
22700 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
22701 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22702 lod.$mdtname.dom_stripesize)
22703 [ ${dom_limit} -eq ${dom_current} ] ||
22704 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
22706 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22707 $LFS setstripe -d $DIR/$tdir
22708 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
22709 error "Can't set directory default striping"
22711 # exceed maximum stripe size
22712 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22713 error "Can't create file with $((dom_limit * 2)) DoM stripe"
22714 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
22715 error "Able to create DoM component size more than LOD limit"
22717 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22718 dom_current=$(do_facet mds1 $LCTL get_param -n \
22719 lod.$mdtname.dom_stripesize)
22720 [ 0 -eq ${dom_current} ] ||
22721 error "Can't set zero DoM stripe limit"
22724 # attempt to create DoM file on server with disabled DoM should
22725 # remove DoM entry from layout and be succeed
22726 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
22727 error "Can't create DoM file (DoM is disabled)"
22728 [ $($LFS getstripe -L $dom) == "mdt" ] &&
22729 error "File has DoM component while DoM is disabled"
22732 # attempt to create DoM file with only DoM stripe should return error
22733 $LFS setstripe -E $dom_limit -L mdt $dom &&
22734 error "Able to create DoM-only file while DoM is disabled"
22736 # too low values to be aligned with smallest stripe size 64K
22737 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
22738 dom_current=$(do_facet mds1 $LCTL get_param -n \
22739 lod.$mdtname.dom_stripesize)
22740 [ 30000 -eq ${dom_current} ] &&
22741 error "Can set too small DoM stripe limit"
22743 # 64K is a minimal stripe size in Lustre, expect limit of that size
22744 [ 65536 -eq ${dom_current} ] ||
22745 error "Limit is not set to 64K but ${dom_current}"
22747 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
22748 dom_current=$(do_facet mds1 $LCTL get_param -n \
22749 lod.$mdtname.dom_stripesize)
22751 [ 2147483648 -eq ${dom_current} ] &&
22752 error "Can set too large DoM stripe limit"
22754 do_facet mds1 $LCTL set_param -n \
22755 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
22756 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22757 error "Can't create DoM component size after limit change"
22758 do_facet mds1 $LCTL set_param -n \
22759 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
22760 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
22761 error "Can't create DoM file after limit decrease"
22762 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
22763 error "Can create big DoM component after limit decrease"
22764 touch ${dom}_def ||
22765 error "Can't create file with old default layout"
22767 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
22770 run_test 270f "DoM: maximum DoM stripe size checks"
22773 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22774 skip "Need MDS version at least 2.13.52"
22775 local dom=$DIR/$tdir/$tfile
22777 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22778 local lodname=${FSNAME}-MDT0000-mdtlov
22780 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22781 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
22782 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
22783 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22785 local dom_limit=1024
22786 local dom_threshold="50%"
22788 $LFS setstripe -d $DIR/$tdir
22789 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
22790 error "Can't set directory default striping"
22792 do_facet mds1 $LCTL set_param -n \
22793 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
22794 # set 0 threshold and create DOM file to change tunable stripesize
22795 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
22796 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22797 error "Failed to create $dom file"
22798 # now tunable dom_cur_stripesize should reach maximum
22799 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22800 lod.${lodname}.dom_stripesize_cur_kb)
22801 [[ $dom_current == $dom_limit ]] ||
22802 error "Current DOM stripesize is not maximum"
22805 # set threshold for further tests
22806 do_facet mds1 $LCTL set_param -n \
22807 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
22808 echo "DOM threshold is $dom_threshold free space"
22811 # Spoof bfree to exceed threshold
22812 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
22813 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
22814 for spfree in 40 20 0 15 30 55; do
22815 do_facet mds1 $LCTL set_param -n fail_val=$spfree
22816 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22817 error "Failed to create $dom file"
22818 dom_def=$(do_facet mds1 $LCTL get_param -n \
22819 lod.${lodname}.dom_stripesize_cur_kb)
22820 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
22821 [[ $dom_def != $dom_current ]] ||
22822 error "Default stripe size was not changed"
22823 if (( spfree > 0 )) ; then
22824 dom_set=$($LFS getstripe -S $dom)
22825 (( dom_set == dom_def * 1024 )) ||
22826 error "DOM component size is still old"
22828 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22829 error "DoM component is set with no free space"
22832 dom_current=$dom_def
22835 run_test 270g "DoM: default DoM stripe size depends on free space"
22838 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22839 skip "Need MDS version at least 2.13.53"
22841 local mdtname=${FSNAME}-MDT0000-mdtlov
22842 local dom=$DIR/$tdir/$tfile
22843 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22845 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
22846 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22848 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22849 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
22850 error "can't create OST file"
22851 # mirrored file with DOM entry in the second mirror
22852 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
22853 error "can't create mirror with DoM component"
22855 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22857 # DOM component in the middle and has other enries in the same mirror,
22858 # should succeed but lost DoM component
22859 $LFS setstripe --copy=${dom}_1 $dom ||
22860 error "Can't create file from OST|DOM mirror layout"
22861 # check new file has no DoM layout after all
22862 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22863 error "File has DoM component while DoM is disabled"
22865 run_test 270h "DoM: DoM stripe removal when disabled on server"
22868 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
22869 skip "Need MDS version at least 2.14.54"
22872 # DoM with plain layout
22873 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
22874 error "default plain layout with DoM must fail"
22875 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
22876 error "setstripe plain file layout with DoM must fail"
22877 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
22878 error "default DoM layout with bad striping must fail"
22879 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
22880 error "setstripe to DoM layout with bad striping must fail"
22883 run_test 270i "DoM: setting invalid DoM striping should fail"
22886 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22887 skip "Need MDS version at least 2.10.55"
22889 local dom=$DIR/$tdir/dom
22891 mkdir -p $DIR/$tdir
22893 $LFS setstripe -E 1024K -L mdt $dom
22895 lctl set_param -n mdc.*.stats=clear
22896 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22897 cat $dom > /dev/null
22898 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
22899 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
22903 run_test 271a "DoM: data is cached for read after write"
22906 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22907 skip "Need MDS version at least 2.10.55"
22909 local dom=$DIR/$tdir/dom
22911 mkdir -p $DIR/$tdir
22913 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22915 lctl set_param -n mdc.*.stats=clear
22916 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22917 cancel_lru_locks mdc
22918 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
22919 # second stat to check size is cached on client
22920 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
22921 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22922 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
22925 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
22928 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22929 skip "Need MDS version at least 2.10.55"
22931 local dom=$DIR/$tdir/dom
22933 mkdir -p $DIR/$tdir
22935 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22937 lctl set_param -n mdc.*.stats=clear
22938 lctl set_param -n osc.*.stats=clear
22939 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
22940 cancel_lru_locks mdc
22941 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22942 # second stat to check size is cached on client
22943 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22944 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22945 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
22946 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
22947 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
22950 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
22956 local mdt=MDT$(printf %04x $mdtidx)
22958 if [ -z $param ]; then
22959 lctl get_param -n mdc.*$mdt*.stats
22961 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
22966 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22967 skip "Need MDS version at least 2.10.55"
22969 local dom=$DIR/$tdir/dom
22971 mkdir -p $DIR/$tdir
22973 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22975 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22976 local facet=mds$((mdtidx + 1))
22978 cancel_lru_locks mdc
22979 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
22980 createmany -o $dom 1000
22981 lctl set_param -n mdc.*.stats=clear
22982 smalliomany -w $dom 1000 200
22983 get_mdc_stats $mdtidx
22984 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22985 # Each file has 1 open, 1 IO enqueues, total 2000
22986 # but now we have also +1 getxattr for security.capability, total 3000
22987 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
22988 unlinkmany $dom 1000
22990 cancel_lru_locks mdc
22991 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
22992 createmany -o $dom 1000
22993 lctl set_param -n mdc.*.stats=clear
22994 smalliomany -w $dom 1000 200
22995 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22996 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
22997 # for OPEN and IO lock.
22998 [ $((enq - enq_2)) -ge 1000 ] ||
22999 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
23000 unlinkmany $dom 1000
23003 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
23005 cleanup_271def_tests() {
23011 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23012 skip "Need MDS version at least 2.10.57"
23014 local dom=$DIR/$tdir/dom
23015 local tmp=$TMP/$tfile
23016 trap "cleanup_271def_tests $tmp" EXIT
23018 mkdir -p $DIR/$tdir
23020 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23022 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23024 cancel_lru_locks mdc
23025 dd if=/dev/urandom of=$tmp bs=1000 count=1
23026 dd if=$tmp of=$dom bs=1000 count=1
23027 cancel_lru_locks mdc
23029 cat /etc/hosts >> $tmp
23030 lctl set_param -n mdc.*.stats=clear
23032 # append data to the same file it should update local page
23033 echo "Append to the same page"
23034 cat /etc/hosts >> $dom
23035 local num=$(get_mdc_stats $mdtidx ost_read)
23036 local ra=$(get_mdc_stats $mdtidx req_active)
23037 local rw=$(get_mdc_stats $mdtidx req_waittime)
23039 [ -z $num ] || error "$num READ RPC occured"
23040 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23044 cmp $tmp $dom || error "file miscompare"
23046 cancel_lru_locks mdc
23047 lctl set_param -n mdc.*.stats=clear
23049 echo "Open and read file"
23050 cat $dom > /dev/null
23051 local num=$(get_mdc_stats $mdtidx ost_read)
23052 local ra=$(get_mdc_stats $mdtidx req_active)
23053 local rw=$(get_mdc_stats $mdtidx req_waittime)
23055 [ -z $num ] || error "$num READ RPC occured"
23056 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23060 cmp $tmp $dom || error "file miscompare"
23064 run_test 271d "DoM: read on open (1K file in reply buffer)"
23067 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23068 skip "Need MDS version at least 2.10.57"
23070 local dom=$DIR/$tdir/dom
23071 local tmp=$TMP/$tfile
23072 trap "cleanup_271def_tests $tmp" EXIT
23074 mkdir -p $DIR/$tdir
23076 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23078 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23080 cancel_lru_locks mdc
23081 dd if=/dev/urandom of=$tmp bs=265000 count=1
23082 dd if=$tmp of=$dom bs=265000 count=1
23083 cancel_lru_locks mdc
23084 cat /etc/hosts >> $tmp
23085 lctl set_param -n mdc.*.stats=clear
23087 echo "Append to the same page"
23088 cat /etc/hosts >> $dom
23089 local num=$(get_mdc_stats $mdtidx ost_read)
23090 local ra=$(get_mdc_stats $mdtidx req_active)
23091 local rw=$(get_mdc_stats $mdtidx req_waittime)
23093 [ -z $num ] || error "$num READ RPC occured"
23094 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23098 cmp $tmp $dom || error "file miscompare"
23100 cancel_lru_locks mdc
23101 lctl set_param -n mdc.*.stats=clear
23103 echo "Open and read file"
23104 cat $dom > /dev/null
23105 local num=$(get_mdc_stats $mdtidx ost_read)
23106 local ra=$(get_mdc_stats $mdtidx req_active)
23107 local rw=$(get_mdc_stats $mdtidx req_waittime)
23109 [ -z $num ] && num=0
23110 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
23111 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23115 cmp $tmp $dom || error "file miscompare"
23119 run_test 271f "DoM: read on open (200K file and read tail)"
23122 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
23123 skip "Skipping due to old client or server version"
23125 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
23127 $CHECKSTAT -t file $DIR1/$tfile
23129 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
23132 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
23133 $LCTL set_param fail_loc=0x80000314
23134 rm $DIR1/$tfile || error "Unlink fails"
23136 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
23137 [ $RC -eq 0 ] || error "Failed write to stale object"
23139 run_test 271g "Discard DoM data vs client flush race"
23142 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23143 skip "Need MDS version at least 2.11.50"
23145 local dom=$DIR/$tdir/dom
23146 mkdir -p $DIR/$tdir
23148 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
23149 dd if=/dev/urandom of=$dom bs=512K count=1 ||
23150 error "failed to write data into $dom"
23151 local old_md5=$(md5sum $dom)
23153 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
23154 error "failed to migrate to the same DoM component"
23156 local new_md5=$(md5sum $dom)
23158 [ "$old_md5" == "$new_md5" ] ||
23159 error "md5sum differ: $old_md5, $new_md5"
23161 [ $($LFS getstripe -c $dom) -eq 2 ] ||
23162 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
23164 run_test 272a "DoM migration: new layout with the same DOM component"
23167 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23168 skip "Need MDS version at least 2.11.50"
23170 local dom=$DIR/$tdir/dom
23171 mkdir -p $DIR/$tdir
23172 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23174 local mdtidx=$($LFS getstripe -m $dom)
23175 local mdtname=MDT$(printf %04x $mdtidx)
23176 local facet=mds$((mdtidx + 1))
23178 local mdtfree1=$(do_facet $facet \
23179 lctl get_param -n osd*.*$mdtname.kbytesfree)
23180 dd if=/dev/urandom of=$dom bs=2M count=1 ||
23181 error "failed to write data into $dom"
23182 local old_md5=$(md5sum $dom)
23183 cancel_lru_locks mdc
23184 local mdtfree1=$(do_facet $facet \
23185 lctl get_param -n osd*.*$mdtname.kbytesfree)
23187 $LFS migrate -c2 $dom ||
23188 error "failed to migrate to the new composite layout"
23189 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23190 error "MDT stripe was not removed"
23192 cancel_lru_locks mdc
23193 local new_md5=$(md5sum $dom)
23194 [ "$old_md5" == "$new_md5" ] ||
23195 error "$old_md5 != $new_md5"
23197 # Skip free space checks with ZFS
23198 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23199 local mdtfree2=$(do_facet $facet \
23200 lctl get_param -n osd*.*$mdtname.kbytesfree)
23201 [ $mdtfree2 -gt $mdtfree1 ] ||
23202 error "MDT space is not freed after migration"
23206 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
23209 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23210 skip "Need MDS version at least 2.11.50"
23212 local dom=$DIR/$tdir/$tfile
23213 mkdir -p $DIR/$tdir
23214 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23216 local mdtidx=$($LFS getstripe -m $dom)
23217 local mdtname=MDT$(printf %04x $mdtidx)
23218 local facet=mds$((mdtidx + 1))
23220 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23221 error "failed to write data into $dom"
23222 local old_md5=$(md5sum $dom)
23223 cancel_lru_locks mdc
23224 local mdtfree1=$(do_facet $facet \
23225 lctl get_param -n osd*.*$mdtname.kbytesfree)
23227 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
23228 error "failed to migrate to the new composite layout"
23229 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
23230 error "MDT stripe was not removed"
23232 cancel_lru_locks mdc
23233 local new_md5=$(md5sum $dom)
23234 [ "$old_md5" == "$new_md5" ] ||
23235 error "$old_md5 != $new_md5"
23237 # Skip free space checks with ZFS
23238 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23239 local mdtfree2=$(do_facet $facet \
23240 lctl get_param -n osd*.*$mdtname.kbytesfree)
23241 [ $mdtfree2 -gt $mdtfree1 ] ||
23242 error "MDS space is not freed after migration"
23246 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
23249 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23250 skip "Need MDS version at least 2.12.55"
23252 local dom=$DIR/$tdir/$tfile
23253 mkdir -p $DIR/$tdir
23254 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23256 local mdtidx=$($LFS getstripe -m $dom)
23257 local mdtname=MDT$(printf %04x $mdtidx)
23258 local facet=mds$((mdtidx + 1))
23260 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23261 error "failed to write data into $dom"
23262 local old_md5=$(md5sum $dom)
23263 cancel_lru_locks mdc
23264 local mdtfree1=$(do_facet $facet \
23265 lctl get_param -n osd*.*$mdtname.kbytesfree)
23267 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
23268 error "failed mirroring to the new composite layout"
23269 $LFS mirror resync $dom ||
23270 error "failed mirror resync"
23271 $LFS mirror split --mirror-id 1 -d $dom ||
23272 error "failed mirror split"
23274 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23275 error "MDT stripe was not removed"
23277 cancel_lru_locks mdc
23278 local new_md5=$(md5sum $dom)
23279 [ "$old_md5" == "$new_md5" ] ||
23280 error "$old_md5 != $new_md5"
23282 # Skip free space checks with ZFS
23283 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23284 local mdtfree2=$(do_facet $facet \
23285 lctl get_param -n osd*.*$mdtname.kbytesfree)
23286 [ $mdtfree2 -gt $mdtfree1 ] ||
23287 error "MDS space is not freed after DOM mirror deletion"
23291 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
23294 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23295 skip "Need MDS version at least 2.12.55"
23297 local dom=$DIR/$tdir/$tfile
23298 mkdir -p $DIR/$tdir
23299 $LFS setstripe -c 2 $dom
23301 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23302 error "failed to write data into $dom"
23303 local old_md5=$(md5sum $dom)
23306 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
23307 error "failed mirroring to the DOM layout"
23308 $LFS mirror resync $dom ||
23309 error "failed mirror resync"
23310 $LFS mirror split --mirror-id 1 -d $dom ||
23311 error "failed mirror split"
23313 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23314 error "MDT stripe wasn't set"
23317 local new_md5=$(md5sum $dom)
23318 [ "$old_md5" == "$new_md5" ] ||
23319 error "$old_md5 != $new_md5"
23323 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
23326 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23327 skip "Need MDS version at least 2.12.55"
23329 local dom=$DIR/$tdir/$tfile
23330 mkdir -p $DIR/$tdir
23331 $LFS setstripe -c 2 $dom
23333 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23334 error "failed to write data into $dom"
23335 local old_md5=$(md5sum $dom)
23338 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
23339 error "failed migrating to the DOM file"
23341 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23342 error "MDT stripe wasn't set"
23345 local new_md5=$(md5sum $dom)
23346 [ "$old_md5" != "$new_md5" ] &&
23347 error "$old_md5 != $new_md5"
23351 run_test 272f "DoM migration: OST-striped file to DOM file"
23354 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23355 skip "Need MDS version at least 2.11.50"
23357 # Layout swap cannot be done if either file has DOM component,
23358 # this will never be supported, migration should be used instead
23360 local dom=$DIR/$tdir/$tfile
23361 mkdir -p $DIR/$tdir
23363 $LFS setstripe -c2 ${dom}_plain
23364 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
23365 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
23366 error "can swap layout with DoM component"
23367 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
23368 error "can swap layout with DoM component"
23370 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
23371 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
23372 error "can swap layout with DoM component"
23373 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
23374 error "can swap layout with DoM component"
23377 run_test 273a "DoM: layout swapping should fail with DOM"
23380 mkdir -p $DIR/$tdir
23381 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
23383 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
23384 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
23386 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
23388 run_test 273b "DoM: race writeback and object destroy"
23391 remote_ost_nodsh && skip "remote OST with nodsh"
23392 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
23393 skip "Need OST version >= 2.10.57"
23395 local file=$DIR/$tfile
23398 oss=$(comma_list $(osts_nodes))
23400 dd if=/dev/urandom of=$file bs=1M count=2 ||
23401 error "failed to create a file"
23402 cancel_lru_locks osc
23405 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23406 error "failed to read a file"
23408 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
23409 $LCTL set_param fail_loc=0x8000031f
23411 cancel_lru_locks osc &
23414 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23415 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23416 #IO takes another lock, but matches the PENDING one
23417 #and places it to the IO RPC
23418 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23419 error "failed to read a file with PENDING lock"
23421 run_test 275 "Read on a canceled duplicate lock"
23424 remote_ost_nodsh && skip "remote OST with nodsh"
23427 do_facet ost1 "(while true; do \
23428 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23429 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23432 for LOOP in $(seq 20); do
23434 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23437 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23438 rm $TMP/sanity_276_pid"
23440 run_test 276 "Race between mount and obd_statfs"
23443 $LCTL set_param ldlm.namespaces.*.lru_size=0
23444 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23445 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23446 grep ^used_mb | awk '{print $2}')
23447 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23448 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23449 oflag=direct conv=notrunc
23450 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23451 grep ^used_mb | awk '{print $2}')
23452 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23454 run_test 277 "Direct IO shall drop page cache"
23457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23458 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23459 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23460 skip "needs the same host for mdt1 mdt2" && return
23465 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23466 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23472 echo "Starting MDTs"
23473 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23475 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23477 do_facet mds2 $LCTL set_param fail_loc=0
23479 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23480 wait_recovery_complete mds2
23482 run_test 278 "Race starting MDS between MDTs stop/start"
23485 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23486 skip "Need MGS version at least 2.13.52"
23487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23488 combined_mgs_mds || skip "needs combined MGS/MDT"
23490 umount_client $MOUNT
23491 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23492 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23494 mount_client $MOUNT &
23496 stop mgs || error "stop mgs failed"
23497 #for a race mgs would crash
23498 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23499 # make sure we unmount client before remounting
23501 umount_client $MOUNT
23502 mount_client $MOUNT || error "mount client failed"
23504 run_test 280 "Race between MGS umount and client llog processing"
23506 cleanup_test_300() {
23510 test_striped_dir() {
23515 mkdir -p $DIR/$tdir
23517 SAVE_UMASK=$(umask)
23518 trap cleanup_test_300 RETURN EXIT
23520 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23521 $DIR/$tdir/striped_dir ||
23522 error "set striped dir error"
23524 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23525 [ "$mode" = "755" ] || error "expect 755 got $mode"
23527 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23528 error "getdirstripe failed"
23529 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23530 if [ "$stripe_count" != "2" ]; then
23531 error "1:stripe_count is $stripe_count, expect 2"
23533 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23534 if [ "$stripe_count" != "2" ]; then
23535 error "2:stripe_count is $stripe_count, expect 2"
23538 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
23539 if [ "$stripe_index" != "$mdt_index" ]; then
23540 error "stripe_index is $stripe_index, expect $mdt_index"
23543 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23544 error "nlink error after create striped dir"
23546 mkdir $DIR/$tdir/striped_dir/a
23547 mkdir $DIR/$tdir/striped_dir/b
23549 stat $DIR/$tdir/striped_dir/a ||
23550 error "create dir under striped dir failed"
23551 stat $DIR/$tdir/striped_dir/b ||
23552 error "create dir under striped dir failed"
23554 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
23555 error "nlink error after mkdir"
23557 rmdir $DIR/$tdir/striped_dir/a
23558 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
23559 error "nlink error after rmdir"
23561 rmdir $DIR/$tdir/striped_dir/b
23562 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23563 error "nlink error after rmdir"
23565 chattr +i $DIR/$tdir/striped_dir
23566 createmany -o $DIR/$tdir/striped_dir/f 10 &&
23567 error "immutable flags not working under striped dir!"
23568 chattr -i $DIR/$tdir/striped_dir
23570 rmdir $DIR/$tdir/striped_dir ||
23571 error "rmdir striped dir error"
23579 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23580 skip "skipped for lustre < 2.7.0"
23581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23582 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23584 test_striped_dir 0 || error "failed on striped dir on MDT0"
23585 test_striped_dir 1 || error "failed on striped dir on MDT0"
23587 run_test 300a "basic striped dir sanity test"
23590 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23591 skip "skipped for lustre < 2.7.0"
23592 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23593 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23600 test_mkdir $DIR/$tdir || error "mkdir fail"
23601 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23602 error "set striped dir error"
23603 for i in {0..9}; do
23604 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
23606 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
23607 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
23608 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
23610 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
23611 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
23612 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
23616 run_test 300b "check ctime/mtime for striped dir"
23619 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23620 skip "skipped for lustre < 2.7.0"
23621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23622 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23626 mkdir_on_mdt0 $DIR/$tdir
23627 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
23628 error "set striped dir error"
23630 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
23631 error "chown striped dir failed"
23633 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
23634 error "create 5k files failed"
23636 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
23638 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
23642 run_test 300c "chown && check ls under striped directory"
23645 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23646 skip "skipped for lustre < 2.7.0"
23647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23648 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23653 mkdir -p $DIR/$tdir
23654 $LFS setstripe -c 2 $DIR/$tdir
23656 #local striped directory
23657 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23658 error "set striped dir error"
23659 #look at the directories for debug purposes
23661 $LFS getdirstripe $DIR/$tdir
23662 ls -l $DIR/$tdir/striped_dir
23663 $LFS getdirstripe $DIR/$tdir/striped_dir
23664 createmany -o $DIR/$tdir/striped_dir/f 10 ||
23665 error "create 10 files failed"
23667 #remote striped directory
23668 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
23669 error "set striped dir error"
23670 #look at the directories for debug purposes
23672 $LFS getdirstripe $DIR/$tdir
23673 ls -l $DIR/$tdir/remote_striped_dir
23674 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
23675 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
23676 error "create 10 files failed"
23678 for file in $(find $DIR/$tdir); do
23679 stripe_count=$($LFS getstripe -c $file)
23680 [ $stripe_count -eq 2 ] ||
23681 error "wrong stripe $stripe_count for $file"
23686 run_test 300d "check default stripe under striped directory"
23689 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23690 skip "Need MDS version at least 2.7.55"
23691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23692 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23697 mkdir -p $DIR/$tdir
23699 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23700 error "set striped dir error"
23702 touch $DIR/$tdir/striped_dir/a
23703 touch $DIR/$tdir/striped_dir/b
23704 touch $DIR/$tdir/striped_dir/c
23706 mkdir $DIR/$tdir/striped_dir/dir_a
23707 mkdir $DIR/$tdir/striped_dir/dir_b
23708 mkdir $DIR/$tdir/striped_dir/dir_c
23710 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
23711 error "set striped adir under striped dir error"
23713 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
23714 error "set striped bdir under striped dir error"
23716 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
23717 error "set striped cdir under striped dir error"
23719 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
23720 error "rename dir under striped dir fails"
23722 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
23723 error "rename dir under different stripes fails"
23725 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
23726 error "rename file under striped dir should succeed"
23728 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
23729 error "rename dir under striped dir should succeed"
23733 run_test 300e "check rename under striped directory"
23736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23737 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23738 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23739 skip "Need MDS version at least 2.7.55"
23745 mkdir -p $DIR/$tdir
23747 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23748 error "set striped dir error"
23750 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
23751 error "set striped dir error"
23753 touch $DIR/$tdir/striped_dir/a
23754 mkdir $DIR/$tdir/striped_dir/dir_a
23755 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
23756 error "create striped dir under striped dir fails"
23758 touch $DIR/$tdir/striped_dir1/b
23759 mkdir $DIR/$tdir/striped_dir1/dir_b
23760 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
23761 error "create striped dir under striped dir fails"
23763 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
23764 error "rename dir under different striped dir should fail"
23766 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
23767 error "rename striped dir under diff striped dir should fail"
23769 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
23770 error "rename file under diff striped dirs fails"
23774 run_test 300f "check rename cross striped directory"
23776 test_300_check_default_striped_dir()
23779 local default_count=$2
23780 local default_index=$3
23783 local dir_stripe_index
23786 echo "checking $dirname $default_count $default_index"
23787 $LFS setdirstripe -D -c $default_count -i $default_index \
23788 -H all_char $DIR/$tdir/$dirname ||
23789 error "set default stripe on striped dir error"
23790 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
23791 [ $stripe_count -eq $default_count ] ||
23792 error "expect $default_count get $stripe_count for $dirname"
23794 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
23795 [ $stripe_index -eq $default_index ] ||
23796 error "expect $default_index get $stripe_index for $dirname"
23798 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
23799 error "create dirs failed"
23801 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
23802 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
23803 for dir in $(find $DIR/$tdir/$dirname/*); do
23804 stripe_count=$($LFS getdirstripe -c $dir)
23805 (( $stripe_count == $default_count )) ||
23806 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
23807 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
23808 error "stripe count $default_count != $stripe_count for $dir"
23810 stripe_index=$($LFS getdirstripe -i $dir)
23811 [ $default_index -eq -1 ] ||
23812 [ $stripe_index -eq $default_index ] ||
23813 error "$stripe_index != $default_index for $dir"
23815 #check default stripe
23816 stripe_count=$($LFS getdirstripe -D -c $dir)
23817 [ $stripe_count -eq $default_count ] ||
23818 error "default count $default_count != $stripe_count for $dir"
23820 stripe_index=$($LFS getdirstripe -D -i $dir)
23821 [ $stripe_index -eq $default_index ] ||
23822 error "default index $default_index != $stripe_index for $dir"
23824 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
23828 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23829 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23830 skip "Need MDS version at least 2.7.55"
23836 mkdir_on_mdt0 $DIR/$tdir
23837 mkdir $DIR/$tdir/normal_dir
23839 #Checking when client cache stripe index
23840 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
23841 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
23842 error "create striped_dir failed"
23844 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
23845 error "create dir0 fails"
23846 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
23847 [ $stripe_index -eq 0 ] ||
23848 error "dir0 expect index 0 got $stripe_index"
23850 mkdir $DIR/$tdir/striped_dir/dir1 ||
23851 error "create dir1 fails"
23852 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
23853 [ $stripe_index -eq 1 ] ||
23854 error "dir1 expect index 1 got $stripe_index"
23856 #check default stripe count/stripe index
23857 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
23858 test_300_check_default_striped_dir normal_dir 1 0
23859 test_300_check_default_striped_dir normal_dir -1 1
23860 test_300_check_default_striped_dir normal_dir 2 -1
23862 #delete default stripe information
23863 echo "delete default stripeEA"
23864 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
23865 error "set default stripe on striped dir error"
23867 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
23868 for dir in $(find $DIR/$tdir/normal_dir/*); do
23869 stripe_count=$($LFS getdirstripe -c $dir)
23870 [ $stripe_count -eq 0 ] ||
23871 error "expect 1 get $stripe_count for $dir"
23874 run_test 300g "check default striped directory for normal directory"
23877 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23878 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23879 skip "Need MDS version at least 2.7.55"
23885 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23886 error "set striped dir error"
23888 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
23889 test_300_check_default_striped_dir striped_dir 1 0
23890 test_300_check_default_striped_dir striped_dir -1 1
23891 test_300_check_default_striped_dir striped_dir 2 -1
23893 #delete default stripe information
23894 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
23895 error "set default stripe on striped dir error"
23897 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
23898 for dir in $(find $DIR/$tdir/striped_dir/*); do
23899 stripe_count=$($LFS getdirstripe -c $dir)
23900 [ $stripe_count -eq 0 ] ||
23901 error "expect 1 get $stripe_count for $dir"
23904 run_test 300h "check default striped directory for striped directory"
23907 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
23908 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
23909 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
23910 skip "Need MDS version at least 2.7.55"
23917 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23918 error "set striped dir error"
23920 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23921 error "create files under striped dir failed"
23923 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
23924 error "set striped hashdir error"
23926 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
23927 error "create dir0 under hash dir failed"
23928 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
23929 error "create dir1 under hash dir failed"
23930 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
23931 error "create dir2 under hash dir failed"
23933 # unfortunately, we need to umount to clear dir layout cache for now
23934 # once we fully implement dir layout, we can drop this
23935 umount_client $MOUNT || error "umount failed"
23936 mount_client $MOUNT || error "mount failed"
23938 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
23939 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
23940 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
23942 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
23943 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
23944 error "create crush2 dir $tdir/hashdir/d3 failed"
23945 $LFS find -H crush2 $DIR/$tdir/hashdir
23946 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
23947 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
23949 # mkdir with an invalid hash type (hash=fail_val) from client
23950 # should be replaced on MDS with a valid (default) hash type
23951 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
23952 $LCTL set_param fail_loc=0x1901 fail_val=99
23953 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
23955 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
23956 local expect=$(do_facet mds1 \
23957 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
23958 [[ $hash == $expect ]] ||
23959 error "d99 hash '$hash' != expected hash '$expect'"
23962 #set the stripe to be unknown hash type on read
23963 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
23964 $LCTL set_param fail_loc=0x1901 fail_val=99
23965 for ((i = 0; i < 10; i++)); do
23966 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
23967 error "stat f-$i failed"
23968 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
23971 touch $DIR/$tdir/striped_dir/f0 &&
23972 error "create under striped dir with unknown hash should fail"
23974 $LCTL set_param fail_loc=0
23976 umount_client $MOUNT || error "umount failed"
23977 mount_client $MOUNT || error "mount failed"
23981 run_test 300i "client handle unknown hash type striped directory"
23984 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23986 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23987 skip "Need MDS version at least 2.7.55"
23994 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
23995 $LCTL set_param fail_loc=0x1702
23996 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23997 error "set striped dir error"
23999 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24000 error "create files under striped dir failed"
24002 $LCTL set_param fail_loc=0
24004 rm -rf $DIR/$tdir || error "unlink striped dir fails"
24008 run_test 300j "test large update record"
24011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24012 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24013 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24014 skip "Need MDS version at least 2.7.55"
24016 # this test needs a huge transaction
24018 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24019 osd*.$FSNAME-MDT0000.kbytestotal")
24020 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
24027 #define OBD_FAIL_LARGE_STRIPE 0x1703
24028 $LCTL set_param fail_loc=0x1703
24029 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
24030 error "set striped dir error"
24031 $LCTL set_param fail_loc=0
24033 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24034 error "getstripeddir fails"
24035 rm -rf $DIR/$tdir/striped_dir ||
24036 error "unlink striped dir fails"
24040 run_test 300k "test large striped directory"
24043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24044 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24045 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24046 skip "Need MDS version at least 2.7.55"
24050 test_mkdir -p $DIR/$tdir/striped_dir
24051 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
24052 error "chown $RUNAS_ID failed"
24053 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
24054 error "set default striped dir failed"
24056 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
24057 $LCTL set_param fail_loc=0x80000158
24058 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
24060 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
24061 [ $stripe_index -eq 1 ] ||
24062 error "expect 1 get $stripe_index for $dir"
24064 run_test 300l "non-root user to create dir under striped dir with stale layout"
24067 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24068 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
24069 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24070 skip "Need MDS version at least 2.7.55"
24072 mkdir -p $DIR/$tdir/striped_dir
24073 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
24074 error "set default stripes dir error"
24076 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
24078 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
24079 [ $stripe_count -eq 0 ] ||
24080 error "expect 0 get $stripe_count for a"
24082 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
24083 error "set default stripes dir error"
24085 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
24087 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
24088 [ $stripe_count -eq 0 ] ||
24089 error "expect 0 get $stripe_count for b"
24091 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
24092 error "set default stripes dir error"
24094 mkdir $DIR/$tdir/striped_dir/c &&
24095 error "default stripe_index is invalid, mkdir c should fails"
24097 rm -rf $DIR/$tdir || error "rmdir fails"
24099 run_test 300m "setstriped directory on single MDT FS"
24102 local list=$(comma_list $(mdts_nodes))
24105 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24110 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24111 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24112 skip "Need MDS version at least 2.7.55"
24113 remote_mds_nodsh && skip "remote MDS with nodsh"
24116 local list=$(comma_list $(mdts_nodes))
24118 trap cleanup_300n RETURN EXIT
24119 mkdir -p $DIR/$tdir
24120 chmod 777 $DIR/$tdir
24121 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
24122 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24123 error "create striped dir succeeds with gid=0"
24125 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24126 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
24127 error "create striped dir fails with gid=-1"
24129 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24130 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
24131 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24132 error "set default striped dir succeeds with gid=0"
24135 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24136 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
24137 error "set default striped dir fails with gid=-1"
24140 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24141 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
24142 error "create test_dir fails"
24143 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
24144 error "create test_dir1 fails"
24145 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
24146 error "create test_dir2 fails"
24149 run_test 300n "non-root user to create dir under striped dir with default EA"
24152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24153 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24154 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24155 skip "Need MDS version at least 2.7.55"
24160 mkdir -p $DIR/$tdir
24162 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
24163 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
24164 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
24165 skip "not enough free inodes $numfree1 $numfree2"
24168 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
24169 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
24170 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
24171 skip "not enough free space $numfree1 $numfree2"
24174 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
24175 error "setdirstripe fails"
24177 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
24178 error "create dirs fails"
24180 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
24181 ls $DIR/$tdir/striped_dir > /dev/null ||
24182 error "ls striped dir fails"
24183 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
24184 error "unlink big striped dir fails"
24186 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
24189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24190 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24191 remote_mds_nodsh && skip "remote MDS with nodsh"
24193 mkdir_on_mdt0 $DIR/$tdir
24195 #define OBD_FAIL_OUT_ENOSPC 0x1704
24196 do_facet mds2 lctl set_param fail_loc=0x80001704
24197 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
24198 && error "create striped directory should fail"
24200 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
24202 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
24205 run_test 300p "create striped directory without space"
24208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24209 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24211 local fd=$(free_fd)
24212 local cmd="exec $fd<$tdir"
24214 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
24217 trap "eval $cmd" EXIT
24218 cd $tdir || error "cd $tdir fails"
24219 rmdir ../$tdir || error "rmdir $tdir fails"
24220 mkdir local_dir && error "create dir succeeds"
24221 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
24225 run_test 300q "create remote directory under orphan directory"
24228 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24229 skip "Need MDS version at least 2.7.55" && return
24230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24234 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
24235 error "set striped dir error"
24237 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24238 error "getstripeddir fails"
24241 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
24242 awk '/lmv_stripe_count:/ { print $2 }')
24244 [ $MDSCOUNT -ne $stripe_count ] &&
24245 error "wrong stripe count $stripe_count expected $MDSCOUNT"
24247 rm -rf $DIR/$tdir/striped_dir ||
24248 error "unlink striped dir fails"
24250 run_test 300r "test -1 striped directory"
24252 test_300s_helper() {
24255 local stripe_dir=$DIR/$tdir/striped_dir.$count
24257 $LFS mkdir -c $count $stripe_dir ||
24258 error "lfs mkdir -c error"
24260 $LFS getdirstripe $stripe_dir ||
24261 error "lfs getdirstripe fails"
24264 stripe_count=$($LFS getdirstripe $stripe_dir |
24265 awk '/lmv_stripe_count:/ { print $2 }')
24267 [ $count -ne $stripe_count ] &&
24268 error_noexit "bad stripe count $stripe_count expected $count"
24271 dupe_stripes=$($LFS getdirstripe $stripe_dir |
24272 awk '/0x/ {count[$1] += 1}; END {
24273 for (idx in count) {
24274 if (count[idx]>1) {
24275 print "index " idx " count " count[idx]
24280 if [[ -n "$dupe_stripes" ]] ; then
24281 lfs getdirstripe $stripe_dir
24282 error_noexit "Dupe MDT above: $dupe_stripes "
24285 rm -rf $stripe_dir ||
24286 error_noexit "unlink $stripe_dir fails"
24290 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24291 skip "Need MDS version at least 2.7.55" && return
24292 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24295 for count in $(seq 2 $MDSCOUNT); do
24296 test_300s_helper $count
24299 run_test 300s "test lfs mkdir -c without -i"
24302 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
24303 skip "need MDS 2.14.55 or later"
24304 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
24306 local testdir="$DIR/$tdir/striped_dir"
24307 local dir1=$testdir/dir1
24308 local dir2=$testdir/dir2
24312 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
24313 error "failed to set default stripe count for $testdir"
24316 local stripe_count=$($LFS getdirstripe -c $dir1)
24318 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
24320 local max_count=$((MDSCOUNT - 1))
24321 local mdts=$(comma_list $(mdts_nodes))
24323 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
24324 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
24327 stripe_count=$($LFS getdirstripe -c $dir2)
24329 (( $stripe_count == $max_count )) || error "wrong stripe count"
24331 run_test 300t "test max_mdt_stripecount"
24333 prepare_remote_file() {
24334 mkdir $DIR/$tdir/src_dir ||
24335 error "create remote source failed"
24337 cp /etc/hosts $DIR/$tdir/src_dir/a ||
24338 error "cp to remote source failed"
24339 touch $DIR/$tdir/src_dir/a
24341 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
24342 error "create remote target dir failed"
24344 touch $DIR/$tdir/tgt_dir/b
24346 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
24347 error "rename dir cross MDT failed!"
24349 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
24350 error "src_child still exists after rename"
24352 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
24353 error "missing file(a) after rename"
24355 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
24356 error "diff after rename"
24360 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24363 local remote_file=$DIR/$tdir/tgt_dir/b
24365 mkdir -p $DIR/$tdir
24367 prepare_remote_file || error "prepare remote file failed"
24370 $OPENUNLINK $remote_file $remote_file ||
24371 error "openunlink $remote_file failed"
24372 $CHECKSTAT -a $remote_file || error "$remote_file exists"
24374 run_test 310a "open unlink remote file"
24377 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24380 local remote_file=$DIR/$tdir/tgt_dir/b
24382 mkdir -p $DIR/$tdir
24384 prepare_remote_file || error "prepare remote file failed"
24386 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24387 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
24388 $CHECKSTAT -t file $remote_file || error "check file failed"
24390 run_test 310b "unlink remote file with multiple links while open"
24393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24394 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
24396 local remote_file=$DIR/$tdir/tgt_dir/b
24398 mkdir -p $DIR/$tdir
24400 prepare_remote_file || error "prepare remote file failed"
24402 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24403 multiop_bg_pause $remote_file O_uc ||
24404 error "mulitop failed for remote file"
24406 $MULTIOP $DIR/$tfile Ouc
24407 kill -USR1 $MULTIPID
24410 run_test 310c "open-unlink remote file with multiple links"
24414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24415 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24416 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
24417 skip "lustre < 2.8.54 does not contain LU-4825 fix"
24418 remote_mds_nodsh && skip "remote MDS with nodsh"
24420 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24421 local mdts=$(comma_list $(mdts_nodes))
24423 mkdir -p $DIR/$tdir
24424 $LFS setstripe -i 0 -c 1 $DIR/$tdir
24425 createmany -o $DIR/$tdir/$tfile. 1000
24427 # statfs data is not real time, let's just calculate it
24428 old_iused=$((old_iused + 1000))
24430 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24431 osp.*OST0000*MDT0000.create_count")
24432 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24433 osp.*OST0000*MDT0000.max_create_count")
24434 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24436 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24437 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24438 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24440 unlinkmany $DIR/$tdir/$tfile. 1000
24442 do_nodes $mdts "$LCTL set_param -n \
24443 osp.*OST0000*.max_create_count=$max_count"
24444 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24445 do_nodes $mdts "$LCTL set_param -n \
24446 osp.*OST0000*.create_count=$count"
24447 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24448 grep "=0" && error "create_count is zero"
24451 for i in $(seq 120); do
24452 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24453 # system may be too busy to destroy all objs in time, use
24454 # a somewhat small value to not fail autotest
24455 [ $((old_iused - new_iused)) -gt 400 ] && break
24459 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24460 [ $((old_iused - new_iused)) -gt 400 ] ||
24461 error "objs not destroyed after unlink"
24463 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24470 local vdevdir=$(dirname $(facet_vdevice $ost))
24471 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24472 local zfs_zapid=$(do_facet $ost $cmd |
24473 grep -w "/O/0/d$((objid%32))" -C 5 |
24474 awk '/Object/{getline; print $1}')
24475 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24476 awk "/$objid = /"'{printf $3}')
24481 zfs_object_blksz() {
24485 local vdevdir=$(dirname $(facet_vdevice $ost))
24486 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24487 local blksz=$(do_facet $ost $cmd $objid |
24488 awk '/dblk/{getline; printf $4}')
24490 case "${blksz: -1}" in
24491 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24492 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24499 test_312() { # LU-4856
24500 remote_ost_nodsh && skip "remote OST with nodsh"
24501 [ "$ost1_FSTYPE" = "zfs" ] ||
24502 skip_env "the test only applies to zfs"
24504 local max_blksz=$(do_facet ost1 \
24505 $ZFS get -p recordsize $(facet_device ost1) |
24506 awk '!/VALUE/{print $3}')
24508 # to make life a little bit easier
24509 $LFS mkdir -c 1 -i 0 $DIR/$tdir
24510 $LFS setstripe -c 1 -i 0 $DIR/$tdir
24512 local tf=$DIR/$tdir/$tfile
24514 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24516 # Get ZFS object id
24517 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24518 # block size change by sequential overwrite
24521 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24522 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24524 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
24525 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
24529 # block size change by sequential append write
24530 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24531 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24532 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24535 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24536 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24537 oflag=sync conv=notrunc
24539 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24540 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
24541 error "blksz error, actual $blksz, " \
24542 "expected: 2 * $count * $PAGE_SIZE"
24548 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24549 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24551 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
24552 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24553 [ $blksz -eq $PAGE_SIZE ] ||
24554 error "blksz error: $blksz, expected: $PAGE_SIZE"
24556 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
24557 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24558 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
24560 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
24561 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24562 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
24564 run_test 312 "make sure ZFS adjusts its block size by write pattern"
24567 remote_ost_nodsh && skip "remote OST with nodsh"
24569 local file=$DIR/$tfile
24572 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
24574 # define OBD_FAIL_TGT_RCVD_EIO 0x720
24575 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24576 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
24577 error "write should failed"
24578 do_facet ost1 "$LCTL set_param fail_loc=0"
24581 run_test 313 "io should fail after last_rcvd update fail"
24584 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24586 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
24587 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24589 wait_delete_completed
24590 do_facet ost1 "$LCTL set_param fail_loc=0"
24592 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
24594 test_315() { # LU-618
24595 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
24597 local file=$DIR/$tfile
24600 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
24601 error "multiop file write failed"
24602 $MULTIOP $file oO_RDONLY:r4063232_c &
24607 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
24610 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
24613 run_test 315 "read should be accounted"
24616 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24617 large_xattr_enabled || skip "ea_inode feature disabled"
24619 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
24620 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
24621 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
24622 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
24624 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
24626 run_test 316 "lfs migrate of file with large_xattr enabled"
24629 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
24630 skip "Need MDS version at least 2.11.53"
24631 if [ "$ost1_FSTYPE" == "zfs" ]; then
24632 skip "LU-10370: no implementation for ZFS"
24636 local grant_blk_size
24638 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
24639 awk '/grant_block_size:/ { print $2; exit; }')
24641 # Create File of size 5M. Truncate it to below size's and verify
24644 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
24645 error "Create file $DIR/$tfile failed"
24646 stack_trap "rm -f $DIR/$tfile" EXIT
24648 for trunc_sz in 2097152 4097 4000 509 0; do
24649 $TRUNCATE $DIR/$tfile $trunc_sz ||
24650 error "truncate $tfile to $trunc_sz failed"
24651 local sz=$(stat --format=%s $DIR/$tfile)
24652 local blk=$(stat --format=%b $DIR/$tfile)
24653 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
24654 grant_blk_size) * 8))
24656 if [[ $blk -ne $trunc_blk ]]; then
24657 $(which stat) $DIR/$tfile
24658 error "Expected Block $trunc_blk got $blk for $tfile"
24661 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24662 error "Expected Size $trunc_sz got $sz for $tfile"
24667 # Create file with a hole and write actual 65536 bytes which aligned
24668 # with 4K and 64K PAGE_SIZE. Block count must be 128.
24671 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
24672 error "Create file : $DIR/$tfile"
24675 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
24676 # blocks. The block count must drop to 8.
24678 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
24679 ((bs - grant_blk_size) + 1)))
24680 $TRUNCATE $DIR/$tfile $trunc_sz ||
24681 error "truncate $tfile to $trunc_sz failed"
24683 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
24684 sz=$(stat --format=%s $DIR/$tfile)
24685 blk=$(stat --format=%b $DIR/$tfile)
24687 if [[ $blk -ne $trunc_bsz ]]; then
24688 $(which stat) $DIR/$tfile
24689 error "Expected Block $trunc_bsz got $blk for $tfile"
24692 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24693 error "Expected Size $trunc_sz got $sz for $tfile"
24695 run_test 317 "Verify blocks get correctly update after truncate"
24698 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
24699 local old_max_active=$($LCTL get_param -n \
24700 ${llite_name}.max_read_ahead_async_active \
24703 $LCTL set_param llite.*.max_read_ahead_async_active=256
24704 local max_active=$($LCTL get_param -n \
24705 ${llite_name}.max_read_ahead_async_active \
24707 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
24709 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
24710 error "set max_read_ahead_async_active should succeed"
24712 $LCTL set_param llite.*.max_read_ahead_async_active=512
24713 max_active=$($LCTL get_param -n \
24714 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
24715 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
24717 # restore @max_active
24718 [ $old_max_active -ne 0 ] && $LCTL set_param \
24719 llite.*.max_read_ahead_async_active=$old_max_active
24721 local old_threshold=$($LCTL get_param -n \
24722 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24723 local max_per_file_mb=$($LCTL get_param -n \
24724 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
24726 local invalid=$(($max_per_file_mb + 1))
24728 llite.*.read_ahead_async_file_threshold_mb=$invalid\
24729 && error "set $invalid should fail"
24731 local valid=$(($invalid - 1))
24733 llite.*.read_ahead_async_file_threshold_mb=$valid ||
24734 error "set $valid should succeed"
24735 local threshold=$($LCTL get_param -n \
24736 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24737 [ $threshold -eq $valid ] || error \
24738 "expect threshold $valid got $threshold"
24740 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
24742 run_test 318 "Verify async readahead tunables"
24745 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24747 local before=$(date +%s)
24749 local mdir=$DIR/$tdir
24750 local file=$mdir/xxx
24752 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
24755 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
24756 $LCTL set_param fail_val=5 fail_loc=0x8000032c
24757 $LFS migrate -m1 $mdir &
24760 dd if=$file of=/dev/null
24762 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
24763 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
24765 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
24767 run_test 319 "lost lease lock on migrate error"
24769 test_398a() { # LU-4198
24770 local ost1_imp=$(get_osc_import_name client ost1)
24771 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24774 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24775 $LCTL set_param ldlm.namespaces.*.lru_size=clear
24777 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
24778 # request a new lock on client
24779 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24781 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24782 #local lock_count=$($LCTL get_param -n \
24783 # ldlm.namespaces.$imp_name.lru_size)
24784 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
24786 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24788 # no lock cached, should use lockless DIO and not enqueue new lock
24789 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
24791 error "dio write failed"
24792 lock_count=$($LCTL get_param -n \
24793 ldlm.namespaces.$imp_name.lru_size)
24794 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
24796 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24798 # no lock cached, should use locked DIO append
24799 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
24800 conv=notrunc || error "DIO append failed"
24801 lock_count=$($LCTL get_param -n \
24802 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
24803 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
24805 run_test 398a "direct IO should cancel lock otherwise lockless"
24807 test_398b() { # LU-4198
24808 which fio || skip_env "no fio installed"
24809 $LFS setstripe -c -1 -S 1M $DIR/$tfile
24812 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
24815 # Single page, multiple pages, stripe size, 4*stripe size
24816 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
24817 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
24818 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
24819 --numjobs=$njobs --fallocate=none \
24820 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24821 --filename=$DIR/$tfile &
24824 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
24825 fio --name=rand-rw --rw=randrw --bs=$bsize \
24826 --numjobs=$njobs --fallocate=none \
24827 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24828 --filename=$DIR/$tfile || true
24832 evict=$(do_facet client $LCTL get_param \
24833 osc.$FSNAME-OST*-osc-*/state |
24834 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
24836 [ -z "$evict" ] || [[ $evict -le $before ]] ||
24837 (do_facet client $LCTL get_param \
24838 osc.$FSNAME-OST*-osc-*/state;
24839 error "eviction happened: $evict before:$before")
24843 run_test 398b "DIO and buffer IO race"
24845 test_398c() { # LU-4198
24846 local ost1_imp=$(get_osc_import_name client ost1)
24847 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24850 which fio || skip_env "no fio installed"
24852 saved_debug=$($LCTL get_param -n debug)
24853 $LCTL set_param debug=0
24855 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
24856 ((size /= 1024)) # by megabytes
24857 ((size /= 2)) # write half of the OST at most
24858 [ $size -gt 40 ] && size=40 #reduce test time anyway
24860 $LFS setstripe -c 1 $DIR/$tfile
24862 # it seems like ldiskfs reserves more space than necessary if the
24863 # writing blocks are not mapped, so it extends the file firstly
24864 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
24865 cancel_lru_locks osc
24867 # clear and verify rpc_stats later
24868 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
24871 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
24872 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
24873 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24874 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24875 --filename=$DIR/$tfile
24876 [ $? -eq 0 ] || error "fio write error"
24878 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
24879 error "Locks were requested while doing AIO"
24881 # get the percentage of 1-page I/O
24882 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
24883 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
24885 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
24887 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
24888 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24889 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24890 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24891 --filename=$DIR/$tfile
24892 [ $? -eq 0 ] || error "fio mixed read write error"
24894 echo "AIO with large block size ${size}M"
24895 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
24896 --numjobs=1 --fallocate=none --ioengine=libaio \
24897 --iodepth=16 --allow_file_create=0 --size=${size}M \
24898 --filename=$DIR/$tfile
24899 [ $? -eq 0 ] || error "fio large block size failed"
24902 $LCTL set_param debug="$saved_debug"
24904 run_test 398c "run fio to test AIO"
24906 test_398d() { # LU-13846
24907 which aiocp || skip_env "no aiocp installed"
24908 local aio_file=$DIR/$tfile.aio
24910 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24912 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
24913 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
24914 stack_trap "rm -f $DIR/$tfile $aio_file"
24916 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
24918 # make sure we don't crash and fail properly
24919 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24920 error "aio not aligned with PAGE SIZE should fail"
24922 rm -f $DIR/$tfile $aio_file
24924 run_test 398d "run aiocp to verify block size > stripe size"
24927 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
24928 touch $DIR/$tfile.new
24929 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
24931 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
24933 test_398f() { # LU-14687
24934 which aiocp || skip_env "no aiocp installed"
24935 local aio_file=$DIR/$tfile.aio
24937 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24939 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
24940 stack_trap "rm -f $DIR/$tfile $aio_file"
24942 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24943 $LCTL set_param fail_loc=0x1418
24944 # make sure we don't crash and fail properly
24945 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24946 error "aio with page allocation failure succeeded"
24947 $LCTL set_param fail_loc=0
24948 diff $DIR/$tfile $aio_file
24949 [[ $? != 0 ]] || error "no diff after failed aiocp"
24951 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
24953 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
24954 # stripe and i/o size must be > stripe size
24955 # Old style synchronous DIO waits after submitting each chunk, resulting in a
24956 # single RPC in flight. This test shows async DIO submission is working by
24957 # showing multiple RPCs in flight.
24958 test_398g() { # LU-13798
24959 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24961 # We need to do some i/o first to acquire enough grant to put our RPCs
24962 # in flight; otherwise a new connection may not have enough grant
24964 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24965 error "parallel dio failed"
24966 stack_trap "rm -f $DIR/$tfile"
24968 # Reduce RPC size to 1M to avoid combination in to larger RPCs
24969 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24970 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24971 stack_trap "$LCTL set_param -n $pages_per_rpc"
24973 # Recreate file so it's empty
24975 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24976 #Pause rpc completion to guarantee we see multiple rpcs in flight
24977 #define OBD_FAIL_OST_BRW_PAUSE_BULK
24978 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
24979 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24982 $LCTL set_param osc.*.rpc_stats=c
24984 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24985 error "parallel dio failed"
24986 stack_trap "rm -f $DIR/$tfile"
24988 $LCTL get_param osc.*-OST0000-*.rpc_stats
24989 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24990 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24991 grep "8:" | awk '{print $8}')
24992 # We look at the "8 rpcs in flight" field, and verify A) it is present
24993 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
24994 # as expected for an 8M DIO to a file with 1M stripes.
24995 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
24997 # Verify turning off parallel dio works as expected
24999 $LCTL set_param osc.*.rpc_stats=c
25000 $LCTL set_param llite.*.parallel_dio=0
25001 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
25003 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25004 error "dio with parallel dio disabled failed"
25006 # Ideally, we would see only one RPC in flight here, but there is an
25007 # unavoidable race between i/o completion and RPC in flight counting,
25008 # so while only 1 i/o is in flight at a time, the RPC in flight counter
25009 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
25010 # So instead we just verify it's always < 8.
25011 $LCTL get_param osc.*-OST0000-*.rpc_stats
25012 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25013 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25014 grep '^$' -B1 | grep . | awk '{print $1}')
25015 [ $ret != "8:" ] ||
25016 error "we should see fewer than 8 RPCs in flight (saw $ret)"
25018 run_test 398g "verify parallel dio async RPC submission"
25020 test_398h() { # LU-13798
25021 local dio_file=$DIR/$tfile.dio
25023 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25025 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25026 stack_trap "rm -f $DIR/$tfile $dio_file"
25028 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
25029 error "parallel dio failed"
25030 diff $DIR/$tfile $dio_file
25031 [[ $? == 0 ]] || error "file diff after aiocp"
25033 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
25035 test_398i() { # LU-13798
25036 local dio_file=$DIR/$tfile.dio
25038 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25040 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25041 stack_trap "rm -f $DIR/$tfile $dio_file"
25043 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25044 $LCTL set_param fail_loc=0x1418
25045 # make sure we don't crash and fail properly
25046 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
25047 error "parallel dio page allocation failure succeeded"
25048 diff $DIR/$tfile $dio_file
25049 [[ $? != 0 ]] || error "no diff after failed aiocp"
25051 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
25053 test_398j() { # LU-13798
25054 # Stripe size > RPC size but less than i/o size tests split across
25055 # stripes and RPCs for individual i/o op
25056 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
25058 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
25059 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25060 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25061 stack_trap "$LCTL set_param -n $pages_per_rpc"
25063 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25064 error "parallel dio write failed"
25065 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
25067 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
25068 error "parallel dio read failed"
25069 diff $DIR/$tfile $DIR/$tfile.2
25070 [[ $? == 0 ]] || error "file diff after parallel dio read"
25072 run_test 398j "test parallel dio where stripe size > rpc_size"
25074 test_398k() { # LU-13798
25075 wait_delete_completed
25078 # 4 stripe file; we will cause out of space on OST0
25079 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25081 # Fill OST0 (if it's not too large)
25082 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25084 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25085 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25087 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25088 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25089 error "dd should fill OST0"
25090 stack_trap "rm -f $DIR/$tfile.1"
25092 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25096 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
25097 error "file is not 0 bytes in size"
25099 # dd above should not succeed, but don't error until here so we can
25100 # get debug info above
25102 error "parallel dio write with enospc succeeded"
25103 stack_trap "rm -f $DIR/$tfile"
25105 run_test 398k "test enospc on first stripe"
25107 test_398l() { # LU-13798
25108 wait_delete_completed
25111 # 4 stripe file; we will cause out of space on OST0
25112 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
25113 # happens on the second i/o chunk we issue
25114 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
25116 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
25117 stack_trap "rm -f $DIR/$tfile"
25119 # Fill OST0 (if it's not too large)
25120 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25122 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25123 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25125 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25126 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25127 error "dd should fill OST0"
25128 stack_trap "rm -f $DIR/$tfile.1"
25130 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
25132 stack_trap "rm -f $DIR/$tfile.2"
25134 # Check that short write completed as expected
25135 ls -la $DIR/$tfile.2
25136 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
25137 error "file is not 1M in size"
25139 # dd above should not succeed, but don't error until here so we can
25140 # get debug info above
25142 error "parallel dio write with enospc succeeded"
25144 # Truncate source file to same length as output file and diff them
25145 $TRUNCATE $DIR/$tfile 1048576
25146 diff $DIR/$tfile $DIR/$tfile.2
25147 [[ $? == 0 ]] || error "data incorrect after short write"
25149 run_test 398l "test enospc on intermediate stripe/RPC"
25151 test_398m() { # LU-13798
25152 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25154 # Set up failure on OST0, the first stripe:
25155 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
25156 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
25157 # So this fail_val specifies OST0
25158 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
25159 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25161 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25162 error "parallel dio write with failure on first stripe succeeded"
25163 stack_trap "rm -f $DIR/$tfile"
25164 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25166 # Place data in file for read
25167 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25168 error "parallel dio write failed"
25170 # Fail read on OST0, first stripe
25171 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25172 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
25173 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25174 error "parallel dio read with error on first stripe succeeded"
25175 rm -f $DIR/$tfile.2
25176 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25178 # Switch to testing on OST1, second stripe
25179 # Clear file contents, maintain striping
25181 # Set up failure on OST1, second stripe:
25182 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
25183 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25185 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25186 error "parallel dio write with failure on first stripe succeeded"
25187 stack_trap "rm -f $DIR/$tfile"
25188 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25190 # Place data in file for read
25191 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25192 error "parallel dio write failed"
25194 # Fail read on OST1, second stripe
25195 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25196 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
25197 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25198 error "parallel dio read with error on first stripe succeeded"
25199 rm -f $DIR/$tfile.2
25200 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25202 run_test 398m "test RPC failures with parallel dio"
25204 # Parallel submission of DIO should not cause problems for append, but it's
25205 # important to verify.
25206 test_398n() { # LU-13798
25207 $LFS setstripe -C 2 -S 1M $DIR/$tfile
25209 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
25210 error "dd to create source file failed"
25211 stack_trap "rm -f $DIR/$tfile"
25213 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
25214 error "parallel dio write with failure on second stripe succeeded"
25215 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
25216 diff $DIR/$tfile $DIR/$tfile.1
25217 [[ $? == 0 ]] || error "data incorrect after append"
25220 run_test 398n "test append with parallel DIO"
25223 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
25225 run_test 398o "right kms with DIO"
25228 local read_write=$1
25229 if [ "$read_write" = "write" ]; then
25230 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
25231 elif [ "$read_write" = "read" ]; then
25232 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
25234 error "argument error"
25237 # turn off debug for performance testing
25238 local saved_debug=$($LCTL get_param -n debug)
25239 $LCTL set_param debug=0
25241 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25243 # get ost1 size - $FSNAME-OST0000
25244 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
25245 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
25246 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
25248 if [ "$read_write" = "read" ]; then
25249 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
25252 local start_time=$(date +%s.%N)
25253 $dd_cmd bs=1M count=$blocks oflag=sync ||
25254 error "real dd $read_write error"
25255 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
25257 if [ "$read_write" = "write" ]; then
25261 # define OBD_FAIL_OST_FAKE_RW 0x238
25262 do_facet ost1 $LCTL set_param fail_loc=0x238
25264 local start_time=$(date +%s.%N)
25265 $dd_cmd bs=1M count=$blocks oflag=sync ||
25266 error "fake dd $read_write error"
25267 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
25269 if [ "$read_write" = "write" ]; then
25271 cancel_lru_locks osc
25272 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
25273 error "$tfile size not $blocks MB"
25275 do_facet ost1 $LCTL set_param fail_loc=0
25277 echo "fake $read_write $duration_fake vs. normal $read_write" \
25278 "$duration in seconds"
25279 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
25280 error_not_in_vm "fake write is slower"
25282 $LCTL set_param -n debug="$saved_debug"
25285 test_399a() { # LU-7655 for OST fake write
25286 remote_ost_nodsh && skip "remote OST with nodsh"
25290 run_test 399a "fake write should not be slower than normal write"
25292 test_399b() { # LU-8726 for OST fake read
25293 remote_ost_nodsh && skip "remote OST with nodsh"
25294 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
25295 skip_env "ldiskfs only test"
25300 run_test 399b "fake read should not be slower than normal read"
25302 test_400a() { # LU-1606, was conf-sanity test_74
25303 if ! which $CC > /dev/null 2>&1; then
25304 skip_env "$CC is not installed"
25307 local extra_flags=''
25308 local out=$TMP/$tfile
25309 local prefix=/usr/include/lustre
25312 # Oleg removes c files in his test rig so test if any c files exist
25313 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
25314 skip_env "Needed c test files are missing"
25316 if ! [[ -d $prefix ]]; then
25317 # Assume we're running in tree and fixup the include path.
25318 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
25319 extra_flags+=" -L$LUSTRE/utils/.lib"
25322 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
25323 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
25324 error "client api broken"
25328 run_test 400a "Lustre client api program can compile and link"
25330 test_400b() { # LU-1606, LU-5011
25332 local out=$TMP/$tfile
25333 local prefix=/usr/include/linux/lustre
25335 # We use a hard coded prefix so that this test will not fail
25336 # when run in tree. There are headers in lustre/include/lustre/
25337 # that are not packaged (like lustre_idl.h) and have more
25338 # complicated include dependencies (like config.h and lnet/types.h).
25339 # Since this test about correct packaging we just skip them when
25340 # they don't exist (see below) rather than try to fixup cppflags.
25342 if ! which $CC > /dev/null 2>&1; then
25343 skip_env "$CC is not installed"
25346 for header in $prefix/*.h; do
25347 if ! [[ -f "$header" ]]; then
25351 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
25352 continue # lustre_ioctl.h is internal header
25355 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
25356 error "cannot compile '$header'"
25360 run_test 400b "packaged headers can be compiled"
25362 test_401a() { #LU-7437
25363 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
25364 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
25366 #count the number of parameters by "list_param -R"
25367 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
25368 #count the number of parameters by listing proc files
25369 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
25370 echo "proc_dirs='$proc_dirs'"
25371 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
25372 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
25375 [ $params -eq $procs ] ||
25376 error "found $params parameters vs. $procs proc files"
25378 # test the list_param -D option only returns directories
25379 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
25380 #count the number of parameters by listing proc directories
25381 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
25384 [ $params -eq $procs ] ||
25385 error "found $params parameters vs. $procs proc files"
25387 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
25390 # jobid_var may not allow arbitrary values, so use jobid_name
25392 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25393 local testname=jobid_name tmp='testing%p'
25395 local testname=jobid_var tmp=testing
25398 local save=$($LCTL get_param -n $testname)
25400 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
25401 error "no error returned when setting bad parameters"
25403 local jobid_new=$($LCTL get_param -n foe $testname baz)
25404 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
25406 $LCTL set_param -n fog=bam $testname=$save bat=fog
25407 local jobid_old=$($LCTL get_param -n foe $testname bag)
25408 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
25410 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
25413 # jobid_var may not allow arbitrary values, so use jobid_name
25415 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25416 local testname=jobid_name
25418 local testname=jobid_var
25421 local jobid_var_old=$($LCTL get_param -n $testname)
25422 local jobid_var_new
25424 $LCTL set_param $testname= &&
25425 error "no error returned for 'set_param a='"
25427 jobid_var_new=$($LCTL get_param -n $testname)
25428 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25429 error "$testname was changed by setting without value"
25431 $LCTL set_param $testname &&
25432 error "no error returned for 'set_param a'"
25434 jobid_var_new=$($LCTL get_param -n $testname)
25435 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25436 error "$testname was changed by setting without value"
25438 run_test 401c "Verify 'lctl set_param' without value fails in either format."
25441 # jobid_var may not allow arbitrary values, so use jobid_name
25443 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25444 local testname=jobid_name new_value='foo=bar%p'
25446 local testname=jobid_var new_valuie=foo=bar
25449 local jobid_var_old=$($LCTL get_param -n $testname)
25450 local jobid_var_new
25452 $LCTL set_param $testname=$new_value ||
25453 error "'set_param a=b' did not accept a value containing '='"
25455 jobid_var_new=$($LCTL get_param -n $testname)
25456 [[ "$jobid_var_new" == "$new_value" ]] ||
25457 error "'set_param a=b' failed on a value containing '='"
25459 # Reset the $testname to test the other format
25460 $LCTL set_param $testname=$jobid_var_old
25461 jobid_var_new=$($LCTL get_param -n $testname)
25462 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25463 error "failed to reset $testname"
25465 $LCTL set_param $testname $new_value ||
25466 error "'set_param a b' did not accept a value containing '='"
25468 jobid_var_new=$($LCTL get_param -n $testname)
25469 [[ "$jobid_var_new" == "$new_value" ]] ||
25470 error "'set_param a b' failed on a value containing '='"
25472 $LCTL set_param $testname $jobid_var_old
25473 jobid_var_new=$($LCTL get_param -n $testname)
25474 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25475 error "failed to reset $testname"
25477 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25479 test_401e() { # LU-14779
25480 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25481 error "lctl list_param MGC* failed"
25482 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25483 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25484 error "lctl get_param lru_size failed"
25486 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25489 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25490 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25491 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25492 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25493 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25494 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25495 remote_mds_nodsh && skip "remote MDS with nodsh"
25497 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25498 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25499 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25500 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25501 echo "Touch failed - OK"
25503 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25506 local file1=$DIR/$tfile.1
25507 local file2=$DIR/$tfile.2
25508 local tfile=$TMP/$tfile
25510 rm -f $file1 $file2 $tfile
25515 # 30 sec OBD_TIMEOUT in ll_getattr()
25516 # right before populating st_nlink
25517 $LCTL set_param fail_loc=0x80001409
25518 stat -c %h $file1 > $tfile &
25520 # create an alias, drop all locks and reclaim the dentry
25522 cancel_lru_locks mdc
25523 cancel_lru_locks osc
25524 sysctl -w vm.drop_caches=2
25528 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25530 rm -f $tfile $file1 $file2
25532 run_test 403 "i_nlink should not drop to zero due to aliasing"
25534 test_404() { # LU-6601
25535 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
25536 skip "Need server version newer than 2.8.52"
25537 remote_mds_nodsh && skip "remote MDS with nodsh"
25539 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
25540 awk '/osp .*-osc-MDT/ { print $4}')
25543 for osp in $mosps; do
25544 echo "Deactivate: " $osp
25545 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
25546 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25547 awk -vp=$osp '$4 == p { print $2 }')
25548 [ $stat = IN ] || {
25549 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25550 error "deactivate error"
25552 echo "Activate: " $osp
25553 do_facet $SINGLEMDS $LCTL --device %$osp activate
25554 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25555 awk -vp=$osp '$4 == p { print $2 }')
25556 [ $stat = UP ] || {
25557 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25558 error "activate error"
25562 run_test 404 "validate manual {de}activated works properly for OSPs"
25565 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
25566 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
25567 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
25568 skip "Layout swap lock is not supported"
25570 check_swap_layouts_support
25571 check_swap_layout_no_dom $DIR
25573 test_mkdir $DIR/$tdir
25574 swap_lock_test -d $DIR/$tdir ||
25575 error "One layout swap locked test failed"
25577 run_test 405 "Various layout swap lock tests"
25580 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25581 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
25582 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
25583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25584 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
25585 skip "Need MDS version at least 2.8.50"
25587 local def_stripe_size=$($LFS getstripe -S $MOUNT)
25588 local test_pool=$TESTNAME
25590 pool_add $test_pool || error "pool_add failed"
25591 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
25592 error "pool_add_targets failed"
25594 save_layout_restore_at_exit $MOUNT
25596 # parent set default stripe count only, child will stripe from both
25597 # parent and fs default
25598 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
25599 error "setstripe $MOUNT failed"
25600 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
25601 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
25602 for i in $(seq 10); do
25603 local f=$DIR/$tdir/$tfile.$i
25604 touch $f || error "touch failed"
25605 local count=$($LFS getstripe -c $f)
25606 [ $count -eq $OSTCOUNT ] ||
25607 error "$f stripe count $count != $OSTCOUNT"
25608 local offset=$($LFS getstripe -i $f)
25609 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
25610 local size=$($LFS getstripe -S $f)
25611 [ $size -eq $((def_stripe_size * 2)) ] ||
25612 error "$f stripe size $size != $((def_stripe_size * 2))"
25613 local pool=$($LFS getstripe -p $f)
25614 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
25617 # change fs default striping, delete parent default striping, now child
25618 # will stripe from new fs default striping only
25619 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
25620 error "change $MOUNT default stripe failed"
25621 $LFS setstripe -c 0 $DIR/$tdir ||
25622 error "delete $tdir default stripe failed"
25623 for i in $(seq 11 20); do
25624 local f=$DIR/$tdir/$tfile.$i
25625 touch $f || error "touch $f failed"
25626 local count=$($LFS getstripe -c $f)
25627 [ $count -eq 1 ] || error "$f stripe count $count != 1"
25628 local offset=$($LFS getstripe -i $f)
25629 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
25630 local size=$($LFS getstripe -S $f)
25631 [ $size -eq $def_stripe_size ] ||
25632 error "$f stripe size $size != $def_stripe_size"
25633 local pool=$($LFS getstripe -p $f)
25634 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
25637 unlinkmany $DIR/$tdir/$tfile. 1 20
25639 local f=$DIR/$tdir/$tfile
25640 pool_remove_all_targets $test_pool $f
25641 pool_remove $test_pool $f
25643 run_test 406 "DNE support fs default striping"
25646 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25647 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
25648 skip "Need MDS version at least 2.8.55"
25649 remote_mds_nodsh && skip "remote MDS with nodsh"
25651 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
25652 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
25653 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
25654 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
25655 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
25657 #define OBD_FAIL_DT_TXN_STOP 0x2019
25658 for idx in $(seq $MDSCOUNT); do
25659 do_facet mds$idx "lctl set_param fail_loc=0x2019"
25661 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
25662 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
25663 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
25666 run_test 407 "transaction fail should cause operation fail"
25669 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
25671 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
25672 lctl set_param fail_loc=0x8000040a
25673 # let ll_prepare_partial_page() fail
25674 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
25678 # create at least 100 unused inodes so that
25679 # shrink_icache_memory(0) should not return 0
25680 touch $DIR/$tfile-{0..100}
25681 rm -f $DIR/$tfile-{0..100}
25684 echo 2 > /proc/sys/vm/drop_caches
25686 run_test 408 "drop_caches should not hang due to page leaks"
25690 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25692 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
25693 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
25694 touch $DIR/$tdir/guard || error "(2) Fail to create"
25696 local PREFIX=$(str_repeat 'A' 128)
25697 echo "Create 1K hard links start at $(date)"
25698 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25699 error "(3) Fail to hard link"
25701 echo "Links count should be right although linkEA overflow"
25702 stat $DIR/$tdir/guard || error "(4) Fail to stat"
25703 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
25704 [ $linkcount -eq 1001 ] ||
25705 error "(5) Unexpected hard links count: $linkcount"
25707 echo "List all links start at $(date)"
25708 ls -l $DIR/$tdir/foo > /dev/null ||
25709 error "(6) Fail to list $DIR/$tdir/foo"
25711 echo "Unlink hard links start at $(date)"
25712 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25713 error "(7) Fail to unlink"
25714 echo "Unlink hard links finished at $(date)"
25716 run_test 409 "Large amount of cross-MDTs hard links on the same file"
25720 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
25721 skip "Need client version at least 2.9.59"
25722 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
25723 skip "Need MODULES build"
25725 # Create a file, and stat it from the kernel
25726 local testfile=$DIR/$tfile
25729 local run_id=$RANDOM
25730 local my_ino=$(stat --format "%i" $testfile)
25732 # Try to insert the module. This will always fail as the
25733 # module is designed to not be inserted.
25734 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
25737 # Anything but success is a test failure
25739 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
25740 error "no inode match"
25742 run_test 410 "Test inode number returned from kernel thread"
25744 cleanup_test411_cgroup() {
25750 local cg_basedir=/sys/fs/cgroup/memory
25752 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
25753 skip "no setup for cgroup"
25755 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
25756 error "test file creation failed"
25757 cancel_lru_locks osc
25759 # Create a very small memory cgroup to force a slab allocation error
25760 local cgdir=$cg_basedir/osc_slab_alloc
25761 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
25762 trap "cleanup_test411_cgroup $cgdir" EXIT
25763 echo 2M > $cgdir/memory.kmem.limit_in_bytes
25764 echo 1M > $cgdir/memory.limit_in_bytes
25766 # Should not LBUG, just be killed by oom-killer
25767 # dd will return 0 even allocation failure in some environment.
25768 # So don't check return value
25769 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
25770 cleanup_test411_cgroup $cgdir
25774 run_test 411 "Slab allocation error with cgroup does not LBUG"
25777 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
25778 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
25779 skip "Need server version at least 2.10.55"
25781 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
25782 error "mkdir failed"
25783 $LFS getdirstripe $DIR/$tdir
25784 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
25785 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
25786 error "expect $((MDSCOUT - 1)) get $stripe_index"
25787 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
25788 [ $stripe_count -eq 2 ] ||
25789 error "expect 2 get $stripe_count"
25791 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
25796 # subdirs should be on the same MDT as parent
25797 for i in $(seq 0 $((MDSCOUNT - 1))); do
25798 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
25799 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
25800 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
25801 (( index == i )) || error "mdt$i/sub on MDT$index"
25804 # stripe offset -1, ditto
25805 for i in {1..10}; do
25806 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
25807 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
25808 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
25809 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
25810 (( index == index2 )) ||
25811 error "qos$i on MDT$index, sub on MDT$index2"
25814 local testdir=$DIR/$tdir/inherit
25816 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
25819 testdir=$testdir/s$i
25820 mkdir $testdir || error "mkdir $testdir failed"
25821 index=$($LFS getstripe -m $testdir)
25822 (( index == 1 )) ||
25823 error "$testdir on MDT$index"
25826 # not inherit any more
25827 testdir=$testdir/s3
25828 mkdir $testdir || error "mkdir $testdir failed"
25829 getfattr -d -m dmv $testdir | grep dmv &&
25830 error "default LMV set on $testdir" || true
25832 run_test 412 "mkdir on specific MDTs"
25834 TEST413_COUNT=${TEST413_COUNT:-200}
25835 generate_uneven_mdts() {
25837 local lmv_qos_maxage
25838 local lod_qos_maxage
25848 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25849 $LCTL set_param lmv.*.qos_maxage=1
25850 stack_trap "$LCTL set_param \
25851 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
25852 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25853 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25854 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25855 lod.*.mdt_qos_maxage=1
25856 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25857 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
25860 echo "Check for uneven MDTs: "
25862 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25863 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25864 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25866 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25867 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25870 for ((i = 1; i < ${#ffree[@]}; i++)); do
25871 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25872 if [ $tmp -gt $max ]; then
25876 if [ $tmp -lt $min ]; then
25882 (( ${ffree[min_index]} > 0 )) ||
25883 skip "no free files in MDT$min_index"
25884 (( ${ffree[min_index]} < 10000000 )) ||
25885 skip "too many free files in MDT$min_index"
25887 # Check if we need to generate uneven MDTs
25888 local diff=$(((max - min) * 100 / min))
25889 local testdir=$DIR/$tdir-fillmdt
25893 while (( diff < threshold )); do
25895 # generate uneven MDTs, create till $threshold% diff
25896 echo -n "weight diff=$diff% must be > $threshold% ..."
25897 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
25898 testdir=$DIR/$tdir-fillmdt/$i
25899 [ -d $testdir ] && continue
25900 $LFS mkdir -i $min_index $testdir ||
25901 error "mkdir $testdir failed"
25902 $LFS setstripe -E 1M -L mdt $testdir ||
25903 error "setstripe $testdir failed"
25905 for ((F=0; F < TEST413_COUNT; F++)); do
25906 dd if=/dev/zero of=$testdir/f.$F bs=128K count=1 > \
25907 /dev/null 2>&1 || error "dd $F failed"
25909 sync; sleep 1; sync
25911 # wait for QOS to update
25912 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
25914 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
25915 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
25916 max=$(((${ffree[max_index]} >> 8) *
25917 (${bavail[max_index]} * bsize >> 16)))
25918 min=$(((${ffree[min_index]} >> 8) *
25919 (${bavail[min_index]} * bsize >> 16)))
25920 diff=$(((max - min) * 100 / min))
25924 echo "MDT filesfree available: ${ffree[*]}"
25925 echo "MDT blocks available: ${bavail[*]}"
25926 echo "weight diff=$diff%"
25931 local stripe_count=$2
25932 local mdts=$(comma_list $(mdts_nodes))
25935 local lmv_qos_prio_free
25936 local lmv_qos_threshold_rr
25937 local lmv_qos_maxage
25938 local lod_qos_prio_free
25939 local lod_qos_threshold_rr
25940 local lod_qos_maxage
25944 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
25945 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
25946 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25948 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
25949 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25950 stack_trap "$LCTL set_param \
25951 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
25952 stack_trap "$LCTL set_param \
25953 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
25954 stack_trap "$LCTL set_param \
25955 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
25957 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
25958 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
25959 lod_qos_prio_free=${lod_qos_prio_free%%%}
25960 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
25961 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
25962 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
25963 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25964 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25965 stack_trap "do_nodes $mdts $LCTL set_param \
25966 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
25967 stack_trap "do_nodes $mdts $LCTL set_param \
25968 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
25969 stack_trap "do_nodes $mdts $LCTL set_param \
25970 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
25972 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
25973 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
25975 testdir=$DIR/$tdir-s$stripe_count/rr
25977 local stripe_index=$($LFS getstripe -m $testdir)
25978 local test_mkdir_rr=true
25980 getfattr -d -m dmv -e hex $testdir | grep dmv
25981 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
25982 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
25983 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
25984 test_mkdir_rr=false
25989 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
25990 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
25992 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
25993 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
25994 eval $mkdir_cmd $testdir/subdir$i ||
25995 error "$mkdir_cmd subdir$i failed"
25998 for (( i = 0; i < $MDSCOUNT; i++ )); do
25999 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26000 echo "$count directories created on MDT$i"
26001 if $test_mkdir_rr; then
26002 (( $count == 100 )) ||
26003 error "subdirs are not evenly distributed"
26004 elif (( $i == $stripe_index )); then
26005 (( $count == 100 * MDSCOUNT )) ||
26006 error "$count subdirs created on MDT$i"
26008 (( $count == 0 )) ||
26009 error "$count subdirs created on MDT$i"
26012 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
26013 count=$($LFS getdirstripe $testdir/* |
26014 grep -c -P "^\s+$i\t")
26015 echo "$count stripes created on MDT$i"
26016 # deviation should < 5% of average
26017 (( $count >= 95 * stripe_count &&
26018 $count <= 105 * stripe_count)) ||
26019 error "stripes are not evenly distributed"
26024 echo "Check for uneven MDTs: "
26034 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26035 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26036 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26038 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26039 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26042 for ((i = 1; i < ${#ffree[@]}; i++)); do
26043 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26044 if [ $tmp -gt $max ]; then
26048 if [ $tmp -lt $min ]; then
26054 (( ${ffree[min_index]} > 0 )) ||
26055 skip "no free files in MDT$min_index"
26056 (( ${ffree[min_index]} < 10000000 )) ||
26057 skip "too many free files in MDT$min_index"
26059 echo "MDT filesfree available: ${ffree[*]}"
26060 echo "MDT blocks available: ${bavail[*]}"
26061 echo "weight diff=$(((max - min) * 100 / min))%"
26063 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
26065 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
26066 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
26067 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
26068 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
26069 # decrease statfs age, so that it can be updated in time
26070 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
26071 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
26075 testdir=$DIR/$tdir-s$stripe_count/qos
26078 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
26079 for (( i = 0; i < num * MDSCOUNT; i++ )); do
26080 eval $mkdir_cmd $testdir/subdir$i ||
26081 error "$mkdir_cmd subdir$i failed"
26085 for (( i = 0; i < $MDSCOUNT; i++ )); do
26086 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26087 (( count > max )) && max=$count
26088 echo "$count directories created on MDT$i"
26091 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
26093 # D-value should > 10% of averge
26094 (( max - min > num / 10 )) ||
26095 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
26097 # ditto for stripes
26098 if (( stripe_count > 1 )); then
26100 for (( i = 0; i < $MDSCOUNT; i++ )); do
26101 count=$($LFS getdirstripe $testdir/* |
26102 grep -c -P "^\s+$i\t")
26103 (( count > max )) && max=$count
26104 echo "$count stripes created on MDT$i"
26107 min=$($LFS getdirstripe $testdir/* |
26108 grep -c -P "^\s+$min_index\t")
26109 (( max - min > num * stripe_count / 10 )) ||
26110 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
26122 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26123 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26124 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26126 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26128 for ((i = 1; i < ${#ffree[@]}; i++)); do
26129 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26130 (( tmp < min )) && min=$tmp && min_index=$i
26137 [ $MDSCOUNT -lt 2 ] &&
26138 skip "We need at least 2 MDTs for this test"
26140 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26141 skip "Need server version at least 2.12.52"
26145 generate_uneven_mdts 100
26146 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26147 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
26148 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
26149 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
26150 error "mkdir failed"
26151 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
26154 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
26157 [ $MDSCOUNT -lt 2 ] &&
26158 skip "We need at least 2 MDTs for this test"
26160 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26161 skip "Need server version at least 2.12.52"
26166 generate_uneven_mdts 100
26167 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26168 testdir=$DIR/$tdir-s$stripe_count
26169 mkdir $testdir || error "mkdir $testdir failed"
26170 mkdir $testdir/rr || error "mkdir rr failed"
26171 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
26172 error "mkdir qos failed"
26173 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
26174 $testdir/rr || error "setdirstripe rr failed"
26175 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
26176 error "setdirstripe failed"
26177 test_qos_mkdir "mkdir" $stripe_count
26180 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
26183 (( $MDSCOUNT >= 2 )) ||
26184 skip "We need at least 2 MDTs for this test"
26186 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
26187 skip "Need server version at least 2.14.51"
26193 testdir=$DIR/${tdir}-s1
26194 mkdir $testdir || error "mkdir $testdir failed"
26195 mkdir $testdir/rr || error "mkdir rr failed"
26196 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
26197 # default max_inherit is -1, default max_inherit_rr is 0
26198 $LFS setdirstripe -D -c 1 $testdir/rr ||
26199 error "setdirstripe rr failed"
26200 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
26201 error "setdirstripe qos failed"
26202 test_qos_mkdir "mkdir" 1
26204 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
26205 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
26206 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
26207 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
26208 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
26210 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
26211 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
26212 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
26213 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
26214 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
26215 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
26216 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
26217 error "level2 shouldn't have default LMV" || true
26219 run_test 413c "mkdir with default LMV max inherit rr"
26222 (( MDSCOUNT >= 2 )) ||
26223 skip "We need at least 2 MDTs for this test"
26225 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
26226 skip "Need server version at least 2.14.51"
26228 local lmv_qos_threshold_rr
26230 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26232 stack_trap "$LCTL set_param \
26233 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
26235 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26236 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
26237 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
26238 error "$tdir shouldn't have default LMV"
26239 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
26240 error "mkdir sub failed"
26242 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
26244 (( count == 100 )) || error "$count subdirs on MDT0"
26246 run_test 413d "inherit ROOT default LMV"
26249 (( MDSCOUNT >= 2 )) ||
26250 skip "We need at least 2 MDTs for this test"
26251 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26252 skip "Need server version at least 2.14.55"
26254 local testdir=$DIR/$tdir
26255 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
26257 local sub_max_inherit
26259 mkdir -p $testdir || error "failed to create $testdir"
26261 # set default max-inherit to -1 if stripe count is 0 or 1
26262 $LFS setdirstripe -D -c 1 $testdir ||
26263 error "failed to set default LMV"
26264 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26265 (( max_inherit == -1 )) ||
26266 error "wrong max_inherit value $max_inherit"
26268 # set default max_inherit to a fixed value if stripe count is not 0 or 1
26269 $LFS setdirstripe -D -c -1 $testdir ||
26270 error "failed to set default LMV"
26271 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26272 (( max_inherit > 0 )) ||
26273 error "wrong max_inherit value $max_inherit"
26275 # and the subdir will decrease the max_inherit by 1
26276 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
26277 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
26278 (( sub_max_inherit == max_inherit - 1)) ||
26279 error "wrong max-inherit of subdir $sub_max_inherit"
26281 # check specified --max-inherit and warning message
26282 stack_trap "rm -f $tmpfile"
26283 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
26284 error "failed to set default LMV"
26285 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26286 (( max_inherit == -1 )) ||
26287 error "wrong max_inherit value $max_inherit"
26289 # check the warning messages
26290 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
26291 error "failed to detect warning string"
26294 run_test 413e "check default max-inherit value"
26296 test_fs_dmv_inherit()
26298 local testdir=$DIR/$tdir
26305 mkdir $testdir || error "mkdir $testdir failed"
26306 count=$($LFS getdirstripe -D -c $testdir)
26307 (( count == 1 )) ||
26308 error "$testdir default LMV count mismatch $count != 1"
26309 inherit=$($LFS getdirstripe -D -X $testdir)
26310 (( inherit == 3 - i )) ||
26311 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
26312 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
26313 (( inherit_rr == 3 - i )) ||
26314 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
26315 testdir=$testdir/sub
26318 mkdir $testdir || error "mkdir $testdir failed"
26319 count=$($LFS getdirstripe -D -c $testdir)
26320 (( count == 0 )) ||
26321 error "$testdir default LMV count not zero: $count"
26325 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26327 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26328 skip "Need server version at least 2.14.55"
26330 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26331 error "dump $DIR default LMV failed"
26332 stack_trap "setfattr --restore=$TMP/dmv.ea"
26334 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26335 error "set $DIR default LMV failed"
26337 test_fs_dmv_inherit
26339 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
26342 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26344 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
26345 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26346 error "dump $DIR default LMV failed"
26347 stack_trap "setfattr --restore=$TMP/dmv.ea"
26349 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26350 error "set $DIR default LMV failed"
26352 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
26353 error "mount $MOUNT2 failed"
26354 stack_trap "umount_client $MOUNT2"
26356 local saved_DIR=$DIR
26360 stack_trap "export DIR=$saved_DIR"
26362 # first check filesystem-wide default LMV inheritance
26363 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
26365 # then check subdirs are spread to all MDTs
26366 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
26368 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
26370 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
26372 run_test 413g "enforce ROOT default LMV on subdir mount"
26375 (( MDSCOUNT >= 2 )) ||
26376 skip "We need at least 2 MDTs for this test"
26378 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
26379 skip "Need server version at least 2.15.50.6"
26381 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26383 stack_trap "$LCTL set_param \
26384 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26385 $LCTL set_param lmv.*.qos_maxage=1
26389 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
26390 local count=$((MDSCOUNT * 20))
26392 generate_uneven_mdts 50
26394 mkdir -p $dir || error "mkdir $dir failed"
26395 stack_trap "rm -rf $dir"
26396 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
26397 --max-inherit-rr=$rr_depth $dir
26399 for ((d=0; d < depth + 2; d++)); do
26401 for ((sub=0; sub < count; sub++)); do
26404 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
26405 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
26406 # subdirs within $rr_depth should be created round-robin
26407 if (( d < rr_depth )); then
26408 (( ${num[0]} != count )) ||
26409 error "all objects created on MDT ${num[1]}"
26415 run_test 413h "don't stick to parent for round-robin dirs"
26422 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
26423 unlinkmany $subdir/f. $TEST413_COUNT &
26427 for pid in $pids; do
26431 run_test 413z "413 test cleanup"
26434 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
26435 $LCTL set_param fail_loc=0x80000521
26436 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26439 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
26442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26443 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26444 skip "Need server version at least 2.11.52"
26454 # this test may be slow on ZFS
26455 [ "$mds1_FSTYPE" == "zfs" ] && total=50
26457 # though this test is designed for striped directory, let's test normal
26458 # directory too since lock is always saved as CoS lock.
26459 test_mkdir $DIR/$tdir || error "mkdir $tdir"
26460 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
26469 start_time=$(date +%s)
26470 for i in $(seq $total); do
26471 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
26474 end_time=$(date +%s)
26475 duration=$((end_time - start_time))
26477 kill -9 $setattr_pid
26479 echo "rename $total files took $duration sec"
26480 [ $duration -lt 100 ] || error "rename took $duration sec"
26482 run_test 415 "lock revoke is not missing"
26485 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26486 skip "Need server version at least 2.11.55"
26488 # define OBD_FAIL_OSD_TXN_START 0x19a
26489 do_facet mds1 lctl set_param fail_loc=0x19a
26491 lfs mkdir -c $MDSCOUNT $DIR/$tdir
26495 run_test 416 "transaction start failure won't cause system hung"
26499 do_nodes $(comma_list $(mdts_nodes)) \
26500 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
26501 do_nodes $(comma_list $(mdts_nodes)) \
26502 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
26503 do_nodes $(comma_list $(mdts_nodes)) \
26504 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
26508 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26509 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
26510 skip "Need MDS version at least 2.11.56"
26512 trap cleanup_417 RETURN EXIT
26514 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
26515 do_nodes $(comma_list $(mdts_nodes)) \
26516 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
26517 $LFS migrate -m 0 $DIR/$tdir.1 &&
26518 error "migrate dir $tdir.1 should fail"
26520 do_nodes $(comma_list $(mdts_nodes)) \
26521 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
26522 $LFS mkdir -i 1 $DIR/$tdir.2 &&
26523 error "create remote dir $tdir.2 should fail"
26525 do_nodes $(comma_list $(mdts_nodes)) \
26526 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
26527 $LFS mkdir -c 2 $DIR/$tdir.3 &&
26528 error "create striped dir $tdir.3 should fail"
26531 run_test 417 "disable remote dir, striped dir and dir migration"
26533 # Checks that the outputs of df [-i] and lfs df [-i] match
26535 # usage: check_lfs_df <blocks | inodes> <mountpoint>
26545 [ "$1" == "blocks" ] && inodes= || inodes="-i"
26547 for count in {1..100}; do
26548 do_nodes "$CLIENTS" \
26549 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26552 # read the lines of interest
26553 df_out=($(df -P $inodes $dir | tail -n +2)) ||
26554 error "df $inodes $dir | tail -n +2 failed"
26555 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
26556 error "lfs df $inodes $dir | grep summary: failed"
26558 # skip first substrings of each output as they are different
26559 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
26560 # compare the two outputs
26562 # skip "available" on MDT until LU-13997 is fixed.
26563 #for i in {1..5}; do
26564 for i in 1 2 4 5; do
26565 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
26573 lfs df $inodes $dir
26574 error "df and lfs df $1 output mismatch: " \
26575 "df ${inodes}: ${df_out[*]}, " \
26576 "lfs df ${inodes}: ${lfs_df_out[*]}"
26581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26583 local dir=$DIR/$tdir
26584 local numfiles=$((RANDOM % 4096 + 2))
26585 local numblocks=$((RANDOM % 256 + 1))
26587 wait_delete_completed
26590 # check block output
26591 check_lfs_df blocks $dir
26592 # check inode output
26593 check_lfs_df inodes $dir
26595 # create a single file and retest
26596 echo "Creating a single file and testing"
26597 createmany -o $dir/$tfile- 1 &>/dev/null ||
26598 error "creating 1 file in $dir failed"
26599 check_lfs_df blocks $dir
26600 check_lfs_df inodes $dir
26602 # create a random number of files
26603 echo "Creating $((numfiles - 1)) files and testing"
26604 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
26605 error "creating $((numfiles - 1)) files in $dir failed"
26607 # write a random number of blocks to the first test file
26608 echo "Writing $numblocks 4K blocks and testing"
26609 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
26610 count=$numblocks &>/dev/null ||
26611 error "dd to $dir/${tfile}-0 failed"
26614 check_lfs_df blocks $dir
26615 check_lfs_df inodes $dir
26617 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
26618 error "unlinking $numfiles files in $dir failed"
26620 run_test 418 "df and lfs df outputs match"
26624 local dir=$DIR/$tdir
26629 cancel_lru_locks mdc
26631 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
26632 $LCTL set_param fail_loc=0x1410
26634 $LCTL set_param fail_loc=0
26637 run_test 419 "Verify open file by name doesn't crash kernel"
26641 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
26642 skip "Need MDS version at least 2.12.53"
26644 local SAVE_UMASK=$(umask)
26645 local dir=$DIR/$tdir
26646 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
26650 mkdir -m03777 $dir/testdir
26651 ls -dn $dir/testdir
26652 # Need to remove trailing '.' when SELinux is enabled
26653 local dirperms=$(ls -dn $dir/testdir |
26654 awk '{ sub(/\.$/, "", $1); print $1}')
26655 [ $dirperms == "drwxrwsrwt" ] ||
26656 error "incorrect perms on $dir/testdir"
26658 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
26659 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
26660 ls -n $dir/testdir/testfile
26661 local fileperms=$(ls -n $dir/testdir/testfile |
26662 awk '{ sub(/\.$/, "", $1); print $1}')
26663 [ $fileperms == "-rwxr-xr-x" ] ||
26664 error "incorrect perms on $dir/testdir/testfile"
26668 run_test 420 "clear SGID bit on non-directories for non-members"
26675 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26676 skip "Need MDS version at least 2.12.54"
26678 test_mkdir $DIR/$tdir
26679 createmany -o $DIR/$tdir/f 3
26680 cnt=$(ls -1 $DIR/$tdir | wc -l)
26681 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26683 fid1=$(lfs path2fid $DIR/$tdir/f1)
26684 fid2=$(lfs path2fid $DIR/$tdir/f2)
26685 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
26687 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
26688 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
26690 cnt=$(ls -1 $DIR/$tdir | wc -l)
26691 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26693 rm -f $DIR/$tdir/f3 || error "can't remove f3"
26694 createmany -o $DIR/$tdir/f 3
26695 cnt=$(ls -1 $DIR/$tdir | wc -l)
26696 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26698 fid1=$(lfs path2fid $DIR/$tdir/f1)
26699 fid2=$(lfs path2fid $DIR/$tdir/f2)
26700 echo "remove using fsname $FSNAME"
26701 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
26703 cnt=$(ls -1 $DIR/$tdir | wc -l)
26704 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26706 run_test 421a "simple rm by fid"
26713 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26714 skip "Need MDS version at least 2.12.54"
26716 test_mkdir $DIR/$tdir
26717 createmany -o $DIR/$tdir/f 3
26718 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
26721 FID1=$(lfs path2fid $DIR/$tdir/f1)
26722 FID2=$(lfs path2fid $DIR/$tdir/f2)
26723 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
26725 kill -USR1 $MULTIPID
26728 cnt=$(ls $DIR/$tdir | wc -l)
26729 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
26731 run_test 421b "rm by fid on open file"
26737 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26738 skip "Need MDS version at least 2.12.54"
26740 test_mkdir $DIR/$tdir
26741 createmany -o $DIR/$tdir/f 3
26742 touch $DIR/$tdir/$tfile
26743 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
26744 cnt=$(ls -1 $DIR/$tdir | wc -l)
26745 [ $cnt != 184 ] && error "unexpected #files: $cnt"
26747 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
26748 $LFS rmfid $DIR $FID1 || error "rmfid failed"
26750 cnt=$(ls $DIR/$tdir | wc -l)
26751 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
26753 run_test 421c "rm by fid against hardlinked files"
26759 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26760 skip "Need MDS version at least 2.12.54"
26762 test_mkdir $DIR/$tdir
26763 createmany -o $DIR/$tdir/f 4097
26764 cnt=$(ls -1 $DIR/$tdir | wc -l)
26765 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
26767 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
26768 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26770 cnt=$(ls $DIR/$tdir | wc -l)
26772 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26774 run_test 421d "rmfid en masse"
26780 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26781 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26782 skip "Need MDS version at least 2.12.54"
26784 mkdir -p $DIR/$tdir
26785 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26786 createmany -o $DIR/$tdir/striped_dir/f 512
26787 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26788 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26790 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26791 sed "s/[/][^:]*://g")
26792 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26794 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26796 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26798 run_test 421e "rmfid in DNE"
26804 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26805 skip "Need MDS version at least 2.12.54"
26807 test_mkdir $DIR/$tdir
26809 cnt=$(ls -1 $DIR/$tdir | wc -l)
26810 [ $cnt != 1 ] && error "unexpected #files: $cnt"
26812 FID=$(lfs path2fid $DIR/$tdir/f)
26813 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
26814 # rmfid should fail
26815 cnt=$(ls -1 $DIR/$tdir | wc -l)
26816 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
26818 chmod a+rw $DIR/$tdir
26820 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
26821 # rmfid should fail
26822 cnt=$(ls -1 $DIR/$tdir | wc -l)
26823 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
26826 $RUNAS touch $DIR/$tdir/f
26827 FID=$(lfs path2fid $DIR/$tdir/f)
26828 echo "rmfid as root"
26829 $LFS rmfid $DIR $FID || error "rmfid as root failed"
26830 cnt=$(ls -1 $DIR/$tdir | wc -l)
26831 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
26834 $RUNAS touch $DIR/$tdir/f
26835 cnt=$(ls -1 $DIR/$tdir | wc -l)
26836 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
26837 FID=$(lfs path2fid $DIR/$tdir/f)
26838 # rmfid w/o user_fid2path mount option should fail
26839 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
26840 cnt=$(ls -1 $DIR/$tdir | wc -l)
26841 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
26843 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
26844 stack_trap "rmdir $tmpdir"
26845 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
26846 error "failed to mount client'"
26847 stack_trap "umount_client $tmpdir"
26849 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
26850 # rmfid should succeed
26851 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
26852 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
26854 # rmfid shouldn't allow to remove files due to dir's permission
26855 chmod a+rwx $tmpdir/$tdir
26856 touch $tmpdir/$tdir/f
26857 ls -la $tmpdir/$tdir
26858 FID=$(lfs path2fid $tmpdir/$tdir/f)
26859 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
26862 run_test 421f "rmfid checks permissions"
26868 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26869 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26870 skip "Need MDS version at least 2.12.54"
26872 mkdir -p $DIR/$tdir
26873 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26874 createmany -o $DIR/$tdir/striped_dir/f 512
26875 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26876 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26878 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26879 sed "s/[/][^:]*://g")
26881 rm -f $DIR/$tdir/striped_dir/f1*
26882 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26883 removed=$((512 - cnt))
26885 # few files have been just removed, so we expect
26886 # rmfid to fail on their fids
26887 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
26888 [ $removed != $errors ] && error "$errors != $removed"
26890 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26892 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26894 run_test 421g "rmfid to return errors properly"
26897 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
26898 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
26899 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
26900 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
26901 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
26903 local amc=$(at_max_get client)
26904 local amo=$(at_max_get mds1)
26905 local timeout=`lctl get_param -n timeout`
26907 at_max_set 0 client
26910 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
26911 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
26912 fail_val=$(((2*timeout + 10)*1000))
26913 touch $DIR/$tdir/d3/file &
26915 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
26916 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
26917 fail_val=$((2*timeout + 5))
26918 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
26922 sleep $((2 * timeout))
26926 touch $DIR/$tdir/d2/file3
26927 touch $DIR/$tdir/d2/file4
26928 touch $DIR/$tdir/d2/file5
26931 at_max_set $amc client
26932 at_max_set $amo mds1
26934 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
26935 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
26936 error "Watchdog is always throttled"
26938 run_test 422 "kill a process with RPC in progress"
26951 # ensure statfs cache is expired
26954 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
26955 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
26959 run_test 423 "statfs should return a right data"
26962 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
26963 $LCTL set_param fail_loc=0x80000522
26964 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26967 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
26970 test_mkdir -c -1 $DIR/$tdir
26971 $LFS setstripe -c -1 $DIR/$tdir
26973 lru_resize_disable "" 100
26974 stack_trap "lru_resize_enable" EXIT
26978 for i in $(seq $((MDSCOUNT * 125))); do
26979 local t=$DIR/$tdir/$tfile_$i
26981 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
26982 error_noexit "Create file $t"
26984 stack_trap "rm -rf $DIR/$tdir" EXIT
26986 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
26987 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
26988 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
26990 [ $lock_count -le $lru_size ] ||
26991 error "osc lock count $lock_count > lru size $lru_size"
26994 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
26995 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
26996 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
26998 [ $lock_count -le $lru_size ] ||
26999 error "mdc lock count $lock_count > lru size $lru_size"
27002 run_test 425 "lock count should not exceed lru size"
27005 splice-test -r $DIR/$tfile
27006 splice-test -rd $DIR/$tfile
27007 splice-test $DIR/$tfile
27008 splice-test -d $DIR/$tfile
27010 run_test 426 "splice test on Lustre"
27013 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
27014 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
27015 skip "Need MDS version at least 2.12.4"
27021 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
27022 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
27024 $LFS getdirstripe $DIR/$tdir/1/dir
27026 #first setfattr for creating updatelog
27027 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
27029 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
27030 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
27031 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
27032 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
27036 wait_recovery_complete mds2 $((2*TIMEOUT))
27038 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
27039 echo $log | grep "get update log failed" &&
27040 error "update log corruption is detected" || true
27042 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
27045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27046 local cache_limit=$CACHE_MAX
27048 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
27049 $LCTL set_param -n llite.*.max_cached_mb=64
27052 $LFS setstripe -c 1 $DIR/$tdir
27053 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
27054 stack_trap "rm -f $DIR/$tdir/$tfile.*"
27056 for f in $(seq 4); do
27057 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
27061 cancel_lru_locks osc
27063 for f in $(seq 4); do
27064 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
27068 run_test 428 "large block size IO should not hang"
27070 test_429() { # LU-7915 / LU-10948
27071 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
27072 local testfile=$DIR/$tfile
27073 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
27079 $LCTL get_param $ll_opencache_threshold_count ||
27080 skip "client does not have opencache parameter"
27082 set_opencache $new_flag
27083 stack_trap "restore_opencache"
27084 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
27085 error "enable opencache failed"
27087 # drop MDC DLM locks
27088 cancel_lru_locks mdc
27089 # clear MDC RPC stats counters
27090 $LCTL set_param $mdc_rpcstats=clear
27092 # According to the current implementation, we need to run 3 times
27093 # open & close file to verify if opencache is enabled correctly.
27094 # 1st, RPCs are sent for lookup/open and open handle is released on
27096 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
27097 # so open handle won't be released thereafter.
27098 # 3rd, No RPC is sent out.
27099 $MULTIOP $testfile oc || error "multiop failed"
27100 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27101 echo "1st: $first_rpc RPCs in flight"
27103 $MULTIOP $testfile oc || error "multiop failed"
27104 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27105 echo "2nd: $second_rpc RPCs in flight"
27107 $MULTIOP $testfile oc || error "multiop failed"
27108 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27109 echo "3rd: $third_rpc RPCs in flight"
27111 #verify no MDC RPC is sent
27112 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
27114 run_test 429 "verify if opencache flag on client side does work"
27120 # data at [200K, 400K)
27121 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
27122 error "256K->512K dd fails"
27124 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
27125 error "2M->3M dd fails"
27127 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
27128 error "4M->5M dd fails"
27129 echo "Data at 256K...512K, 2M...3M and 4M...5M"
27130 # start at first component hole #1
27131 printf "Seeking hole from 1000 ... "
27132 offset=$(lseek_test -l 1000 $file)
27134 [[ $offset == 1000 ]] || error "offset $offset != 1000"
27135 printf "Seeking data from 1000 ... "
27136 offset=$(lseek_test -d 1000 $file)
27138 [[ $offset == 262144 ]] || error "offset $offset != 262144"
27140 # start at first component data block
27141 printf "Seeking hole from 300000 ... "
27142 offset=$(lseek_test -l 300000 $file)
27144 [[ $offset == 524288 ]] || error "offset $offset != 524288"
27145 printf "Seeking data from 300000 ... "
27146 offset=$(lseek_test -d 300000 $file)
27148 [[ $offset == 300000 ]] || error "offset $offset != 300000"
27150 # start at the first component but beyond end of object size
27151 printf "Seeking hole from 1000000 ... "
27152 offset=$(lseek_test -l 1000000 $file)
27154 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27155 printf "Seeking data from 1000000 ... "
27156 offset=$(lseek_test -d 1000000 $file)
27158 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27160 # start at second component stripe 2 (empty file)
27161 printf "Seeking hole from 1500000 ... "
27162 offset=$(lseek_test -l 1500000 $file)
27164 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
27165 printf "Seeking data from 1500000 ... "
27166 offset=$(lseek_test -d 1500000 $file)
27168 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27170 # start at second component stripe 1 (all data)
27171 printf "Seeking hole from 3000000 ... "
27172 offset=$(lseek_test -l 3000000 $file)
27174 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
27175 printf "Seeking data from 3000000 ... "
27176 offset=$(lseek_test -d 3000000 $file)
27178 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
27180 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
27181 error "2nd dd fails"
27182 echo "Add data block at 640K...1280K"
27184 # start at before new data block, in hole
27185 printf "Seeking hole from 600000 ... "
27186 offset=$(lseek_test -l 600000 $file)
27188 [[ $offset == 600000 ]] || error "offset $offset != 600000"
27189 printf "Seeking data from 600000 ... "
27190 offset=$(lseek_test -d 600000 $file)
27192 [[ $offset == 655360 ]] || error "offset $offset != 655360"
27194 # start at the first component new data block
27195 printf "Seeking hole from 1000000 ... "
27196 offset=$(lseek_test -l 1000000 $file)
27198 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27199 printf "Seeking data from 1000000 ... "
27200 offset=$(lseek_test -d 1000000 $file)
27202 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27204 # start at second component stripe 2, new data
27205 printf "Seeking hole from 1200000 ... "
27206 offset=$(lseek_test -l 1200000 $file)
27208 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27209 printf "Seeking data from 1200000 ... "
27210 offset=$(lseek_test -d 1200000 $file)
27212 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
27214 # start beyond file end
27215 printf "Using offset > filesize ... "
27216 lseek_test -l 4000000 $file && error "lseek should fail"
27217 printf "Using offset > filesize ... "
27218 lseek_test -d 4000000 $file && error "lseek should fail"
27224 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
27225 skip "MDT does not support SEEK_HOLE"
27227 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27228 skip "OST does not support SEEK_HOLE"
27230 local file=$DIR/$tdir/$tfile
27232 mkdir -p $DIR/$tdir
27234 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
27235 # OST stripe #1 will have continuous data at [1M, 3M)
27236 # OST stripe #2 is empty
27237 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
27238 lseek_test_430 $file
27240 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
27241 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
27242 lseek_test_430 $file
27244 $LFS setstripe -c2 -S 512K $file
27245 echo "Two stripes, stripe size 512K"
27246 lseek_test_430 $file
27248 # FLR with stale mirror
27249 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
27251 echo "Mirrored file:"
27252 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
27253 echo "Plain 2 stripes 1M"
27254 lseek_test_430 $file
27257 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
27260 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27261 skip "OST does not support SEEK_HOLE"
27264 local file=$DIR/$tdir/$tfile
27266 mkdir -p $DIR/$tdir
27267 # Empty layout lseek should fail
27270 printf "Seeking hole from 0 ... "
27271 lseek_test -l 0 $file && error "lseek should fail"
27272 printf "Seeking data from 0 ... "
27273 lseek_test -d 0 $file && error "lseek should fail"
27277 $LFS setstripe -E 1M -c2 -E eof $file
27278 $TRUNCATE $file 1048576
27279 printf "Seeking hole from 1000000 ... "
27280 offset=$(lseek_test -l 1000000 $file)
27282 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27283 printf "Seeking data from 1000000 ... "
27284 lseek_test -d 1000000 $file && error "lseek should fail"
27287 # full component followed by non-inited one
27288 $LFS setstripe -E 1M -c2 -E eof $file
27289 dd if=/dev/urandom of=$file bs=1M count=1
27290 printf "Seeking hole from 1000000 ... "
27291 offset=$(lseek_test -l 1000000 $file)
27293 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27294 printf "Seeking hole from 1048576 ... "
27295 lseek_test -l 1048576 $file && error "lseek should fail"
27296 # init second component and truncate back
27297 echo "123" >> $file
27298 $TRUNCATE $file 1048576
27299 printf "Seeking hole from 1000000 ... "
27300 offset=$(lseek_test -l 1000000 $file)
27302 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27303 printf "Seeking hole from 1048576 ... "
27304 lseek_test -l 1048576 $file && error "lseek should fail"
27305 # boundary checks for big values
27306 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
27307 offset=$(lseek_test -d 0 $file.10g)
27308 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
27309 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
27310 offset=$(lseek_test -d 0 $file.100g)
27311 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
27314 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
27317 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27318 skip "OST does not support SEEK_HOLE"
27320 local file=$DIR/$tdir/$tfile
27323 mkdir -p $DIR/$tdir
27324 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
27326 # cp version 8.33+ prefers lseek over fiemap
27327 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
27329 time cp $file /dev/null
27330 (( SECONDS - start < 5 )) ||
27331 error "cp: too long runtime $((SECONDS - start))"
27334 # tar version 1.29+ supports SEEK_HOLE/DATA
27335 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
27337 time tar cS $file - | cat > /dev/null
27338 (( SECONDS - start < 5 )) ||
27339 error "tar: too long runtime $((SECONDS - start))"
27342 run_test 430c "lseek: external tools check"
27344 test_431() { # LU-14187
27345 local file=$DIR/$tdir/$tfile
27347 mkdir -p $DIR/$tdir
27348 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
27349 dd if=/dev/urandom of=$file bs=4k count=1
27350 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
27351 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
27352 #define OBD_FAIL_OST_RESTART_IO 0x251
27353 do_facet ost1 "$LCTL set_param fail_loc=0x251"
27354 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
27358 echo 3 > /proc/sys/vm/drop_caches
27359 diff $file $file.0 || error "data diff"
27361 run_test 431 "Restart transaction for IO"
27363 cleanup_test_432() {
27364 do_facet mgs $LCTL nodemap_activate 0
27365 wait_nm_sync active
27369 local tmpdir=$TMP/dir432
27371 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
27372 skip "Need MDS version at least 2.14.52"
27374 stack_trap cleanup_test_432 EXIT
27378 do_facet mgs $LCTL nodemap_activate 1
27379 wait_nm_sync active
27380 do_facet mgs $LCTL nodemap_modify --name default \
27381 --property admin --value 1
27382 do_facet mgs $LCTL nodemap_modify --name default \
27383 --property trusted --value 1
27384 cancel_lru_locks mdc
27385 wait_nm_sync default admin_nodemap
27386 wait_nm_sync default trusted_nodemap
27388 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
27389 grep -ci "Operation not permitted") -ne 0 ]; then
27390 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
27393 run_test 432 "mv dir from outside Lustre"
27396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27398 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
27399 skip "inode cache not supported"
27401 $LCTL set_param llite.*.inode_cache=0
27402 stack_trap "$LCTL set_param llite.*.inode_cache=1"
27408 cancel_lru_locks mdc
27409 test_mkdir $DIR/$tdir || error "mkdir $tdir"
27410 createmany -m $DIR/$tdir/f $count
27411 createmany -d $DIR/$tdir/d $count
27412 ls -l $DIR/$tdir > /dev/null
27413 stack_trap "rm -rf $DIR/$tdir"
27415 before=$(num_objects)
27416 cancel_lru_locks mdc
27417 after=$(num_objects)
27419 # sometimes even @before is less than 2 * count
27420 while (( before - after < count )); do
27422 after=$(num_objects)
27424 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
27425 if (( wait > 60 )); then
27426 error "inode slab grew from $before to $after"
27430 echo "lustre_inode_cache $before objs before lock cancel, $after after"
27432 run_test 433 "ldlm lock cancel releases dentries and inodes"
27435 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27436 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27437 skip "Need server version at least 2.9.55"
27439 start_full_debug_logging
27443 stop_full_debug_logging
27447 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27448 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27449 awk '/The barrier for/ { print $7 }')
27452 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
27457 barrier_expired() {
27460 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27461 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27462 awk '/will be expired/ { print $7 }')
27464 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
27473 echo "Start barrier_freeze at: $(date)"
27474 #define OBD_FAIL_BARRIER_DELAY 0x2202
27475 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27476 # Do not reduce barrier time - See LU-11873
27477 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
27480 local b_status=$(barrier_stat)
27481 echo "Got barrier status at: $(date)"
27482 [ "$b_status" = "'freezing_p1'" ] ||
27483 error "(1) unexpected barrier status $b_status"
27485 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27487 b_status=$(barrier_stat)
27488 [ "$b_status" = "'frozen'" ] ||
27489 error "(2) unexpected barrier status $b_status"
27491 local expired=$(barrier_expired)
27492 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
27493 sleep $((expired + 3))
27495 b_status=$(barrier_stat)
27496 [ "$b_status" = "'expired'" ] ||
27497 error "(3) unexpected barrier status $b_status"
27499 # Do not reduce barrier time - See LU-11873
27500 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
27501 error "(4) fail to freeze barrier"
27503 b_status=$(barrier_stat)
27504 [ "$b_status" = "'frozen'" ] ||
27505 error "(5) unexpected barrier status $b_status"
27507 echo "Start barrier_thaw at: $(date)"
27508 #define OBD_FAIL_BARRIER_DELAY 0x2202
27509 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27510 do_facet mgs $LCTL barrier_thaw $FSNAME &
27513 b_status=$(barrier_stat)
27514 echo "Got barrier status at: $(date)"
27515 [ "$b_status" = "'thawing'" ] ||
27516 error "(6) unexpected barrier status $b_status"
27518 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27520 b_status=$(barrier_stat)
27521 [ "$b_status" = "'thawed'" ] ||
27522 error "(7) unexpected barrier status $b_status"
27524 #define OBD_FAIL_BARRIER_FAILURE 0x2203
27525 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
27526 do_facet mgs $LCTL barrier_freeze $FSNAME
27528 b_status=$(barrier_stat)
27529 [ "$b_status" = "'failed'" ] ||
27530 error "(8) unexpected barrier status $b_status"
27532 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
27533 do_facet mgs $LCTL barrier_thaw $FSNAME
27537 run_test 801a "write barrier user interfaces and stat machine"
27542 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27543 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
27544 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
27545 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
27546 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
27548 cancel_lru_locks mdc
27550 # 180 seconds should be long enough
27551 do_facet mgs $LCTL barrier_freeze $FSNAME 180
27553 local b_status=$(barrier_stat)
27554 [ "$b_status" = "'frozen'" ] ||
27555 error "(6) unexpected barrier status $b_status"
27557 mkdir $DIR/$tdir/d0/d10 &
27560 touch $DIR/$tdir/d1/f13 &
27563 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
27566 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
27569 rm -f $DIR/$tdir/d4/f12 &
27572 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
27574 # To guarantee taht the 'stat' is not blocked
27575 b_status=$(barrier_stat)
27576 [ "$b_status" = "'frozen'" ] ||
27577 error "(8) unexpected barrier status $b_status"
27579 # let above commands to run at background
27582 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
27583 ps -p $touch_pid || error "(10) touch should be blocked"
27584 ps -p $ln_pid || error "(11) link should be blocked"
27585 ps -p $mv_pid || error "(12) rename should be blocked"
27586 ps -p $rm_pid || error "(13) unlink should be blocked"
27588 b_status=$(barrier_stat)
27589 [ "$b_status" = "'frozen'" ] ||
27590 error "(14) unexpected barrier status $b_status"
27592 do_facet mgs $LCTL barrier_thaw $FSNAME
27593 b_status=$(barrier_stat)
27594 [ "$b_status" = "'thawed'" ] ||
27595 error "(15) unexpected barrier status $b_status"
27597 wait $mkdir_pid || error "(16) mkdir should succeed"
27598 wait $touch_pid || error "(17) touch should succeed"
27599 wait $ln_pid || error "(18) link should succeed"
27600 wait $mv_pid || error "(19) rename should succeed"
27601 wait $rm_pid || error "(20) unlink should succeed"
27605 run_test 801b "modification will be blocked by write barrier"
27608 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27612 stop mds2 || error "(1) Fail to stop mds2"
27614 do_facet mgs $LCTL barrier_freeze $FSNAME 30
27616 local b_status=$(barrier_stat)
27617 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
27618 do_facet mgs $LCTL barrier_thaw $FSNAME
27619 error "(2) unexpected barrier status $b_status"
27622 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27623 error "(3) Fail to rescan barrier bitmap"
27625 # Do not reduce barrier time - See LU-11873
27626 do_facet mgs $LCTL barrier_freeze $FSNAME 20
27628 b_status=$(barrier_stat)
27629 [ "$b_status" = "'frozen'" ] ||
27630 error "(4) unexpected barrier status $b_status"
27632 do_facet mgs $LCTL barrier_thaw $FSNAME
27633 b_status=$(barrier_stat)
27634 [ "$b_status" = "'thawed'" ] ||
27635 error "(5) unexpected barrier status $b_status"
27637 local devname=$(mdsdevname 2)
27639 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
27641 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27642 error "(7) Fail to rescan barrier bitmap"
27646 run_test 801c "rescan barrier bitmap"
27648 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
27649 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
27650 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
27651 saved_MOUNT_OPTS=$MOUNT_OPTS
27657 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
27658 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
27659 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
27660 MOUNT_OPTS=$saved_MOUNT_OPTS
27665 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
27666 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27667 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27668 skip "Need server version at least 2.9.55"
27670 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
27672 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27674 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27675 error "(2) Fail to copy"
27677 trap cleanup_802a EXIT
27679 # sync by force before remount as readonly
27680 sync; sync_all_data; sleep 3; sync_all_data
27684 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
27685 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
27686 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
27688 echo "Mount the server as read only"
27689 setupall server_only || error "(3) Fail to start servers"
27691 echo "Mount client without ro should fail"
27692 mount_client $MOUNT &&
27693 error "(4) Mount client without 'ro' should fail"
27695 echo "Mount client with ro should succeed"
27696 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
27697 mount_client $MOUNT ||
27698 error "(5) Mount client with 'ro' should succeed"
27700 echo "Modify should be refused"
27701 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27703 echo "Read should be allowed"
27704 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27705 error "(7) Read should succeed under ro mode"
27709 run_test 802a "simulate readonly device"
27712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27713 remote_mds_nodsh && skip "remote MDS with nodsh"
27715 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
27716 skip "readonly option not available"
27718 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
27720 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27721 error "(2) Fail to copy"
27723 # write back all cached data before setting MDT to readonly
27727 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
27728 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
27730 echo "Modify should be refused"
27731 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27733 echo "Read should be allowed"
27734 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27735 error "(7) Read should succeed under ro mode"
27738 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
27740 run_test 802b "be able to set MDTs to readonly"
27743 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27744 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27745 skip "MDS needs to be newer than 2.10.54"
27747 mkdir_on_mdt0 $DIR/$tdir
27748 # Create some objects on all MDTs to trigger related logs objects
27749 for idx in $(seq $MDSCOUNT); do
27750 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
27751 $DIR/$tdir/dir${idx} ||
27752 error "Fail to create $DIR/$tdir/dir${idx}"
27756 wait_delete_completed # ensure old test cleanups are finished
27757 echo "before create:"
27759 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27761 for i in {1..10}; do
27762 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
27763 error "Fail to create $DIR/$tdir/foo$i"
27767 echo "after create:"
27769 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27771 # allow for an llog to be cleaned up during the test
27772 [ $after_used -ge $((before_used + 10 - 1)) ] ||
27773 error "before ($before_used) + 10 > after ($after_used)"
27775 for i in {1..10}; do
27776 rm -rf $DIR/$tdir/foo$i ||
27777 error "Fail to remove $DIR/$tdir/foo$i"
27780 sleep 3 # avoid MDT return cached statfs
27781 wait_delete_completed
27782 echo "after unlink:"
27784 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27786 # allow for an llog to be created during the test
27787 [ $after_used -le $((before_used + 1)) ] ||
27788 error "after ($after_used) > before ($before_used) + 1"
27790 run_test 803a "verify agent object for remote object"
27793 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27794 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
27795 skip "MDS needs to be newer than 2.13.56"
27796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27798 for i in $(seq 0 $((MDSCOUNT - 1))); do
27799 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
27807 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27808 for i in $(seq 0 $((MDSCOUNT - 1))); do
27809 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27810 awk '/getattr/ { print $2 }')
27811 before=$((before + tmp))
27813 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27814 for i in $(seq 0 $((MDSCOUNT - 1))); do
27815 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27816 awk '/getattr/ { print $2 }')
27817 after=$((after + tmp))
27820 [ $before -eq $after ] || error "getattr count $before != $after"
27822 run_test 803b "remote object can getattr from cache"
27825 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27826 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27827 skip "MDS needs to be newer than 2.10.54"
27828 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
27830 mkdir -p $DIR/$tdir
27831 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
27832 error "Fail to create $DIR/$tdir/dir0"
27834 local fid=$($LFS path2fid $DIR/$tdir/dir0)
27835 local dev=$(mdsdevname 2)
27837 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27838 grep ${fid} || error "NOT found agent entry for dir0"
27840 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
27841 error "Fail to create $DIR/$tdir/dir1"
27843 touch $DIR/$tdir/dir1/foo0 ||
27844 error "Fail to create $DIR/$tdir/dir1/foo0"
27845 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
27848 for idx in $(seq $MDSCOUNT); do
27849 dev=$(mdsdevname $idx)
27850 do_facet mds${idx} \
27851 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27852 grep ${fid} && rc=$idx
27855 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
27856 error "Fail to rename foo0 to foo1"
27857 if [ $rc -eq 0 ]; then
27858 for idx in $(seq $MDSCOUNT); do
27859 dev=$(mdsdevname $idx)
27860 do_facet mds${idx} \
27861 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27862 grep ${fid} && rc=$idx
27866 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
27867 error "Fail to rename foo1 to foo2"
27868 if [ $rc -eq 0 ]; then
27869 for idx in $(seq $MDSCOUNT); do
27870 dev=$(mdsdevname $idx)
27871 do_facet mds${idx} \
27872 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27873 grep ${fid} && rc=$idx
27877 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
27879 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
27880 error "Fail to link to $DIR/$tdir/dir1/foo2"
27881 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
27882 error "Fail to rename foo2 to foo0"
27883 unlink $DIR/$tdir/dir1/foo0 ||
27884 error "Fail to unlink $DIR/$tdir/dir1/foo0"
27885 rm -rf $DIR/$tdir/dir0 ||
27886 error "Fail to rm $DIR/$tdir/dir0"
27888 for idx in $(seq $MDSCOUNT); do
27892 dev=$(mdsdevname $idx)
27893 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
27895 start mds${idx} $dev $MDS_MOUNT_OPTS ||
27896 error "mount mds$idx failed"
27897 df $MOUNT > /dev/null 2>&1
27899 # e2fsck should not return error
27901 error "e2fsck detected error on MDT${idx}: rc=$rc"
27904 run_test 804 "verify agent entry for remote entry"
27907 do_facet $SINGLEMDS zfs set quota=$old $fsset
27908 unlinkmany $DIR/$tdir/f- 1000000
27913 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
27914 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
27915 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
27916 skip "netfree not implemented before 0.7"
27917 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
27918 skip "Need MDS version at least 2.10.57"
27925 local pref="osd-zfs.$FSNAME-MDT0000."
27927 # limit available space on MDS dataset to meet nospace issue
27928 # quickly. then ZFS 0.7.2 can use reserved space if asked
27929 # properly (using netfree flag in osd_declare_destroy()
27930 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
27931 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
27933 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
27934 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
27935 let "usedkb=usedkb-freekb"
27936 let "freekb=freekb/2"
27937 if let "freekb > 5000"; then
27940 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
27941 trap cleanup_805 EXIT
27942 mkdir_on_mdt0 $DIR/$tdir
27943 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
27944 error "Can't set PFL layout"
27945 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
27946 rm -rf $DIR/$tdir || error "not able to remove"
27947 do_facet $SINGLEMDS zfs set quota=$old $fsset
27950 run_test 805 "ZFS can remove from full fs"
27956 local expect=$(stat -c %s $file)
27958 check_lsom_size $1 $expect
27960 local blocks=$($LFS getsom -b $file)
27961 expect=$(stat -c %b $file)
27962 [[ $blocks == $expect ]] ||
27963 error "$file expected blocks: $expect, got: $blocks"
27971 cancel_lru_locks mdc
27973 size=$($LFS getsom -s $1)
27974 [[ $size == $expect ]] ||
27975 error "$file expected size: $expect, got: $size"
27979 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
27980 skip "Need MDS version at least 2.11.52"
27984 touch $DIR/$tfile || error "touch $tfile failed"
27986 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
27987 save_lustre_params client "llite.*.xattr_cache" > $save
27988 lctl set_param llite.*.xattr_cache=0
27989 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
27991 # single-threaded write
27992 echo "Test SOM for single-threaded write"
27993 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
27994 error "write $tfile failed"
27995 check_lsom_size $DIR/$tfile $bs
27998 local size=$(($num * $bs))
28002 echo "Test SOM for single client multi-threaded($num) write"
28003 $TRUNCATE $DIR/$tfile 0
28004 for ((i = 0; i < $num; i++)); do
28005 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28007 offset=$((offset + $bs))
28009 for (( i=0; i < $num; i++ )); do
28012 check_lsom_size $DIR/$tfile $size
28014 $TRUNCATE $DIR/$tfile 0
28015 for ((i = 0; i < $num; i++)); do
28016 offset=$((offset - $bs))
28017 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28020 for (( i=0; i < $num; i++ )); do
28023 check_lsom_size $DIR/$tfile $size
28025 # multi-client writes
28026 num=$(get_node_count ${CLIENTS//,/ })
28027 size=$(($num * $bs))
28031 echo "Test SOM for multi-client ($num) writes"
28032 $TRUNCATE $DIR/$tfile 0
28033 for client in ${CLIENTS//,/ }; do
28034 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28037 offset=$((offset + $bs))
28039 for (( i=0; i < $num; i++ )); do
28042 check_lsom_size $DIR/$tfile $offset
28045 $TRUNCATE $DIR/$tfile 0
28046 for client in ${CLIENTS//,/ }; do
28047 offset=$((offset - $bs))
28048 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28052 for (( i=0; i < $num; i++ )); do
28055 check_lsom_size $DIR/$tfile $size
28058 echo "Test SOM for truncate"
28059 $TRUNCATE $DIR/$tfile 1048576
28060 check_lsom_size $DIR/$tfile 1048576
28061 $TRUNCATE $DIR/$tfile 1234
28062 check_lsom_size $DIR/$tfile 1234
28064 # verify SOM blocks count
28065 echo "Verify SOM block count"
28066 $TRUNCATE $DIR/$tfile 0
28067 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
28068 error "failed to write file $tfile"
28069 check_lsom_data $DIR/$tfile
28071 run_test 806 "Verify Lazy Size on MDS"
28074 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
28075 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28076 skip "Need MDS version at least 2.11.52"
28078 # Registration step
28079 changelog_register || error "changelog_register failed"
28080 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
28081 changelog_users $SINGLEMDS | grep -q $cl_user ||
28082 error "User $cl_user not found in changelog_users"
28084 rm -rf $DIR/$tdir || error "rm $tdir failed"
28085 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
28086 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
28087 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
28088 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
28089 error "truncate $tdir/trunc failed"
28092 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
28093 error "write $tfile failed"
28095 # multi-client wirtes
28096 local num=$(get_node_count ${CLIENTS//,/ })
28100 echo "Test SOM for multi-client ($num) writes"
28101 touch $DIR/$tfile || error "touch $tfile failed"
28102 $TRUNCATE $DIR/$tfile 0
28103 for client in ${CLIENTS//,/ }; do
28104 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28107 offset=$((offset + $bs))
28109 for (( i=0; i < $num; i++ )); do
28113 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
28114 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
28115 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
28116 check_lsom_data $DIR/$tdir/trunc
28117 check_lsom_data $DIR/$tdir/single_dd
28118 check_lsom_data $DIR/$tfile
28121 # Deregistration step
28122 changelog_deregister || error "changelog_deregister failed"
28124 run_test 807 "verify LSOM syncing tool"
28126 check_som_nologged()
28128 local lines=$($LFS changelog $FSNAME-MDT0000 |
28129 grep 'x=trusted.som' | wc -l)
28130 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
28134 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28135 skip "Need MDS version at least 2.11.55"
28137 # Registration step
28138 changelog_register || error "changelog_register failed"
28140 touch $DIR/$tfile || error "touch $tfile failed"
28143 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
28144 error "write $tfile failed"
28147 $TRUNCATE $DIR/$tfile 1234
28150 $TRUNCATE $DIR/$tfile 1048576
28153 # Deregistration step
28154 changelog_deregister || error "changelog_deregister failed"
28156 run_test 808 "Check trusted.som xattr not logged in Changelogs"
28161 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
28165 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
28166 skip "Need MDS version at least 2.11.56"
28168 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
28169 error "failed to create DoM-only file $DIR/$tfile"
28170 touch $DIR/$tfile || error "touch $tfile failed"
28171 check_som_nodata $DIR/$tfile
28173 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
28174 error "write $tfile failed"
28175 check_som_nodata $DIR/$tfile
28177 $TRUNCATE $DIR/$tfile 1234
28178 check_som_nodata $DIR/$tfile
28180 $TRUNCATE $DIR/$tfile 4097
28181 check_som_nodata $DIR/$file
28183 run_test 809 "Verify no SOM xattr store for DoM-only files"
28186 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28187 $GSS && skip_env "could not run with gss"
28188 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
28189 skip "OST < 2.12.58 doesn't align checksum"
28192 stack_trap "set_checksums $ORIG_CSUM" EXIT
28193 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
28198 for csum in $CKSUM_TYPES; do
28199 #define OBD_FAIL_OSC_NO_GRANT 0x411
28200 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
28201 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
28203 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
28204 before=$(md5sum $DIR/$tfile)
28205 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
28206 after=$(md5sum $DIR/$tfile)
28207 [ "$before" == "$after" ] ||
28208 error "$csum: $before != $after bs=$1 seek=$2"
28212 run_test 810 "partial page writes on ZFS (LU-11663)"
28215 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28216 skip "OST < 2.12.51 doesn't support this fail_loc"
28218 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28219 # ensure ost1 is connected
28220 stat $DIR/$tfile >/dev/null || error "can't stat"
28221 wait_osc_import_state client ost1 FULL
28222 # no locks, no reqs to let the connection idle
28223 cancel_lru_locks osc
28225 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28226 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28227 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28228 wait_osc_import_state client ost1 CONNECTING
28229 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28231 stat $DIR/$tfile >/dev/null || error "can't stat file"
28233 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
28235 test_812b() { # LU-12378
28236 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28237 skip "OST < 2.12.51 doesn't support this fail_loc"
28239 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
28240 # ensure ost1 is connected
28241 stat $DIR/$tfile >/dev/null || error "can't stat"
28242 wait_osc_import_state client ost1 FULL
28243 # no locks, no reqs to let the connection idle
28244 cancel_lru_locks osc
28246 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28247 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28248 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28249 wait_osc_import_state client ost1 CONNECTING
28250 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28252 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
28253 wait_osc_import_state client ost1 IDLE
28255 run_test 812b "do not drop no resend request for idle connect"
28260 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
28262 $LFS setstripe -c 1 -o 0 $DIR/$tfile
28263 $LFS getstripe $DIR/$tfile
28264 $LCTL set_param osc.*.idle_timeout=10
28265 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
28266 # ensure ost1 is connected
28267 stat $DIR/$tfile >/dev/null || error "can't stat"
28268 wait_osc_import_state client ost1 FULL
28269 # no locks, no reqs to let the connection idle
28270 cancel_lru_locks osc
28272 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
28273 $LCTL set_param fail_loc=0x80000533
28275 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
28277 run_test 812c "idle import vs lock enqueue race"
28280 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
28281 [ -z "$file_heat_sav" ] && skip "no file heat support"
28292 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
28293 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
28295 $LCTL set_param -n llite.*.file_heat=1
28296 echo "Turn on file heat"
28297 echo "Period second: $period_second, Decay percentage: $decay_pct"
28299 echo "QQQQ" > $DIR/$tfile
28300 echo "QQQQ" > $DIR/$tfile
28301 echo "QQQQ" > $DIR/$tfile
28302 cat $DIR/$tfile > /dev/null
28303 cat $DIR/$tfile > /dev/null
28304 cat $DIR/$tfile > /dev/null
28305 cat $DIR/$tfile > /dev/null
28307 local out=$($LFS heat_get $DIR/$tfile)
28309 $LFS heat_get $DIR/$tfile
28310 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28311 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28312 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28313 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28315 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
28316 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
28317 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
28318 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
28320 sleep $((period_second + 3))
28321 echo "Sleep $((period_second + 3)) seconds..."
28322 # The recursion formula to calculate the heat of the file f is as
28324 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
28325 # Where Hi is the heat value in the period between time points i*I and
28326 # (i+1)*I; Ci is the access count in the period; the symbol P refers
28327 # to the weight of Ci.
28328 out=$($LFS heat_get $DIR/$tfile)
28329 $LFS heat_get $DIR/$tfile
28330 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28331 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28332 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28333 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28335 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
28336 error "read sample ($readsample) is wrong"
28337 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
28338 error "write sample ($writesample) is wrong"
28339 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
28340 error "read bytes ($readbyte) is wrong"
28341 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
28342 error "write bytes ($writebyte) is wrong"
28344 echo "QQQQ" > $DIR/$tfile
28345 echo "QQQQ" > $DIR/$tfile
28346 echo "QQQQ" > $DIR/$tfile
28347 cat $DIR/$tfile > /dev/null
28348 cat $DIR/$tfile > /dev/null
28349 cat $DIR/$tfile > /dev/null
28350 cat $DIR/$tfile > /dev/null
28352 sleep $((period_second + 3))
28353 echo "Sleep $((period_second + 3)) seconds..."
28355 out=$($LFS heat_get $DIR/$tfile)
28356 $LFS heat_get $DIR/$tfile
28357 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28358 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28359 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28360 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28362 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
28363 4 * $decay_pct) / 100") -eq 1 ] ||
28364 error "read sample ($readsample1) is wrong"
28365 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
28366 3 * $decay_pct) / 100") -eq 1 ] ||
28367 error "write sample ($writesample1) is wrong"
28368 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
28369 20 * $decay_pct) / 100") -eq 1 ] ||
28370 error "read bytes ($readbyte1) is wrong"
28371 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
28372 15 * $decay_pct) / 100") -eq 1 ] ||
28373 error "write bytes ($writebyte1) is wrong"
28375 echo "Turn off file heat for the file $DIR/$tfile"
28376 $LFS heat_set -o $DIR/$tfile
28378 echo "QQQQ" > $DIR/$tfile
28379 echo "QQQQ" > $DIR/$tfile
28380 echo "QQQQ" > $DIR/$tfile
28381 cat $DIR/$tfile > /dev/null
28382 cat $DIR/$tfile > /dev/null
28383 cat $DIR/$tfile > /dev/null
28384 cat $DIR/$tfile > /dev/null
28386 out=$($LFS heat_get $DIR/$tfile)
28387 $LFS heat_get $DIR/$tfile
28388 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28389 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28390 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28391 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28393 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28394 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28395 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28396 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28398 echo "Trun on file heat for the file $DIR/$tfile"
28399 $LFS heat_set -O $DIR/$tfile
28401 echo "QQQQ" > $DIR/$tfile
28402 echo "QQQQ" > $DIR/$tfile
28403 echo "QQQQ" > $DIR/$tfile
28404 cat $DIR/$tfile > /dev/null
28405 cat $DIR/$tfile > /dev/null
28406 cat $DIR/$tfile > /dev/null
28407 cat $DIR/$tfile > /dev/null
28409 out=$($LFS heat_get $DIR/$tfile)
28410 $LFS heat_get $DIR/$tfile
28411 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28412 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28413 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28414 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28416 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
28417 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
28418 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
28419 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
28421 $LFS heat_set -c $DIR/$tfile
28422 $LCTL set_param -n llite.*.file_heat=0
28423 echo "Turn off file heat support for the Lustre filesystem"
28425 echo "QQQQ" > $DIR/$tfile
28426 echo "QQQQ" > $DIR/$tfile
28427 echo "QQQQ" > $DIR/$tfile
28428 cat $DIR/$tfile > /dev/null
28429 cat $DIR/$tfile > /dev/null
28430 cat $DIR/$tfile > /dev/null
28431 cat $DIR/$tfile > /dev/null
28433 out=$($LFS heat_get $DIR/$tfile)
28434 $LFS heat_get $DIR/$tfile
28435 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28436 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28437 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28438 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28440 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28441 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28442 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28443 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28445 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
28448 run_test 813 "File heat verfication"
28452 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
28453 echo -n y >> $DIR/$tfile
28454 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
28455 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
28457 run_test 814 "sparse cp works as expected (LU-12361)"
28461 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
28462 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
28464 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
28467 local ost1_imp=$(get_osc_import_name client ost1)
28468 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
28471 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28472 # ensure ost1 is connected
28474 stat $DIR/$tfile >/dev/null || error "can't stat"
28475 wait_osc_import_state client ost1 FULL
28476 # no locks, no reqs to let the connection idle
28477 cancel_lru_locks osc
28478 lru_resize_disable osc
28481 before=$($LCTL get_param -n \
28482 ldlm.namespaces.$imp_name.lru_size)
28484 wait_osc_import_state client ost1 IDLE
28485 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
28486 now=$($LCTL get_param -n \
28487 ldlm.namespaces.$imp_name.lru_size)
28488 [ $before == $now ] || error "lru_size changed $before != $now"
28490 run_test 816 "do not reset lru_resize on idle reconnect"
28494 exportfs -u localhost:$DIR/nfsexp
28499 systemctl restart nfs-server.service || skip "failed to restart nfsd"
28501 mkdir -p $DIR/nfsexp
28502 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
28503 error "failed to export nfs"
28505 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
28506 stack_trap cleanup_817 EXIT
28508 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
28509 error "failed to mount nfs to $tmpdir"
28511 cp /bin/true $tmpdir
28512 $DIR/nfsexp/true || error "failed to execute 'true' command"
28514 run_test 817 "nfsd won't cache write lock for exec file"
28517 test_mkdir -i0 -c1 $DIR/$tdir
28518 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
28519 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
28522 # restore osp-syn threads
28523 stack_trap "fail $SINGLEMDS"
28525 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
28526 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
28527 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
28528 error "start $SINGLEMDS failed"
28531 local testid=$(echo $TESTNAME | tr '_' ' ')
28533 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
28534 grep "run LFSCK" || error "run LFSCK is not suggested"
28536 run_test 818 "unlink with failed llog"
28539 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28540 cancel_lru_locks osc
28541 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28542 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28543 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
28546 run_test 819a "too big niobuf in read"
28549 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28550 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28551 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28552 cancel_lru_locks osc
28556 run_test 819b "too big niobuf in write"
28559 function test_820_start_ost() {
28562 for num in $(seq $OSTCOUNT); do
28563 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
28568 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28571 umount_client $MOUNT || error "umount failed"
28572 for num in $(seq $OSTCOUNT); do
28576 # mount client with no active OSTs
28577 # so that the client can't initialize max LOV EA size
28578 # from OSC notifications
28579 mount_client $MOUNT || error "mount failed"
28580 # delay OST starting to keep this 0 max EA size for a while
28581 test_820_start_ost &
28583 # create a directory on MDS2
28584 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
28585 error "Failed to create directory"
28586 # open intent should update default EA size
28587 # see mdc_update_max_ea_from_body()
28588 # notice this is the very first RPC to MDS2
28589 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
28592 # With SSK, this situation can lead to -EPERM being returned.
28593 # In that case, simply retry.
28594 if [ $ret -ne 0 ] && $SHARED_KEY; then
28595 if echo "$out" | grep -q "not permitted"; then
28596 cp /etc/services $DIR/$tdir/mds2
28600 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
28602 run_test 820 "update max EA from open intent"
28605 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28606 local OST_MAX_PRECREATE=20000
28608 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
28609 skip "Need MDS version at least 2.14.56"
28611 save_lustre_params mds1 \
28612 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28613 do_facet $SINGLEMDS "$LCTL set_param -n \
28614 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28615 do_facet $SINGLEMDS "$LCTL set_param -n \
28616 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
28618 stack_trap "restore_lustre_params < $p; rm $p"
28620 do_facet $SINGLEMDS "$LCTL set_param -n \
28621 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
28623 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28624 osp.$FSNAME-OST0000*MDT0000.create_count")
28625 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28626 osp.$FSNAME-OST0000*MDT0000.max_create_count")
28627 local expect_count=$(((($max/2)/256) * 256))
28629 log "setting create_count to 100200:"
28630 log " -result- count: $count with max: $max, expecting: $expect_count"
28632 [[ $count -eq expect_count ]] ||
28633 error "Create count not set to max precreate."
28635 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
28638 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
28639 skip "Need MDS version 2.14.56"
28641 local sync_changes=$(do_facet $SINGLEMDS \
28642 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28644 [ "$sync_changes" -gt 100 ] &&
28645 skip "Sync changes $sync_changes > 100 already"
28647 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28649 $LFS mkdir -i 0 $DIR/$tdir
28650 $LFS setstripe -c 1 -i 0 $DIR/$tdir
28652 save_lustre_params mds1 \
28653 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
28654 save_lustre_params mds1 \
28655 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
28657 do_facet mds1 "$LCTL set_param -n \
28658 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
28659 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
28660 stack_trap "restore_lustre_params < $p" EXIT
28662 createmany -o $DIR/$tdir/f- 1000
28663 unlinkmany $DIR/$tdir/f- 1000 &
28664 local UNLINK_PID=$!
28667 sync_changes=$(do_facet mds1 \
28668 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28669 # the check in the code is racy, fail the test
28670 # if the value above the limit by 10.
28671 [ $sync_changes -gt 110 ] && {
28672 kill -2 $UNLINK_PID
28674 error "osp changes throttling failed, $sync_changes>110"
28676 kill -0 $UNLINK_PID 2> /dev/null || break
28680 run_test 831 "throttling unlink/setattr queuing on OSP"
28683 # tests that do cleanup/setup should be run at the end
28687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28690 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
28691 $LCTL set_param fail_loc=0x903
28693 cancel_lru_locks MGC
28695 FAIL_ON_ERROR=true cleanup
28696 FAIL_ON_ERROR=true setup
28698 run_test 900 "umount should not race with any mgc requeue thread"
28700 # LUS-6253/LU-11185
28708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28710 # some get_param have a bug to handle dot in param name
28711 cancel_lru_locks MGC
28712 old=$(mount -t lustre | wc -l)
28720 while [ $old -ne $oldc ]; do
28721 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28724 if [ $count -ge $TIMEOUT ]; then
28725 error "too large timeout"
28728 umount_client $MOUNT || error "umount failed"
28729 mount_client $MOUNT || error "mount failed"
28730 cancel_lru_locks MGC
28731 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28733 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
28737 run_test 901 "don't leak a mgc lock on client umount"
28741 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
28742 skip "client does not have LU-13377 fix"
28743 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
28744 $LCTL set_param fail_loc=0x1415
28745 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28746 cancel_lru_locks osc
28749 run_test 902 "test short write doesn't hang lustre"
28753 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
28754 echo "blah" > $DIR/${tfile}-2
28755 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
28756 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
28757 $LCTL set_param fail_loc=0x417 fail_val=20
28759 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
28760 sleep 1 # To start the destroy
28761 wait_destroy_complete 150 || error "Destroy taking too long"
28762 cat $DIR/$tfile > /dev/null || error "Evicted"
28764 run_test 903 "Test long page discard does not cause evictions"
28767 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
28768 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
28769 grep -q project || skip "skip project quota not supported"
28771 local testfile="$DIR/$tdir/$tfile"
28772 local xattr="trusted.projid"
28774 local mdts=$(comma_list $(mdts_nodes))
28775 local saved=$(do_facet mds1 $LCTL get_param -n \
28776 osd-ldiskfs.*MDT0000.enable_projid_xattr)
28778 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
28779 stack_trap "do_nodes $mdts $LCTL set_param \
28780 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
28782 mkdir -p $DIR/$tdir
28784 #hide projid xattr on server
28785 $LFS project -p 1 $testfile ||
28786 error "set $testfile project id failed"
28787 getfattr -m - $testfile | grep $xattr &&
28788 error "do not show trusted.projid when disabled on server"
28789 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
28790 #should be hidden when projid is 0
28791 $LFS project -p 0 $testfile ||
28792 error "set $testfile project id failed"
28793 getfattr -m - $testfile | grep $xattr &&
28794 error "do not show trusted.projid with project ID 0"
28796 #still can getxattr explicitly
28797 projid=$(getfattr -n $xattr $testfile |
28798 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28799 [ $projid == "0" ] ||
28800 error "projid expected 0 not $projid"
28802 #set the projid via setxattr
28803 setfattr -n $xattr -v "1000" $testfile ||
28804 error "setattr failed with $?"
28805 projid=($($LFS project $testfile))
28806 [ ${projid[0]} == "1000" ] ||
28807 error "projid expected 1000 not $projid"
28809 #check the new projid via getxattr
28810 $LFS project -p 1001 $testfile ||
28811 error "set $testfile project id failed"
28812 getfattr -m - $testfile | grep $xattr ||
28813 error "should show trusted.projid when project ID != 0"
28814 projid=$(getfattr -n $xattr $testfile |
28815 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28816 [ $projid == "1001" ] ||
28817 error "projid expected 1001 not $projid"
28819 #try to set invalid projid
28820 setfattr -n $xattr -v "4294967295" $testfile &&
28821 error "set invalid projid should fail"
28823 #remove the xattr means setting projid to 0
28824 setfattr -x $xattr $testfile ||
28825 error "setfattr failed with $?"
28826 projid=($($LFS project $testfile))
28827 [ ${projid[0]} == "0" ] ||
28828 error "projid expected 0 not $projid"
28830 #should be hidden when parent has inherit flag and same projid
28831 $LFS project -srp 1002 $DIR/$tdir ||
28832 error "set $tdir project id failed"
28833 getfattr -m - $testfile | grep $xattr &&
28834 error "do not show trusted.projid with inherit flag"
28836 #still can getxattr explicitly
28837 projid=$(getfattr -n $xattr $testfile |
28838 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28839 [ $projid == "1002" ] ||
28840 error "projid expected 1002 not $projid"
28842 run_test 904 "virtual project ID xattr"
28846 (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
28847 skip "lustre < 2.8.54 does not support ladvise"
28849 remote_ost_nodsh && skip "remote OST with nodsh"
28850 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
28852 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
28854 #define OBD_FAIL_OST_OPCODE 0x253
28856 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
28857 $LFS ladvise -a willread $DIR/$tfile &&
28858 error "unexpected success of ladvise with fault injection"
28859 $LFS ladvise -a willread $DIR/$tfile |&
28860 grep -q "Operation not supported"
28861 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
28863 run_test 905 "bad or new opcode should not stuck client"
28866 grep -q io_uring_setup /proc/kallsyms ||
28867 skip "Client OS does not support io_uring I/O engine"
28868 io_uring_probe || skip "kernel does not support io_uring fully"
28869 which fio || skip_env "no fio installed"
28870 fio --enghelp | grep -q io_uring ||
28871 skip_env "fio does not support io_uring I/O engine"
28873 local file=$DIR/$tfile
28874 local ioengine="io_uring"
28878 fio --name=seqwrite --ioengine=$ioengine \
28879 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
28880 --iodepth=64 --size=$size --filename=$file --rw=write ||
28881 error "fio seqwrite $file failed"
28883 fio --name=seqread --ioengine=$ioengine \
28884 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
28885 --iodepth=64 --size=$size --filename=$file --rw=read ||
28886 error "fio seqread $file failed"
28888 rm -f $file || error "rm -f $file failed"
28890 run_test 906 "Simple test for io_uring I/O engine via fio"
28893 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
28894 check_and_cleanup_lustre
28895 if [ "$I_MOUNTED" != "yes" ]; then
28896 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true