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 # the number of "bad" hashes is random, as it depends on the random
4343 # filenames generated by "mktemp". Allow some margin in the results.
4344 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4345 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4346 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4347 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4350 # crush2 doesn't put suffixes with special characters on the same MDT
4351 # filename like $tfile.txt.1234 should *not* be considered temp
4352 for pattern in ${patterns[*]}; do
4353 local base=${pattern%%X*}
4354 local suff=${pattern#$base}
4356 pattern=$base...${suff/XXX}
4357 echo "pattern=$pattern"
4358 for (( i = 0; i < $count; i++ )); do
4359 fname=$(mktemp $DIR/$tdir/$pattern) ||
4360 error "touch $fname failed"
4361 index2=$($LFS getstripe -m $fname)
4362 (( $index != $index2 )) && continue
4368 # the number of "bad" hashes is random, as it depends on the random
4369 # filenames generated by "mktemp". Allow some margin in the results.
4370 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4371 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4372 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4373 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4377 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4378 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4379 skip "Need MDS version at least 2.13.50"
4383 run_test 33h "temp file is located on the same MDT as target (crush)"
4386 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4387 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4388 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4389 skip "Need MDS version at least 2.15.0 for crush2"
4393 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4397 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4399 local FNAME=$(str_repeat 'f' 250)
4401 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4402 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4407 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4409 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4411 lctl --device %$MDC deactivate
4412 stack_trap "lctl --device %$MDC activate"
4413 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4414 total=$(\ls -l $DIR/$tdir | wc -l)
4415 # "ls -l" will list total in the first line
4416 total=$((total - 1))
4417 (( total + count == 1000 )) ||
4418 error "ls list $total files, $count files on MDT1"
4420 run_test 33i "striped directory can be accessed when one MDT is down"
4422 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4425 $MCREATE $DIR/f34 || error "mcreate failed"
4426 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4427 error "getstripe failed"
4428 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4429 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4430 error "getstripe failed"
4431 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4432 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4434 run_test 34a "truncate file that has not been opened ==========="
4437 [ ! -f $DIR/f34 ] && test_34a
4438 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4439 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4440 $OPENFILE -f O_RDONLY $DIR/f34
4441 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4442 error "getstripe failed"
4443 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4444 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4446 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4449 [ ! -f $DIR/f34 ] && test_34a
4450 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4451 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4452 $OPENFILE -f O_RDWR $DIR/f34
4453 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4454 error "$LFS getstripe failed"
4455 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4456 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4458 run_test 34c "O_RDWR opening file-with-size works =============="
4461 [ ! -f $DIR/f34 ] && test_34a
4462 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4464 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4465 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4468 run_test 34d "write to sparse file ============================="
4472 $MCREATE $DIR/f34e || error "mcreate failed"
4473 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4474 $CHECKSTAT -s 1000 $DIR/f34e ||
4475 error "Size of $DIR/f34e not equal to 1000 bytes"
4476 $OPENFILE -f O_RDWR $DIR/f34e
4477 $CHECKSTAT -s 1000 $DIR/f34e ||
4478 error "Size of $DIR/f34e not equal to 1000 bytes"
4480 run_test 34e "create objects, some with size and some without =="
4482 test_34f() { # bug 6242, 6243
4483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4487 $MCREATE $DIR/f34f || error "mcreate failed"
4488 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4489 dd if=$DIR/f34f of=$TMP/f34f
4490 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4491 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4492 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4493 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4494 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4496 run_test 34f "read from a file with no objects until EOF ======="
4499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4501 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4503 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4504 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4505 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4506 cancel_lru_locks osc
4507 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4508 error "wrong size after lock cancel"
4510 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4511 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4512 error "expanding truncate failed"
4513 cancel_lru_locks osc
4514 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4515 error "wrong expanded size after lock cancel"
4517 run_test 34g "truncate long file ==============================="
4520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4525 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4526 sync # Flush the cache so that multiop below does not block on cache
4527 # flush when getting the group lock
4528 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4531 # Since just timed wait is not good enough, let's do a sync write
4532 # that way we are sure enough time for a roundtrip + processing
4533 # passed + 2 seconds of extra margin.
4534 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4538 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4539 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4543 local nsz=`stat -c %s $DIR/$tfile`
4544 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4546 run_test 34h "ftruncate file under grouplock should not block"
4549 cp /bin/sh $DIR/f35a
4551 chown $RUNAS_ID $DIR/f35a
4552 $RUNAS $DIR/f35a && error || true
4555 run_test 35a "exec file with mode 444 (should return and not leak)"
4559 utime $DIR/f36 || error "utime failed for MDS"
4561 run_test 36a "MDS utime check (mknod, utime)"
4565 utime $DIR/f36 || error "utime failed for OST"
4567 run_test 36b "OST utime check (open, utime)"
4572 chown $RUNAS_ID $DIR/d36
4573 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4575 run_test 36c "non-root MDS utime check (mknod, utime)"
4578 [ ! -d $DIR/d36 ] && test_36c
4579 echo "" > $DIR/d36/f36
4580 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4582 run_test 36d "non-root OST utime check (open, utime)"
4585 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4587 test_mkdir $DIR/$tdir
4588 touch $DIR/$tdir/$tfile
4589 $RUNAS utime $DIR/$tdir/$tfile &&
4590 error "utime worked, expected failure" || true
4592 run_test 36e "utime on non-owned file (should return error)"
4596 local LANG_SAVE=$LANG
4597 local LC_LANG_SAVE=$LC_LANG
4598 export LANG=C LC_LANG=C # for date language
4600 DATESTR="Dec 20 2000"
4601 test_mkdir $DIR/$tdir
4602 lctl set_param fail_loc=$fl
4604 cp /etc/hosts $DIR/$tdir/$tfile
4605 sync & # write RPC generated with "current" inode timestamp, but delayed
4607 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4608 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4609 cancel_lru_locks $OSC
4610 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4612 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4613 echo "BEFORE: $LS_BEFORE" && \
4614 echo "AFTER : $LS_AFTER" && \
4615 echo "WANT : $DATESTR" && \
4616 error "$DIR/$tdir/$tfile timestamps changed" || true
4618 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4624 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4625 subr_36fh "0x80000214"
4627 run_test 36f "utime on file racing with OST BRW write =========="
4630 remote_ost_nodsh && skip "remote OST with nodsh"
4631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4632 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4633 skip "Need MDS version at least 2.12.51"
4638 local tgt="obdfilter"
4640 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4642 test_mkdir $DIR/$tdir
4643 fmd_max_age=$(do_facet $facet \
4644 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4647 echo "FMD max age: ${fmd_max_age}s"
4648 touch $DIR/$tdir/$tfile
4649 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4650 gawk '{cnt=cnt+$1} END{print cnt}')
4651 echo "FMD before: $fmd"
4653 error "FMD wasn't create by touch"
4654 sleep $((fmd_max_age + 12))
4655 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4656 gawk '{cnt=cnt+$1} END{print cnt}')
4657 echo "FMD after: $fmd"
4659 error "FMD wasn't expired by ping"
4661 run_test 36g "FMD cache expiry ====================="
4664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4666 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4667 subr_36fh "0x80000227"
4669 run_test 36h "utime on file racing with OST BRW write =========="
4672 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4674 test_mkdir $DIR/$tdir
4675 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4677 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4678 local new_mtime=$((mtime + 200))
4680 #change Modify time of striped dir
4681 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4682 error "change mtime failed"
4684 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4686 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4688 run_test 36i "change mtime on striped directory"
4690 # test_37 - duplicate with tests 32q 32r
4693 local file=$DIR/$tfile
4695 openfile -f O_DIRECTORY $file
4698 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4699 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4701 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4703 test_39a() { # was test_39
4705 touch $DIR/${tfile}2
4706 # ls -l $DIR/$tfile $DIR/${tfile}2
4707 # ls -lu $DIR/$tfile $DIR/${tfile}2
4708 # ls -lc $DIR/$tfile $DIR/${tfile}2
4710 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4711 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4713 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4715 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4717 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4718 error "O_TRUNC didn't change timestamps"
4721 run_test 39a "mtime changed on create"
4724 test_mkdir -c1 $DIR/$tdir
4725 cp -p /etc/passwd $DIR/$tdir/fopen
4726 cp -p /etc/passwd $DIR/$tdir/flink
4727 cp -p /etc/passwd $DIR/$tdir/funlink
4728 cp -p /etc/passwd $DIR/$tdir/frename
4729 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4732 echo "aaaaaa" >> $DIR/$tdir/fopen
4733 echo "aaaaaa" >> $DIR/$tdir/flink
4734 echo "aaaaaa" >> $DIR/$tdir/funlink
4735 echo "aaaaaa" >> $DIR/$tdir/frename
4737 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4738 local link_new=`stat -c %Y $DIR/$tdir/flink`
4739 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4740 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4742 cat $DIR/$tdir/fopen > /dev/null
4743 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4744 rm -f $DIR/$tdir/funlink2
4745 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4747 for (( i=0; i < 2; i++ )) ; do
4748 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4749 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4750 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4751 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4753 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4754 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4755 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4756 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4758 cancel_lru_locks $OSC
4759 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4762 run_test 39b "mtime change on open, link, unlink, rename ======"
4764 # this should be set to past
4765 TEST_39_MTIME=`date -d "1 year ago" +%s`
4771 local mtime0=`stat -c %Y $DIR1/$tfile`
4773 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4774 local mtime1=`stat -c %Y $DIR1/$tfile`
4775 [ "$mtime1" = $TEST_39_MTIME ] || \
4776 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4779 echo hello >> $DIR1/$tfile
4781 local mtime2=`stat -c %Y $DIR1/$tfile`
4782 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4783 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4785 mv $DIR1/$tfile $DIR1/$tfile-1
4787 for (( i=0; i < 2; i++ )) ; do
4788 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4789 [ "$mtime2" = "$mtime3" ] || \
4790 error "mtime ($mtime2) changed (to $mtime3) on rename"
4792 cancel_lru_locks $OSC
4793 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4796 run_test 39c "mtime change on rename ==========================="
4800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4803 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4805 for (( i=0; i < 2; i++ )) ; do
4806 local mtime=`stat -c %Y $DIR1/$tfile`
4807 [ $mtime = $TEST_39_MTIME ] || \
4808 error "mtime($mtime) is not set to $TEST_39_MTIME"
4810 cancel_lru_locks $OSC
4811 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4814 run_test 39d "create, utime, stat =============================="
4818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4821 local mtime1=`stat -c %Y $DIR1/$tfile`
4823 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4825 for (( i=0; i < 2; i++ )) ; do
4826 local mtime2=`stat -c %Y $DIR1/$tfile`
4827 [ $mtime2 = $TEST_39_MTIME ] || \
4828 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4830 cancel_lru_locks $OSC
4831 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4834 run_test 39e "create, stat, utime, stat ========================"
4838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4841 mtime1=`stat -c %Y $DIR1/$tfile`
4844 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4846 for (( i=0; i < 2; i++ )) ; do
4847 local mtime2=`stat -c %Y $DIR1/$tfile`
4848 [ $mtime2 = $TEST_39_MTIME ] || \
4849 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4851 cancel_lru_locks $OSC
4852 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4855 run_test 39f "create, stat, sleep, utime, stat ================="
4859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4861 echo hello >> $DIR1/$tfile
4862 local mtime1=`stat -c %Y $DIR1/$tfile`
4865 chmod o+r $DIR1/$tfile
4867 for (( i=0; i < 2; i++ )) ; do
4868 local mtime2=`stat -c %Y $DIR1/$tfile`
4869 [ "$mtime1" = "$mtime2" ] || \
4870 error "lost mtime: $mtime2, should be $mtime1"
4872 cancel_lru_locks $OSC
4873 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4876 run_test 39g "write, chmod, stat ==============================="
4880 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4886 echo hello >> $DIR1/$tfile
4887 local mtime1=`stat -c %Y $DIR1/$tfile`
4889 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4891 if [ "$d1" != "$d2" ]; then
4892 echo "write and touch not within one second"
4894 for (( i=0; i < 2; i++ )) ; do
4895 local mtime2=`stat -c %Y $DIR1/$tfile`
4896 [ "$mtime2" = $TEST_39_MTIME ] || \
4897 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4899 cancel_lru_locks $OSC
4900 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4904 run_test 39h "write, utime within one second, stat ============="
4907 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4912 echo hello >> $DIR1/$tfile
4913 local mtime1=`stat -c %Y $DIR1/$tfile`
4915 mv $DIR1/$tfile $DIR1/$tfile-1
4917 for (( i=0; i < 2; i++ )) ; do
4918 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4920 [ "$mtime1" = "$mtime2" ] || \
4921 error "lost mtime: $mtime2, should be $mtime1"
4923 cancel_lru_locks $OSC
4924 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4927 run_test 39i "write, rename, stat =============================="
4930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4932 start_full_debug_logging
4936 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4937 lctl set_param fail_loc=0x80000412
4938 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4939 error "multiop failed"
4941 local mtime1=`stat -c %Y $DIR1/$tfile`
4943 mv $DIR1/$tfile $DIR1/$tfile-1
4945 kill -USR1 $multipid
4946 wait $multipid || error "multiop close failed"
4948 for (( i=0; i < 2; i++ )) ; do
4949 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4950 [ "$mtime1" = "$mtime2" ] ||
4951 error "mtime is lost on close: $mtime2, " \
4955 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4957 lctl set_param fail_loc=0
4958 stop_full_debug_logging
4960 run_test 39j "write, rename, close, stat ======================="
4963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4968 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4970 local mtime1=`stat -c %Y $DIR1/$tfile`
4972 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4974 kill -USR1 $multipid
4975 wait $multipid || error "multiop close failed"
4977 for (( i=0; i < 2; i++ )) ; do
4978 local mtime2=`stat -c %Y $DIR1/$tfile`
4980 [ "$mtime2" = $TEST_39_MTIME ] || \
4981 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4984 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4987 run_test 39k "write, utime, close, stat ========================"
4989 # this should be set to future
4990 TEST_39_ATIME=`date -d "1 year" +%s`
4993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4994 remote_mds_nodsh && skip "remote MDS with nodsh"
4996 local atime_diff=$(do_facet $SINGLEMDS \
4997 lctl get_param -n mdd.*MDT0000*.atime_diff)
4999 mkdir_on_mdt0 $DIR/$tdir
5001 # test setting directory atime to future
5002 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5003 local atime=$(stat -c %X $DIR/$tdir)
5004 [ "$atime" = $TEST_39_ATIME ] ||
5005 error "atime is not set to future: $atime, $TEST_39_ATIME"
5007 # test setting directory atime from future to now
5008 local now=$(date +%s)
5009 touch -a -d @$now $DIR/$tdir
5011 atime=$(stat -c %X $DIR/$tdir)
5012 [ "$atime" -eq "$now" ] ||
5013 error "atime is not updated from future: $atime, $now"
5015 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5018 # test setting directory atime when now > dir atime + atime_diff
5019 local d1=$(date +%s)
5021 local d2=$(date +%s)
5022 cancel_lru_locks mdc
5023 atime=$(stat -c %X $DIR/$tdir)
5024 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5025 error "atime is not updated : $atime, should be $d2"
5027 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5030 # test not setting directory atime when now < dir atime + atime_diff
5032 cancel_lru_locks mdc
5033 atime=$(stat -c %X $DIR/$tdir)
5034 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5035 error "atime is updated to $atime, should remain $d1<atime<$d2"
5037 do_facet $SINGLEMDS \
5038 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5040 run_test 39l "directory atime update ==========================="
5043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5047 local far_past_mtime=$(date -d "May 29 1953" +%s)
5048 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5050 touch -m -d @$far_past_mtime $DIR1/$tfile
5051 touch -a -d @$far_past_atime $DIR1/$tfile
5053 for (( i=0; i < 2; i++ )) ; do
5054 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5055 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5056 error "atime or mtime set incorrectly"
5058 cancel_lru_locks $OSC
5059 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5062 run_test 39m "test atime and mtime before 1970"
5064 test_39n() { # LU-3832
5065 remote_mds_nodsh && skip "remote MDS with nodsh"
5067 local atime_diff=$(do_facet $SINGLEMDS \
5068 lctl get_param -n mdd.*MDT0000*.atime_diff)
5073 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5076 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5077 atime0=$(stat -c %X $DIR/$tfile)
5080 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5081 atime1=$(stat -c %X $DIR/$tfile)
5084 cancel_lru_locks mdc
5085 cancel_lru_locks osc
5086 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5087 atime2=$(stat -c %X $DIR/$tfile)
5089 do_facet $SINGLEMDS \
5090 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5092 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5093 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5095 run_test 39n "check that O_NOATIME is honored"
5098 TESTDIR=$DIR/$tdir/$tfile
5099 [ -e $TESTDIR ] && rm -rf $TESTDIR
5106 links2=$(stat -c %h .)
5107 [ $(($links1 + 2)) != $links2 ] &&
5108 error "wrong links count $(($links1 + 2)) != $links2"
5110 links3=$(stat -c %h .)
5111 [ $(($links1 + 1)) != $links3 ] &&
5112 error "wrong links count $links1 != $links3"
5115 run_test 39o "directory cached attributes updated after create"
5118 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5121 TESTDIR=$DIR/$tdir/$tdir
5122 [ -e $TESTDIR ] && rm -rf $TESTDIR
5123 test_mkdir -p $TESTDIR
5127 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5128 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5130 links2=$(stat -c %h .)
5131 [ $(($links1 + 2)) != $links2 ] &&
5132 error "wrong links count $(($links1 + 2)) != $links2"
5134 links3=$(stat -c %h .)
5135 [ $(($links1 + 1)) != $links3 ] &&
5136 error "wrong links count $links1 != $links3"
5139 run_test 39p "remote directory cached attributes updated after create ========"
5142 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5143 skip "no atime update on old OST"
5144 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5145 skip_env "ldiskfs only test"
5149 saved_adiff=$(do_facet ost1 \
5150 lctl get_param -n obdfilter.*OST0000.atime_diff)
5151 stack_trap "do_facet ost1 \
5152 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5154 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5156 $LFS setstripe -i 0 $DIR/$tfile
5157 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5158 error "can't write initial file"
5159 cancel_lru_locks osc
5161 # exceed atime_diff and access file
5163 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5164 error "can't udpate atime"
5166 local atime_cli=$(stat -c %X $DIR/$tfile)
5167 echo "client atime: $atime_cli"
5168 # allow atime update to be written to device
5169 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5172 local ostdev=$(ostdevname 1)
5173 local fid=($(lfs getstripe -y $DIR/$tfile |
5174 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
5175 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
5176 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5178 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5179 local atime_ost=$(do_facet ost1 "$cmd" |&
5180 awk -F'[: ]' '/atime:/ { print $4 }')
5181 (( atime_cli == atime_ost )) ||
5182 error "atime on client $atime_cli != ost $atime_ost"
5184 run_test 39r "lazy atime update on OST"
5186 test_39q() { # LU-8041
5187 local testdir=$DIR/$tdir
5189 multiop_bg_pause $testdir D_c || error "multiop failed"
5191 cancel_lru_locks mdc
5192 kill -USR1 $multipid
5193 local atime=$(stat -c %X $testdir)
5194 [ "$atime" -ne 0 ] || error "atime is zero"
5196 run_test 39q "close won't zero out atime"
5199 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5200 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5201 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5202 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5203 error "$tfile is not 4096 bytes in size"
5205 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5209 small_write $DIR/f41 18
5211 run_test 41 "test small file write + fstat ====================="
5213 count_ost_writes() {
5214 lctl get_param -n ${OSC}.*.stats |
5215 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5216 END { printf("%0.0f", writes) }'
5223 BG_DIRTY_RATIO_SAVE=10
5224 MAX_BG_DIRTY_RATIO=25
5228 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5229 # dirty_ratio, dirty_background_ratio
5230 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5231 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5232 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5233 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5235 # if file not here, we are a 2.4 kernel
5236 kill -CONT `pidof kupdated`
5241 # setup the trap first, so someone cannot exit the test at the
5242 # exact wrong time and mess up a machine
5243 trap start_writeback EXIT
5244 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5245 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5246 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5247 sysctl -w vm.dirty_writeback_centisecs=0
5248 sysctl -w vm.dirty_writeback_centisecs=0
5249 # save and increase /proc/sys/vm/dirty_ratio
5250 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5251 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5252 # save and increase /proc/sys/vm/dirty_background_ratio
5253 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5254 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5256 # if file not here, we are a 2.4 kernel
5257 kill -STOP `pidof kupdated`
5261 # ensure that all stripes have some grant before we test client-side cache
5263 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5264 dd if=/dev/zero of=$i bs=4k count=1
5269 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5270 # file truncation, and file removal.
5272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5275 cancel_lru_locks $OSC
5277 sync; sleep 1; sync # just to be safe
5278 BEFOREWRITES=`count_ost_writes`
5279 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5280 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5281 AFTERWRITES=`count_ost_writes`
5282 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5283 error "$BEFOREWRITES < $AFTERWRITES"
5286 run_test 42a "ensure that we don't flush on close"
5289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5292 cancel_lru_locks $OSC
5295 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5296 BEFOREWRITES=$(count_ost_writes)
5297 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5298 AFTERWRITES=$(count_ost_writes)
5299 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5300 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5302 BEFOREWRITES=$(count_ost_writes)
5303 sync || error "sync: $?"
5304 AFTERWRITES=$(count_ost_writes)
5305 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5306 error "$BEFOREWRITES < $AFTERWRITES on sync"
5308 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5312 run_test 42b "test destroy of file with cached dirty data ======"
5314 # if these tests just want to test the effect of truncation,
5315 # they have to be very careful. consider:
5316 # - the first open gets a {0,EOF}PR lock
5317 # - the first write conflicts and gets a {0, count-1}PW
5318 # - the rest of the writes are under {count,EOF}PW
5319 # - the open for truncate tries to match a {0,EOF}PR
5320 # for the filesize and cancels the PWs.
5321 # any number of fixes (don't get {0,EOF} on open, match
5322 # composite locks, do smarter file size management) fix
5323 # this, but for now we want these tests to verify that
5324 # the cancellation with truncate intent works, so we
5325 # start the file with a full-file pw lock to match against
5326 # until the truncate.
5331 cancel_lru_locks $OSC
5333 # prime the file with 0,EOF PW to match
5337 # now the real test..
5338 dd if=/dev/zero of=$file bs=1024 count=100
5339 BEFOREWRITES=`count_ost_writes`
5340 $TRUNCATE $file $offset
5341 cancel_lru_locks $OSC
5342 AFTERWRITES=`count_ost_writes`
5347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5350 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5351 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5354 run_test 42c "test partial truncate of file with cached dirty data"
5357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5359 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5360 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5361 $LCTL set_param debug=+cache
5364 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5365 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5368 run_test 42d "test complete truncate of file with cached dirty data"
5370 test_42e() { # bug22074
5371 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5373 local TDIR=$DIR/${tdir}e
5374 local pages=16 # hardcoded 16 pages, don't change it.
5375 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5376 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5380 test_mkdir $DIR/${tdir}e
5381 $LFS setstripe -c 1 $TDIR
5382 createmany -o $TDIR/f $files
5384 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5386 # we assume that with $OSTCOUNT files, at least one of them will
5387 # be allocated on OST0.
5388 warmup_files=$((OSTCOUNT * max_dirty_mb))
5389 createmany -o $TDIR/w $warmup_files
5391 # write a large amount of data into one file and sync, to get good
5392 # avail_grant number from OST.
5393 for ((i=0; i<$warmup_files; i++)); do
5394 idx=$($LFS getstripe -i $TDIR/w$i)
5395 [ $idx -ne 0 ] && continue
5396 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5399 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5401 $LCTL get_param $proc_osc0/cur_dirty_bytes
5402 $LCTL get_param $proc_osc0/cur_grant_bytes
5404 # create as much dirty pages as we can while not to trigger the actual
5405 # RPCs directly. but depends on the env, VFS may trigger flush during this
5406 # period, hopefully we are good.
5407 for ((i=0; i<$warmup_files; i++)); do
5408 idx=$($LFS getstripe -i $TDIR/w$i)
5409 [ $idx -ne 0 ] && continue
5410 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5412 $LCTL get_param $proc_osc0/cur_dirty_bytes
5413 $LCTL get_param $proc_osc0/cur_grant_bytes
5415 # perform the real test
5416 $LCTL set_param $proc_osc0/rpc_stats 0
5417 for ((;i<$files; i++)); do
5418 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5419 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5422 $LCTL get_param $proc_osc0/rpc_stats
5425 local have_ppr=false
5426 $LCTL get_param $proc_osc0/rpc_stats |
5427 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5428 # skip lines until we are at the RPC histogram data
5429 [ "$PPR" == "pages" ] && have_ppr=true && continue
5430 $have_ppr || continue
5432 # we only want the percent stat for < 16 pages
5433 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5435 percent=$((percent + WPCT))
5436 if [[ $percent -gt 15 ]]; then
5437 error "less than 16-pages write RPCs" \
5444 run_test 42e "verify sub-RPC writes are not done synchronously"
5446 test_43A() { # was test_43
5447 test_mkdir $DIR/$tdir
5448 cp -p /bin/ls $DIR/$tdir/$tfile
5449 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5451 # give multiop a chance to open
5454 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5456 # Wait for multiop to exit
5459 run_test 43A "execution of file opened for write should return -ETXTBSY"
5462 test_mkdir $DIR/$tdir
5463 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5464 $DIR/$tdir/sleep 60 &
5466 # Make sure exec of $tdir/sleep wins race with truncate
5468 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5471 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5476 test_mkdir $DIR/$tdir
5477 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5478 $DIR/$tdir/sleep 60 &
5480 # Make sure exec of $tdir/sleep wins race with truncate
5482 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5485 run_test 43b "truncate of file being executed should return -ETXTBSY"
5488 local testdir="$DIR/$tdir"
5491 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5492 ( cd $testdir && md5sum -c )
5494 run_test 43c "md5sum of copy into lustre"
5496 test_44A() { # was test_44
5497 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5499 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5500 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5502 run_test 44A "zero length read from a sparse stripe"
5505 local nstripe=$($LFS getstripe -c -d $DIR)
5506 [ -z "$nstripe" ] && skip "can't get stripe info"
5507 [[ $nstripe -gt $OSTCOUNT ]] &&
5508 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5510 local stride=$($LFS getstripe -S -d $DIR)
5511 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5512 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5515 OFFSETS="0 $((stride/2)) $((stride-1))"
5516 for offset in $OFFSETS; do
5517 for i in $(seq 0 $((nstripe-1))); do
5518 local GLOBALOFFSETS=""
5520 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5521 local myfn=$DIR/d44a-$size
5522 echo "--------writing $myfn at $size"
5523 ll_sparseness_write $myfn $size ||
5524 error "ll_sparseness_write"
5525 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5526 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5527 error "ll_sparseness_verify $GLOBALOFFSETS"
5529 for j in $(seq 0 $((nstripe-1))); do
5531 size=$((((j + $nstripe )*$stride + $offset)))
5532 ll_sparseness_write $myfn $size ||
5533 error "ll_sparseness_write"
5534 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5536 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5537 error "ll_sparseness_verify $GLOBALOFFSETS"
5542 run_test 44a "test sparse pwrite ==============================="
5546 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5552 before=`dirty_osc_total`
5553 echo executing "\"$*\""
5555 after=`dirty_osc_total`
5556 echo before $before, after $after
5559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5562 # Obtain grants from OST if it supports it
5563 echo blah > ${f}_grant
5566 do_dirty_record "echo blah > $f"
5567 [[ $before -eq $after ]] && error "write wasn't cached"
5568 do_dirty_record "> $f"
5569 [[ $before -gt $after ]] || error "truncate 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 "sync"
5573 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5574 do_dirty_record "echo blah > $f"
5575 [[ $before -eq $after ]] && error "write wasn't cached"
5576 do_dirty_record "cancel_lru_locks osc"
5577 [[ $before -gt $after ]] ||
5578 error "lock cancellation didn't lower dirty count"
5581 run_test 45 "osc io page accounting ============================"
5583 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5584 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5585 # objects offset and an assert hit when an rpc was built with 1023's mapped
5586 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5593 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5595 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5596 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5600 run_test 46 "dirtying a previously written page ================"
5602 # test_47 is removed "Device nodes check" is moved to test_28
5604 test_48a() { # bug 2399
5605 [ "$mds1_FSTYPE" = "zfs" ] &&
5606 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5607 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5609 test_mkdir $DIR/$tdir
5611 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5612 test_mkdir $DIR/$tdir
5613 touch foo || error "'touch foo' failed after recreating cwd"
5615 touch .foo || error "'touch .foo' failed after recreating cwd"
5617 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5618 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5619 cd . || error "'cd .' failed after recreating cwd"
5620 mkdir . && error "'mkdir .' worked after recreating cwd"
5621 rmdir . && error "'rmdir .' worked after recreating cwd"
5622 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5623 cd .. || error "'cd ..' failed after recreating cwd"
5625 run_test 48a "Access renamed working dir (should return errors)="
5627 test_48b() { # bug 2399
5629 test_mkdir $DIR/$tdir
5631 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5632 touch foo && error "'touch foo' worked after removing cwd"
5633 mkdir foo && error "'mkdir foo' worked after removing cwd"
5634 touch .foo && error "'touch .foo' worked after removing cwd"
5635 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5636 ls . > /dev/null && error "'ls .' worked after removing cwd"
5637 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5638 mkdir . && error "'mkdir .' worked after removing cwd"
5639 rmdir . && error "'rmdir .' worked after removing cwd"
5640 ln -s . foo && error "'ln -s .' worked after removing cwd"
5641 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5643 run_test 48b "Access removed working dir (should return errors)="
5645 test_48c() { # bug 2350
5646 #lctl set_param debug=-1
5649 test_mkdir -p $DIR/$tdir/dir
5651 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5652 $TRACE touch foo && error "touch foo worked after removing cwd"
5653 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5654 touch .foo && error "touch .foo worked after removing cwd"
5655 mkdir .foo && error "mkdir .foo worked after removing cwd"
5656 $TRACE ls . && error "'ls .' worked after removing cwd"
5657 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5658 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5659 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5660 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5661 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5663 run_test 48c "Access removed working subdir (should return errors)"
5665 test_48d() { # bug 2350
5666 #lctl set_param debug=-1
5669 test_mkdir -p $DIR/$tdir/dir
5671 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5672 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5673 $TRACE touch foo && error "'touch foo' worked after removing parent"
5674 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5675 touch .foo && error "'touch .foo' worked after removing parent"
5676 mkdir .foo && error "mkdir .foo worked after removing parent"
5677 $TRACE ls . && error "'ls .' worked after removing parent"
5678 $TRACE ls .. && error "'ls ..' worked after removing parent"
5679 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5680 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5681 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5684 run_test 48d "Access removed parent subdir (should return errors)"
5686 test_48e() { # bug 4134
5687 #lctl set_param debug=-1
5690 test_mkdir -p $DIR/$tdir/dir
5692 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5693 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5694 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5695 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5696 # On a buggy kernel addition of "touch foo" after cd .. will
5697 # produce kernel oops in lookup_hash_it
5698 touch ../foo && error "'cd ..' worked after recreate parent"
5700 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5702 run_test 48e "Access to recreated parent subdir (should return errors)"
5705 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5706 skip "need MDS >= 2.13.55"
5707 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5708 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5709 skip "needs different host for mdt1 mdt2"
5710 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5712 $LFS mkdir -i0 $DIR/$tdir
5713 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5715 for d in sub1 sub2 sub3; do
5716 #define OBD_FAIL_OSD_REF_DEL 0x19c
5717 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5718 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5721 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5723 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5725 test_49() { # LU-1030
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5727 remote_ost_nodsh && skip "remote OST with nodsh"
5729 # get ost1 size - $FSNAME-OST0000
5730 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5732 # write 800M at maximum
5733 [[ $ost1_size -lt 2 ]] && ost1_size=2
5734 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5736 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5737 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5740 # change max_pages_per_rpc while writing the file
5741 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5742 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5743 # loop until dd process exits
5744 while ps ax -opid | grep -wq $dd_pid; do
5745 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5746 sleep $((RANDOM % 5 + 1))
5748 # restore original max_pages_per_rpc
5749 $LCTL set_param $osc1_mppc=$orig_mppc
5750 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5752 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5756 test_mkdir $DIR/$tdir
5758 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5760 run_test 50 "special situations: /proc symlinks ==============="
5762 test_51a() { # was test_51
5763 # bug 1516 - create an empty entry right after ".." then split dir
5764 test_mkdir -c1 $DIR/$tdir
5765 touch $DIR/$tdir/foo
5766 $MCREATE $DIR/$tdir/bar
5768 createmany -m $DIR/$tdir/longfile 201
5770 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5771 $MCREATE $DIR/$tdir/longfile$FNUM
5776 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5778 run_test 51a "special situations: split htree with empty entry =="
5780 cleanup_print_lfs_df () {
5787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5789 local dir=$DIR/$tdir
5790 local nrdirs=$((65536 + 100))
5792 # cleanup the directory
5795 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5799 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5800 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5801 [[ $numfree -lt $nrdirs ]] &&
5802 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5804 # need to check free space for the directories as well
5805 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5806 numfree=$(( blkfree / $(fs_inode_ksize) ))
5807 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5809 trap cleanup_print_lfs_df EXIT
5812 createmany -d $dir/d $nrdirs || {
5813 unlinkmany $dir/d $nrdirs
5814 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5818 nrdirs=$(ls -U $dir | wc -l)
5820 # unlink all but 100 subdirectories, then check it still works
5822 local delete=$((nrdirs - left))
5827 # for ldiskfs the nlink count should be 1, but this is OSD specific
5828 # and so this is listed for informational purposes only
5829 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5830 unlinkmany -d $dir/d $delete ||
5831 error "unlink of first $delete subdirs failed"
5833 echo "nlink between: $(stat -c %h $dir)"
5834 local found=$(ls -U $dir | wc -l)
5835 [ $found -ne $left ] &&
5836 error "can't find subdirs: found only $found, expected $left"
5838 unlinkmany -d $dir/d $delete $left ||
5839 error "unlink of second $left subdirs failed"
5840 # regardless of whether the backing filesystem tracks nlink accurately
5841 # or not, the nlink count shouldn't be more than "." and ".." here
5842 local after=$(stat -c %h $dir)
5843 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5844 echo "nlink after: $after"
5846 cleanup_print_lfs_df
5848 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5851 local stripecount=$1
5854 log "create files with stripecount=$stripecount"
5855 $LFS setstripe -C $stripecount $DIR/$tdir
5856 createmany -o $DIR/$tdir/t- $nfiles
5857 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5858 for ((n = 0; n < $OSTCOUNT; n++)); do
5859 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5860 END { printf("%0.0f", objs) }' $TMP/$tfile)
5861 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5862 '($1 == '$n') { objs += 1 } \
5863 END { printf("%0.0f", objs) }')
5864 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5866 unlinkmany $DIR/$tdir/t- $nfiles
5871 local max=6 # allow variance of (1 - $min/$max) = 33% by default
5873 # For some combinations of stripecount and OSTCOUNT current code
5874 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
5875 # than others. Rather than skipping this test entirely, check that
5876 # and keep testing to ensure imbalance does not get worse. LU-15282
5877 (( (OSTCOUNT == 6 && stripecount == 4) ||
5878 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
5879 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
5880 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
5881 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5882 { $LFS df && $LFS df -i &&
5883 error "stripecount=$stripecount: " \
5884 "OST $n has fewer objects vs. OST $nlast " \
5885 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
5886 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5887 { $LFS df && $LFS df -i &&
5888 error "stripecount=$stripecount: " \
5889 "OST $n has more objects vs. OST $nlast " \
5890 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
5892 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
5893 { $LFS df && $LFS df -i &&
5894 error "stripecount=$stripecount: " \
5895 "OST $n has fewer #0 objects vs. OST $nlast " \
5896 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
5897 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
5898 { $LFS df && $LFS df -i &&
5899 error "stripecount=$stripecount: " \
5900 "OST $n has more #0 objects vs. OST $nlast " \
5901 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
5906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5907 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5911 local nfiles=$((per_ost * OSTCOUNT))
5912 local mdts=$(comma_list $(mdts_nodes))
5913 local param="osp.*.create_count"
5914 local qos_old=$(do_facet mds1 \
5915 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
5918 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
5919 stack_trap "do_nodes $mdts \
5920 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
5922 test_mkdir $DIR/$tdir
5923 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
5924 (( dirstripes > 0 )) || dirstripes=1
5926 # Ensure enough OST objects precreated for tests to pass without
5927 # running out of objects. This is an LOV r-r OST algorithm test,
5928 # not an OST object precreation test.
5929 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
5930 (( old >= nfiles )) ||
5932 local create_count=$((nfiles * OSTCOUNT / dirstripes))
5934 do_nodes $mdts "$LCTL set_param $param=$create_count"
5935 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
5937 # trigger precreation from all MDTs for all OSTs
5938 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
5939 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
5943 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
5944 sleep 8 # allow object precreation to catch up
5945 test_51d_sub $stripecount $nfiles
5948 run_test 51d "check LOV round-robin OST object distribution"
5951 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5952 skip_env "ldiskfs only test"
5955 test_mkdir -c1 $DIR/$tdir
5956 test_mkdir -c1 $DIR/$tdir/d0
5958 touch $DIR/$tdir/d0/foo
5959 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5960 error "file exceed 65000 nlink limit!"
5961 unlinkmany $DIR/$tdir/d0/f- 65001
5964 run_test 51e "check file nlink limit"
5967 test_mkdir $DIR/$tdir
5970 local ulimit_old=$(ulimit -n)
5971 local spare=20 # number of spare fd's for scripts/libraries, etc.
5972 local mdt=$($LFS getstripe -m $DIR/$tdir)
5973 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5975 echo "MDT$mdt numfree=$numfree, max=$max"
5976 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5977 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5978 while ! ulimit -n $((numfree + spare)); do
5979 numfree=$((numfree * 3 / 4))
5981 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5983 echo "left ulimit at $ulimit_old"
5986 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5987 unlinkmany $DIR/$tdir/f $numfree
5988 error "create+open $numfree files in $DIR/$tdir failed"
5990 ulimit -n $ulimit_old
5992 # if createmany exits at 120s there will be fewer than $numfree files
5993 unlinkmany $DIR/$tdir/f $numfree || true
5995 run_test 51f "check many open files limit"
5998 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5999 test_mkdir $DIR/$tdir
6000 touch $DIR/$tdir/foo
6001 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6002 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6003 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6004 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6005 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6007 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6008 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6009 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6011 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6012 cp -r $DIR/$tdir $TMP/
6013 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6015 run_test 52a "append-only flag test (should return errors)"
6018 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6019 test_mkdir $DIR/$tdir
6020 touch $DIR/$tdir/foo
6021 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6022 cat test > $DIR/$tdir/foo && error "cat test worked"
6023 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6024 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6025 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6027 echo foo >> $DIR/$tdir/foo && error "echo worked"
6028 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6029 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6030 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6031 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6033 chattr -i $DIR/$tdir/foo || error "chattr failed"
6035 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6037 run_test 52b "immutable flag test (should return errors) ======="
6040 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6041 remote_mds_nodsh && skip "remote MDS with nodsh"
6042 remote_ost_nodsh && skip "remote OST with nodsh"
6055 local support_last_seq=true
6057 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6058 support_last_seq=false
6061 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6063 for value in $(do_facet $SINGLEMDS \
6064 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6065 param=$(echo ${value[0]} | cut -d "=" -f1)
6066 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6068 if $support_last_seq; then
6069 param_seq=$(echo $param |
6070 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6071 mds_last_seq=$(do_facet $SINGLEMDS \
6072 $LCTL get_param -n $param_seq)
6074 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6076 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6077 node=$(facet_active_host ost$((ostnum+1)))
6078 param="obdfilter.$ostname.last_id"
6079 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6080 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6081 ost_last_id=$ost_last
6083 if $support_last_seq; then
6084 ost_last_id=$(echo $ost_last |
6085 awk -F':' '{print $2}' |
6087 ost_last_seq=$(echo $ost_last |
6088 awk -F':' '{print $1}')
6089 [[ $ost_last_seq = $mds_last_seq ]] || continue
6092 if [[ $ost_last_id != $mds_last ]]; then
6093 error "$ost_last_id != $mds_last"
6100 $found || error "can not match last_seq/last_id for $mdtosc"
6103 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6106 perl -MSocket -e ';' || skip "no Socket perl module installed"
6108 $SOCKETSERVER $DIR/socket ||
6109 error "$SOCKETSERVER $DIR/socket failed: $?"
6110 $SOCKETCLIENT $DIR/socket ||
6111 error "$SOCKETCLIENT $DIR/socket failed: $?"
6112 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
6114 run_test 54a "unix domain socket test =========================="
6120 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6122 run_test 54b "char device works in lustre ======================"
6125 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6126 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6127 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6129 for i in $(seq 3 7); do
6130 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6139 loopdev="$DIR/loop54c"
6142 $UMOUNT $DIR/$tdir || rc=$?
6143 losetup -d $loopdev || true
6144 losetup -d $LOOPDEV || true
6145 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6150 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6152 loopdev="$DIR/loop54c"
6155 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6156 trap cleanup_54c EXIT
6157 mknod $loopdev b 7 $LOOPNUM
6158 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6159 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6160 losetup $loopdev $DIR/$tfile ||
6161 error "can't set up $loopdev for $DIR/$tfile"
6162 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6163 test_mkdir $DIR/$tdir
6164 mount -t ext2 $loopdev $DIR/$tdir ||
6165 error "error mounting $loopdev on $DIR/$tdir"
6166 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6169 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6173 run_test 54c "block device works in lustre ====================="
6176 local pipe="$DIR/$tfile.pipe"
6177 local string="aaaaaa"
6180 echo -n "$string" > $pipe &
6181 local result=$(cat $pipe)
6182 [[ "$result" == "$string" ]] || error "$result != $string"
6184 run_test 54d "fifo device works in lustre ======================"
6189 cp -aL /dev/console $f
6190 echo $string > $f || error "echo $string to $f failed"
6192 run_test 54e "console/tty device works in lustre ======================"
6197 local dir=$DIR/$tdir
6200 test_mkdir -p $dir/dir
6201 for i in $(seq $numfiles); do
6203 touch $dir/dir/file$i
6206 local numcomp=$($LFS getstripe --component-count $dir)
6208 [[ $numcomp == 0 ]] && numcomp=1
6210 # test lfs getstripe with --recursive
6211 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6213 [[ $filenum -eq $((numfiles * 2)) ]] ||
6214 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6215 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6216 [[ $filenum -eq $numfiles ]] ||
6217 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6218 echo "$LFS getstripe showed obdidx or l_ost_idx"
6220 # test lfs getstripe with file instead of dir
6221 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6222 [[ $filenum -eq 1 ]] ||
6223 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6224 echo "$LFS getstripe file1 passed"
6226 #test lfs getstripe with --verbose
6227 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6228 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6229 error "$LFS getstripe --verbose $dir: "\
6230 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6231 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6232 error "$LFS getstripe $dir: showed lmm_magic"
6234 #test lfs getstripe with -v prints lmm_fid
6235 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6236 local countfids=$((numdirs + numfiles * numcomp))
6237 [[ $filenum -eq $countfids ]] ||
6238 error "$LFS getstripe -v $dir: "\
6239 "got $filenum want $countfids lmm_fid"
6240 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6241 error "$LFS getstripe $dir: showed lmm_fid by default"
6242 echo "$LFS getstripe --verbose passed"
6244 #check for FID information
6245 local fid1=$($LFS getstripe --fid $dir/file1)
6246 local fid2=$($LFS getstripe --verbose $dir/file1 |
6247 awk '/lmm_fid: / { print $2; exit; }')
6248 local fid3=$($LFS path2fid $dir/file1)
6250 [ "$fid1" != "$fid2" ] &&
6251 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6252 [ "$fid1" != "$fid3" ] &&
6253 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6254 echo "$LFS getstripe --fid passed"
6256 #test lfs getstripe with --obd
6257 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6258 error "$LFS getstripe --obd wrong_uuid: should return error"
6260 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6263 local obduuid=$(ostuuid_from_index $ostidx)
6264 local found=$($LFS getstripe -r --obd $obduuid $dir |
6265 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6267 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6268 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6270 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6273 [[ $found -eq $filenum ]] ||
6274 error "$LFS getstripe --obd: found $found expect $filenum"
6275 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6276 sed '/^[ ]*'${ostidx}'[ ]/d' |
6277 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6278 error "$LFS getstripe --obd: should not show file on other obd"
6279 echo "$LFS getstripe --obd passed"
6281 run_test 56a "check $LFS getstripe"
6284 local dir=$DIR/$tdir
6288 for i in $(seq $numdirs); do
6289 test_mkdir $dir/dir$i
6292 # test lfs getdirstripe default mode is non-recursion, which is
6293 # different from lfs getstripe
6294 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6296 [[ $dircnt -eq 1 ]] ||
6297 error "$LFS getdirstripe: found $dircnt, not 1"
6298 dircnt=$($LFS getdirstripe --recursive $dir |
6299 grep -c lmv_stripe_count)
6300 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6301 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6303 run_test 56b "check $LFS getdirstripe"
6306 remote_ost_nodsh && skip "remote OST with nodsh"
6309 local ost_name=$(ostname_from_index $ost_idx)
6310 local old_status=$(ost_dev_status $ost_idx)
6311 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6313 [[ -z "$old_status" ]] ||
6314 skip_env "OST $ost_name is in $old_status status"
6316 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6317 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6318 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6319 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6320 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6321 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6324 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6325 error "$LFS df -v showing inactive devices"
6328 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6330 [[ "$new_status" =~ "D" ]] ||
6331 error "$ost_name status is '$new_status', missing 'D'"
6332 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6333 [[ "$new_status" =~ "N" ]] ||
6334 error "$ost_name status is '$new_status', missing 'N'"
6336 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6337 [[ "$new_status" =~ "f" ]] ||
6338 error "$ost_name status is '$new_status', missing 'f'"
6341 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6342 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6343 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6344 [[ -z "$p" ]] && restore_lustre_params < $p || true
6347 new_status=$(ost_dev_status $ost_idx)
6348 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6349 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6350 # can't check 'f' as devices may actually be on flash
6352 run_test 56c "check 'lfs df' showing device status"
6355 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6356 local osts=$($LFS df -v $MOUNT | grep -c OST)
6360 (( mdts == MDSCOUNT )) ||
6361 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6362 (( osts == OSTCOUNT )) ||
6363 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6365 run_test 56d "'lfs df -v' prints only configured devices"
6368 err_enoent=2 # No such file or directory
6369 err_eopnotsupp=95 # Operation not supported
6371 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6372 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6374 # Check for handling of path not exists
6375 output=$($LFS df $enoent_mnt 2>&1)
6378 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6379 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6380 error "expect failure $err_enoent, not $ret"
6382 # Check for handling of non-Lustre FS
6383 output=$($LFS df $notsup_mnt)
6386 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6387 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6388 error "expect success $err_eopnotsupp, not $ret"
6390 # Check for multiple LustreFS argument
6391 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6394 [[ $output -eq 3 && $ret -eq 0 ]] ||
6395 error "expect success 3, not $output, rc = $ret"
6397 # Check for correct non-Lustre FS handling among multiple
6399 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6400 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6403 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6404 error "expect success 2, not $output, rc = $ret"
6406 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6411 local local_tdir="$1"
6412 local local_numfiles="$2"
6413 local local_numdirs="$3"
6414 local dir_params="$4"
6415 local dir_stripe_params="$5"
6417 if [ ! -d "$local_tdir" ] ; then
6418 test_mkdir -p $dir_stripe_params $local_tdir
6419 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6420 for i in $(seq $local_numfiles) ; do
6421 touch $local_tdir/file$i
6423 for i in $(seq $local_numdirs) ; do
6424 test_mkdir $dir_stripe_params $local_tdir/dir$i
6425 for j in $(seq $local_numfiles) ; do
6426 touch $local_tdir/dir$i/file$j
6432 setup_56_special() {
6434 local local_numfiles=$2
6435 local local_numdirs=$3
6437 setup_56 $local_tdir $local_numfiles $local_numdirs
6439 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6440 for i in $(seq $local_numfiles) ; do
6441 mknod $local_tdir/loop${i}b b 7 $i
6442 mknod $local_tdir/null${i}c c 1 3
6443 ln -s $local_tdir/file1 $local_tdir/link${i}
6445 for i in $(seq $local_numdirs) ; do
6446 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6447 mknod $local_tdir/dir$i/null${i}c c 1 3
6448 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6454 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6455 local expected=$(($NUMDIRS + 2))
6457 setup_56 $dir $NUMFILES $NUMDIRS
6459 # test lfs find with -name
6460 for i in $(seq $NUMFILES) ; do
6461 local nums=$($LFS find -name "*$i" $dir | wc -l)
6463 [ $nums -eq $expected ] ||
6464 error "lfs find -name '*$i' $dir wrong: "\
6465 "found $nums, expected $expected"
6468 run_test 56g "check lfs find -name"
6471 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6472 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6474 setup_56 $dir $NUMFILES $NUMDIRS
6476 # test lfs find with ! -name
6477 for i in $(seq $NUMFILES) ; do
6478 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6480 [ $nums -eq $expected ] ||
6481 error "lfs find ! -name '*$i' $dir wrong: "\
6482 "found $nums, expected $expected"
6485 run_test 56h "check lfs find ! -name"
6488 local dir=$DIR/$tdir
6492 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6495 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6497 run_test 56i "check 'lfs find -ost UUID' skips directories"
6500 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6502 setup_56_special $dir $NUMFILES $NUMDIRS
6504 local expected=$((NUMDIRS + 1))
6505 local cmd="$LFS find -type d $dir"
6506 local nums=$($cmd | wc -l)
6508 [ $nums -eq $expected ] ||
6509 error "'$cmd' wrong: found $nums, expected $expected"
6511 run_test 56j "check lfs find -type d"
6514 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6516 setup_56_special $dir $NUMFILES $NUMDIRS
6518 local expected=$(((NUMDIRS + 1) * NUMFILES))
6519 local cmd="$LFS find -type f $dir"
6520 local nums=$($cmd | wc -l)
6522 [ $nums -eq $expected ] ||
6523 error "'$cmd' wrong: found $nums, expected $expected"
6525 run_test 56k "check lfs find -type f"
6528 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6530 setup_56_special $dir $NUMFILES $NUMDIRS
6532 local expected=$((NUMDIRS + NUMFILES))
6533 local cmd="$LFS find -type b $dir"
6534 local nums=$($cmd | wc -l)
6536 [ $nums -eq $expected ] ||
6537 error "'$cmd' wrong: found $nums, expected $expected"
6539 run_test 56l "check lfs find -type b"
6542 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6544 setup_56_special $dir $NUMFILES $NUMDIRS
6546 local expected=$((NUMDIRS + NUMFILES))
6547 local cmd="$LFS find -type c $dir"
6548 local nums=$($cmd | wc -l)
6549 [ $nums -eq $expected ] ||
6550 error "'$cmd' wrong: found $nums, expected $expected"
6552 run_test 56m "check lfs find -type c"
6555 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6556 setup_56_special $dir $NUMFILES $NUMDIRS
6558 local expected=$((NUMDIRS + NUMFILES))
6559 local cmd="$LFS find -type l $dir"
6560 local nums=$($cmd | wc -l)
6562 [ $nums -eq $expected ] ||
6563 error "'$cmd' wrong: found $nums, expected $expected"
6565 run_test 56n "check lfs find -type l"
6568 local dir=$DIR/$tdir
6570 setup_56 $dir $NUMFILES $NUMDIRS
6571 utime $dir/file1 > /dev/null || error "utime (1)"
6572 utime $dir/file2 > /dev/null || error "utime (2)"
6573 utime $dir/dir1 > /dev/null || error "utime (3)"
6574 utime $dir/dir2 > /dev/null || error "utime (4)"
6575 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6576 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6579 local nums=$($LFS find -mtime +0 $dir | wc -l)
6581 [ $nums -eq $expected ] ||
6582 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6585 cmd="$LFS find -mtime 0 $dir"
6586 nums=$($cmd | wc -l)
6587 [ $nums -eq $expected ] ||
6588 error "'$cmd' wrong: found $nums, expected $expected"
6590 run_test 56o "check lfs find -mtime for old files"
6593 local dir=$DIR/$tdir
6597 # just to make sure there is something that won't be found
6599 touch $dir/$tfile.now
6601 for age in year week day hour min; do
6602 count=$((count + 1))
6604 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6605 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6606 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6608 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6609 local nums=$($cmd | wc -l)
6610 [ $nums -eq $expected ] ||
6611 error "'$cmd' wrong: found $nums, expected $expected"
6613 cmd="$LFS find $dir -atime $count${age:0:1}"
6614 nums=$($cmd | wc -l)
6615 [ $nums -eq $expected ] ||
6616 error "'$cmd' wrong: found $nums, expected $expected"
6620 cmd="$LFS find $dir -ctime +1s -type f"
6621 nums=$($cmd | wc -l)
6622 (( $nums == $count * 2 + 1)) ||
6623 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6625 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6627 test_newerXY_base() {
6630 local dir=$DIR/$tdir
6634 if [ $y == "t" ]; then
6635 if [ $x == "b" ]; then
6636 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6638 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6641 ref=$DIR/$tfile.newer.$x$y
6642 touch $ref || error "touch $ref failed"
6645 echo "before = $ref"
6647 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6649 if [ $y == "t" ]; then
6650 if [ $x == "b" ]; then
6651 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6653 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6656 negref=$DIR/$tfile.negnewer.$x$y
6657 touch $negref || error "touch $negref failed"
6660 echo "after = $negref"
6661 local cmd="$LFS find $dir -newer$x$y $ref"
6662 local nums=$(eval $cmd | wc -l)
6663 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6665 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6666 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6668 cmd="$LFS find $dir ! -newer$x$y $negref"
6669 nums=$(eval $cmd | wc -l)
6670 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6671 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6673 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6674 nums=$(eval $cmd | wc -l)
6675 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6676 error "'$cmd' wrong: found $nums between, expected $expected"; }
6682 test_newerXY_base "a" "a"
6683 test_newerXY_base "a" "m"
6684 test_newerXY_base "a" "c"
6685 test_newerXY_base "m" "a"
6686 test_newerXY_base "m" "m"
6687 test_newerXY_base "m" "c"
6688 test_newerXY_base "c" "a"
6689 test_newerXY_base "c" "m"
6690 test_newerXY_base "c" "c"
6692 [[ -n "$sles_version" ]] &&
6693 echo "skip timestamp tests on SLES, LU-13665" && return 0
6695 test_newerXY_base "a" "t"
6696 test_newerXY_base "m" "t"
6697 test_newerXY_base "c" "t"
6699 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6700 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6701 ! btime_supported && echo "btime unsupported" && return 0
6703 test_newerXY_base "b" "b"
6704 test_newerXY_base "b" "t"
6706 run_test 56oc "check lfs find -newerXY work"
6709 local dir=$DIR/$tdir
6714 $LFS find $dir -btime -1d -type f
6721 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6722 ! btime_supported && skip "btime unsupported on MDS"
6724 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6725 ! btime_supported && skip "btime unsupported on clients"
6727 local dir=$DIR/$tdir
6728 local ref=$DIR/$tfile.ref
6729 local negref=$DIR/$tfile.negref
6731 mkdir $dir || error "mkdir $dir failed"
6732 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6733 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6734 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6735 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6736 touch $ref || error "touch $ref failed"
6737 # sleep 3 seconds at least
6740 local before=$(do_facet mds1 date +%s)
6741 local skew=$(($(date +%s) - before + 1))
6743 if (( skew < 0 && skew > -5 )); then
6744 sleep $((0 - skew + 1))
6748 # Set the dir stripe params to limit files all on MDT0,
6749 # otherwise we need to calc the max clock skew between
6750 # the client and MDTs.
6751 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6753 touch $negref || error "touch $negref failed"
6755 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6756 local nums=$($cmd | wc -l)
6757 local expected=$(((NUMFILES + 1) * NUMDIRS))
6759 [ $nums -eq $expected ] ||
6760 error "'$cmd' wrong: found $nums, expected $expected"
6762 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6763 nums=$($cmd | wc -l)
6764 expected=$((NUMFILES + 1))
6765 [ $nums -eq $expected ] ||
6766 error "'$cmd' wrong: found $nums, expected $expected"
6768 [ $skew -lt 0 ] && return
6770 local after=$(do_facet mds1 date +%s)
6771 local age=$((after - before + 1 + skew))
6773 cmd="$LFS find $dir -btime -${age}s -type f"
6774 nums=$($cmd | wc -l)
6775 expected=$(((NUMFILES + 1) * NUMDIRS))
6777 echo "Clock skew between client and server: $skew, age:$age"
6778 [ $nums -eq $expected ] ||
6779 error "'$cmd' wrong: found $nums, expected $expected"
6781 expected=$(($NUMDIRS + 1))
6782 cmd="$LFS find $dir -btime -${age}s -type d"
6783 nums=$($cmd | wc -l)
6784 [ $nums -eq $expected ] ||
6785 error "'$cmd' wrong: found $nums, expected $expected"
6786 rm -f $ref $negref || error "Failed to remove $ref $negref"
6788 run_test 56od "check lfs find -btime with units"
6791 [ $RUNAS_ID -eq $UID ] &&
6792 skip_env "RUNAS_ID = UID = $UID -- skipping"
6794 local dir=$DIR/$tdir
6796 setup_56 $dir $NUMFILES $NUMDIRS
6797 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6799 local expected=$NUMFILES
6800 local cmd="$LFS find -uid $RUNAS_ID $dir"
6801 local nums=$($cmd | wc -l)
6803 [ $nums -eq $expected ] ||
6804 error "'$cmd' wrong: found $nums, expected $expected"
6806 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6807 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6808 nums=$($cmd | wc -l)
6809 [ $nums -eq $expected ] ||
6810 error "'$cmd' wrong: found $nums, expected $expected"
6812 run_test 56p "check lfs find -uid and ! -uid"
6815 [ $RUNAS_ID -eq $UID ] &&
6816 skip_env "RUNAS_ID = UID = $UID -- skipping"
6818 local dir=$DIR/$tdir
6820 setup_56 $dir $NUMFILES $NUMDIRS
6821 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6823 local expected=$NUMFILES
6824 local cmd="$LFS find -gid $RUNAS_GID $dir"
6825 local nums=$($cmd | wc -l)
6827 [ $nums -eq $expected ] ||
6828 error "'$cmd' wrong: found $nums, expected $expected"
6830 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6831 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6832 nums=$($cmd | wc -l)
6833 [ $nums -eq $expected ] ||
6834 error "'$cmd' wrong: found $nums, expected $expected"
6836 run_test 56q "check lfs find -gid and ! -gid"
6839 local dir=$DIR/$tdir
6841 setup_56 $dir $NUMFILES $NUMDIRS
6844 local cmd="$LFS find -size 0 -type f -lazy $dir"
6845 local nums=$($cmd | wc -l)
6847 [ $nums -eq $expected ] ||
6848 error "'$cmd' wrong: found $nums, expected $expected"
6849 cmd="$LFS find -size 0 -type f $dir"
6850 nums=$($cmd | wc -l)
6851 [ $nums -eq $expected ] ||
6852 error "'$cmd' wrong: found $nums, expected $expected"
6855 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6856 nums=$($cmd | wc -l)
6857 [ $nums -eq $expected ] ||
6858 error "'$cmd' wrong: found $nums, expected $expected"
6859 cmd="$LFS find ! -size 0 -type f $dir"
6860 nums=$($cmd | wc -l)
6861 [ $nums -eq $expected ] ||
6862 error "'$cmd' wrong: found $nums, expected $expected"
6864 echo "test" > $dir/$tfile
6865 echo "test2" > $dir/$tfile.2 && sync
6867 cmd="$LFS find -size 5 -type f -lazy $dir"
6868 nums=$($cmd | wc -l)
6869 [ $nums -eq $expected ] ||
6870 error "'$cmd' wrong: found $nums, expected $expected"
6871 cmd="$LFS find -size 5 -type f $dir"
6872 nums=$($cmd | wc -l)
6873 [ $nums -eq $expected ] ||
6874 error "'$cmd' wrong: found $nums, expected $expected"
6877 cmd="$LFS find -size +5 -type f -lazy $dir"
6878 nums=$($cmd | wc -l)
6879 [ $nums -eq $expected ] ||
6880 error "'$cmd' wrong: found $nums, expected $expected"
6881 cmd="$LFS find -size +5 -type f $dir"
6882 nums=$($cmd | wc -l)
6883 [ $nums -eq $expected ] ||
6884 error "'$cmd' wrong: found $nums, expected $expected"
6887 cmd="$LFS find -size +0 -type f -lazy $dir"
6888 nums=$($cmd | wc -l)
6889 [ $nums -eq $expected ] ||
6890 error "'$cmd' wrong: found $nums, expected $expected"
6891 cmd="$LFS find -size +0 -type f $dir"
6892 nums=$($cmd | wc -l)
6893 [ $nums -eq $expected ] ||
6894 error "'$cmd' wrong: found $nums, expected $expected"
6897 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6898 nums=$($cmd | wc -l)
6899 [ $nums -eq $expected ] ||
6900 error "'$cmd' wrong: found $nums, expected $expected"
6901 cmd="$LFS find ! -size -5 -type f $dir"
6902 nums=$($cmd | wc -l)
6903 [ $nums -eq $expected ] ||
6904 error "'$cmd' wrong: found $nums, expected $expected"
6907 cmd="$LFS find -size -5 -type f -lazy $dir"
6908 nums=$($cmd | wc -l)
6909 [ $nums -eq $expected ] ||
6910 error "'$cmd' wrong: found $nums, expected $expected"
6911 cmd="$LFS find -size -5 -type f $dir"
6912 nums=$($cmd | wc -l)
6913 [ $nums -eq $expected ] ||
6914 error "'$cmd' wrong: found $nums, expected $expected"
6916 run_test 56r "check lfs find -size works"
6923 cancel_lru_locks $OSC
6925 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6926 local nums=$($cmd | wc -l)
6928 [ $nums -eq $expected ] ||
6929 error "'$cmd' wrong: found $nums, expected $expected"
6931 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6933 if (( rpcs_before + glimpses != rpcs_after )); then
6934 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6935 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6937 if [[ $glimpses == 0 ]]; then
6938 error "'$cmd' should not send glimpse RPCs to OST"
6940 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6946 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6947 skip "MDS < 2.12.58 doesn't return LSOM data"
6948 local dir=$DIR/$tdir
6949 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6951 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6953 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6954 $LCTL set_param -n llite.*.statahead_agl=0
6955 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6957 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6958 # open and close all files to ensure LSOM is updated
6959 cancel_lru_locks $OSC
6960 find $dir -type f | xargs cat > /dev/null
6962 # expect_found glimpse_rpcs command_to_run
6963 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6964 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6965 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6966 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6968 echo "test" > $dir/$tfile
6969 echo "test2" > $dir/$tfile.2 && sync
6970 cancel_lru_locks $OSC
6971 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6973 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6974 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6975 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6976 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6978 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6979 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6980 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6981 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6982 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6983 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6985 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6988 local dir=$DIR/$tdir
6989 local tmp=$TMP/$tfile.log
6992 test_mkdir -p $dir || error "failed to mkdir $dir"
6993 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6994 error "failed to setstripe $dir/$tfile"
6995 mdt_idx=$($LFS getdirstripe -i $dir)
6996 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6998 stack_trap "rm -f $tmp" EXIT
6999 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7000 ! grep -q obd_uuid $tmp ||
7001 error "failed to find --size +100K --ost 0 $dir"
7002 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7003 ! grep -q obd_uuid $tmp ||
7004 error "failed to find --size +100K --mdt $mdt_idx $dir"
7006 run_test 56rb "check lfs find --size --ost/--mdt works"
7009 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7010 local dir=$DIR/$tdir
7013 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7014 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7015 (( $MDSCOUNT > 2 )) &&
7016 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7017 mkdir $dir/$tdir-{1..10}
7018 touch $dir/$tfile-{1..10}
7020 found=$($LFS find $dir --mdt-count 2 | wc -l)
7022 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7024 found=$($LFS find $dir -T +1 | wc -l)
7025 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7026 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7028 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7030 (( $found == $expect )) || error "found $found all_char, expect $expect"
7032 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7033 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7034 (( $found == $expect )) || error "found $found all_char, expect $expect"
7036 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7038 test_56s() { # LU-611 #LU-9369
7039 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7041 local dir=$DIR/$tdir
7042 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7044 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7045 for i in $(seq $NUMDIRS); do
7046 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7049 local expected=$NUMDIRS
7050 local cmd="$LFS find -c $OSTCOUNT $dir"
7051 local nums=$($cmd | wc -l)
7053 [ $nums -eq $expected ] || {
7054 $LFS getstripe -R $dir
7055 error "'$cmd' wrong: found $nums, expected $expected"
7058 expected=$((NUMDIRS + onestripe))
7059 cmd="$LFS find -stripe-count +0 -type f $dir"
7060 nums=$($cmd | wc -l)
7061 [ $nums -eq $expected ] || {
7062 $LFS getstripe -R $dir
7063 error "'$cmd' wrong: found $nums, expected $expected"
7067 cmd="$LFS find -stripe-count 1 -type f $dir"
7068 nums=$($cmd | wc -l)
7069 [ $nums -eq $expected ] || {
7070 $LFS getstripe -R $dir
7071 error "'$cmd' wrong: found $nums, expected $expected"
7074 cmd="$LFS find -stripe-count -2 -type f $dir"
7075 nums=$($cmd | wc -l)
7076 [ $nums -eq $expected ] || {
7077 $LFS getstripe -R $dir
7078 error "'$cmd' wrong: found $nums, expected $expected"
7082 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7083 nums=$($cmd | wc -l)
7084 [ $nums -eq $expected ] || {
7085 $LFS getstripe -R $dir
7086 error "'$cmd' wrong: found $nums, expected $expected"
7089 run_test 56s "check lfs find -stripe-count works"
7091 test_56t() { # LU-611 #LU-9369
7092 local dir=$DIR/$tdir
7094 setup_56 $dir 0 $NUMDIRS
7095 for i in $(seq $NUMDIRS); do
7096 $LFS setstripe -S 8M $dir/dir$i/$tfile
7099 local expected=$NUMDIRS
7100 local cmd="$LFS find -S 8M $dir"
7101 local nums=$($cmd | wc -l)
7103 [ $nums -eq $expected ] || {
7104 $LFS getstripe -R $dir
7105 error "'$cmd' wrong: found $nums, expected $expected"
7109 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7111 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7113 expected=$(((NUMDIRS + 1) * NUMFILES))
7114 cmd="$LFS find -stripe-size 512k -type f $dir"
7115 nums=$($cmd | wc -l)
7116 [ $nums -eq $expected ] ||
7117 error "'$cmd' wrong: found $nums, expected $expected"
7119 cmd="$LFS find -stripe-size +320k -type f $dir"
7120 nums=$($cmd | wc -l)
7121 [ $nums -eq $expected ] ||
7122 error "'$cmd' wrong: found $nums, expected $expected"
7124 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7125 cmd="$LFS find -stripe-size +200k -type f $dir"
7126 nums=$($cmd | wc -l)
7127 [ $nums -eq $expected ] ||
7128 error "'$cmd' wrong: found $nums, expected $expected"
7130 cmd="$LFS find -stripe-size -640k -type f $dir"
7131 nums=$($cmd | wc -l)
7132 [ $nums -eq $expected ] ||
7133 error "'$cmd' wrong: found $nums, expected $expected"
7136 cmd="$LFS find -stripe-size 256k -type f $dir"
7137 nums=$($cmd | wc -l)
7138 [ $nums -eq $expected ] ||
7139 error "'$cmd' wrong: found $nums, expected $expected"
7141 cmd="$LFS find -stripe-size -320k -type f $dir"
7142 nums=$($cmd | wc -l)
7143 [ $nums -eq $expected ] ||
7144 error "'$cmd' wrong: found $nums, expected $expected"
7147 cmd="$LFS find -stripe-size 1024k -type f $dir"
7148 nums=$($cmd | wc -l)
7149 [ $nums -eq $expected ] ||
7150 error "'$cmd' wrong: found $nums, expected $expected"
7152 run_test 56t "check lfs find -stripe-size works"
7154 test_56u() { # LU-611
7155 local dir=$DIR/$tdir
7157 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7159 if [[ $OSTCOUNT -gt 1 ]]; then
7160 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7166 local expected=$(((NUMDIRS + 1) * NUMFILES))
7167 local cmd="$LFS find -stripe-index 0 -type f $dir"
7168 local nums=$($cmd | wc -l)
7170 [ $nums -eq $expected ] ||
7171 error "'$cmd' wrong: found $nums, expected $expected"
7174 cmd="$LFS find -stripe-index 1 -type f $dir"
7175 nums=$($cmd | wc -l)
7176 [ $nums -eq $expected ] ||
7177 error "'$cmd' wrong: found $nums, expected $expected"
7179 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7180 nums=$($cmd | wc -l)
7181 [ $nums -eq $expected ] ||
7182 error "'$cmd' wrong: found $nums, expected $expected"
7185 # This should produce an error and not return any files
7186 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7187 nums=$($cmd 2>/dev/null | wc -l)
7188 [ $nums -eq $expected ] ||
7189 error "'$cmd' wrong: found $nums, expected $expected"
7191 if [[ $OSTCOUNT -gt 1 ]]; then
7192 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7193 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7194 nums=$($cmd | wc -l)
7195 [ $nums -eq $expected ] ||
7196 error "'$cmd' wrong: found $nums, expected $expected"
7199 run_test 56u "check lfs find -stripe-index works"
7203 local dir=$DIR/$tdir
7205 setup_56 $dir $NUMFILES $NUMDIRS
7207 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7208 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7210 for file in $($LFS find -m $UUID $dir); do
7211 file_midx=$($LFS getstripe -m $file)
7212 [ $file_midx -eq $mdt_idx ] ||
7213 error "lfs find -m $UUID != getstripe -m $file_midx"
7216 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7219 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7222 local dir=$DIR/$tdir
7224 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7226 local stripe_size=$($LFS getstripe -S -d $dir) ||
7227 error "$LFS getstripe -S -d $dir failed"
7228 stripe_size=${stripe_size%% *}
7230 local file_size=$((stripe_size * OSTCOUNT))
7231 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7232 local required_space=$((file_num * file_size))
7233 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7235 [[ $free_space -le $((required_space / 1024)) ]] &&
7236 skip_env "need $required_space, have $free_space kbytes"
7239 local dd_count=$((file_size / dd_bs))
7241 # write data into the files
7246 for i in $(seq $NUMFILES); do
7248 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7249 error "write data into $file failed"
7251 for i in $(seq $NUMDIRS); do
7252 for j in $(seq $NUMFILES); do
7253 file=$dir/dir$i/file$j
7254 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7255 error "write data into $file failed"
7259 # $LFS_MIGRATE will fail if hard link migration is unsupported
7260 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
7261 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7262 error "creating links to $dir/dir1/file1 failed"
7267 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
7270 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7273 eval $cmd || error "$cmd failed"
7275 check_stripe_count $dir/file1 $expected
7277 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
7279 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7280 # OST 1 if it is on OST 0. This file is small enough to
7281 # be on only one stripe.
7282 file=$dir/migr_1_ost
7283 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7284 error "write data into $file failed"
7285 local obdidx=$($LFS getstripe -i $file)
7286 local oldmd5=$(md5sum $file)
7289 [[ $obdidx -eq 0 ]] && newobdidx=1
7290 cmd="$LFS migrate -i $newobdidx $file"
7292 eval $cmd || error "$cmd failed"
7294 local realobdix=$($LFS getstripe -i $file)
7295 local newmd5=$(md5sum $file)
7297 [[ $newobdidx -ne $realobdix ]] &&
7298 error "new OST is different (was=$obdidx, "\
7299 "wanted=$newobdidx, got=$realobdix)"
7300 [[ "$oldmd5" != "$newmd5" ]] &&
7301 error "md5sum differ: $oldmd5, $newmd5"
7305 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7307 eval $cmd || error "$cmd failed"
7309 for j in $(seq $NUMFILES); do
7310 check_stripe_count $dir/dir1/file$j $expected
7313 # lfs_migrate works with lfs find
7314 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7315 $LFS_MIGRATE -y -c $expected"
7317 eval $cmd || error "$cmd failed"
7319 for i in $(seq 2 $NUMFILES); do
7320 check_stripe_count $dir/file$i $expected
7322 for i in $(seq 2 $NUMDIRS); do
7323 for j in $(seq $NUMFILES); do
7324 check_stripe_count $dir/dir$i/file$j $expected
7328 run_test 56w "check lfs_migrate -c stripe_count works"
7331 local file1=$DIR/$tdir/file1
7332 local create_pool=false
7333 local initial_pool=$($LFS getstripe -p $DIR)
7337 echo -n "Creating test dir..."
7338 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7341 echo -n "Creating test file..."
7342 touch $file1 || error "cannot create file"
7345 echo -n "Detecting existing pools..."
7346 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7348 if [ ${#pool_list[@]} -gt 0 ]; then
7349 echo "${pool_list[@]}"
7350 for thispool in "${pool_list[@]}"; do
7351 if [[ -z "$initial_pool" ||
7352 "$initial_pool" != "$thispool" ]]; then
7354 echo "Using existing pool '$pool'"
7359 echo "none detected."
7361 if [ -z "$pool" ]; then
7362 pool=${POOL:-testpool}
7363 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7364 echo -n "Creating pool '$pool'..."
7366 pool_add $pool &> /dev/null ||
7367 error "pool_add failed"
7370 echo -n "Adding target to pool..."
7371 pool_add_targets $pool 0 0 1 &> /dev/null ||
7372 error "pool_add_targets failed"
7376 echo -n "Setting pool using -p option..."
7377 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7378 error "migrate failed rc = $?"
7381 echo -n "Verifying test file is in pool after migrating..."
7382 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7383 error "file was not migrated to pool $pool"
7386 echo -n "Removing test file from pool '$pool'..."
7387 # "lfs migrate $file" won't remove the file from the pool
7388 # until some striping information is changed.
7389 $LFS migrate -c 1 $file1 &> /dev/null ||
7390 error "cannot remove from pool"
7391 [ "$($LFS getstripe -p $file1)" ] &&
7392 error "pool still set"
7395 echo -n "Setting pool using --pool option..."
7396 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7397 error "migrate failed rc = $?"
7402 if $create_pool; then
7403 destroy_test_pools 2> /dev/null ||
7404 error "destroy test pools failed"
7407 run_test 56wb "check lfs_migrate pool support"
7410 local file1="$DIR/$tdir/file1"
7417 echo -n "Creating test dir..."
7418 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7419 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7420 error "cannot set stripe by '-S 1M -c 1'"
7423 echo -n "Setting initial stripe for test file..."
7424 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7425 error "cannot set stripe"
7426 cur_ssize=$($LFS getstripe -S "$file1")
7427 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7430 # File currently set to -S 512K -c 1
7432 # Ensure -c and -S options are rejected when -R is set
7433 echo -n "Verifying incompatible options are detected..."
7434 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7435 error "incompatible -c and -R options not detected"
7436 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7437 error "incompatible -S and -R options not detected"
7440 # Ensure unrecognized options are passed through to 'lfs migrate'
7441 echo -n "Verifying -S option is passed through to lfs migrate..."
7442 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7443 error "migration failed"
7444 cur_ssize=$($LFS getstripe -S "$file1")
7445 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7448 # File currently set to -S 1M -c 1
7450 # Ensure long options are supported
7451 echo -n "Verifying long options supported..."
7452 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7453 error "long option without argument not supported"
7454 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7455 error "long option with argument not supported"
7456 cur_ssize=$($LFS getstripe -S "$file1")
7457 [ $cur_ssize -eq 524288 ] ||
7458 error "migrate --stripe-size $cur_ssize != 524288"
7461 # File currently set to -S 512K -c 1
7463 if [ "$OSTCOUNT" -gt 1 ]; then
7464 echo -n "Verifying explicit stripe count can be set..."
7465 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7466 error "migrate failed"
7467 cur_scount=$($LFS getstripe -c "$file1")
7468 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7472 # File currently set to -S 512K -c 1 or -S 512K -c 2
7474 # Ensure parent striping is used if -R is set, and no stripe
7475 # count or size is specified
7476 echo -n "Setting stripe for parent directory..."
7477 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7478 error "cannot set stripe '-S 2M -c 1'"
7481 echo -n "Verifying restripe option uses parent stripe settings..."
7482 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7483 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7484 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7485 error "migrate failed"
7486 cur_ssize=$($LFS getstripe -S "$file1")
7487 [ $cur_ssize -eq $parent_ssize ] ||
7488 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7489 cur_scount=$($LFS getstripe -c "$file1")
7490 [ $cur_scount -eq $parent_scount ] ||
7491 error "migrate -R stripe_count $cur_scount != $parent_scount"
7494 # File currently set to -S 1M -c 1
7496 # Ensure striping is preserved if -R is not set, and no stripe
7497 # count or size is specified
7498 echo -n "Verifying striping size preserved when not specified..."
7499 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7500 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7501 error "cannot set stripe on parent directory"
7502 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7503 error "migrate failed"
7504 cur_ssize=$($LFS getstripe -S "$file1")
7505 [ $cur_ssize -eq $orig_ssize ] ||
7506 error "migrate by default $cur_ssize != $orig_ssize"
7509 # Ensure file name properly detected when final option has no argument
7510 echo -n "Verifying file name properly detected..."
7511 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7512 error "file name interpreted as option argument"
7518 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7521 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7523 local file1=$DIR/$tdir/file1
7525 echo -n "Creating test dir..."
7526 test_mkdir $DIR/$tdir || error "cannot create dir"
7529 echo -n "Creating test file..."
7533 # Ensure 'lfs migrate' will fail by using a non-existent option,
7534 # and make sure rsync is not called to recover
7535 echo -n "Make sure --no-rsync option works..."
7536 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7537 grep -q 'refusing to fall back to rsync' ||
7538 error "rsync was called with --no-rsync set"
7541 # Ensure rsync is called without trying 'lfs migrate' first
7542 echo -n "Make sure --rsync option works..."
7543 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7544 grep -q 'falling back to rsync' &&
7545 error "lfs migrate was called with --rsync set"
7548 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7549 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7550 grep -q 'at the same time' ||
7551 error "--rsync and --no-rsync accepted concurrently"
7557 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7563 test_mkdir $td || error "cannot create $td"
7564 touch $tf || error "cannot touch $tf"
7566 echo -n "Make sure --non-direct|-D works..."
7567 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7568 grep -q "lfs migrate --non-direct" ||
7569 error "--non-direct option cannot work correctly"
7570 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7571 grep -q "lfs migrate -D" ||
7572 error "-D option cannot work correctly"
7575 run_test 56we "check lfs_migrate --non-direct|-D support"
7578 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7579 check_swap_layouts_support
7581 local dir=$DIR/$tdir
7582 local ref1=/etc/passwd
7583 local file1=$dir/file1
7585 test_mkdir $dir || error "creating dir $dir"
7586 $LFS setstripe -c 2 $file1
7588 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7589 stripe=$($LFS getstripe -c $file1)
7590 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7591 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7596 run_test 56x "lfs migration support"
7599 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7600 check_swap_layouts_support
7602 local dir=$DIR/$tdir/$testnum
7606 local ref1=/etc/passwd
7607 local file1=$dir/file1
7609 $LFS setstripe -c 2 $file1
7611 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7613 local stripe=$($LFS getstripe -c $file1)
7615 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7616 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7621 run_test 56xa "lfs migration --block support"
7623 check_migrate_links() {
7625 local file1="$dir/file1"
7629 local total_count=$(($begin + $count - 1))
7630 local symlink_count=10
7633 if [ ! -f "$file1" ]; then
7634 echo -n "creating initial file..."
7635 $LFS setstripe -c 1 -S "512k" "$file1" ||
7636 error "cannot setstripe initial file"
7639 echo -n "creating symlinks..."
7640 for s in $(seq 1 $symlink_count); do
7641 ln -s "$file1" "$dir/slink$s" ||
7642 error "cannot create symlinks"
7646 echo -n "creating nonlinked files..."
7647 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7648 error "cannot create nonlinked files"
7653 if [ ! -f "$dir/file$total_count" ]; then
7654 echo -n "creating hard links $begin:$total_count..."
7655 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7656 /dev/null || error "cannot create hard links"
7660 echo -n "checking number of hard links listed in xattrs..."
7661 local fid=$($LFS getstripe -F "$file1")
7662 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7665 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7666 skip "hard link list has unexpected size, skipping test"
7668 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7669 error "link names should exceed xattrs size"
7672 echo -n "migrating files..."
7673 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7675 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7678 # make sure all links have been properly migrated
7679 echo -n "verifying files..."
7680 fid=$($LFS getstripe -F "$file1") ||
7681 error "cannot get fid for file $file1"
7682 for i in $(seq 2 $total_count); do
7683 local fid2=$($LFS getstripe -F $dir/file$i)
7685 [ "$fid2" == "$fid" ] ||
7686 error "migrated hard link has mismatched FID"
7689 # make sure hard links were properly detected, and migration was
7690 # performed only once for the entire link set; nonlinked files should
7692 local actual=$(grep -c 'done' <<< "$migrate_out")
7693 local expected=$(($uniq_count + 1))
7695 [ "$actual" -eq "$expected" ] ||
7696 error "hard links individually migrated ($actual != $expected)"
7698 # make sure the correct number of hard links are present
7699 local hardlinks=$(stat -c '%h' "$file1")
7701 [ $hardlinks -eq $total_count ] ||
7702 error "num hard links $hardlinks != $total_count"
7709 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7710 skip "Need MDS version at least 2.10.55"
7712 local dir="$DIR/$tdir"
7714 test_mkdir "$dir" || error "cannot create dir $dir"
7716 echo "testing lfs migrate mode when all links fit within xattrs"
7717 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7719 echo "testing rsync mode when all links fit within xattrs"
7720 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7722 echo "testing lfs migrate mode when all links do not fit within xattrs"
7723 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7725 echo "testing rsync mode when all links do not fit within xattrs"
7726 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7728 chown -R $RUNAS_ID $dir
7729 echo "testing non-root lfs migrate mode when not all links are in xattr"
7730 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7735 run_test 56xb "lfs migration hard link support"
7738 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7740 local dir="$DIR/$tdir"
7742 test_mkdir "$dir" || error "cannot create dir $dir"
7744 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7745 echo -n "Setting initial stripe for 20MB test file..."
7746 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7747 error "cannot setstripe 20MB file"
7749 echo -n "Sizing 20MB test file..."
7750 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7752 echo -n "Verifying small file autostripe count is 1..."
7753 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7754 error "cannot migrate 20MB file"
7755 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7756 error "cannot get stripe for $dir/20mb"
7757 [ $stripe_count -eq 1 ] ||
7758 error "unexpected stripe count $stripe_count for 20MB file"
7762 # Test 2: File is small enough to fit within the available space on
7763 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7764 # have at least an additional 1KB for each desired stripe for test 3
7765 echo -n "Setting stripe for 1GB test file..."
7766 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7768 echo -n "Sizing 1GB test file..."
7769 # File size is 1GB + 3KB
7770 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7773 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7774 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7775 if (( avail > 524288 * OSTCOUNT )); then
7776 echo -n "Migrating 1GB file..."
7777 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7778 error "cannot migrate 1GB file"
7780 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7781 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7782 error "cannot getstripe for 1GB file"
7783 [ $stripe_count -eq 2 ] ||
7784 error "unexpected stripe count $stripe_count != 2"
7788 # Test 3: File is too large to fit within the available space on
7789 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7790 if [ $OSTCOUNT -ge 3 ]; then
7791 # The required available space is calculated as
7792 # file size (1GB + 3KB) / OST count (3).
7793 local kb_per_ost=349526
7795 echo -n "Migrating 1GB file with limit..."
7796 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7797 error "cannot migrate 1GB file with limit"
7800 stripe_count=$($LFS getstripe -c "$dir/1gb")
7801 echo -n "Verifying 1GB autostripe count with limited space..."
7802 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7803 error "unexpected stripe count $stripe_count (min 3)"
7810 run_test 56xc "lfs migration autostripe"
7813 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7815 local dir=$DIR/$tdir
7816 local f_mgrt=$dir/$tfile.mgrt
7817 local f_yaml=$dir/$tfile.yaml
7818 local f_copy=$dir/$tfile.copy
7819 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7820 local layout_copy="-c 2 -S 2M -i 1"
7821 local yamlfile=$dir/yamlfile
7822 local layout_before;
7825 test_mkdir "$dir" || error "cannot create dir $dir"
7826 $LFS setstripe $layout_yaml $f_yaml ||
7827 error "cannot setstripe $f_yaml with layout $layout_yaml"
7828 $LFS getstripe --yaml $f_yaml > $yamlfile
7829 $LFS setstripe $layout_copy $f_copy ||
7830 error "cannot setstripe $f_copy with layout $layout_copy"
7832 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7834 # 1. test option --yaml
7835 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7836 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7837 layout_before=$(get_layout_param $f_yaml)
7838 layout_after=$(get_layout_param $f_mgrt)
7839 [ "$layout_after" == "$layout_before" ] ||
7840 error "lfs_migrate --yaml: $layout_after != $layout_before"
7842 # 2. test option --copy
7843 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7844 error "cannot migrate $f_mgrt with --copy $f_copy"
7845 layout_before=$(get_layout_param $f_copy)
7846 layout_after=$(get_layout_param $f_mgrt)
7847 [ "$layout_after" == "$layout_before" ] ||
7848 error "lfs_migrate --copy: $layout_after != $layout_before"
7850 run_test 56xd "check lfs_migrate --yaml and --copy support"
7853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7855 local dir=$DIR/$tdir
7856 local f_comp=$dir/$tfile
7857 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7858 local layout_before=""
7859 local layout_after=""
7861 test_mkdir "$dir" || error "cannot create dir $dir"
7862 $LFS setstripe $layout $f_comp ||
7863 error "cannot setstripe $f_comp with layout $layout"
7864 layout_before=$(get_layout_param $f_comp)
7865 dd if=/dev/zero of=$f_comp bs=1M count=4
7867 # 1. migrate a comp layout file by lfs_migrate
7868 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7869 layout_after=$(get_layout_param $f_comp)
7870 [ "$layout_before" == "$layout_after" ] ||
7871 error "lfs_migrate: $layout_before != $layout_after"
7873 # 2. migrate a comp layout file by lfs migrate
7874 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7875 layout_after=$(get_layout_param $f_comp)
7876 [ "$layout_before" == "$layout_after" ] ||
7877 error "lfs migrate: $layout_before != $layout_after"
7879 run_test 56xe "migrate a composite layout file"
7882 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7884 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7885 skip "Need server version at least 2.13.53"
7887 local dir=$DIR/$tdir
7888 local f_comp=$dir/$tfile
7889 local layout="-E 1M -c1 -E -1 -c2"
7893 test_mkdir "$dir" || error "cannot create dir $dir"
7894 $LFS setstripe $layout $f_comp ||
7895 error "cannot setstripe $f_comp with layout $layout"
7896 fid_before=$($LFS getstripe --fid $f_comp)
7897 dd if=/dev/zero of=$f_comp bs=1M count=4
7899 # 1. migrate a comp layout file to a comp layout
7900 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7901 fid_after=$($LFS getstripe --fid $f_comp)
7902 [ "$fid_before" == "$fid_after" ] ||
7903 error "comp-to-comp migrate: $fid_before != $fid_after"
7905 # 2. migrate a comp layout file to a plain layout
7906 $LFS migrate -c2 $f_comp ||
7907 error "cannot migrate $f_comp by lfs migrate"
7908 fid_after=$($LFS getstripe --fid $f_comp)
7909 [ "$fid_before" == "$fid_after" ] ||
7910 error "comp-to-plain migrate: $fid_before != $fid_after"
7912 # 3. migrate a plain layout file to a comp layout
7913 $LFS migrate $layout $f_comp ||
7914 error "cannot migrate $f_comp by lfs migrate"
7915 fid_after=$($LFS getstripe --fid $f_comp)
7916 [ "$fid_before" == "$fid_after" ] ||
7917 error "plain-to-comp migrate: $fid_before != $fid_after"
7919 run_test 56xf "FID is not lost during migration of a composite layout file"
7921 check_file_ost_range() {
7928 file_range=($($LFS getstripe -y "$file" |
7929 awk '/l_ost_idx:/ { print $NF }'))
7931 if [[ "${#file_range[@]}" = 0 ]]; then
7932 echo "No osts found for $file"
7936 for idx in "${file_range[@]}"; do
7937 [[ " $range " =~ " $idx " ]] ||
7945 local stripe_opt="$1"
7948 local pool_ostidx="$(seq $* | tr '\n' ' ')"
7950 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
7951 error "Fail to migrate $tfile on $pool"
7952 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
7953 error "$tfile is not in pool $pool"
7954 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
7955 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
7959 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7960 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
7961 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
7962 skip "Need MDS version newer than 2.14.52"
7964 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
7965 local -a pool_ranges=("0 0" "1 1" "0 1")
7968 for i in "${!pool_names[@]}"; do
7969 pool_add ${pool_names[$i]} ||
7970 error "pool_add failed (pool: ${pool_names[$i]})"
7971 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
7972 error "pool_add_targets failed (pool: ${pool_names[$i]})"
7975 # init the file to migrate
7976 $LFS setstripe -c1 -i1 $DIR/$tfile ||
7977 error "Unable to create $tfile on OST1"
7978 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
7979 error "Unable to write on $tfile"
7981 echo "1. migrate $tfile on pool ${pool_names[0]}"
7982 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
7984 echo "2. migrate $tfile on pool ${pool_names[2]}"
7985 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
7987 echo "3. migrate $tfile on pool ${pool_names[1]}"
7988 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
7990 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
7991 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
7995 destroy_test_pools ||
7996 error "pool_destroy failed"
7998 run_test 56xg "lfs migrate pool support"
8001 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8002 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8005 local dir=$DIR/$tdir
8009 test_mkdir -p $dir || error "creating dir $dir"
8010 touch $f1 || error "creating std file $f1"
8011 $MULTIOP $f2 H2c || error "creating released file $f2"
8013 # a directory can be raid0, so ask only for files
8014 res=$($LFS find $dir -L raid0 -type f | wc -l)
8015 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8017 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8018 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8020 # only files can be released, so no need to force file search
8021 res=$($LFS find $dir -L released)
8022 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8024 res=$($LFS find $dir -type f \! -L released)
8025 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8027 run_test 56y "lfs find -L raid0|released"
8029 test_56z() { # LU-4824
8030 # This checks to make sure 'lfs find' continues after errors
8031 # There are two classes of errors that should be caught:
8032 # - If multiple paths are provided, all should be searched even if one
8034 # - If errors are encountered during the search, it should not terminate
8036 local dir=$DIR/$tdir
8040 for i in d{0..9}; do
8042 touch $dir/$i/$tfile
8044 $LFS find $DIR/non_existent_dir $dir &&
8045 error "$LFS find did not return an error"
8046 # Make a directory unsearchable. This should NOT be the last entry in
8047 # directory order. Arbitrarily pick the 6th entry
8048 chmod 700 $($LFS find $dir -type d | sed '6!d')
8050 $RUNAS $LFS find $DIR/non_existent $dir
8051 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8053 # The user should be able to see 10 directories and 9 files
8054 (( count == 19 )) ||
8055 error "$LFS find found $count != 19 entries after error"
8057 run_test 56z "lfs find should continue after an error"
8059 test_56aa() { # LU-5937
8060 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8062 local dir=$DIR/$tdir
8065 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8067 createmany -o $dir/striped_dir/${tfile}- 1024
8068 local dirs=$($LFS find --size +8k $dir/)
8070 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8072 run_test 56aa "lfs find --size under striped dir"
8074 test_56ab() { # LU-10705
8075 test_mkdir $DIR/$tdir
8076 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8077 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8078 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8079 # Flush writes to ensure valid blocks. Need to be more thorough for
8080 # ZFS, since blocks are not allocated/returned to client immediately.
8082 wait_zfs_commit ost1 2
8083 cancel_lru_locks osc
8086 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8088 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8090 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8091 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8093 rm -f $DIR/$tdir/$tfile.[123]
8095 run_test 56ab "lfs find --blocks"
8099 local dir="$DIR/$tdir"
8100 local perms=(001 002 003 004 005 006 007
8101 010 020 030 040 050 060 070
8102 100 200 300 400 500 600 700
8103 111 222 333 444 555 666 777)
8104 local perm_minus=(8 8 4 8 4 4 2
8108 local perm_slash=(8 8 12 8 12 12 14
8111 16 16 24 16 24 24 28)
8114 for perm in ${perms[*]}; do
8115 touch "$dir/$tfile.$perm"
8116 chmod $perm "$dir/$tfile.$perm"
8119 for ((i = 0; i < ${#perms[*]}; i++)); do
8120 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8122 error "lfs find -perm ${perms[i]}:"\
8125 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8126 (( $num == ${perm_minus[i]} )) ||
8127 error "lfs find -perm -${perms[i]}:"\
8128 "$num != ${perm_minus[i]}"
8130 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8131 (( $num == ${perm_slash[i]} )) ||
8132 error "lfs find -perm /${perms[i]}:"\
8133 "$num != ${perm_slash[i]}"
8136 run_test 56aca "check lfs find -perm with octal representation"
8139 local dir=$DIR/$tdir
8140 # p is the permission of write and execute for user, group and other
8141 # without the umask. It is used to test +wx.
8142 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8143 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8144 local symbolic=(+t a+t u+t g+t o+t
8150 o=r,ug+o,u+w u=r,a+u,u+w
8151 g=r,ugo=g,u+w u+x,+X +X
8152 u+x,u+X u+X u+x,g+X o+r,+X
8156 for perm in ${perms[*]}; do
8157 touch "$dir/$tfile.$perm"
8158 chmod $perm "$dir/$tfile.$perm"
8161 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8162 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8165 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8168 run_test 56acb "check lfs find -perm with symbolic representation"
8171 local dir=$DIR/$tdir
8172 local tests="17777 787 789 abcd
8173 ug=uu ug=a ug=gu uo=ou urw
8177 for err in $tests; do
8178 if $LFS find $dir -perm $err 2>/dev/null; then
8179 error "lfs find -perm $err: parsing should have failed"
8183 run_test 56acc "check parsing error for lfs find -perm"
8186 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8187 skip "Need MDS version at least 2.10.50"
8189 # Create composite files with one component
8190 local dir=$DIR/$tdir
8192 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8193 # Create composite files with three components
8194 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8195 # Create non-composite files
8196 createmany -o $dir/${tfile}- 10
8198 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8200 [[ $nfiles == 10 ]] ||
8201 error "lfs find -E 1M found $nfiles != 10 files"
8203 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8204 [[ $nfiles == 25 ]] ||
8205 error "lfs find ! -E 1M found $nfiles != 25 files"
8207 # All files have a component that starts at 0
8208 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8209 [[ $nfiles == 35 ]] ||
8210 error "lfs find --component-start 0 - $nfiles != 35 files"
8212 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8213 [[ $nfiles == 15 ]] ||
8214 error "lfs find --component-start 2M - $nfiles != 15 files"
8216 # All files created here have a componenet that does not starts at 2M
8217 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8218 [[ $nfiles == 35 ]] ||
8219 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8221 # Find files with a specified number of components
8222 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8223 [[ $nfiles == 15 ]] ||
8224 error "lfs find --component-count 3 - $nfiles != 15 files"
8226 # Remember non-composite files have a component count of zero
8227 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8228 [[ $nfiles == 10 ]] ||
8229 error "lfs find --component-count 0 - $nfiles != 10 files"
8231 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8232 [[ $nfiles == 20 ]] ||
8233 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8235 # All files have a flag called "init"
8236 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8237 [[ $nfiles == 35 ]] ||
8238 error "lfs find --component-flags init - $nfiles != 35 files"
8240 # Multi-component files will have a component not initialized
8241 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8242 [[ $nfiles == 15 ]] ||
8243 error "lfs find !--component-flags init - $nfiles != 15 files"
8248 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8251 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8252 skip "Need MDS version at least 2.10.57"
8262 # create mirrored directories and mirrored files
8263 mkdir $td || error "mkdir $td failed"
8264 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8265 createmany -o $tf- 10 || error "create $tf- failed"
8267 for i in $(seq 2); do
8269 mkdir $dir || error "mkdir $dir failed"
8270 $LFS mirror create -N$((3 + i)) $dir ||
8271 error "create mirrored dir $dir failed"
8272 createmany -o $dir/$tfile- 10 ||
8273 error "create $dir/$tfile- failed"
8276 # change the states of some mirrored files
8278 for i in $(seq 2); do
8280 for j in $(seq 4 9); do
8281 echo foo > $dir/$tfile-$j
8285 # find mirrored files with specific mirror count
8286 cmd="$LFS find --mirror-count 3 --type f $td"
8287 nfiles=$($cmd | wc -l)
8288 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8290 cmd="$LFS find ! --mirror-count 3 --type f $td"
8291 nfiles=$($cmd | wc -l)
8292 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8294 cmd="$LFS find --mirror-count +2 --type f $td"
8295 nfiles=$($cmd | wc -l)
8296 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8298 cmd="$LFS find --mirror-count -6 --type f $td"
8299 nfiles=$($cmd | wc -l)
8300 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8302 # find mirrored files with specific file state
8303 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8304 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8306 cmd="$LFS find --mirror-state=ro --type f $td"
8307 nfiles=$($cmd | wc -l)
8308 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8310 cmd="$LFS find ! --mirror-state=ro --type f $td"
8311 nfiles=$($cmd | wc -l)
8312 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8314 cmd="$LFS find --mirror-state=wp --type f $td"
8315 nfiles=$($cmd | wc -l)
8316 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8318 cmd="$LFS find ! --mirror-state=sp --type f $td"
8319 nfiles=$($cmd | wc -l)
8320 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8322 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8324 test_56da() { # LU-14179
8325 local path=$DIR/$tdir
8330 local longdir=$(str_repeat 'a' 255)
8332 for i in {1..15}; do
8339 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8344 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8347 touch $(str_repeat 'f' 255)
8349 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8350 error "lfs find reported an error"
8354 run_test 56da "test lfs find with long paths"
8356 test_56ea() { #LU-10378
8357 local path=$DIR/$tdir
8358 local pool=$TESTNAME
8361 pool_add $pool || error "pool_add $pool failed"
8362 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8363 error "adding targets to $pool failed"
8365 # Set default pool on directory before creating file
8366 mkdir $path || error "mkdir $path failed"
8367 $LFS setstripe -p $pool $path ||
8368 error "set OST pool on $pool failed"
8369 touch $path/$tfile || error "touch $path/$tfile failed"
8371 # Compare basic file attributes from -printf and stat
8372 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8373 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8375 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8376 error "Attrs from lfs find and stat don't match"
8378 # Compare Lustre attributes from lfs find and lfs getstripe
8379 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8380 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8381 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8382 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8383 local fpool=$($LFS getstripe --pool $path/$tfile)
8384 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8386 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8387 error "Attrs from lfs find and lfs getstripe don't match"
8389 # Verify behavior for unknown escape/format sequences
8390 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8392 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8393 error "Escape/format codes don't match"
8395 run_test 56ea "test lfs find -printf option"
8398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8399 # note test will not do anything if MDS is not local
8400 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8401 skip_env "ldiskfs only test"
8403 remote_mds_nodsh && skip "remote MDS with nodsh"
8405 local MNTDEV="osd*.*MDT*.mntdev"
8406 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8407 [ -z "$DEV" ] && error "can't access $MNTDEV"
8408 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8409 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8410 error "can't access $DEV"
8411 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8412 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8416 run_test 57a "verify MDS filesystem created with large inodes =="
8419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8420 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8421 skip_env "ldiskfs only test"
8423 remote_mds_nodsh && skip "remote MDS with nodsh"
8425 local dir=$DIR/$tdir
8428 local fileN=$dir/f$filecount
8430 rm -rf $dir || error "removing $dir"
8432 local mdtidx=$($LFS getstripe -m $dir)
8433 local mdtname=MDT$(printf %04x $mdtidx)
8434 local facet=mds$((mdtidx + 1))
8436 echo "mcreating $filecount files"
8437 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8439 # verify that files do not have EAs yet
8440 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8441 error "$file1 has an EA"
8442 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8443 error "$fileN has an EA"
8447 df $dir #make sure we get new statfs data
8448 local mdsfree=$(do_facet $facet \
8449 lctl get_param -n osd*.*$mdtname.kbytesfree)
8450 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8453 echo "opening files to create objects/EAs"
8454 for file in $(seq -f $dir/f%g 1 $filecount); do
8455 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8456 error "opening $file"
8459 # verify that files have EAs now
8460 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8461 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8463 sleep 1 #make sure we get new statfs data
8465 local mdsfree2=$(do_facet $facet \
8466 lctl get_param -n osd*.*$mdtname.kbytesfree)
8467 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8469 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8470 if [ "$mdsfree" != "$mdsfree2" ]; then
8471 error "MDC before $mdcfree != after $mdcfree2"
8473 echo "MDC before $mdcfree != after $mdcfree2"
8474 echo "unable to confirm if MDS has large inodes"
8479 run_test 57b "default LOV EAs are stored inside large inodes ==="
8482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8483 [ -z "$(which wiretest 2>/dev/null)" ] &&
8484 skip_env "could not find wiretest"
8488 run_test 58 "verify cross-platform wire constants =============="
8491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8493 echo "touch 130 files"
8494 createmany -o $DIR/f59- 130
8496 unlinkmany $DIR/f59- 130
8498 # wait for commitment of removal
8499 wait_delete_completed
8501 run_test 59 "verify cancellation of llog records async ========="
8503 TEST60_HEAD="test_60 run $RANDOM"
8505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8506 remote_mgs_nodsh && skip "remote MGS with nodsh"
8507 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8508 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8509 skip_env "missing subtest run-llog.sh"
8511 log "$TEST60_HEAD - from kernel mode"
8512 do_facet mgs "$LCTL dk > /dev/null"
8513 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8514 do_facet mgs $LCTL dk > $TMP/$tfile
8516 # LU-6388: test llog_reader
8517 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8518 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8519 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8520 skip_env "missing llog_reader"
8521 local fstype=$(facet_fstype mgs)
8522 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8523 skip_env "Only for ldiskfs or zfs type mgs"
8525 local mntpt=$(facet_mntpt mgs)
8526 local mgsdev=$(mgsdevname 1)
8538 #get fid and record list
8539 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8541 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8543 #remount mgs as ldiskfs or zfs type
8544 stop mgs || error "stop mgs failed"
8545 mount_fstype mgs || error "remount mgs failed"
8546 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8549 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8550 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8555 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8557 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8559 echo "obj_file is $obj_file"
8560 do_facet mgs $llog_reader $obj_file
8562 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8563 awk '{ print $3 }' | sed -e "s/^type=//g")
8564 if [ $rec_type != $rec ]; then
8565 echo "FAILED test_60a wrong record type $rec_type," \
8571 #check obj path if record type is LLOG_LOGID_MAGIC
8572 if [ "$rec" == "1064553b" ]; then
8573 path=$(do_facet mgs $llog_reader $obj_file |
8574 grep "path=" | awk '{ print $NF }' |
8575 sed -e "s/^path=//g")
8576 if [ $obj_file != $mntpt/$path ]; then
8577 echo "FAILED test_60a wrong obj path" \
8578 "$montpt/$path, should be $obj_file"
8585 #restart mgs before "error", otherwise it will block the next test
8586 stop mgs || error "stop mgs failed"
8587 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8588 $pass || error "test failed, see FAILED test_60a messages for specifics"
8590 run_test 60a "llog_test run from kernel module and test llog_reader"
8592 test_60b() { # bug 6411
8593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8596 LLOG_COUNT=$(do_facet mgs dmesg |
8597 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8598 /llog_[a-z]*.c:[0-9]/ {
8610 [[ $LLOG_COUNT -gt 120 ]] &&
8611 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8613 run_test 60b "limit repeated messages from CERROR/CWARN"
8616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8618 echo "create 5000 files"
8619 createmany -o $DIR/f60c- 5000
8620 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8621 lctl set_param fail_loc=0x80000137
8622 unlinkmany $DIR/f60c- 5000
8623 lctl set_param fail_loc=0
8625 run_test 60c "unlink file when mds full"
8628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8630 SAVEPRINTK=$(lctl get_param -n printk)
8631 # verify "lctl mark" is even working"
8632 MESSAGE="test message ID $RANDOM $$"
8633 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8634 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8636 lctl set_param printk=0 || error "set lnet.printk failed"
8637 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8638 MESSAGE="new test message ID $RANDOM $$"
8639 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8640 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8641 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8643 lctl set_param -n printk="$SAVEPRINTK"
8645 run_test 60d "test printk console message masking"
8648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8649 remote_mds_nodsh && skip "remote MDS with nodsh"
8652 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8653 do_facet mds1 lctl set_param fail_loc=0x15b
8656 run_test 60e "no space while new llog is being created"
8659 local old_path=$($LCTL get_param -n debug_path)
8661 stack_trap "$LCTL set_param debug_path=$old_path"
8662 stack_trap "rm -f $TMP/$tfile*"
8663 rm -f $TMP/$tfile* 2> /dev/null
8664 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8665 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8666 test_mkdir $DIR/$tdir
8667 # retry in case the open is cached and not released
8668 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8669 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8673 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8675 run_test 60f "change debug_path works"
8681 test_mkdir -c $MDSCOUNT $DIR/$tdir
8686 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8687 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8689 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8690 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8691 index=$((index + 1))
8697 for i in {0..100}; do
8698 # define OBD_FAIL_OSD_TXN_START 0x19a
8699 local index=$((i % MDSCOUNT + 1))
8701 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8708 for i in $(seq $MDSCOUNT); do
8709 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8712 mkdir $DIR/$tdir/new || error "mkdir failed"
8713 rmdir $DIR/$tdir/new || error "rmdir failed"
8715 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8717 for i in $(seq $MDSCOUNT); do
8718 wait_update_facet mds$i "$LCTL get_param -n \
8719 mdd.$(facet_svc mds$i).lfsck_namespace |
8720 awk '/^status/ { print \\\$2 }'" "completed"
8724 rm -rf $DIR/$tdir || error "rmdir failed"
8726 run_test 60g "transaction abort won't cause MDT hung"
8729 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8730 skip "Need MDS version at least 2.12.52"
8731 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8735 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8736 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8737 for fail_loc in 0x80000188 0x80000189; do
8738 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8739 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8740 error "mkdir $dir-$fail_loc failed"
8741 for i in {0..10}; do
8742 # create may fail on missing stripe
8743 echo $i > $DIR/$tdir-$fail_loc/$i
8745 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8746 error "getdirstripe $tdir-$fail_loc failed"
8747 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8748 error "migrate $tdir-$fail_loc failed"
8749 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8750 error "getdirstripe $tdir-$fail_loc failed"
8751 pushd $DIR/$tdir-$fail_loc
8753 echo $f | cmp $f - || error "$f data mismatch"
8756 rm -rf $DIR/$tdir-$fail_loc
8759 run_test 60h "striped directory with missing stripes can be accessed"
8761 function t60i_load() {
8763 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8764 $LCTL set_param fail_loc=0x131c fail_val=1
8765 for ((i=0; i<5000; i++)); do
8766 touch $DIR/$tdir/f$i
8771 changelog_register || error "changelog_register failed"
8772 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8773 changelog_users $SINGLEMDS | grep -q $cl_user ||
8774 error "User $cl_user not found in changelog_users"
8775 changelog_chmask "ALL"
8778 for((i=0; i<100; i++)); do
8779 changelog_dump >/dev/null ||
8780 error "can't read changelog"
8784 changelog_deregister || error "changelog_deregister failed"
8785 $LCTL set_param fail_loc=0
8787 run_test 60i "llog: new record vs reader race"
8790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8793 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8794 cancel_lru_locks osc
8795 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8798 run_test 61a "mmap() writes don't make sync hang ================"
8801 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8803 run_test 61b "mmap() of unstriped file is successful"
8805 # bug 2330 - insufficient obd_match error checking causes LBUG
8807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8811 cancel_lru_locks osc
8812 lctl set_param fail_loc=0x405
8813 cat $f && error "cat succeeded, expect -EIO"
8814 lctl set_param fail_loc=0
8816 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8817 # match every page all of the time.
8818 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8820 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8821 # Though this test is irrelevant anymore, it helped to reveal some
8822 # other grant bugs (LU-4482), let's keep it.
8823 test_63a() { # was test_63
8824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8826 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8828 for i in `seq 10` ; do
8829 dd if=/dev/zero of=$DIR/f63 bs=8k &
8835 rm -f $DIR/f63 || true
8837 run_test 63a "Verify oig_wait interruption does not crash ======="
8839 # bug 2248 - async write errors didn't return to application on sync
8840 # bug 3677 - async write errors left page locked
8842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8845 lctl set_param debug=-1
8847 # ensure we have a grant to do async writes
8848 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8851 sync # sync lest earlier test intercept the fail_loc
8853 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8854 lctl set_param fail_loc=0x80000406
8855 $MULTIOP $DIR/$tfile Owy && \
8856 error "sync didn't return ENOMEM"
8857 sync; sleep 2; sync # do a real sync this time to flush page
8858 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8859 error "locked page left in cache after async error" || true
8862 run_test 63b "async write errors should be returned to fsync ==="
8865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8868 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8870 run_test 64a "verify filter grant calculations (in kernel) ====="
8873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8875 bash oos.sh $MOUNT || error "oos.sh failed: $?"
8877 run_test 64b "check out-of-space detection on client"
8880 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8882 run_test 64c "verify grant shrink"
8888 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8891 # this does exactly what osc_request.c:osc_announce_cached() does in
8892 # order to calculate max amount of grants to ask from server
8896 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8897 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8899 ((rpc_in_flight++));
8900 nrpages=$((nrpages * rpc_in_flight))
8902 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8904 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8906 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8907 local undirty=$((nrpages * PAGE_SIZE))
8909 local max_extent_pages
8910 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8911 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8912 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8913 local grant_extent_tax
8914 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8916 undirty=$((undirty + nrextents * grant_extent_tax))
8921 # this is size of unit for grant allocation. It should be equal to
8922 # what tgt_grant.c:tgt_grant_chunk() calculates
8926 local grant_extent_tax
8928 max_brw_size=$(import_param $tgt max_brw_size)
8930 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8932 echo $(((max_brw_size + grant_extent_tax) * 2))
8936 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8937 skip "OST < 2.10.55 doesn't limit grants enough"
8939 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8941 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8942 skip "no grant_param connect flag"
8944 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8946 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8947 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8950 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8951 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8953 $LFS setstripe $DIR/$tfile -i 0 -c 1
8954 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8957 while kill -0 $ddpid; do
8958 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8960 if [[ $cur_grant -gt $max_cur_granted ]]; then
8962 error "cur_grant $cur_grant > $max_cur_granted"
8968 run_test 64d "check grant limit exceed"
8974 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8976 ((cur_grants == expected)) ||
8977 error "$msg: grants mismatch: $cur_grants, expected $expected"
8981 echo $((($1 + $2 - 1) & ~($2 - 1)))
8985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8986 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8987 skip "Need OSS version at least 2.11.56"
8989 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8990 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8991 $LCTL set_param debug=+cache
8993 # Remount client to reset grant
8994 remount_client $MOUNT || error "failed to remount client"
8995 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8997 local init_grants=$(import_param $osc_tgt initial_grant)
8999 check_grants $osc_tgt $init_grants "init grants"
9001 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9002 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9003 local gbs=$(import_param $osc_tgt grant_block_size)
9005 # write random number of bytes from max_brw_size / 4 to max_brw_size
9006 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9007 # align for direct io
9008 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9009 # round to grant consumption unit
9010 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9012 local grants=$((wb_round_up + extent_tax))
9014 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9016 # define OBD_FAIL_TGT_NO_GRANT 0x725
9017 # make the server not grant more back
9018 do_facet ost1 $LCTL set_param fail_loc=0x725
9019 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9021 do_facet ost1 $LCTL set_param fail_loc=0
9023 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9025 rm -f $DIR/$tfile || error "rm failed"
9027 # Remount client to reset grant
9028 remount_client $MOUNT || error "failed to remount client"
9029 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9031 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9033 # define OBD_FAIL_TGT_NO_GRANT 0x725
9034 # make the server not grant more back
9035 do_facet ost1 $LCTL set_param fail_loc=0x725
9036 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9037 do_facet ost1 $LCTL set_param fail_loc=0
9039 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9041 run_test 64e "check grant consumption (no grant allocation)"
9044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9046 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9047 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9048 $LCTL set_param debug=+cache
9050 # Remount client to reset grant
9051 remount_client $MOUNT || error "failed to remount client"
9052 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9054 local init_grants=$(import_param $osc_tgt initial_grant)
9055 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9056 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9057 local gbs=$(import_param $osc_tgt grant_block_size)
9058 local chunk=$(grant_chunk $osc_tgt)
9060 # write random number of bytes from max_brw_size / 4 to max_brw_size
9061 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9062 # align for direct io
9063 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9064 # round to grant consumption unit
9065 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9067 local grants=$((wb_round_up + extent_tax))
9069 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9070 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9071 error "error writing to $DIR/$tfile"
9073 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9074 "direct io with grant allocation"
9076 rm -f $DIR/$tfile || error "rm failed"
9078 # Remount client to reset grant
9079 remount_client $MOUNT || error "failed to remount client"
9080 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9082 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9084 local cmd="oO_WRONLY:w${write_bytes}_yc"
9086 $MULTIOP $DIR/$tfile $cmd &
9090 check_grants $osc_tgt $((init_grants - grants)) \
9091 "buffered io, not write rpc"
9093 kill -USR1 $MULTIPID
9096 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9097 "buffered io, one RPC"
9099 run_test 64f "check grant consumption (with grant allocation)"
9102 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9103 skip "Need MDS version at least 2.14.56"
9105 local mdts=$(comma_list $(mdts_nodes))
9107 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9109 stack_trap "$LCTL set_param $old"
9111 # generate dirty pages and increase dirty granted on MDT
9112 stack_trap "rm -f $DIR/$tfile-*"
9113 for (( i = 0; i < 10; i++)); do
9114 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9115 error "can't set stripe"
9116 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9118 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9119 $LFS getstripe $DIR/$tfile-$i
9120 error "not DoM file"
9127 # wait until grant shrink reset grant dirty on MDTs
9128 for ((i = 0; i < 120; i++)); do
9129 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9130 awk '{sum=sum+$1} END {print sum}')
9131 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9132 echo "$grant_dirty grants, $vm_dirty pages"
9133 (( grant_dirty + vm_dirty == 0 )) && break
9134 (( i == 3 )) && sync &&
9135 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9139 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9140 awk '{sum=sum+$1} END {print sum}')
9141 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9143 run_test 64g "grant shrink on MDT"
9146 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9147 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9149 local instance=$($LFS getname -i $DIR)
9150 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9151 local num_exps=$(do_facet ost1 \
9152 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9153 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9154 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9155 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9157 # 10MiB is for file to be written, max_brw_size * 16 *
9158 # num_exps is space reserve so that tgt_grant_shrink() decided
9160 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9161 (( avail * 1024 < expect )) &&
9162 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9164 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9165 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9166 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9167 $LCTL set_param osc.*OST0000*.grant_shrink=1
9168 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9170 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9171 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9173 # drop cache so that coming read would do rpc
9174 cancel_lru_locks osc
9176 # shrink interval is set to 10, pause for 7 seconds so that
9177 # grant thread did not wake up yet but coming read entered
9178 # shrink mode for rpc (osc_should_shrink_grant())
9181 declare -a cur_grant_bytes
9182 declare -a tot_granted
9183 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9184 tot_granted[0]=$(do_facet ost1 \
9185 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9187 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9189 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9190 tot_granted[1]=$(do_facet ost1 \
9191 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9193 # grant change should be equal on both sides
9194 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9195 tot_granted[0] - tot_granted[1])) ||
9196 error "grant change mismatch, " \
9197 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9198 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9200 run_test 64h "grant shrink on read"
9203 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9204 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9206 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9207 remote_ost_nodsh && skip "remote OSTs with nodsh"
9209 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9213 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9214 local instance=$($LFS getname -i $DIR)
9216 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9217 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9219 # shrink grants and simulate rpc loss
9220 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9221 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9222 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9226 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9228 local testid=$(echo $TESTNAME | tr '_' ' ')
9230 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9231 grep "GRANT, real grant" &&
9232 error "client has more grants then it owns" || true
9234 run_test 64i "shrink on reconnect"
9236 # bug 1414 - set/get directories' stripe info
9238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9240 test_mkdir $DIR/$tdir
9242 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9244 run_test 65a "directory with no stripe info"
9247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9249 test_mkdir $DIR/$tdir
9250 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9252 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9255 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9257 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9261 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9263 test_mkdir $DIR/$tdir
9264 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9266 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9267 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9269 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9271 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9276 test_mkdir $DIR/$tdir
9277 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9278 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9280 if [[ $STRIPECOUNT -le 0 ]]; then
9282 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9283 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9284 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9286 sc=$(($STRIPECOUNT - 1))
9288 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9289 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9290 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9291 error "lverify failed"
9293 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9296 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9298 test_mkdir $DIR/$tdir
9300 $LFS setstripe $DIR/$tdir || error "setstripe"
9301 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9302 error "no stripe info failed"
9304 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9306 run_test 65e "directory setstripe defaults"
9309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9311 test_mkdir $DIR/${tdir}f
9312 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9313 error "setstripe succeeded" || true
9315 run_test 65f "dir setstripe permission (should return error) ==="
9318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9320 test_mkdir $DIR/$tdir
9321 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9323 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9324 error "setstripe -S failed"
9325 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9326 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9327 error "delete default stripe failed"
9329 run_test 65g "directory setstripe -d"
9332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9334 test_mkdir $DIR/$tdir
9335 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9337 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9338 error "setstripe -S failed"
9339 test_mkdir $DIR/$tdir/dd1
9340 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9341 error "stripe info inherit failed"
9343 run_test 65h "directory stripe info inherit ===================="
9346 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9348 save_layout_restore_at_exit $MOUNT
9350 # bug6367: set non-default striping on root directory
9351 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9353 # bug12836: getstripe on -1 default directory striping
9354 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9356 # bug12836: getstripe -v on -1 default directory striping
9357 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9359 # bug12836: new find on -1 default directory striping
9360 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9362 run_test 65i "various tests to set root directory striping"
9364 test_65j() { # bug6367
9365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9369 # if we aren't already remounting for each test, do so for this test
9370 if [ "$I_MOUNTED" = "yes" ]; then
9371 cleanup || error "failed to unmount"
9375 save_layout_restore_at_exit $MOUNT
9377 $LFS setstripe -d $MOUNT || error "setstripe failed"
9379 run_test 65j "set default striping on root directory (bug 6367)="
9383 wait_delete_completed
9384 do_facet $SINGLEMDS "lctl set_param -n \
9385 osp.$ost*MDT0000.max_create_count=$max_count"
9386 do_facet $SINGLEMDS "lctl set_param -n \
9387 osp.$ost*MDT0000.create_count=$count"
9388 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9389 echo $INACTIVE_OSC "is Activate"
9391 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9394 test_65k() { # bug11679
9395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9396 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9397 remote_mds_nodsh && skip "remote MDS with nodsh"
9399 local disable_precreate=true
9400 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9401 disable_precreate=false
9403 echo "Check OST status: "
9404 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9405 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9407 for OSC in $MDS_OSCS; do
9408 echo $OSC "is active"
9409 do_facet $SINGLEMDS lctl --device %$OSC activate
9412 for INACTIVE_OSC in $MDS_OSCS; do
9413 local ost=$(osc_to_ost $INACTIVE_OSC)
9414 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9415 lov.*md*.target_obd |
9416 awk -F: /$ost/'{ print $1 }' | head -n 1)
9419 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9420 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9422 echo "Deactivate: " $INACTIVE_OSC
9423 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9425 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9426 osp.$ost*MDT0000.create_count")
9427 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9428 osp.$ost*MDT0000.max_create_count")
9429 $disable_precreate &&
9430 do_facet $SINGLEMDS "lctl set_param -n \
9431 osp.$ost*MDT0000.max_create_count=0"
9433 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9434 [ -f $DIR/$tdir/$idx ] && continue
9435 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9436 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9438 error "setstripe $idx should succeed"; }
9439 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9441 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9444 do_facet $SINGLEMDS "lctl set_param -n \
9445 osp.$ost*MDT0000.max_create_count=$max_count"
9446 do_facet $SINGLEMDS "lctl set_param -n \
9447 osp.$ost*MDT0000.create_count=$count"
9448 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9449 echo $INACTIVE_OSC "is Activate"
9451 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9454 run_test 65k "validate manual striping works properly with deactivated OSCs"
9456 test_65l() { # bug 12836
9457 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9459 test_mkdir -p $DIR/$tdir/test_dir
9460 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9461 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9463 run_test 65l "lfs find on -1 stripe dir ========================"
9466 local layout=$(save_layout $MOUNT)
9467 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9468 restore_layout $MOUNT $layout
9469 error "setstripe should fail by non-root users"
9473 run_test 65m "normal user can't set filesystem default stripe"
9476 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9477 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9478 skip "Need MDS version at least 2.12.50"
9479 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9481 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9482 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9483 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9485 save_layout_restore_at_exit $MOUNT
9487 # new subdirectory under root directory should not inherit
9488 # the default layout from root
9489 local dir1=$MOUNT/$tdir-1
9490 mkdir $dir1 || error "mkdir $dir1 failed"
9491 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9492 error "$dir1 shouldn't have LOV EA"
9494 # delete the default layout on root directory
9495 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9497 local dir2=$MOUNT/$tdir-2
9498 mkdir $dir2 || error "mkdir $dir2 failed"
9499 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9500 error "$dir2 shouldn't have LOV EA"
9502 # set a new striping pattern on root directory
9503 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9504 local new_def_stripe_size=$((def_stripe_size * 2))
9505 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9506 error "set stripe size on $MOUNT failed"
9508 # new file created in $dir2 should inherit the new stripe size from
9509 # the filesystem default
9510 local file2=$dir2/$tfile-2
9511 touch $file2 || error "touch $file2 failed"
9513 local file2_stripe_size=$($LFS getstripe -S $file2)
9514 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9516 echo "file2_stripe_size: '$file2_stripe_size'"
9517 echo "new_def_stripe_size: '$new_def_stripe_size'"
9518 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9521 local dir3=$MOUNT/$tdir-3
9522 mkdir $dir3 || error "mkdir $dir3 failed"
9523 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9524 # the root layout, which is the actual default layout that will be used
9525 # when new files are created in $dir3.
9526 local dir3_layout=$(get_layout_param $dir3)
9527 local root_dir_layout=$(get_layout_param $MOUNT)
9528 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9530 echo "dir3_layout: '$dir3_layout'"
9531 echo "root_dir_layout: '$root_dir_layout'"
9532 error "$dir3 should show the default layout from $MOUNT"
9535 # set OST pool on root directory
9536 local pool=$TESTNAME
9537 pool_add $pool || error "add $pool failed"
9538 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9539 error "add targets to $pool failed"
9541 $LFS setstripe -p $pool $MOUNT ||
9542 error "set OST pool on $MOUNT failed"
9544 # new file created in $dir3 should inherit the pool from
9545 # the filesystem default
9546 local file3=$dir3/$tfile-3
9547 touch $file3 || error "touch $file3 failed"
9549 local file3_pool=$($LFS getstripe -p $file3)
9550 [[ "$file3_pool" = "$pool" ]] ||
9551 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9553 local dir4=$MOUNT/$tdir-4
9554 mkdir $dir4 || error "mkdir $dir4 failed"
9555 local dir4_layout=$(get_layout_param $dir4)
9556 root_dir_layout=$(get_layout_param $MOUNT)
9557 echo "$LFS getstripe -d $dir4"
9558 $LFS getstripe -d $dir4
9559 echo "$LFS getstripe -d $MOUNT"
9560 $LFS getstripe -d $MOUNT
9561 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9563 echo "dir4_layout: '$dir4_layout'"
9564 echo "root_dir_layout: '$root_dir_layout'"
9565 error "$dir4 should show the default layout from $MOUNT"
9568 # new file created in $dir4 should inherit the pool from
9569 # the filesystem default
9570 local file4=$dir4/$tfile-4
9571 touch $file4 || error "touch $file4 failed"
9573 local file4_pool=$($LFS getstripe -p $file4)
9574 [[ "$file4_pool" = "$pool" ]] ||
9575 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9577 # new subdirectory under non-root directory should inherit
9578 # the default layout from its parent directory
9579 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9580 error "set directory layout on $dir4 failed"
9582 local dir5=$dir4/$tdir-5
9583 mkdir $dir5 || error "mkdir $dir5 failed"
9585 dir4_layout=$(get_layout_param $dir4)
9586 local dir5_layout=$(get_layout_param $dir5)
9587 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9589 echo "dir4_layout: '$dir4_layout'"
9590 echo "dir5_layout: '$dir5_layout'"
9591 error "$dir5 should inherit the default layout from $dir4"
9594 # though subdir under ROOT doesn't inherit default layout, but
9595 # its sub dir/file should be created with default layout.
9596 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9597 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9598 skip "Need MDS version at least 2.12.59"
9600 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9601 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9602 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9604 if [ $default_lmv_hash == "none" ]; then
9605 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9607 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9608 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9611 $LFS setdirstripe -D -c 2 $MOUNT ||
9612 error "setdirstripe -D -c 2 failed"
9613 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9614 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9615 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9617 # $dir4 layout includes pool
9618 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9619 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9620 error "pool lost on setstripe"
9621 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9622 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9623 error "pool lost on compound layout setstripe"
9625 run_test 65n "don't inherit default layout from root for new subdirectories"
9628 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
9629 skip "need MDS version at least 2.14.57"
9631 # set OST pool on root directory
9632 local pool=$TESTNAME
9634 pool_add $pool || error "add $pool failed"
9635 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9636 error "add targets to $pool failed"
9638 local dir1=$MOUNT/$tdir
9640 mkdir $dir1 || error "mkdir $dir1 failed"
9642 # set a new striping pattern on root directory
9643 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9645 $LFS setstripe -p $pool $dir1 ||
9646 error "set directory layout on $dir1 failed"
9648 # $dir1 layout includes pool
9649 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
9650 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9651 error "pool lost on setstripe"
9652 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
9653 $LFS getstripe $dir1
9654 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9655 error "pool lost on compound layout setstripe"
9657 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
9658 error "setdirstripe failed on sub-dir with inherited pool"
9659 $LFS getstripe $dir1/dir2
9660 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
9661 error "pool lost on compound layout setdirstripe"
9663 $LFS setstripe -E -1 -c 1 $dir1
9664 $LFS getstripe -d $dir1
9665 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
9666 error "pool lost on setstripe"
9668 run_test 65o "pool inheritance for mdt component"
9670 test_65p () { # LU-16152
9671 local src_dir=$DIR/$tdir/src_dir
9672 local dst_dir=$DIR/$tdir/dst_dir
9673 local yaml_file=$DIR/$tdir/layout.yaml
9676 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
9677 skip "Need at least version 2.15.51"
9679 test_mkdir -p $src_dir
9680 $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
9681 error "failed to setstripe"
9682 $LFS getstripe --yaml -d $src_dir > $yaml_file ||
9683 error "failed to getstripe"
9685 test_mkdir -p $dst_dir
9686 $LFS setstripe --yaml $yaml_file $dst_dir ||
9687 error "failed to setstripe with yaml file"
9688 border=$($LFS getstripe -d $dst_dir |
9689 awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
9690 error "failed to getstripe"
9692 # 2048M is 0x80000000, or 2147483648
9693 (( $border == 2147483648 )) ||
9694 error "failed to handle huge number in yaml layout"
9696 run_test 65p "setstripe with yaml file and huge number"
9698 # bug 2543 - update blocks count on client
9700 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9702 local COUNT=${COUNT:-8}
9703 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9704 sync; sync_all_data; sync; sync_all_data
9705 cancel_lru_locks osc
9706 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
9707 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9709 run_test 66 "update inode blocks count on client ==============="
9712 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9716 swapon -s | awk '($1 == "'$1'") { print $4 }'
9719 # bug5265, obdfilter oa2dentry return -ENOENT
9720 # #define OBD_FAIL_SRV_ENOENT 0x217
9722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9723 remote_ost_nodsh && skip "remote OST with nodsh"
9726 $LFS setstripe -c 1 -i 0 $f
9728 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9730 do_facet ost1 lctl set_param fail_loc=0x217
9731 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9732 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9734 do_facet ost1 lctl set_param fail_loc=0
9735 $DIRECTIO write $f 0 2 || error "write error"
9737 cancel_lru_locks osc
9738 $DIRECTIO read $f 0 1 || error "read error"
9740 do_facet ost1 lctl set_param fail_loc=0x217
9741 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9743 do_facet ost1 lctl set_param fail_loc=0
9746 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9749 test_mkdir $DIR/$tdir
9750 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9751 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9753 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9755 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9757 [ "$RUNAS_ID" = "$UID" ] &&
9758 skip_env "RUNAS_ID = UID = $UID -- skipping"
9759 # Check that testing environment is properly set up. Skip if not
9760 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9761 skip_env "User $RUNAS_ID does not exist - skipping"
9764 chmod 777 $DIR/$tfile
9765 chmod ug+s $DIR/$tfile
9766 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9767 error "$RUNAS dd $DIR/$tfile failed"
9768 # See if we are still setuid/sgid
9769 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9770 error "S/gid is not dropped on write"
9771 # Now test that MDS is updated too
9772 cancel_lru_locks mdc
9773 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9774 error "S/gid is not dropped on MDS"
9777 run_test 72a "Test that remove suid works properly (bug5695) ===="
9779 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9782 [ "$RUNAS_ID" = "$UID" ] &&
9783 skip_env "RUNAS_ID = UID = $UID -- skipping"
9784 [ "$RUNAS_ID" -eq 0 ] &&
9785 skip_env "RUNAS_ID = 0 -- skipping"
9786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9787 # Check that testing environment is properly set up. Skip if not
9788 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9789 skip_env "User $RUNAS_ID does not exist - skipping"
9791 touch $DIR/${tfile}-f{g,u}
9792 test_mkdir $DIR/${tfile}-dg
9793 test_mkdir $DIR/${tfile}-du
9794 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9795 chmod g+s $DIR/${tfile}-{f,d}g
9796 chmod u+s $DIR/${tfile}-{f,d}u
9797 for perm in 777 2777 4777; do
9798 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9799 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9800 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9801 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9805 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9807 # bug 3462 - multiple simultaneous MDC requests
9809 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9811 test_mkdir $DIR/d73-1
9812 test_mkdir $DIR/d73-2
9813 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9816 lctl set_param fail_loc=0x80000129
9817 $MULTIOP $DIR/d73-1/f73-2 Oc &
9819 lctl set_param fail_loc=0
9821 $MULTIOP $DIR/d73-2/f73-3 Oc &
9825 wait $pid1 || return 1
9829 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9830 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9831 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9835 run_test 73 "multiple MDC requests (should not deadlock)"
9837 test_74a() { # bug 6149, 6184
9838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9841 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9843 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9844 # will spin in a tight reconnection loop
9845 $LCTL set_param fail_loc=0x8000030e
9846 # get any lock that won't be difficult - lookup works.
9848 $LCTL set_param fail_loc=0
9852 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9854 test_74b() { # bug 13310
9855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9857 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9859 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9860 # will spin in a tight reconnection loop
9861 $LCTL set_param fail_loc=0x8000030e
9862 # get a "difficult" lock
9864 $LCTL set_param fail_loc=0
9868 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9873 #define OBD_FAIL_LDLM_NEW_LOCK
9874 $LCTL set_param fail_loc=0x319
9875 touch $DIR/$tfile && error "touch successful"
9876 $LCTL set_param fail_loc=0
9879 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9881 slab_lic=/sys/kernel/slab/lustre_inode_cache
9883 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9884 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9885 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9888 test_76a() { # Now for b=20433, added originally in b=1443
9889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9891 cancel_lru_locks osc
9892 # there may be some slab objects cached per core
9893 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9894 local before=$(num_objects)
9895 local count=$((512 * cpus))
9896 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9897 local margin=$((count / 10))
9898 if [[ -f $slab_lic/aliases ]]; then
9899 local aliases=$(cat $slab_lic/aliases)
9900 (( aliases > 0 )) && margin=$((margin * aliases))
9903 echo "before slab objects: $before"
9904 for i in $(seq $count); do
9908 cancel_lru_locks osc
9909 local after=$(num_objects)
9910 echo "created: $count, after slab objects: $after"
9911 # shared slab counts are not very accurate, allow significant margin
9912 # the main goal is that the cache growth is not permanently > $count
9913 while (( after > before + margin )); do
9915 after=$(num_objects)
9917 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9918 if (( wait > 60 )); then
9919 error "inode slab grew from $before+$margin to $after"
9923 run_test 76a "confirm clients recycle inodes properly ===="
9926 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9927 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9930 local before=$(num_objects)
9932 for i in $(seq $count); do
9937 local after=$(num_objects)
9940 while (( after > before )); do
9942 after=$(num_objects)
9944 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9945 if (( wait > 60 )); then
9946 error "inode slab grew from $before to $after"
9950 echo "slab objects before: $before, after: $after"
9952 run_test 76b "confirm clients recycle directory inodes properly ===="
9957 # Note: in sptlrpc modes which enable its own bulk checksum, the
9958 # original crc32_le bulk checksum will be automatically disabled,
9959 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9960 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9961 # In this case set_checksums() will not be no-op, because sptlrpc
9962 # bulk checksum will be enabled all through the test.
9964 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9965 lctl set_param -n osc.*.checksums $1
9969 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9970 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9971 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9972 tr -d [] | head -n1)}
9975 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9977 log "set checksum type to $1, rc = $rc"
9981 get_osc_checksum_type()
9983 # arugment 1: OST name, like OST0000
9985 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9986 sed 's/.*\[\(.*\)\].*/\1/g')
9988 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9992 F77_TMP=$TMP/f77-temp
9995 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9996 error "error writing to $F77_TMP"
9999 test_77a() { # bug 10889
10000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10001 $GSS && skip_env "could not run with gss"
10003 [ ! -f $F77_TMP ] && setup_f77
10005 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
10009 run_test 77a "normal checksum read/write operation"
10011 test_77b() { # bug 10889
10012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10013 $GSS && skip_env "could not run with gss"
10015 [ ! -f $F77_TMP ] && setup_f77
10016 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10017 $LCTL set_param fail_loc=0x80000409
10020 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10021 error "dd error: $?"
10022 $LCTL set_param fail_loc=0
10024 for algo in $CKSUM_TYPES; do
10025 cancel_lru_locks osc
10026 set_checksum_type $algo
10027 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10028 $LCTL set_param fail_loc=0x80000408
10029 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10030 $LCTL set_param fail_loc=0
10033 set_checksum_type $ORIG_CSUM_TYPE
10036 run_test 77b "checksum error on client write, read"
10041 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10043 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10044 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10045 $check_ost && [ -n "$ost_file_prefix" ] &&
10046 do_facet ost1 rm -f ${ost_file_prefix}\*
10050 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10051 $GSS && skip_env "could not run with gss"
10052 remote_ost_nodsh && skip "remote OST with nodsh"
10055 local osc_file_prefix
10057 local check_ost=false
10058 local ost_file_prefix
10064 # ensure corruption will occur on first OSS/OST
10065 $LFS setstripe -i 0 $DIR/$tfile
10067 [ ! -f $F77_TMP ] && setup_f77
10068 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10069 error "dd write error: $?"
10070 fid=$($LFS path2fid $DIR/$tfile)
10072 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10075 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10076 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10078 echo "OSS do not support bulk pages dump upon error"
10081 osc_file_prefix=$($LCTL get_param -n debug_path)
10082 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10084 trap cleanup_77c EXIT
10087 # enable bulk pages dump upon error on Client
10088 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10089 # enable bulk pages dump upon error on OSS
10091 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10093 # flush Client cache to allow next read to reach OSS
10094 cancel_lru_locks osc
10096 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10097 $LCTL set_param fail_loc=0x80000408
10098 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10099 $LCTL set_param fail_loc=0
10103 # check cksum dump on Client
10104 osc_file=$(ls ${osc_file_prefix}*)
10105 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10106 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10107 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10108 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10109 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10111 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10112 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10113 error "dump content does not match on Client"
10115 $check_ost || skip "No need to check cksum dump on OSS"
10117 # check cksum dump on OSS
10118 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10119 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10120 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10121 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10122 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10123 error "dump content does not match on OSS"
10127 run_test 77c "checksum error on client read with debug"
10129 test_77d() { # bug 10889
10130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10131 $GSS && skip_env "could not run with gss"
10133 stack_trap "rm -f $DIR/$tfile"
10134 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10135 $LCTL set_param fail_loc=0x80000409
10137 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10138 error "direct write: rc=$?"
10139 $LCTL set_param fail_loc=0
10142 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10143 $LCTL set_param fail_loc=0x80000408
10145 cancel_lru_locks osc
10146 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10147 error "direct read: rc=$?"
10148 $LCTL set_param fail_loc=0
10151 run_test 77d "checksum error on OST direct write, read"
10153 test_77f() { # bug 10889
10154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10155 $GSS && skip_env "could not run with gss"
10158 stack_trap "rm -f $DIR/$tfile"
10159 for algo in $CKSUM_TYPES; do
10160 cancel_lru_locks osc
10161 set_checksum_type $algo
10162 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10163 $LCTL set_param fail_loc=0x409
10164 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10165 error "direct write succeeded"
10166 $LCTL set_param fail_loc=0
10168 set_checksum_type $ORIG_CSUM_TYPE
10171 run_test 77f "repeat checksum error on write (expect error)"
10173 test_77g() { # bug 10889
10174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10175 $GSS && skip_env "could not run with gss"
10176 remote_ost_nodsh && skip "remote OST with nodsh"
10178 [ ! -f $F77_TMP ] && setup_f77
10180 local file=$DIR/$tfile
10181 stack_trap "rm -f $file" EXIT
10183 $LFS setstripe -c 1 -i 0 $file
10184 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10185 do_facet ost1 lctl set_param fail_loc=0x8000021a
10187 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10188 error "write error: rc=$?"
10189 do_facet ost1 lctl set_param fail_loc=0
10192 cancel_lru_locks osc
10193 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10194 do_facet ost1 lctl set_param fail_loc=0x8000021b
10196 cmp $F77_TMP $file || error "file compare failed"
10197 do_facet ost1 lctl set_param fail_loc=0
10200 run_test 77g "checksum error on OST write, read"
10202 test_77k() { # LU-10906
10203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10204 $GSS && skip_env "could not run with gss"
10206 local cksum_param="osc.$FSNAME*.checksums"
10207 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10211 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10212 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10213 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10216 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10217 error "failed to set checksum=$i on MGS"
10218 wait_update $HOSTNAME "$get_checksum" $i
10220 echo "remount client, checksum should be $i"
10221 remount_client $MOUNT || error "failed to remount client"
10222 checksum=$(eval $get_checksum)
10223 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10225 # remove persistent param to avoid races with checksum mountopt below
10226 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10227 error "failed to delete checksum on MGS"
10229 for opt in "checksum" "nochecksum"; do
10230 #remount with mount option
10231 echo "remount client with option $opt, checksum should be $i"
10232 umount_client $MOUNT || error "failed to umount client"
10233 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10234 error "failed to mount client with option '$opt'"
10235 checksum=$(eval $get_checksum)
10236 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10240 remount_client $MOUNT || error "failed to remount client"
10242 run_test 77k "enable/disable checksum correctly"
10245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10246 $GSS && skip_env "could not run with gss"
10249 stack_trap "set_checksums $ORIG_CSUM" EXIT
10250 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10252 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10254 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10255 for algo in $CKSUM_TYPES; do
10256 set_checksum_type $algo || error "fail to set checksum type $algo"
10257 osc_algo=$(get_osc_checksum_type OST0000)
10258 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10260 # no locks, no reqs to let the connection idle
10261 cancel_lru_locks osc
10262 lru_resize_disable osc
10263 wait_osc_import_state client ost1 IDLE
10265 # ensure ost1 is connected
10266 stat $DIR/$tfile >/dev/null || error "can't stat"
10267 wait_osc_import_state client ost1 FULL
10269 osc_algo=$(get_osc_checksum_type OST0000)
10270 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10274 run_test 77l "preferred checksum type is remembered after reconnected"
10276 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10281 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10282 skip "Need at least version 2.14.52"
10283 local param=checksum_speed
10285 $LCTL get_param $param || error "reading $param failed"
10287 csum_speeds=$($LCTL get_param -n $param)
10289 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10290 error "known checksum types are missing"
10292 run_test 77m "Verify checksum_speed is correctly read"
10294 check_filefrag_77n() {
10299 while read extidx a b start end rest; do
10300 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10301 nr_ext=$(( $nr_ext + 1 ))
10302 starts+=( ${start%..} )
10305 done < <( filefrag -sv $1 )
10307 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10312 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10315 $TRUNCATE $DIR/$tfile 0
10316 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10317 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10318 check_filefrag_77n $DIR/$tfile ||
10319 skip "$tfile blocks not contiguous around hole"
10322 stack_trap "set_checksums $ORIG_CSUM" EXIT
10323 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10324 stack_trap "rm -f $DIR/$tfile"
10326 for algo in $CKSUM_TYPES; do
10327 if [[ "$algo" =~ ^t10 ]]; then
10328 set_checksum_type $algo ||
10329 error "fail to set checksum type $algo"
10330 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10331 error "fail to read $tfile with $algo"
10337 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10340 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10341 skip "Need MDS version at least 2.14.55"
10342 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10343 skip "Need OST version at least 2.14.55"
10344 local ofd=obdfilter
10347 # print OST checksum_type
10348 echo "$ofd.$FSNAME-*.checksum_type:"
10349 do_nodes $(comma_list $(osts_nodes)) \
10350 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10352 # print MDT checksum_type
10353 echo "$mdt.$FSNAME-*.checksum_type:"
10354 do_nodes $(comma_list $(mdts_nodes)) \
10355 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10357 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10358 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10360 (( $o_count == $OSTCOUNT )) ||
10361 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10363 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10364 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10366 (( $m_count == $MDSCOUNT )) ||
10367 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10369 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10371 cleanup_test_78() {
10376 test_78() { # bug 10901
10377 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10378 remote_ost || skip_env "local OST"
10381 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10382 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10383 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10384 echo "MemTotal: $MEMTOTAL"
10386 # reserve 256MB of memory for the kernel and other running processes,
10387 # and then take 1/2 of the remaining memory for the read/write buffers.
10388 if [ $MEMTOTAL -gt 512 ] ;then
10389 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10391 # for those poor memory-starved high-end clusters...
10392 MEMTOTAL=$((MEMTOTAL / 2))
10394 echo "Mem to use for directio: $MEMTOTAL"
10396 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10397 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10398 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10399 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10401 echo "Smallest OST: $SMALLESTOST"
10402 [[ $SMALLESTOST -lt 10240 ]] &&
10403 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10405 trap cleanup_test_78 EXIT
10407 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10408 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10410 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10411 echo "File size: $F78SIZE"
10412 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10413 for i in $(seq 1 $NSEQ); do
10414 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10415 echo directIO rdwr round $i of $NSEQ
10416 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10421 run_test 78 "handle large O_DIRECT writes correctly ============"
10423 test_79() { # bug 12743
10424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10426 wait_delete_completed
10428 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10429 BKFREE=$(calc_osc_kbytes kbytesfree)
10430 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10432 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10433 DFTOTAL=`echo $STRING | cut -d, -f1`
10434 DFUSED=`echo $STRING | cut -d, -f2`
10435 DFAVAIL=`echo $STRING | cut -d, -f3`
10436 DFFREE=$(($DFTOTAL - $DFUSED))
10438 ALLOWANCE=$((64 * $OSTCOUNT))
10440 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10441 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10442 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10444 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10445 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10446 error "df free($DFFREE) mismatch OST free($BKFREE)"
10448 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10449 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10450 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10453 run_test 79 "df report consistency check ======================="
10455 test_80() { # bug 10718
10456 remote_ost_nodsh && skip "remote OST with nodsh"
10457 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10459 # relax strong synchronous semantics for slow backends like ZFS
10460 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10461 local soc="obdfilter.*.sync_lock_cancel"
10462 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10464 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10465 if [ -z "$save" ]; then
10466 soc="obdfilter.*.sync_on_lock_cancel"
10467 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10470 if [ "$save" != "never" ]; then
10471 local hosts=$(comma_list $(osts_nodes))
10473 do_nodes $hosts $LCTL set_param $soc=never
10474 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10478 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10479 sync; sleep 1; sync
10480 local before=$(date +%s)
10481 cancel_lru_locks osc
10482 local after=$(date +%s)
10483 local diff=$((after - before))
10484 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10488 run_test 80 "Page eviction is equally fast at high offsets too"
10490 test_81a() { # LU-456
10491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10492 remote_ost_nodsh && skip "remote OST with nodsh"
10494 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10495 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10496 do_facet ost1 lctl set_param fail_loc=0x80000228
10498 # write should trigger a retry and success
10499 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10500 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10502 if [ $RC -ne 0 ] ; then
10503 error "write should success, but failed for $RC"
10506 run_test 81a "OST should retry write when get -ENOSPC ==============="
10508 test_81b() { # LU-456
10509 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10510 remote_ost_nodsh && skip "remote OST with nodsh"
10512 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10513 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10514 do_facet ost1 lctl set_param fail_loc=0x228
10516 # write should retry several times and return -ENOSPC finally
10517 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10518 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10521 if [ $RC -ne $ENOSPC ] ; then
10522 error "dd should fail for -ENOSPC, but succeed."
10525 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10528 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10530 test_mkdir $DIR/$tdir.cvsroot
10531 chown $RUNAS_ID $DIR/$tdir.cvsroot
10534 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10537 # some versions of cvs import exit(1) when asked to import links or
10538 # files they can't read. ignore those files.
10539 local toignore=$(find . -type l -printf '-I %f\n' -o \
10540 ! -perm /4 -printf '-I %f\n')
10541 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10542 $tdir.reposname vtag rtag
10545 test_mkdir $DIR/$tdir.reposname
10546 chown $RUNAS_ID $DIR/$tdir.reposname
10547 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10549 cd $DIR/$tdir.reposname
10551 $RUNAS cvs add -m 'addmsg' foo99
10553 $RUNAS cvs commit -m 'nomsg' foo99
10554 rm -fr $DIR/$tdir.cvsroot
10556 run_test 99 "cvs strange file/directory operations"
10559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10560 [[ "$NETTYPE" =~ tcp ]] ||
10561 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10562 remote_ost_nodsh && skip "remote OST with nodsh"
10563 remote_mds_nodsh && skip "remote MDS with nodsh"
10565 skip "useless for local single node setup"
10567 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10568 [ "$PROT" != "tcp" ] && continue
10569 RPORT=$(echo $REMOTE | cut -d: -f2)
10570 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10573 LPORT=`echo $LOCAL | cut -d: -f2`
10574 if [ $LPORT -ge 1024 ]; then
10575 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10577 error_exit "local: $LPORT > 1024, remote: $RPORT"
10580 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10582 run_test 100 "check local port using privileged port ==========="
10584 function get_named_value()
10588 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10591 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10592 awk '/^max_cached_mb/ { print $2 }')
10595 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10605 local cache_limit=32
10607 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10608 trap cleanup_101a EXIT
10609 $LCTL set_param -n llite.*.read_ahead_stats=0
10610 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10613 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10615 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10616 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10619 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10620 get_named_value 'read.but.discarded'); do
10621 discard=$(($discard + $s))
10625 $LCTL get_param osc.*-osc*.rpc_stats
10626 $LCTL get_param llite.*.read_ahead_stats
10628 # Discard is generally zero, but sometimes a few random reads line up
10629 # and trigger larger readahead, which is wasted & leads to discards.
10630 if [[ $(($discard)) -gt $nreads ]]; then
10631 error "too many ($discard) discarded pages"
10633 rm -f $DIR/$tfile || true
10635 run_test 101a "check read-ahead for random reads"
10637 setup_test101bc() {
10638 test_mkdir $DIR/$tdir
10640 local FILE_LENGTH=$2
10643 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10645 local list=$(comma_list $(osts_nodes))
10646 set_osd_param $list '' read_cache_enable 0
10647 set_osd_param $list '' writethrough_cache_enable 0
10649 trap cleanup_test101bc EXIT
10650 # prepare the read-ahead file
10651 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10653 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10654 count=$FILE_SIZE_MB 2> /dev/null
10658 cleanup_test101bc() {
10663 local list=$(comma_list $(osts_nodes))
10664 set_osd_param $list '' read_cache_enable 1
10665 set_osd_param $list '' writethrough_cache_enable 1
10669 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10674 local stripe_size=$2
10675 local stride_length=$((stripe_size / read_size))
10676 local stride_width=$((stride_length * OSTCOUNT))
10677 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10678 (stride_width - stride_length) ))
10679 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10680 get_named_value 'read.but.discarded' | calc_total)
10682 if [[ $discard -gt $discard_limit ]]; then
10683 $LCTL get_param llite.*.read_ahead_stats
10684 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
10686 echo "Read-ahead success for size ${read_size}"
10691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10692 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10694 local STRIPE_SIZE=1048576
10695 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10697 if [ $SLOW == "yes" ]; then
10698 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10700 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10703 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10705 # prepare the read-ahead file
10706 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10707 cancel_lru_locks osc
10708 for BIDX in 2 4 8 16 32 64 128 256
10710 local BSIZE=$((BIDX*4096))
10711 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10712 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10713 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10714 $LCTL set_param -n llite.*.read_ahead_stats=0
10715 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10716 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10717 cancel_lru_locks osc
10718 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10723 run_test 101b "check stride-io mode read-ahead ================="
10726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10728 local STRIPE_SIZE=1048576
10729 local FILE_LENGTH=$((STRIPE_SIZE*100))
10732 local osc_rpc_stats
10734 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10736 cancel_lru_locks osc
10737 $LCTL set_param osc.*.rpc_stats=0
10738 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10739 $LCTL get_param osc.*.rpc_stats
10740 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10741 local stats=$($LCTL get_param -n $osc_rpc_stats)
10742 local lines=$(echo "$stats" | awk 'END {print NR;}')
10745 if [ $lines -le 20 ]; then
10746 echo "continue debug"
10749 for size in 1 2 4 8; do
10750 local rpc=$(echo "$stats" |
10751 awk '($1 == "'$size':") {print $2; exit; }')
10752 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10753 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10755 echo "$osc_rpc_stats check passed!"
10760 run_test 101c "check stripe_size aligned read-ahead"
10763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10765 local file=$DIR/$tfile
10766 local sz_MB=${FILESIZE_101d:-80}
10767 local ra_MB=${READAHEAD_MB:-40}
10769 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10770 [ $free_MB -lt $sz_MB ] &&
10771 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10773 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10774 $LFS setstripe -c -1 $file || error "setstripe failed"
10776 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10777 echo Cancel LRU locks on lustre client to flush the client cache
10778 cancel_lru_locks osc
10780 echo Disable read-ahead
10781 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10782 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10783 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10784 $LCTL get_param -n llite.*.max_read_ahead_mb
10786 echo "Reading the test file $file with read-ahead disabled"
10787 local sz_KB=$((sz_MB * 1024 / 4))
10788 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10789 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10790 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10791 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10793 echo "Cancel LRU locks on lustre client to flush the client cache"
10794 cancel_lru_locks osc
10795 echo Enable read-ahead with ${ra_MB}MB
10796 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10798 echo "Reading the test file $file with read-ahead enabled"
10799 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10800 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10802 echo "read-ahead disabled time read $raOFF"
10803 echo "read-ahead enabled time read $raON"
10806 wait_delete_completed
10808 # use awk for this check instead of bash because it handles decimals
10809 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10810 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10812 run_test 101d "file read with and without read-ahead enabled"
10815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10817 local file=$DIR/$tfile
10818 local size_KB=500 #KB
10822 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10823 local need_KB=$((count * size_KB))
10824 [[ $free_KB -le $need_KB ]] &&
10825 skip_env "Need free space $need_KB, have $free_KB"
10827 echo "Creating $count ${size_KB}K test files"
10828 for ((i = 0; i < $count; i++)); do
10829 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10832 echo "Cancel LRU locks on lustre client to flush the client cache"
10833 cancel_lru_locks $OSC
10835 echo "Reset readahead stats"
10836 $LCTL set_param -n llite.*.read_ahead_stats=0
10838 for ((i = 0; i < $count; i++)); do
10839 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10842 $LCTL get_param llite.*.max_cached_mb
10843 $LCTL get_param llite.*.read_ahead_stats
10844 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10845 get_named_value 'misses' | calc_total)
10847 for ((i = 0; i < $count; i++)); do
10848 rm -rf $file.$i 2>/dev/null
10851 #10000 means 20% reads are missing in readahead
10852 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10854 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10857 which iozone || skip_env "no iozone installed"
10859 local old_debug=$($LCTL get_param debug)
10860 old_debug=${old_debug#*=}
10861 $LCTL set_param debug="reada mmap"
10863 # create a test file
10864 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10866 echo Cancel LRU locks on lustre client to flush the client cache
10867 cancel_lru_locks osc
10869 echo Reset readahead stats
10870 $LCTL set_param -n llite.*.read_ahead_stats=0
10872 echo mmap read the file with small block size
10873 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10876 echo checking missing pages
10877 $LCTL get_param llite.*.read_ahead_stats
10878 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10879 get_named_value 'misses' | calc_total)
10881 $LCTL set_param debug="$old_debug"
10882 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10885 run_test 101f "check mmap read performance"
10887 test_101g_brw_size_test() {
10889 local pages=$((mb * 1048576 / PAGE_SIZE))
10890 local file=$DIR/$tfile
10892 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10893 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10894 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10895 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10899 stack_trap "rm -f $file" EXIT
10900 $LCTL set_param -n osc.*.rpc_stats=0
10902 # 10 RPCs should be enough for the test
10904 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10905 { error "dd write ${mb} MB blocks failed"; return 3; }
10906 cancel_lru_locks osc
10907 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10908 { error "dd write ${mb} MB blocks failed"; return 4; }
10910 # calculate number of full-sized read and write RPCs
10911 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10912 sed -n '/pages per rpc/,/^$/p' |
10913 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10914 END { print reads,writes }'))
10915 # allow one extra full-sized read RPC for async readahead
10916 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10917 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10918 [[ ${rpcs[1]} == $count ]] ||
10919 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10923 remote_ost_nodsh && skip "remote OST with nodsh"
10926 local osts=$(get_facets OST)
10927 local list=$(comma_list $(osts_nodes))
10928 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10929 local brw_size="obdfilter.*.brw_size"
10931 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10933 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10935 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10936 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10937 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10938 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10939 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10940 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10942 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10945 if [[ $orig_mb -lt 16 ]]; then
10946 save_lustre_params $osts "$brw_size" > $p
10947 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10948 error "set 16MB RPC size failed"
10950 echo "remount client to enable new RPC size"
10951 remount_client $MOUNT || error "remount_client failed"
10954 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10955 # should be able to set brw_size=12, but no rpc_stats for that
10956 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10959 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10961 if [[ $orig_mb -lt 16 ]]; then
10962 restore_lustre_params < $p
10963 remount_client $MOUNT || error "remount_client restore failed"
10966 rm -f $p $DIR/$tfile
10968 run_test 101g "Big bulk(4/16 MiB) readahead"
10971 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10973 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10974 error "dd 70M file failed"
10975 echo Cancel LRU locks on lustre client to flush the client cache
10976 cancel_lru_locks osc
10978 echo "Reset readahead stats"
10979 $LCTL set_param -n llite.*.read_ahead_stats 0
10981 echo "Read 10M of data but cross 64M bundary"
10982 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10983 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10984 get_named_value 'misses' | calc_total)
10985 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10986 rm -f $p $DIR/$tfile
10988 run_test 101h "Readahead should cover current read window"
10991 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10992 error "dd 10M file failed"
10994 local max_per_file_mb=$($LCTL get_param -n \
10995 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10996 cancel_lru_locks osc
10997 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10998 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10999 error "set max_read_ahead_per_file_mb to 1 failed"
11001 echo "Reset readahead stats"
11002 $LCTL set_param llite.*.read_ahead_stats=0
11004 dd if=$DIR/$tfile of=/dev/null bs=2M
11006 $LCTL get_param llite.*.read_ahead_stats
11007 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11008 awk '/misses/ { print $2 }')
11009 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
11012 run_test 101i "allow current readahead to exceed reservation"
11015 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
11016 error "setstripe $DIR/$tfile failed"
11017 local file_size=$((1048576 * 16))
11018 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11019 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
11021 echo Disable read-ahead
11022 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11024 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
11025 for blk in $PAGE_SIZE 1048576 $file_size; do
11026 cancel_lru_locks osc
11027 echo "Reset readahead stats"
11028 $LCTL set_param -n llite.*.read_ahead_stats=0
11029 local count=$(($file_size / $blk))
11030 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11031 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11032 get_named_value 'failed.to.fast.read' | calc_total)
11033 $LCTL get_param -n llite.*.read_ahead_stats
11034 [ $miss -eq $count ] || error "expected $count got $miss"
11037 rm -f $p $DIR/$tfile
11039 run_test 101j "A complete read block should be submitted when no RA"
11042 test_mkdir $DIR/$tdir
11043 chown $RUNAS_ID $DIR/$tdir
11046 STRIPE_COUNT=$OSTCOUNT
11047 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11049 trap cleanup_test102 EXIT
11051 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11053 for num in 1 2 3 4; do
11054 for count in $(seq 1 $STRIPE_COUNT); do
11055 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11056 local size=`expr $STRIPE_SIZE \* $num`
11057 local file=file"$num-$idx-$count"
11058 $1 $LFS setstripe -S $size -i $idx -c $count $file
11064 $1 tar cf $TMP/f102.tar $tdir --xattrs
11067 cleanup_test102() {
11069 rm -f $TMP/f102.tar
11070 rm -rf $DIR/d0.sanity/d102
11074 [ "$UID" != 0 ] && skip "must run as root"
11075 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11076 skip_env "must have user_xattr"
11078 [ -z "$(which setfattr 2>/dev/null)" ] &&
11079 skip_env "could not find setfattr"
11081 local testfile=$DIR/$tfile
11084 echo "set/get xattr..."
11085 setfattr -n trusted.name1 -v value1 $testfile ||
11086 error "setfattr -n trusted.name1=value1 $testfile failed"
11087 getfattr -n trusted.name1 $testfile 2> /dev/null |
11088 grep "trusted.name1=.value1" ||
11089 error "$testfile missing trusted.name1=value1"
11091 setfattr -n user.author1 -v author1 $testfile ||
11092 error "setfattr -n user.author1=author1 $testfile failed"
11093 getfattr -n user.author1 $testfile 2> /dev/null |
11094 grep "user.author1=.author1" ||
11095 error "$testfile missing trusted.author1=author1"
11097 echo "listxattr..."
11098 setfattr -n trusted.name2 -v value2 $testfile ||
11099 error "$testfile unable to set trusted.name2"
11100 setfattr -n trusted.name3 -v value3 $testfile ||
11101 error "$testfile unable to set trusted.name3"
11102 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11103 grep "trusted.name" | wc -l) -eq 3 ] ||
11104 error "$testfile missing 3 trusted.name xattrs"
11106 setfattr -n user.author2 -v author2 $testfile ||
11107 error "$testfile unable to set user.author2"
11108 setfattr -n user.author3 -v author3 $testfile ||
11109 error "$testfile unable to set user.author3"
11110 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11111 grep "user.author" | wc -l) -eq 3 ] ||
11112 error "$testfile missing 3 user.author xattrs"
11114 echo "remove xattr..."
11115 setfattr -x trusted.name1 $testfile ||
11116 error "$testfile error deleting trusted.name1"
11117 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11118 error "$testfile did not delete trusted.name1 xattr"
11120 setfattr -x user.author1 $testfile ||
11121 error "$testfile error deleting user.author1"
11122 echo "set lustre special xattr ..."
11123 $LFS setstripe -c1 $testfile
11124 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11125 awk -F "=" '/trusted.lov/ { print $2 }' )
11126 setfattr -n "trusted.lov" -v $lovea $testfile ||
11127 error "$testfile doesn't ignore setting trusted.lov again"
11128 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11129 error "$testfile allow setting invalid trusted.lov"
11132 run_test 102a "user xattr test =================================="
11134 check_102b_layout() {
11136 local testfile=$DIR/$tfile
11138 echo "test layout '$layout'"
11139 $LFS setstripe $layout $testfile || error "setstripe failed"
11140 $LFS getstripe -y $testfile
11142 echo "get/set/list trusted.lov xattr ..." # b=10930
11143 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11144 [[ "$value" =~ "trusted.lov" ]] ||
11145 error "can't get trusted.lov from $testfile"
11146 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11147 error "getstripe failed"
11149 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11151 value=$(cut -d= -f2 <<<$value)
11152 # LU-13168: truncated xattr should fail if short lov_user_md header
11153 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11154 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11155 for len in $lens; do
11156 echo "setfattr $len $testfile.2"
11157 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11158 [ $len -lt 66 ] && error "short xattr len=$len worked"
11160 local stripe_size=$($LFS getstripe -S $testfile.2)
11161 local stripe_count=$($LFS getstripe -c $testfile.2)
11162 [[ $stripe_size -eq 65536 ]] ||
11163 error "stripe size $stripe_size != 65536"
11164 [[ $stripe_count -eq $stripe_count_orig ]] ||
11165 error "stripe count $stripe_count != $stripe_count_orig"
11166 rm $testfile $testfile.2
11170 [ -z "$(which setfattr 2>/dev/null)" ] &&
11171 skip_env "could not find setfattr"
11172 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11174 # check plain layout
11175 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11177 # and also check composite layout
11178 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11181 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11184 [ -z "$(which setfattr 2>/dev/null)" ] &&
11185 skip_env "could not find setfattr"
11186 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11188 # b10930: get/set/list lustre.lov xattr
11189 echo "get/set/list lustre.lov xattr ..."
11190 test_mkdir $DIR/$tdir
11191 chown $RUNAS_ID $DIR/$tdir
11192 local testfile=$DIR/$tdir/$tfile
11193 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11194 error "setstripe failed"
11195 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11196 error "getstripe failed"
11197 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11198 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11200 local testfile2=${testfile}2
11201 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11202 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11204 $RUNAS $MCREATE $testfile2
11205 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11206 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11207 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11208 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11209 [ $stripe_count -eq $STRIPECOUNT ] ||
11210 error "stripe count $stripe_count != $STRIPECOUNT"
11212 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11214 compare_stripe_info1() {
11215 local stripe_index_all_zero=true
11217 for num in 1 2 3 4; do
11218 for count in $(seq 1 $STRIPE_COUNT); do
11219 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11220 local size=$((STRIPE_SIZE * num))
11221 local file=file"$num-$offset-$count"
11222 stripe_size=$($LFS getstripe -S $PWD/$file)
11223 [[ $stripe_size -ne $size ]] &&
11224 error "$file: size $stripe_size != $size"
11225 stripe_count=$($LFS getstripe -c $PWD/$file)
11226 # allow fewer stripes to be created, ORI-601
11227 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11228 error "$file: count $stripe_count != $count"
11229 stripe_index=$($LFS getstripe -i $PWD/$file)
11230 [[ $stripe_index -ne 0 ]] &&
11231 stripe_index_all_zero=false
11235 $stripe_index_all_zero &&
11236 error "all files are being extracted starting from OST index 0"
11240 have_xattrs_include() {
11241 tar --help | grep -q xattrs-include &&
11242 echo --xattrs-include="lustre.*"
11246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11247 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11249 XINC=$(have_xattrs_include)
11251 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11252 cd $DIR/$tdir/$tdir
11253 compare_stripe_info1
11255 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11259 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11261 XINC=$(have_xattrs_include)
11263 test_mkdir $DIR/$tdir.restore
11265 tar cf - --xattrs $tdir | tar xf - \
11266 -C $DIR/$tdir.restore --xattrs $XINC
11267 cd $DIR/$tdir.restore/$tdir
11268 compare_stripe_info1
11270 run_test 102f "tar copy files, not keep osts"
11273 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11274 skip "must have user_xattr"
11275 [ -z "$(which setfattr 2>/dev/null)" ] &&
11276 skip_env "could not find setfattr"
11277 [ -z "$(which getfattr 2>/dev/null)" ] &&
11278 skip_env "could not find getfattr"
11280 local xsize=${1:-1024} # in bytes
11281 local file=$DIR/$tfile
11282 local value="$(generate_string $xsize)"
11283 local xbig=trusted.big
11287 log "save $xbig on $file"
11288 if [ -z "$toobig" ]
11290 setfattr -n $xbig -v $value $file ||
11291 error "saving $xbig on $file failed"
11293 setfattr -n $xbig -v $value $file &&
11294 error "saving $xbig on $file succeeded"
11298 local orig=$(get_xattr_value $xbig $file)
11299 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11301 local xsml=trusted.sml
11302 log "save $xsml on $file"
11303 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11305 local new=$(get_xattr_value $xbig $file)
11306 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11308 log "grow $xsml on $file"
11309 setfattr -n $xsml -v "$value" $file ||
11310 error "growing $xsml on $file failed"
11312 new=$(get_xattr_value $xbig $file)
11313 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11314 log "$xbig still valid after growing $xsml"
11319 test_102h() { # bug 15777
11322 run_test 102h "grow xattr from inside inode to external block"
11325 large_xattr_enabled || skip_env "ea_inode feature disabled"
11327 echo "setting xattr of max xattr size: $(max_xattr_size)"
11328 grow_xattr $(max_xattr_size)
11330 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11331 echo "This should fail:"
11332 grow_xattr $(($(max_xattr_size) + 10)) 1
11334 run_test 102ha "grow xattr from inside inode to external inode"
11336 test_102i() { # bug 17038
11337 [ -z "$(which getfattr 2>/dev/null)" ] &&
11338 skip "could not find getfattr"
11341 ln -s $DIR/$tfile $DIR/${tfile}link
11342 getfattr -n trusted.lov $DIR/$tfile ||
11343 error "lgetxattr on $DIR/$tfile failed"
11344 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11345 grep -i "no such attr" ||
11346 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11347 rm -f $DIR/$tfile $DIR/${tfile}link
11349 run_test 102i "lgetxattr test on symbolic link ============"
11352 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11353 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11355 XINC=$(have_xattrs_include)
11356 setup_test102 "$RUNAS"
11357 chown $RUNAS_ID $DIR/$tdir
11358 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11359 cd $DIR/$tdir/$tdir
11360 compare_stripe_info1 "$RUNAS"
11362 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11365 [ -z "$(which setfattr 2>/dev/null)" ] &&
11366 skip "could not find setfattr"
11369 # b22187 just check that does not crash for regular file.
11370 setfattr -n trusted.lov $DIR/$tfile
11371 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11372 local test_kdir=$DIR/$tdir
11373 test_mkdir $test_kdir
11374 local default_size=$($LFS getstripe -S $test_kdir)
11375 local default_count=$($LFS getstripe -c $test_kdir)
11376 local default_offset=$($LFS getstripe -i $test_kdir)
11377 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11378 error 'dir setstripe failed'
11379 setfattr -n trusted.lov $test_kdir
11380 local stripe_size=$($LFS getstripe -S $test_kdir)
11381 local stripe_count=$($LFS getstripe -c $test_kdir)
11382 local stripe_offset=$($LFS getstripe -i $test_kdir)
11383 [ $stripe_size -eq $default_size ] ||
11384 error "stripe size $stripe_size != $default_size"
11385 [ $stripe_count -eq $default_count ] ||
11386 error "stripe count $stripe_count != $default_count"
11387 [ $stripe_offset -eq $default_offset ] ||
11388 error "stripe offset $stripe_offset != $default_offset"
11389 rm -rf $DIR/$tfile $test_kdir
11391 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11394 [ -z "$(which getfattr 2>/dev/null)" ] &&
11395 skip "could not find getfattr"
11397 # LU-532 trusted. xattr is invisible to non-root
11398 local testfile=$DIR/$tfile
11402 echo "listxattr as user..."
11403 chown $RUNAS_ID $testfile
11404 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11405 grep -q "trusted" &&
11406 error "$testfile trusted xattrs are user visible"
11410 run_test 102l "listxattr size test =================================="
11412 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11413 local path=$DIR/$tfile
11416 listxattr_size_check $path || error "listattr_size_check $path failed"
11418 run_test 102m "Ensure listxattr fails on small bufffer ========"
11422 getxattr() { # getxattr path name
11423 # Return the base64 encoding of the value of xattr name on path.
11427 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11429 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11431 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11433 getfattr --absolute-names --encoding=base64 --name=$name $path |
11434 awk -F= -v name=$name '$1 == name {
11435 print substr($0, index($0, "=") + 1);
11439 test_102n() { # LU-4101 mdt: protect internal xattrs
11440 [ -z "$(which setfattr 2>/dev/null)" ] &&
11441 skip "could not find setfattr"
11442 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11444 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11447 local file0=$DIR/$tfile.0
11448 local file1=$DIR/$tfile.1
11449 local xattr0=$TMP/$tfile.0
11450 local xattr1=$TMP/$tfile.1
11451 local namelist="lov lma lmv link fid version som hsm"
11455 rm -rf $file0 $file1 $xattr0 $xattr1
11456 touch $file0 $file1
11458 # Get 'before' xattrs of $file1.
11459 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11461 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11462 namelist+=" lfsck_namespace"
11463 for name in $namelist; do
11464 # Try to copy xattr from $file0 to $file1.
11465 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11467 setfattr --name=trusted.$name --value="$value" $file1 ||
11468 error "setxattr 'trusted.$name' failed"
11470 # Try to set a garbage xattr.
11471 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11473 if [[ x$name == "xlov" ]]; then
11474 setfattr --name=trusted.lov --value="$value" $file1 &&
11475 error "setxattr invalid 'trusted.lov' success"
11477 setfattr --name=trusted.$name --value="$value" $file1 ||
11478 error "setxattr invalid 'trusted.$name' failed"
11481 # Try to remove the xattr from $file1. We don't care if this
11482 # appears to succeed or fail, we just don't want there to be
11483 # any changes or crashes.
11484 setfattr --remove=$trusted.$name $file1 2> /dev/null
11487 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11490 # Try to copy xattr from $file0 to $file1.
11491 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11493 setfattr --name=trusted.$name --value="$value" $file1 ||
11494 error "setxattr 'trusted.$name' failed"
11496 # Try to set a garbage xattr.
11497 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11499 setfattr --name=trusted.$name --value="$value" $file1 ||
11500 error "setxattr 'trusted.$name' failed"
11502 # Try to remove the xattr from $file1. We don't care if this
11503 # appears to succeed or fail, we just don't want there to be
11504 # any changes or crashes.
11505 setfattr --remove=$trusted.$name $file1 2> /dev/null
11508 # Get 'after' xattrs of file1.
11509 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11511 if ! diff $xattr0 $xattr1; then
11512 error "before and after xattrs of '$file1' differ"
11515 rm -rf $file0 $file1 $xattr0 $xattr1
11519 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11521 test_102p() { # LU-4703 setxattr did not check ownership
11522 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11523 skip "MDS needs to be at least 2.5.56"
11525 local testfile=$DIR/$tfile
11529 echo "setfacl as user..."
11530 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11531 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11533 echo "setfattr as user..."
11534 setfacl -m "u:$RUNAS_ID:---" $testfile
11535 $RUNAS setfattr -x system.posix_acl_access $testfile
11536 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11538 run_test 102p "check setxattr(2) correctly fails without permission"
11541 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11542 skip "MDS needs to be at least 2.6.92"
11544 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11546 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11549 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11550 skip "MDS needs to be at least 2.6.93"
11552 touch $DIR/$tfile || error "touch"
11553 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11554 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11555 rm $DIR/$tfile || error "rm"
11558 mkdir -p $DIR/$tdir || error "mkdir"
11559 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11560 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11561 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11562 error "$testfile error deleting user.author1"
11563 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11564 grep "user.$(basename $tdir)" &&
11565 error "$tdir did not delete user.$(basename $tdir)"
11566 rmdir $DIR/$tdir || error "rmdir"
11569 test_mkdir $DIR/$tdir
11570 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11571 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11572 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11573 error "$testfile error deleting user.author1"
11574 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11575 grep "user.$(basename $tdir)" &&
11576 error "$tdir did not delete user.$(basename $tdir)"
11577 rmdir $DIR/$tdir || error "rm striped dir"
11579 run_test 102r "set EAs with empty values"
11582 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11583 skip "MDS needs to be at least 2.11.52"
11585 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11587 save_lustre_params client "llite.*.xattr_cache" > $save
11589 for cache in 0 1; do
11590 lctl set_param llite.*.xattr_cache=$cache
11593 touch $DIR/$tfile || error "touch"
11594 for prefix in lustre security system trusted user; do
11595 # Note getxattr() may fail with 'Operation not
11596 # supported' or 'No such attribute' depending
11597 # on prefix and cache.
11598 getfattr -n $prefix.n102s $DIR/$tfile &&
11599 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11603 restore_lustre_params < $save
11605 run_test 102s "getting nonexistent xattrs should fail"
11608 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11609 skip "MDS needs to be at least 2.11.52"
11611 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11613 save_lustre_params client "llite.*.xattr_cache" > $save
11615 for cache in 0 1; do
11616 lctl set_param llite.*.xattr_cache=$cache
11618 for buf_size in 0 256; do
11620 touch $DIR/$tfile || error "touch"
11621 setfattr -n user.multiop $DIR/$tfile
11622 $MULTIOP $DIR/$tfile oa$buf_size ||
11623 error "cannot get zero length xattr value (buf_size = $buf_size)"
11627 restore_lustre_params < $save
11629 run_test 102t "zero length xattr values handled correctly"
11633 local test=$LUSTRE/tests/acl/$1.test
11634 local tmp=$(mktemp -t $1-XXXXXX).test
11642 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
11643 local sedgroups="-e s/:users/:$grp/g"
11644 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
11646 sed $sedusers $sedgroups < $test > $tmp
11647 stack_trap "rm -f $tmp"
11648 [[ -s $tmp ]] || error "sed failed to create test script"
11650 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
11651 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
11655 [ "$UID" != 0 ] && skip "must run as root"
11656 $GSS && skip_env "could not run under gss"
11657 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
11658 skip_env "must have acl enabled"
11659 which setfacl || skip_env "could not find setfacl"
11660 remote_mds_nodsh && skip "remote MDS with nodsh"
11662 ACLBIN=${ACLBIN:-"bin"}
11663 ACLDMN=${ACLDMN:-"daemon"}
11664 ACLGRP=${ACLGRP:-"users"}
11665 ACLNBD=${ACLNBD:-"nobody"}
11668 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
11669 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
11671 if ! id $ACLBIN ; then
11673 skip_env "can't find suitable ACL 'bin' $ACLBIN"
11676 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
11677 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
11678 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
11680 if ! id $ACLDMN ; then
11682 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
11685 if ! getent group $ACLGRP; then
11686 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
11688 if ! getent group $ACLGRP; then
11689 echo "cannot find group '$ACLGRP', adding it"
11691 add_group 60000 $ACLGRP
11695 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
11696 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
11697 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11699 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11700 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
11702 if ! getent group $ACLGRP; then
11703 echo "cannot find group '$ACLGRP', adding it"
11705 add_group 60000 $ACLGRP
11707 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
11708 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
11710 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
11714 gpasswd -a $ACLDMN $ACLBIN ||
11715 error "setting client group failed" # LU-5641
11716 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
11717 error "setting MDS group failed" # LU-5641
11719 declare -a identity_old
11721 for num in $(seq $MDSCOUNT); do
11722 switch_identity $num true || identity_old[$num]=$?
11725 SAVE_UMASK=$(umask)
11727 mkdir -p $DIR/$tdir
11730 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
11731 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
11732 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
11733 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
11734 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
11735 # CentOS7- uses nobody=99, while newer distros use nobody=65534
11736 if ! id -u $ACLNBD ||
11737 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
11739 if ! id -u $ACLNBD; then
11743 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
11744 add_group $(id -u $ACLNBD) $ACLNBD
11745 if ! getent group $ACLNBD; then
11749 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
11750 [[ -n "$ACLNBD" ]] && which setfattr; then
11751 run_acl_subtest permissions_xattr \
11752 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
11753 elif [[ -z "$ACLNBD" ]]; then
11754 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
11756 echo "skip 'permission_xattr' test - missing setfattr command"
11758 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
11760 # inheritance test got from HP
11761 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11762 chmod +x make-tree || error "chmod +x failed"
11763 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
11766 echo "LU-974 ignore umask when acl is enabled..."
11767 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
11768 if [ $MDSCOUNT -ge 2 ]; then
11769 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
11772 echo "LU-2561 newly created file is same size as directory..."
11773 if [ "$mds1_FSTYPE" != "zfs" ]; then
11774 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
11776 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
11779 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
11784 for num in $(seq $MDSCOUNT); do
11785 if [ "${identity_old[$num]}" = 1 ]; then
11786 switch_identity $num false || identity_old[$num]=$?
11790 run_test 103a "acl test"
11796 for U in {0..511}; do
11798 local O=$(printf "%04o" $U)
11800 umask $(printf "%04o" $((511 ^ $O)))
11801 $LFS setstripe -c 1 $DIR/$tfile.s$O
11802 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11804 (( $S == ($O & 0666) )) ||
11805 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11807 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11808 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11809 (( $S == ($O & 0666) )) ||
11810 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11812 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11813 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11814 (( $S == ($O & 0666) )) ||
11815 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11816 rm -f $DIR/$tfile.[smp]$0
11820 # limit the concurrently running threads to 64. LU-11878
11821 local idx=$((U % 64))
11822 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11827 run_test 103b "umask lfs setstripe"
11830 mkdir -p $DIR/$tdir
11831 cp -rp $DIR/$tdir $DIR/$tdir.bak
11833 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11834 error "$DIR/$tdir shouldn't contain default ACL"
11835 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11836 error "$DIR/$tdir.bak shouldn't contain default ACL"
11839 run_test 103c "'cp -rp' won't set empty acl"
11844 local saved_debug=$($LCTL get_param -n debug)
11846 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
11847 skip "MDS needs to be at least 2.14.52"
11849 large_xattr_enabled || skip_env "ea_inode feature disabled"
11851 mkdir -p $DIR/$tdir
11852 # add big LOV EA to cause reply buffer overflow earlier
11853 $LFS setstripe -C 1000 $DIR/$tdir
11854 lctl set_param mdc.*-mdc*.stats=clear
11856 $LCTL set_param debug=0
11857 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11858 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11860 # add a large number of default ACLs (expect 8000+ for 2.13+)
11861 for U in {2..7000}; do
11862 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11863 error "Able to add just $U default ACLs"
11865 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11866 echo "$numacl default ACLs created"
11868 stat $DIR/$tdir || error "Cannot stat directory"
11869 # check file creation
11870 touch $DIR/$tdir/$tfile ||
11871 error "failed to create $tfile with $numacl default ACLs"
11872 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11873 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11874 echo "$fileacl ACLs were inherited"
11875 (( $fileacl == $numacl )) ||
11876 error "Not all default ACLs were inherited: $numacl != $fileacl"
11877 # check that new ACLs creation adds new ACLs to inherited ACLs
11878 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11879 error "Cannot set new ACL"
11880 numacl=$((numacl + 1))
11881 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11882 (( $fileacl == $numacl )) ||
11883 error "failed to add new ACL: $fileacl != $numacl as expected"
11884 # adds more ACLs to a file to reach their maximum at 8000+
11886 for U in {20000..25000}; do
11887 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11888 numacl=$((numacl + 1))
11890 echo "Added $numacl more ACLs to the file"
11891 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11892 echo "Total $fileacl ACLs in file"
11893 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11894 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11895 rmdir $DIR/$tdir || error "Cannot remove directory"
11897 run_test 103e "inheritance of big amount of default ACLs"
11900 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11901 skip "MDS needs to be at least 2.14.51"
11903 large_xattr_enabled || skip_env "ea_inode feature disabled"
11905 # enable changelog to consume more internal MDD buffers
11908 mkdir -p $DIR/$tdir
11910 $LFS setstripe -C 1000 $DIR/$tdir
11911 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11912 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11913 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11914 rmdir $DIR/$tdir || error "Cannot remove directory"
11916 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11922 lfs df || error "lfs df failed"
11923 lfs df -ih || error "lfs df -ih failed"
11924 lfs df -h $DIR || error "lfs df -h $DIR failed"
11925 lfs df -i $DIR || error "lfs df -i $DIR failed"
11926 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11927 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11929 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11930 lctl --device %$OSC deactivate
11931 lfs df || error "lfs df with deactivated OSC failed"
11932 lctl --device %$OSC activate
11933 # wait the osc back to normal
11934 wait_osc_import_ready client ost
11936 lfs df || error "lfs df with reactivated OSC failed"
11939 run_test 104a "lfs df [-ih] [path] test ========================="
11942 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11943 [ $RUNAS_ID -eq $UID ] &&
11944 skip_env "RUNAS_ID = UID = $UID -- skipping"
11946 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11947 grep "Permission denied" | wc -l)))
11948 if [ $denied_cnt -ne 0 ]; then
11949 error "lfs check servers test failed"
11952 run_test 104b "$RUNAS lfs check servers test ===================="
11955 # Verify $1 is within range of $2.
11956 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11957 # $1 is <= 2% of $2. Else Fail.
11960 # Strip all units (M, G, T)
11961 actual=$(echo $1 | tr -d A-Z)
11962 expect=$(echo $2 | tr -d A-Z)
11964 expect_lo=$(($expect * 98 / 100)) # 2% below
11965 expect_hi=$(($expect * 102 / 100)) # 2% above
11967 # permit 2% drift above and below
11968 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11972 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11973 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11975 local ost_param="osd-zfs.$FSNAME-OST0000."
11976 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11977 local ofacets=$(get_facets OST)
11978 local mfacets=$(get_facets MDS)
11979 local saved_ost_blocks=
11980 local saved_mdt_blocks=
11982 echo "Before recordsize change"
11983 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11984 df=($(df -h | grep "$MOUNT"$))
11987 echo "lfs output : ${lfs_df[*]}"
11988 echo "df output : ${df[*]}"
11990 for facet in ${ofacets//,/ }; do
11991 if [ -z $saved_ost_blocks ]; then
11992 saved_ost_blocks=$(do_facet $facet \
11993 lctl get_param -n $ost_param.blocksize)
11994 echo "OST Blocksize: $saved_ost_blocks"
11996 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11997 do_facet $facet zfs set recordsize=32768 $ost
12000 # BS too small. Sufficient for functional testing.
12001 for facet in ${mfacets//,/ }; do
12002 if [ -z $saved_mdt_blocks ]; then
12003 saved_mdt_blocks=$(do_facet $facet \
12004 lctl get_param -n $mdt_param.blocksize)
12005 echo "MDT Blocksize: $saved_mdt_blocks"
12007 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12008 do_facet $facet zfs set recordsize=32768 $mdt
12011 # Give new values chance to reflect change
12014 echo "After recordsize change"
12015 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
12016 df_after=($(df -h | grep "$MOUNT"$))
12019 echo "lfs output : ${lfs_df_after[*]}"
12020 echo "df output : ${df_after[*]}"
12023 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
12024 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
12025 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
12026 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
12027 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12028 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12031 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12032 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12033 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12034 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12035 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12036 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12038 # Restore MDT recordize back to original
12039 for facet in ${mfacets//,/ }; do
12040 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12041 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12044 # Restore OST recordize back to original
12045 for facet in ${ofacets//,/ }; do
12046 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12047 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12052 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12055 (( $RUNAS_ID != $UID )) ||
12056 skip_env "RUNAS_ID = UID = $UID -- skipping"
12058 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12059 skip "lustre version doesn't support lctl dl with non-root"
12061 # debugfs only allows root users to access files, so the
12062 # previous move of the "devices" file to debugfs broke
12063 # "lctl dl" for non-root users. The LU-9680 Netlink
12064 # interface again allows non-root users to list devices.
12065 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12066 error "lctl dl doesn't work for non root"
12068 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12069 [ "$ost_count" -eq $OSTCOUNT ] ||
12070 error "lctl dl reports wrong number of OST devices"
12072 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12073 [ "$mdt_count" -eq $MDSCOUNT ] ||
12074 error "lctl dl reports wrong number of MDT devices"
12076 run_test 104d "$RUNAS lctl dl test"
12079 # doesn't work on 2.4 kernels
12081 if $(flock_is_enabled); then
12082 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12084 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12088 run_test 105a "flock when mounted without -o flock test ========"
12092 if $(flock_is_enabled); then
12093 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12095 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12099 run_test 105b "fcntl when mounted without -o flock test ========"
12103 if $(flock_is_enabled); then
12104 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12106 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12110 run_test 105c "lockf when mounted without -o flock test"
12112 test_105d() { # bug 15924
12113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12115 test_mkdir $DIR/$tdir
12116 flock_is_enabled || skip_env "mount w/o flock enabled"
12117 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12118 $LCTL set_param fail_loc=0x80000315
12119 flocks_test 2 $DIR/$tdir
12121 run_test 105d "flock race (should not freeze) ========"
12123 test_105e() { # bug 22660 && 22040
12124 flock_is_enabled || skip_env "mount w/o flock enabled"
12127 flocks_test 3 $DIR/$tfile
12129 run_test 105e "Two conflicting flocks from same process"
12131 test_106() { #bug 10921
12132 test_mkdir $DIR/$tdir
12133 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12134 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12136 run_test 106 "attempt exec of dir followed by chown of that dir"
12139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12147 local save_pattern=$(sysctl -n kernel.core_pattern)
12148 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12149 sysctl -w kernel.core_pattern=$file
12150 sysctl -w kernel.core_uses_pid=0
12152 ulimit -c unlimited
12158 kill -s 11 $SLEEPPID
12160 if [ -e $file ]; then
12161 size=`stat -c%s $file`
12162 [ $size -eq 0 ] && error "Fail to create core file $file"
12164 error "Fail to create core file $file"
12167 sysctl -w kernel.core_pattern=$save_pattern
12168 sysctl -w kernel.core_uses_pid=$save_uses_pid
12171 run_test 107 "Coredump on SIG"
12174 test_mkdir $DIR/$tdir
12175 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12176 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12177 error "mkdir with 256 char should fail, but did not"
12178 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12179 error "create with 255 char failed"
12180 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12181 error "create with 256 char should fail, but did not"
12186 run_test 110 "filename length checking"
12189 # Purpose: To verify dynamic thread (OSS) creation.
12192 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12193 remote_ost_nodsh && skip "remote OST with nodsh"
12195 # Lustre does not stop service threads once they are started.
12196 # Reset number of running threads to default.
12201 local save_params="$TMP/sanity-$TESTNAME.parameters"
12203 # Get ll_ost_io count before I/O
12204 OSTIO_pre=$(do_facet ost1 \
12205 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
12206 # Exit if lustre is not running (ll_ost_io not running).
12207 [ -z "$OSTIO_pre" ] && error "no OSS threads"
12209 echo "Starting with $OSTIO_pre threads"
12210 local thread_max=$((OSTIO_pre * 2))
12211 local rpc_in_flight=$((thread_max * 2))
12212 # this is limited to OSC_MAX_RIF_MAX (256)
12213 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
12214 thread_max=$((rpc_in_flight / 2))
12215 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
12218 # Number of I/O Process proposed to be started.
12220 local facets=$(get_facets OST)
12222 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
12223 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
12225 # Set in_flight to $rpc_in_flight
12226 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
12227 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
12228 nfiles=${rpc_in_flight}
12229 # Set ost thread_max to $thread_max
12230 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
12232 # 5 Minutes should be sufficient for max number of OSS
12233 # threads(thread_max) to be created.
12237 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
12238 test_mkdir $DIR/$tdir
12239 for i in $(seq $nfiles); do
12240 local file=$DIR/$tdir/${tfile}-$i
12241 $LFS setstripe -c -1 -i 0 $file
12242 ($WTL $file $timeout)&
12245 # I/O Started - Wait for thread_started to reach thread_max or report
12246 # error if thread_started is more than thread_max.
12247 echo "Waiting for thread_started to reach thread_max"
12248 local thread_started=0
12249 local end_time=$((SECONDS + timeout))
12251 while [ $SECONDS -le $end_time ] ; do
12253 # Get ost i/o thread_started count.
12254 thread_started=$(do_facet ost1 \
12256 ost.OSS.ost_io.threads_started | cut -d= -f2")
12257 # Break out if thread_started is equal/greater than thread_max
12258 if [[ $thread_started -ge $thread_max ]]; then
12259 echo ll_ost_io thread_started $thread_started, \
12260 equal/greater than thread_max $thread_max
12266 # Cleanup - We have the numbers, Kill i/o jobs if running.
12267 jobcount=($(jobs -p))
12268 for i in $(seq 0 $((${#jobcount[@]}-1)))
12270 kill -9 ${jobcount[$i]}
12271 if [ $? -ne 0 ] ; then
12273 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
12277 # Cleanup files left by WTL binary.
12278 for i in $(seq $nfiles); do
12279 local file=$DIR/$tdir/${tfile}-$i
12281 if [ $? -ne 0 ] ; then
12282 echo "Warning: Failed to delete file $file"
12286 restore_lustre_params <$save_params
12287 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
12289 # Error out if no new thread has started or Thread started is greater
12291 if [[ $thread_started -le $OSTIO_pre ||
12292 $thread_started -gt $thread_max ]]; then
12293 error "ll_ost_io: thread_started $thread_started" \
12294 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
12295 "No new thread started or thread started greater " \
12299 run_test 115 "verify dynamic thread creation===================="
12301 test_116a() { # was previously test_116()
12302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12303 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12304 remote_mds_nodsh && skip "remote MDS with nodsh"
12306 echo -n "Free space priority "
12307 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12312 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12313 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12314 stack_trap simple_cleanup_common
12316 # Check if we need to generate uneven OSTs
12317 test_mkdir -p $DIR/$tdir/OST${MINI}
12318 local FILL=$((MINV / 4))
12319 local DIFF=$((MAXV - MINV))
12320 local DIFF2=$((DIFF * 100 / MINV))
12322 local threshold=$(do_facet $SINGLEMDS \
12323 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12324 threshold=${threshold%%%}
12325 echo -n "Check for uneven OSTs: "
12326 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12328 if [[ $DIFF2 -gt $threshold ]]; then
12330 echo "Don't need to fill OST$MINI"
12332 # generate uneven OSTs. Write 2% over the QOS threshold value
12334 DIFF=$((threshold - DIFF2 + 2))
12335 DIFF2=$((MINV * DIFF / 100))
12336 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12337 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12338 error "setstripe failed"
12339 DIFF=$((DIFF2 / 2048))
12341 while [ $i -lt $DIFF ]; do
12343 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12344 bs=2M count=1 2>/dev/null
12353 DIFF=$((MAXV - MINV))
12354 DIFF2=$((DIFF * 100 / MINV))
12355 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12356 if [ $DIFF2 -gt $threshold ]; then
12359 skip "QOS imbalance criteria not met"
12367 # now fill using QOS
12368 $LFS setstripe -c 1 $DIR/$tdir
12369 FILL=$((FILL / 200))
12370 if [ $FILL -gt 600 ]; then
12373 echo "writing $FILL files to QOS-assigned OSTs"
12375 while [ $i -lt $FILL ]; do
12377 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12378 count=1 2>/dev/null
12381 echo "wrote $i 200k files"
12385 echo "Note: free space may not be updated, so measurements might be off"
12387 DIFF2=$((MAXV - MINV))
12388 echo "free space delta: orig $DIFF final $DIFF2"
12389 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12390 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12391 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12392 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12393 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12394 if [[ $DIFF -gt 0 ]]; then
12395 FILL=$((DIFF2 * 100 / DIFF - 100))
12396 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12399 # Figure out which files were written where
12400 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12401 awk '/'$MINI1': / {print $2; exit}')
12403 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12404 echo "$MINC files created on smaller OST $MINI1"
12405 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12406 awk '/'$MAXI1': / {print $2; exit}')
12408 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12409 echo "$MAXC files created on larger OST $MAXI1"
12410 if [[ $MINC -gt 0 ]]; then
12411 FILL=$((MAXC * 100 / MINC - 100))
12412 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12414 [[ $MAXC -gt $MINC ]] ||
12415 error_ignore LU-9 "stripe QOS didn't balance free space"
12417 run_test 116a "stripe QOS: free space balance ==================="
12419 test_116b() { # LU-2093
12420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12421 remote_mds_nodsh && skip "remote MDS with nodsh"
12423 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12424 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12425 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12426 [ -z "$old_rr" ] && skip "no QOS"
12427 do_facet $SINGLEMDS lctl set_param \
12428 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12429 mkdir -p $DIR/$tdir
12430 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12431 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12432 do_facet $SINGLEMDS lctl set_param fail_loc=0
12434 do_facet $SINGLEMDS lctl set_param \
12435 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12437 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12439 test_117() # bug 10891
12441 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12443 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12444 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12445 lctl set_param fail_loc=0x21e
12446 > $DIR/$tfile || error "truncate failed"
12447 lctl set_param fail_loc=0
12448 echo "Truncate succeeded."
12451 run_test 117 "verify osd extend =========="
12453 NO_SLOW_RESENDCOUNT=4
12454 export OLD_RESENDCOUNT=""
12455 set_resend_count () {
12456 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12457 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12458 lctl set_param -n $PROC_RESENDCOUNT $1
12459 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12462 # for reduce test_118* time (b=14842)
12463 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12465 # Reset async IO behavior after error case
12467 FILE=$DIR/reset_async
12469 # Ensure all OSCs are cleared
12470 $LFS setstripe -c -1 $FILE
12471 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12476 test_118a() #bug 11710
12478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12482 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12483 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12484 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12486 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12487 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12492 run_test 118a "verify O_SYNC works =========="
12496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12497 remote_ost_nodsh && skip "remote OST with nodsh"
12501 #define OBD_FAIL_SRV_ENOENT 0x217
12502 set_nodes_failloc "$(osts_nodes)" 0x217
12503 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12505 set_nodes_failloc "$(osts_nodes)" 0
12506 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12507 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12510 if [[ $RC -eq 0 ]]; then
12511 error "Must return error due to dropped pages, rc=$RC"
12515 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12516 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12520 echo "Dirty pages not leaked on ENOENT"
12522 # Due to the above error the OSC will issue all RPCs syncronously
12523 # until a subsequent RPC completes successfully without error.
12524 $MULTIOP $DIR/$tfile Ow4096yc
12529 run_test 118b "Reclaim dirty pages on fatal error =========="
12533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12535 # for 118c, restore the original resend count, LU-1940
12536 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12537 set_resend_count $OLD_RESENDCOUNT
12538 remote_ost_nodsh && skip "remote OST with nodsh"
12542 #define OBD_FAIL_OST_EROFS 0x216
12543 set_nodes_failloc "$(osts_nodes)" 0x216
12545 # multiop should block due to fsync until pages are written
12546 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12550 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12551 error "Multiop failed to block on fsync, pid=$MULTIPID"
12554 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12556 if [[ $WRITEBACK -eq 0 ]]; then
12557 error "No page in writeback, writeback=$WRITEBACK"
12560 set_nodes_failloc "$(osts_nodes)" 0
12563 if [[ $RC -ne 0 ]]; then
12564 error "Multiop fsync failed, rc=$RC"
12567 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12568 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12570 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12571 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12575 echo "Dirty pages flushed via fsync on EROFS"
12578 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12580 # continue to use small resend count to reduce test_118* time (b=14842)
12581 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12586 remote_ost_nodsh && skip "remote OST with nodsh"
12590 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12591 set_nodes_failloc "$(osts_nodes)" 0x214
12592 # multiop should block due to fsync until pages are written
12593 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12597 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12598 error "Multiop failed to block on fsync, pid=$MULTIPID"
12601 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12603 if [[ $WRITEBACK -eq 0 ]]; then
12604 error "No page in writeback, writeback=$WRITEBACK"
12607 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12608 set_nodes_failloc "$(osts_nodes)" 0
12610 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12611 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12613 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12614 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12618 echo "Dirty pages gaurenteed flushed via fsync"
12621 run_test 118d "Fsync validation inject a delay of the bulk =========="
12624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12628 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12629 lctl set_param fail_loc=0x8000040a
12631 # Should simulate EINVAL error which is fatal
12632 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12634 if [[ $RC -eq 0 ]]; then
12635 error "Must return error due to dropped pages, rc=$RC"
12638 lctl set_param fail_loc=0x0
12640 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12641 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12642 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12644 if [[ $LOCKED -ne 0 ]]; then
12645 error "Locked pages remain in cache, locked=$LOCKED"
12648 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12649 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12653 echo "No pages locked after fsync"
12658 run_test 118f "Simulate unrecoverable OSC side error =========="
12661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12665 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12666 lctl set_param fail_loc=0x406
12668 # simulate local -ENOMEM
12669 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12672 lctl set_param fail_loc=0
12673 if [[ $RC -eq 0 ]]; then
12674 error "Must return error due to dropped pages, rc=$RC"
12677 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12678 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12679 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12681 if [[ $LOCKED -ne 0 ]]; then
12682 error "Locked pages remain in cache, locked=$LOCKED"
12685 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12686 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12690 echo "No pages locked after fsync"
12695 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12699 remote_ost_nodsh && skip "remote OST with nodsh"
12703 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12704 set_nodes_failloc "$(osts_nodes)" 0x20e
12705 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12706 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12709 set_nodes_failloc "$(osts_nodes)" 0
12710 if [[ $RC -eq 0 ]]; then
12711 error "Must return error due to dropped pages, rc=$RC"
12714 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12715 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12716 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12718 if [[ $LOCKED -ne 0 ]]; then
12719 error "Locked pages remain in cache, locked=$LOCKED"
12722 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12723 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12727 echo "No pages locked after fsync"
12731 run_test 118h "Verify timeout in handling recoverables errors =========="
12733 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12737 remote_ost_nodsh && skip "remote OST with nodsh"
12741 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12742 set_nodes_failloc "$(osts_nodes)" 0x20e
12744 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12745 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12748 set_nodes_failloc "$(osts_nodes)" 0
12752 if [[ $RC -ne 0 ]]; then
12753 error "got error, but should be not, rc=$RC"
12756 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12757 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12758 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12759 if [[ $LOCKED -ne 0 ]]; then
12760 error "Locked pages remain in cache, locked=$LOCKED"
12763 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12764 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12768 echo "No pages locked after fsync"
12772 run_test 118i "Fix error before timeout in recoverable error =========="
12774 [ "$SLOW" = "no" ] && set_resend_count 4
12777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12778 remote_ost_nodsh && skip "remote OST with nodsh"
12782 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12783 set_nodes_failloc "$(osts_nodes)" 0x220
12785 # return -EIO from OST
12786 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12788 set_nodes_failloc "$(osts_nodes)" 0x0
12789 if [[ $RC -eq 0 ]]; then
12790 error "Must return error due to dropped pages, rc=$RC"
12793 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12794 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12795 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12796 if [[ $LOCKED -ne 0 ]]; then
12797 error "Locked pages remain in cache, locked=$LOCKED"
12800 # in recoverable error on OST we want resend and stay until it finished
12801 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12802 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12806 echo "No pages locked after fsync"
12810 run_test 118j "Simulate unrecoverable OST side error =========="
12814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12815 remote_ost_nodsh && skip "remote OSTs with nodsh"
12817 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12818 set_nodes_failloc "$(osts_nodes)" 0x20e
12819 test_mkdir $DIR/$tdir
12821 for ((i=0;i<10;i++)); do
12822 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12823 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12830 set_nodes_failloc "$(osts_nodes)" 0
12833 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12835 test_118l() # LU-646
12837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12839 test_mkdir $DIR/$tdir
12840 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12843 run_test 118l "fsync dir"
12845 test_118m() # LU-3066
12847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12849 test_mkdir $DIR/$tdir
12850 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12853 run_test 118m "fdatasync dir ========="
12855 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12863 remote_ost_nodsh && skip "remote OSTs with nodsh"
12865 # Sleep to avoid a cached response.
12866 #define OBD_STATFS_CACHE_SECONDS 1
12869 # Inject a 10 second delay in the OST_STATFS handler.
12870 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12871 set_nodes_failloc "$(osts_nodes)" 0x242
12874 stat --file-system $MOUNT > /dev/null
12877 set_nodes_failloc "$(osts_nodes)" 0
12879 if ((end - begin > 20)); then
12880 error "statfs took $((end - begin)) seconds, expected 10"
12883 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12885 test_119a() # bug 11737
12887 BSIZE=$((512 * 1024))
12888 directio write $DIR/$tfile 0 1 $BSIZE
12889 # We ask to read two blocks, which is more than a file size.
12890 # directio will indicate an error when requested and actual
12891 # sizes aren't equeal (a normal situation in this case) and
12892 # print actual read amount.
12893 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12894 if [ "$NOB" != "$BSIZE" ]; then
12895 error "read $NOB bytes instead of $BSIZE"
12899 run_test 119a "Short directIO read must return actual read amount"
12901 test_119b() # bug 11737
12903 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12905 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12906 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12908 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12909 error "direct read failed"
12912 run_test 119b "Sparse directIO read must return actual read amount"
12914 test_119c() # bug 13099
12917 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12918 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12921 run_test 119c "Testing for direct read hitting hole"
12923 test_119d() # bug 15950
12925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12927 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12928 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12930 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12931 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12932 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12933 lctl set_param fail_loc=0x40d
12934 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12937 cat $DIR/$tfile > /dev/null &
12938 lctl set_param fail_loc=0
12941 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12943 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12944 error "the read rpcs have not completed in 2s"
12946 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12948 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12951 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12952 remote_mds_nodsh && skip "remote MDS with nodsh"
12953 test_mkdir -i0 -c1 $DIR/$tdir
12954 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12955 skip_env "no early lock cancel on server"
12957 lru_resize_disable mdc
12958 lru_resize_disable osc
12959 cancel_lru_locks mdc
12960 # asynchronous object destroy at MDT could cause bl ast to client
12961 cancel_lru_locks osc
12963 stat $DIR/$tdir > /dev/null
12964 can1=$(do_facet mds1 \
12965 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12966 awk '/ldlm_cancel/ {print $2}')
12967 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12968 awk '/ldlm_bl_callback/ {print $2}')
12969 test_mkdir -i0 -c1 $DIR/$tdir/d1
12970 can2=$(do_facet mds1 \
12971 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12972 awk '/ldlm_cancel/ {print $2}')
12973 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12974 awk '/ldlm_bl_callback/ {print $2}')
12975 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12976 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12977 lru_resize_enable mdc
12978 lru_resize_enable osc
12980 run_test 120a "Early Lock Cancel: mkdir test"
12983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12984 remote_mds_nodsh && skip "remote MDS with nodsh"
12985 test_mkdir $DIR/$tdir
12986 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12987 skip_env "no early lock cancel on server"
12989 lru_resize_disable mdc
12990 lru_resize_disable osc
12991 cancel_lru_locks mdc
12992 stat $DIR/$tdir > /dev/null
12993 can1=$(do_facet $SINGLEMDS \
12994 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12995 awk '/ldlm_cancel/ {print $2}')
12996 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12997 awk '/ldlm_bl_callback/ {print $2}')
12998 touch $DIR/$tdir/f1
12999 can2=$(do_facet $SINGLEMDS \
13000 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13001 awk '/ldlm_cancel/ {print $2}')
13002 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13003 awk '/ldlm_bl_callback/ {print $2}')
13004 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13005 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13006 lru_resize_enable mdc
13007 lru_resize_enable osc
13009 run_test 120b "Early Lock Cancel: create test"
13012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13013 remote_mds_nodsh && skip "remote MDS with nodsh"
13014 test_mkdir -i0 -c1 $DIR/$tdir
13015 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13016 skip "no early lock cancel on server"
13018 lru_resize_disable mdc
13019 lru_resize_disable osc
13020 test_mkdir -i0 -c1 $DIR/$tdir/d1
13021 test_mkdir -i0 -c1 $DIR/$tdir/d2
13022 touch $DIR/$tdir/d1/f1
13023 cancel_lru_locks mdc
13024 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
13025 can1=$(do_facet mds1 \
13026 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13027 awk '/ldlm_cancel/ {print $2}')
13028 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13029 awk '/ldlm_bl_callback/ {print $2}')
13030 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13031 can2=$(do_facet mds1 \
13032 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13033 awk '/ldlm_cancel/ {print $2}')
13034 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13035 awk '/ldlm_bl_callback/ {print $2}')
13036 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13037 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13038 lru_resize_enable mdc
13039 lru_resize_enable osc
13041 run_test 120c "Early Lock Cancel: link test"
13044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13045 remote_mds_nodsh && skip "remote MDS with nodsh"
13046 test_mkdir -i0 -c1 $DIR/$tdir
13047 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13048 skip_env "no early lock cancel on server"
13050 lru_resize_disable mdc
13051 lru_resize_disable osc
13053 cancel_lru_locks mdc
13054 stat $DIR/$tdir > /dev/null
13055 can1=$(do_facet mds1 \
13056 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13057 awk '/ldlm_cancel/ {print $2}')
13058 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13059 awk '/ldlm_bl_callback/ {print $2}')
13060 chmod a+x $DIR/$tdir
13061 can2=$(do_facet mds1 \
13062 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13063 awk '/ldlm_cancel/ {print $2}')
13064 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13065 awk '/ldlm_bl_callback/ {print $2}')
13066 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13067 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13068 lru_resize_enable mdc
13069 lru_resize_enable osc
13071 run_test 120d "Early Lock Cancel: setattr test"
13074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13075 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13076 skip_env "no early lock cancel on server"
13077 remote_mds_nodsh && skip "remote MDS with nodsh"
13079 local dlmtrace_set=false
13081 test_mkdir -i0 -c1 $DIR/$tdir
13082 lru_resize_disable mdc
13083 lru_resize_disable osc
13084 ! $LCTL get_param debug | grep -q dlmtrace &&
13085 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13086 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13087 cancel_lru_locks mdc
13088 cancel_lru_locks osc
13089 dd if=$DIR/$tdir/f1 of=/dev/null
13090 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13091 # XXX client can not do early lock cancel of OST lock
13092 # during unlink (LU-4206), so cancel osc lock now.
13094 cancel_lru_locks osc
13095 can1=$(do_facet mds1 \
13096 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13097 awk '/ldlm_cancel/ {print $2}')
13098 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13099 awk '/ldlm_bl_callback/ {print $2}')
13100 unlink $DIR/$tdir/f1
13102 can2=$(do_facet mds1 \
13103 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13104 awk '/ldlm_cancel/ {print $2}')
13105 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13106 awk '/ldlm_bl_callback/ {print $2}')
13107 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
13108 $LCTL dk $TMP/cancel.debug.txt
13109 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
13110 $LCTL dk $TMP/blocking.debug.txt
13111 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
13112 lru_resize_enable mdc
13113 lru_resize_enable osc
13115 run_test 120e "Early Lock Cancel: unlink test"
13118 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13119 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13120 skip_env "no early lock cancel on server"
13121 remote_mds_nodsh && skip "remote MDS with nodsh"
13123 test_mkdir -i0 -c1 $DIR/$tdir
13124 lru_resize_disable mdc
13125 lru_resize_disable osc
13126 test_mkdir -i0 -c1 $DIR/$tdir/d1
13127 test_mkdir -i0 -c1 $DIR/$tdir/d2
13128 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
13129 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
13130 cancel_lru_locks mdc
13131 cancel_lru_locks osc
13132 dd if=$DIR/$tdir/d1/f1 of=/dev/null
13133 dd if=$DIR/$tdir/d2/f2 of=/dev/null
13134 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
13135 # XXX client can not do early lock cancel of OST lock
13136 # during rename (LU-4206), so cancel osc lock now.
13138 cancel_lru_locks osc
13139 can1=$(do_facet mds1 \
13140 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13141 awk '/ldlm_cancel/ {print $2}')
13142 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13143 awk '/ldlm_bl_callback/ {print $2}')
13144 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13146 can2=$(do_facet mds1 \
13147 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13148 awk '/ldlm_cancel/ {print $2}')
13149 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13150 awk '/ldlm_bl_callback/ {print $2}')
13151 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13152 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13153 lru_resize_enable mdc
13154 lru_resize_enable osc
13156 run_test 120f "Early Lock Cancel: rename test"
13159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13160 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13161 skip_env "no early lock cancel on server"
13162 remote_mds_nodsh && skip "remote MDS with nodsh"
13164 lru_resize_disable mdc
13165 lru_resize_disable osc
13167 echo create $count files
13168 test_mkdir $DIR/$tdir
13169 cancel_lru_locks mdc
13170 cancel_lru_locks osc
13173 can0=$(do_facet $SINGLEMDS \
13174 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13175 awk '/ldlm_cancel/ {print $2}')
13176 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13177 awk '/ldlm_bl_callback/ {print $2}')
13178 createmany -o $DIR/$tdir/f $count
13180 can1=$(do_facet $SINGLEMDS \
13181 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13182 awk '/ldlm_cancel/ {print $2}')
13183 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13184 awk '/ldlm_bl_callback/ {print $2}')
13186 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13187 echo rm $count files
13190 can2=$(do_facet $SINGLEMDS \
13191 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13192 awk '/ldlm_cancel/ {print $2}')
13193 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13194 awk '/ldlm_bl_callback/ {print $2}')
13196 echo total: $count removes in $((t2-t1))
13197 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13199 # wait for commitment of removal
13200 lru_resize_enable mdc
13201 lru_resize_enable osc
13203 run_test 120g "Early Lock Cancel: performance test"
13205 test_121() { #bug #10589
13206 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13209 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13210 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13211 lctl set_param fail_loc=0x310
13212 cancel_lru_locks osc > /dev/null
13213 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13214 lctl set_param fail_loc=0
13215 [[ $reads -eq $writes ]] ||
13216 error "read $reads blocks, must be $writes blocks"
13218 run_test 121 "read cancel race ========="
13220 test_123a_base() { # was test 123, statahead(bug 11401)
13224 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13225 log "testing UP system. Performance may be lower than expected."
13228 running_in_vm && SLOWOK=1
13231 test_mkdir $DIR/$tdir
13232 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13233 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13235 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13236 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13238 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13239 lctl set_param -n llite.*.statahead_max 0
13240 lctl get_param llite.*.statahead_max
13241 cancel_lru_locks mdc
13242 cancel_lru_locks osc
13244 time $lsx $DIR/$tdir | wc -l
13246 delta=$((etime - stime))
13247 log "$lsx $i files without statahead: $delta sec"
13248 lctl set_param llite.*.statahead_max=$max
13250 swrong=$(lctl get_param -n llite.*.statahead_stats |
13251 awk '/statahead.wrong:/ { print $NF }')
13252 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13253 cancel_lru_locks mdc
13254 cancel_lru_locks osc
13256 time $lsx $DIR/$tdir | wc -l
13258 delta_sa=$((etime - stime))
13259 log "$lsx $i files with statahead: $delta_sa sec"
13260 lctl get_param -n llite.*.statahead_stats
13261 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13262 awk '/statahead.wrong:/ { print $NF }')
13264 [[ $swrong -lt $ewrong ]] &&
13265 log "statahead was stopped, maybe too many locks held!"
13266 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13268 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
13269 max=$(lctl get_param -n llite.*.statahead_max |
13271 lctl set_param -n llite.*.statahead_max 0
13272 lctl get_param llite.*.statahead_max
13273 cancel_lru_locks mdc
13274 cancel_lru_locks osc
13276 time $lsx $DIR/$tdir | wc -l
13278 delta=$((etime - stime))
13279 log "$lsx $i files again without statahead: $delta sec"
13280 lctl set_param llite.*.statahead_max=$max
13281 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
13282 if [ $SLOWOK -eq 0 ]; then
13283 error "$lsx $i files is slower with statahead!"
13285 log "$lsx $i files is slower with statahead!"
13291 [ $delta -gt 20 ] && break
13292 [ $delta -gt 8 ] && MULT=$((50 / delta))
13293 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
13301 delta=$((etime - stime))
13302 log "rm -r $DIR/$tdir/: $delta seconds"
13304 lctl get_param -n llite.*.statahead_stats
13308 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13310 test_123a_base "ls -l"
13312 run_test 123aa "verify statahead work"
13315 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13317 statx_supported || skip_env "Test must be statx() syscall supported"
13319 test_123a_base "$STATX -l"
13321 run_test 123ab "verify statahead work by using statx"
13324 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13326 statx_supported || skip_env "Test must be statx() syscall supported"
13333 cancel_lru_locks $OSC
13334 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13335 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
13336 awk '/agl.total:/ { print $NF }')
13337 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
13338 test_123a_base "$STATX --cached=always -D"
13339 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
13340 awk '/agl.total:/ { print $NF }')
13341 [ $agl_before -eq $agl_after ] ||
13342 error "Should not trigger AGL thread - $agl_before:$agl_after"
13343 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13344 [ $rpcs_after -eq $rpcs_before ] ||
13345 error "$STATX should not send glimpse RPCs to $OSC"
13347 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
13349 test_123b () { # statahead(bug 15027)
13350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13352 test_mkdir $DIR/$tdir
13353 createmany -o $DIR/$tdir/$tfile-%d 1000
13355 cancel_lru_locks mdc
13356 cancel_lru_locks osc
13358 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13359 lctl set_param fail_loc=0x80000803
13360 ls -lR $DIR/$tdir > /dev/null
13362 lctl set_param fail_loc=0x0
13363 lctl get_param -n llite.*.statahead_stats
13368 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13371 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13373 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13374 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13375 touch $DIR/$tdir.1/{1..3}
13376 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13378 remount_client $MOUNT
13380 $MULTIOP $DIR/$tdir.0 Q
13382 # let statahead to complete
13383 ls -l $DIR/$tdir.0 > /dev/null
13385 testid=$(echo $TESTNAME | tr '_' ' ')
13386 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13387 error "statahead warning" || true
13389 run_test 123c "Can not initialize inode warning on DNE statahead"
13396 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
13397 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
13398 error "setdirstripe $DIR/$tdir failed"
13399 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
13400 remount_client $MOUNT
13401 $LCTL get_param llite.*.statahead_max
13402 $LCTL set_param llite.*.statahead_stats=0 ||
13403 error "clear statahead_stats failed"
13404 swrong=$(lctl get_param -n llite.*.statahead_stats |
13405 awk '/statahead.wrong:/ { print $NF }')
13406 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
13407 # wait for statahead thread finished to update hit/miss stats.
13409 $LCTL get_param -n llite.*.statahead_stats
13410 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13411 awk '/statahead.wrong:/ { print $NF }')
13412 (( $swrong == $ewrong )) ||
13413 log "statahead was stopped, maybe too many locks held!"
13415 run_test 123d "Statahead on striped directories works correctly"
13418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13419 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13420 skip_env "no lru resize on server"
13424 test_mkdir $DIR/$tdir
13426 log "create $NR files at $DIR/$tdir"
13427 createmany -o $DIR/$tdir/f $NR ||
13428 error "failed to create $NR files in $DIR/$tdir"
13430 cancel_lru_locks mdc
13431 ls -l $DIR/$tdir > /dev/null
13435 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13436 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13437 LRU_SIZE=$($LCTL get_param -n $PARAM)
13438 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13439 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13441 log "NS=$(basename $NSDIR)"
13446 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13447 skip "Not enough cached locks created!"
13449 log "LRU=$LRU_SIZE"
13453 # We know that lru resize allows one client to hold $LIMIT locks
13454 # for 10h. After that locks begin to be killed by client.
13456 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13458 if [ $LIMIT -lt $LRU_SIZE ]; then
13459 skip "Limit is too small $LIMIT"
13462 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13463 # killing locks. Some time was spent for creating locks. This means
13464 # that up to the moment of sleep finish we must have killed some of
13465 # them (10-100 locks). This depends on how fast ther were created.
13466 # Many of them were touched in almost the same moment and thus will
13467 # be killed in groups.
13468 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13470 # Use $LRU_SIZE_B here to take into account real number of locks
13471 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13472 local LRU_SIZE_B=$LRU_SIZE
13474 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13475 log "OLD_LVF=$OLD_LVF"
13476 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13478 # Let's make sure that we really have some margin. Client checks
13479 # cached locks every 10 sec.
13480 SLEEP=$((SLEEP+20))
13481 log "Sleep ${SLEEP} sec"
13483 while ((SEC<$SLEEP)); do
13487 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13488 echo -n "$LRU_SIZE"
13491 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13492 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13494 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13495 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13496 unlinkmany $DIR/$tdir/f $NR
13500 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13501 log "unlink $NR files at $DIR/$tdir"
13502 unlinkmany $DIR/$tdir/f $NR
13504 run_test 124a "lru resize ======================================="
13506 get_max_pool_limit()
13508 local limit=$($LCTL get_param \
13509 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13511 for l in $limit; do
13512 if [[ $l -gt $max ]]; then
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 LIMIT=$(get_max_pool_limit)
13526 NR=$(($(default_lru_size)*20))
13527 if [[ $NR -gt $LIMIT ]]; then
13528 log "Limit lock number by $LIMIT locks"
13532 IFree=$(mdsrate_inodes_available)
13533 if [ $IFree -lt $NR ]; then
13534 log "Limit lock number by $IFree inodes"
13538 lru_resize_disable mdc
13539 test_mkdir -p $DIR/$tdir/disable_lru_resize
13541 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13542 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13543 cancel_lru_locks mdc
13546 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13549 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13552 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13556 nolruresize_delta=$((etime-stime))
13557 log "ls -la time: $nolruresize_delta seconds"
13558 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13559 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13561 lru_resize_enable mdc
13562 test_mkdir -p $DIR/$tdir/enable_lru_resize
13564 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13565 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13566 cancel_lru_locks mdc
13569 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13572 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13575 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13579 lruresize_delta=$((etime-stime))
13580 log "ls -la time: $lruresize_delta seconds"
13581 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13583 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13584 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13585 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13586 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13588 log "lru resize performs the same with no lru resize"
13590 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13592 run_test 124b "lru resize (performance test) ======================="
13595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13596 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13597 skip_env "no lru resize on server"
13599 # cache ununsed locks on client
13601 cancel_lru_locks mdc
13602 test_mkdir $DIR/$tdir
13603 createmany -o $DIR/$tdir/f $nr ||
13604 error "failed to create $nr files in $DIR/$tdir"
13605 ls -l $DIR/$tdir > /dev/null
13607 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13608 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13609 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13610 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13611 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13613 # set lru_max_age to 1 sec
13614 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13615 echo "sleep $((recalc_p * 2)) seconds..."
13616 sleep $((recalc_p * 2))
13618 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13619 # restore lru_max_age
13620 $LCTL set_param -n $nsdir.lru_max_age $max_age
13621 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13622 unlinkmany $DIR/$tdir/f $nr
13624 run_test 124c "LRUR cancel very aged locks"
13627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13628 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13629 skip_env "no lru resize on server"
13631 # cache ununsed locks on client
13634 lru_resize_disable mdc
13635 stack_trap "lru_resize_enable mdc" EXIT
13637 cancel_lru_locks mdc
13639 # asynchronous object destroy at MDT could cause bl ast to client
13640 test_mkdir $DIR/$tdir
13641 createmany -o $DIR/$tdir/f $nr ||
13642 error "failed to create $nr files in $DIR/$tdir"
13643 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13645 ls -l $DIR/$tdir > /dev/null
13647 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13648 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13649 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13650 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13652 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13654 # set lru_max_age to 1 sec
13655 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13656 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13658 echo "sleep $((recalc_p * 2)) seconds..."
13659 sleep $((recalc_p * 2))
13661 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13663 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13665 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13667 test_125() { # 13358
13668 $LCTL get_param -n llite.*.client_type | grep -q local ||
13669 skip "must run as local client"
13670 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13671 skip_env "must have acl enabled"
13672 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13674 test_mkdir $DIR/$tdir
13675 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13676 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
13677 error "setfacl $DIR/$tdir failed"
13678 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13680 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13682 test_126() { # bug 12829/13455
13683 $GSS && skip_env "must run as gss disabled"
13684 $LCTL get_param -n llite.*.client_type | grep -q local ||
13685 skip "must run as local client"
13686 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13688 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13689 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13691 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13693 run_test 126 "check that the fsgid provided by the client is taken into account"
13695 test_127a() { # bug 15521
13696 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13697 local name count samp unit min max sum sumsq
13699 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13700 echo "stats before reset"
13701 $LCTL get_param osc.*.stats
13702 $LCTL set_param osc.*.stats=0
13703 local fsize=$((2048 * 1024))
13705 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13706 cancel_lru_locks osc
13707 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13709 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
13710 stack_trap "rm -f $TMP/$tfile.tmp"
13711 while read name count samp unit min max sum sumsq; do
13712 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13713 [ ! $min ] && error "Missing min value for $name proc entry"
13714 eval $name=$count || error "Wrong proc format"
13717 read_bytes|write_bytes)
13718 [[ "$unit" =~ "bytes" ]] ||
13719 error "unit is not 'bytes': $unit"
13720 (( $min >= 4096 )) || error "min is too small: $min"
13721 (( $min <= $fsize )) || error "min is too big: $min"
13722 (( $max >= 4096 )) || error "max is too small: $max"
13723 (( $max <= $fsize )) || error "max is too big: $max"
13724 (( $sum == $fsize )) || error "sum is wrong: $sum"
13725 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13726 error "sumsquare is too small: $sumsq"
13727 (( $sumsq <= $fsize * $fsize )) ||
13728 error "sumsquare is too big: $sumsq"
13730 ost_read|ost_write)
13731 [[ "$unit" =~ "usec" ]] ||
13732 error "unit is not 'usec': $unit"
13736 done < $DIR/$tfile.tmp
13738 #check that we actually got some stats
13739 [ "$read_bytes" ] || error "Missing read_bytes stats"
13740 [ "$write_bytes" ] || error "Missing write_bytes stats"
13741 [ "$read_bytes" != 0 ] || error "no read done"
13742 [ "$write_bytes" != 0 ] || error "no write done"
13744 run_test 127a "verify the client stats are sane"
13746 test_127b() { # bug LU-333
13747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13748 local name count samp unit min max sum sumsq
13750 echo "stats before reset"
13751 $LCTL get_param llite.*.stats
13752 $LCTL set_param llite.*.stats=0
13754 # perform 2 reads and writes so MAX is different from SUM.
13755 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13756 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13757 cancel_lru_locks osc
13758 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13759 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13761 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13762 stack_trap "rm -f $TMP/$tfile.tmp"
13763 while read name count samp unit min max sum sumsq; do
13764 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13765 eval $name=$count || error "Wrong proc format"
13768 read_bytes|write_bytes)
13769 [[ "$unit" =~ "bytes" ]] ||
13770 error "unit is not 'bytes': $unit"
13771 (( $count == 2 )) || error "count is not 2: $count"
13772 (( $min == $PAGE_SIZE )) ||
13773 error "min is not $PAGE_SIZE: $min"
13774 (( $max == $PAGE_SIZE )) ||
13775 error "max is not $PAGE_SIZE: $max"
13776 (( $sum == $PAGE_SIZE * 2 )) ||
13777 error "sum is not $((PAGE_SIZE * 2)): $sum"
13780 [[ "$unit" =~ "usec" ]] ||
13781 error "unit is not 'usec': $unit"
13785 done < $TMP/$tfile.tmp
13787 #check that we actually got some stats
13788 [ "$read_bytes" ] || error "Missing read_bytes stats"
13789 [ "$write_bytes" ] || error "Missing write_bytes stats"
13790 [ "$read_bytes" != 0 ] || error "no read done"
13791 [ "$write_bytes" != 0 ] || error "no write done"
13793 run_test 127b "verify the llite client stats are sane"
13795 test_127c() { # LU-12394
13796 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13803 $LCTL set_param llite.*.extents_stats=1
13804 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13806 # Use two stripes so there is enough space in default config
13807 $LFS setstripe -c 2 $DIR/$tfile
13809 # Extent stats start at 0-4K and go in power of two buckets
13810 # LL_HIST_START = 12 --> 2^12 = 4K
13811 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13812 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13814 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13816 # Write and read, 2x each, second time at a non-zero offset
13817 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13818 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13819 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13820 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13824 $LCTL get_param llite.*.extents_stats
13827 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13829 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13831 reads=$(echo $bucket | awk '{print $5}')
13832 writes=$(echo $bucket | awk '{print $9}')
13833 [ "$reads" -eq $count ] ||
13834 error "$reads reads in < $bsize bucket, expect $count"
13835 [ "$writes" -eq $count ] ||
13836 error "$writes writes in < $bsize bucket, expect $count"
13839 # Test mmap write and read
13840 $LCTL set_param llite.*.extents_stats=c
13842 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13843 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13844 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13846 $LCTL get_param llite.*.extents_stats
13848 count=$(((size*1024) / PAGE_SIZE))
13850 bsize=$((2 * PAGE_SIZE / 1024))K
13852 bucket=$($LCTL get_param -n llite.*.extents_stats |
13854 reads=$(echo $bucket | awk '{print $5}')
13855 writes=$(echo $bucket | awk '{print $9}')
13856 # mmap writes fault in the page first, creating an additonal read
13857 [ "$reads" -eq $((2 * count)) ] ||
13858 error "$reads reads in < $bsize bucket, expect $count"
13859 [ "$writes" -eq $count ] ||
13860 error "$writes writes in < $bsize bucket, expect $count"
13862 run_test 127c "test llite extent stats with regular & mmap i/o"
13864 test_128() { # bug 15212
13866 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13871 result=$(grep error $TMP/$tfile.log)
13872 rm -f $DIR/$tfile $TMP/$tfile.log
13873 [ -z "$result" ] ||
13874 error "consecutive find's under interactive lfs failed"
13876 run_test 128 "interactive lfs for 2 consecutive find's"
13878 set_dir_limits () {
13883 local ldproc=/proc/fs/ldiskfs
13884 local facets=$(get_facets MDS)
13886 for facet in ${facets//,/ }; do
13887 canondev=$(ldiskfs_canon \
13888 *.$(convert_facet2label $facet).mntdev $facet)
13889 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13890 ldproc=/sys/fs/ldiskfs
13891 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13892 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13896 check_mds_dmesg() {
13897 local facets=$(get_facets MDS)
13898 for facet in ${facets//,/ }; do
13899 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13906 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13907 skip "Need MDS version with at least 2.5.56"
13908 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13909 skip_env "ldiskfs only test"
13911 remote_mds_nodsh && skip "remote MDS with nodsh"
13914 local has_warning=false
13917 mkdir -p $DIR/$tdir
13919 # block size of mds1
13920 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13921 set_dir_limits $maxsize $((maxsize * 6 / 8))
13922 stack_trap "set_dir_limits 0 0"
13923 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13924 local dirsize=$(stat -c%s "$DIR/$tdir")
13926 while (( $dirsize <= $maxsize )); do
13927 $MCREATE $DIR/$tdir/file_base_$nfiles
13929 # check two errors:
13930 # ENOSPC for ext4 max_dir_size, which has been used since
13931 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13932 if (( rc == ENOSPC )); then
13934 echo "rc=$rc returned as expected after $nfiles files"
13936 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13937 error "create failed w/o dir size limit"
13939 # messages may be rate limited if test is run repeatedly
13940 check_mds_dmesg '"is approaching max"' ||
13941 echo "warning message should be output"
13942 check_mds_dmesg '"has reached max"' ||
13943 echo "reached message should be output"
13945 dirsize=$(stat -c%s "$DIR/$tdir")
13947 [[ $dirsize -ge $maxsize ]] && return 0
13948 error "dirsize $dirsize < $maxsize after $nfiles files"
13949 elif (( rc != 0 )); then
13952 nfiles=$((nfiles + 1))
13953 dirsize=$(stat -c%s "$DIR/$tdir")
13956 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13958 run_test 129 "test directory size limit ========================"
13967 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13968 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
13970 trap cleanup_130 EXIT RETURN
13972 local fm_file=$DIR/$tfile
13973 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13974 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13975 error "dd failed for $fm_file"
13977 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
13978 filefrag -ves $fm_file
13980 [[ "$ost1_FSTYPE" != "zfs" ]] ||
13981 skip "LU-1941: FIEMAP unimplemented on ZFS"
13982 (( $rc == 0 )) || error "filefrag $fm_file failed"
13984 filefrag_op=$(filefrag -ve -k $fm_file |
13985 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13986 local lun=$($LFS getstripe -i $fm_file)
13988 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
13991 for line in $filefrag_op; do
13992 local frag_lun=$(echo $line | cut -d: -f5)
13993 local ext_len=$(echo $line | cut -d: -f4)
13995 if (( $frag_lun != $lun )); then
13996 error "FIEMAP on 1-stripe file($fm_file) failed"
13999 (( tot_len += ext_len ))
14002 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
14003 error "FIEMAP on 1-stripe file($fm_file) failed"
14007 echo "FIEMAP on single striped file succeeded"
14009 run_test 130a "FIEMAP (1-stripe file)"
14012 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14014 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14015 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14016 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14017 skip "LU-1941: FIEMAP unimplemented on ZFS"
14019 trap cleanup_130 EXIT RETURN
14021 local fm_file=$DIR/$tfile
14022 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14023 error "setstripe on $fm_file"
14025 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
14026 error "dd failed on $fm_file"
14028 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14029 filefrag_op=$(filefrag -ve -k $fm_file |
14030 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14032 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14033 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14039 for line in $filefrag_op; do
14040 local frag_lun=$(echo $line | cut -d: -f5 |
14041 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14042 local ext_len=$(echo $line | cut -d: -f4)
14043 if (( $frag_lun != $last_lun )); then
14044 if (( tot_len != 1024 )); then
14045 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14048 (( num_luns += 1 ))
14052 (( tot_len += ext_len ))
14055 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
14056 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14060 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
14062 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
14065 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14067 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14068 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14069 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14070 skip "LU-1941: FIEMAP unimplemented on ZFS"
14072 trap cleanup_130 EXIT RETURN
14074 local fm_file=$DIR/$tfile
14075 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
14077 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
14078 error "dd failed on $fm_file"
14080 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14081 filefrag_op=$(filefrag -ve -k $fm_file |
14082 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14084 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14085 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14090 for line in $filefrag_op; do
14091 local frag_lun=$(echo $line | cut -d: -f5 |
14092 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14093 local ext_len=$(echo $line | cut -d: -f4)
14094 if (( $frag_lun != $last_lun )); then
14095 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
14096 if (( logical != 512 )); then
14097 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
14100 if (( tot_len != 512 )); then
14101 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14104 (( num_luns += 1 ))
14108 (( tot_len += ext_len ))
14111 if (( num_luns != 2 || tot_len != 512 )); then
14112 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14116 echo "FIEMAP on 2-stripe file with hole succeeded"
14118 run_test 130c "FIEMAP (2-stripe file with hole)"
14121 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
14123 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14124 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14125 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14126 skip "LU-1941: FIEMAP unimplemented on ZFS"
14128 trap cleanup_130 EXIT RETURN
14130 local fm_file=$DIR/$tfile
14131 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
14132 error "setstripe on $fm_file"
14134 local actual_stripe_count=$($LFS getstripe -c $fm_file)
14135 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
14136 error "dd failed on $fm_file"
14138 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14139 filefrag_op=$(filefrag -ve -k $fm_file |
14140 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14142 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
14143 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14148 for line in $filefrag_op; do
14149 local frag_lun=$(echo $line | cut -d: -f5 |
14150 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
14151 local ext_len=$(echo $line | cut -d: -f4)
14152 if (( $frag_lun != $last_lun )); then
14153 if (( tot_len != 1024 )); then
14154 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
14157 (( num_luns += 1 ))
14161 (( tot_len += ext_len ))
14164 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
14165 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
14169 echo "FIEMAP on N-stripe file succeeded"
14171 run_test 130d "FIEMAP (N-stripe file)"
14174 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
14176 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14177 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14178 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14179 skip "LU-1941: FIEMAP unimplemented on ZFS"
14181 trap cleanup_130 EXIT RETURN
14183 local fm_file=$DIR/$tfile
14184 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
14187 local expected_len=$(( (num_blks / 2) * 64 ))
14188 for ((i = 0; i < $num_blks; i++)); do
14189 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
14190 conv=notrunc > /dev/null 2>&1
14193 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14194 filefrag_op=$(filefrag -ve -k $fm_file |
14195 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14197 local last_lun=$(echo $filefrag_op | cut -d: -f5)
14202 for line in $filefrag_op; do
14203 local frag_lun=$(echo $line | cut -d: -f5)
14204 local ext_len=$(echo $line | cut -d: -f4)
14205 if (( $frag_lun != $last_lun )); then
14206 if (( tot_len != $expected_len )); then
14207 error "OST$last_lun $tot_len != $expected_len"
14209 (( num_luns += 1 ))
14213 (( tot_len += ext_len ))
14216 if (( num_luns != 2 || tot_len != $expected_len )); then
14217 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
14220 echo "FIEMAP with continuation calls succeeded"
14222 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
14225 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14226 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14227 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14228 skip "LU-1941: FIEMAP unimplemented on ZFS"
14230 local fm_file=$DIR/$tfile
14231 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
14232 error "multiop create with lov_delay_create on $fm_file"
14234 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14235 filefrag_extents=$(filefrag -vek $fm_file |
14236 awk '/extents? found/ { print $2 }')
14237 if (( $filefrag_extents != 0 )); then
14238 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
14243 run_test 130f "FIEMAP (unstriped file)"
14246 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
14247 skip "Need MDS version with at least 2.12.53 for overstriping"
14248 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
14249 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
14250 [[ "$ost1_FSTYPE" != "zfs" ]] ||
14251 skip "LU-1941: FIEMAP unimplemented on ZFS"
14253 local file=$DIR/$tfile
14254 local nr=$((OSTCOUNT * 100))
14256 $LFS setstripe -C $nr $file || error "failed to setstripe -C $nr $file"
14258 stack_trap "rm -f $file"
14259 dd if=/dev/zero of=$file count=$nr bs=1M
14261 nr=$($LFS getstripe -c $file)
14263 local extents=$(filefrag -v $file |
14264 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
14266 echo "filefrag list $extents extents in file with stripecount $nr"
14267 if (( extents < nr )); then
14268 $LFS getstripe $file
14270 error "filefrag printed $extents < $nr extents"
14273 run_test 130g "FIEMAP (overstripe file)"
14275 # Test for writev/readv
14277 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
14278 error "writev test failed"
14279 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
14280 error "readv failed"
14283 run_test 131a "test iov's crossing stripe boundary for writev/readv"
14286 local fsize=$((524288 + 1048576 + 1572864))
14287 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
14288 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14289 error "append writev test failed"
14291 ((fsize += 1572864 + 1048576))
14292 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
14293 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14294 error "append writev test failed"
14297 run_test 131b "test append writev"
14300 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
14303 run_test 131c "test read/write on file w/o objects"
14306 rwv -f $DIR/$tfile -w -n 1 1572864
14307 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
14308 if [ "$NOB" != 1572864 ]; then
14309 error "Short read filed: read $NOB bytes instead of 1572864"
14313 run_test 131d "test short read"
14316 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
14317 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
14318 error "read hitting hole failed"
14321 run_test 131e "test read hitting hole"
14329 # open 11 samples [usecs] 468 4793 13658 35791898
14331 mds*) res=($(do_facet $facet \
14332 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
14334 ost*) res=($(do_facet $facet \
14335 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
14337 *) error "Wrong facet '$facet'" ;;
14339 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
14340 # if $want is zero, it means any stat increment is ok.
14341 if (( $want > 0 )); then
14342 local count=${res[1]}
14344 if (( $count != $want )); then
14345 if [[ $facet =~ "mds" ]]; then
14346 do_nodes $(comma_list $(mdts_nodes)) \
14347 $LCTL get_param mdt.*.md_stats
14349 do_nodes $(comma_list $(osts-nodes)) \
14350 $LCTL get_param obdfilter.*.stats
14352 error "The $op counter on $facet is $count, not $want"
14358 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14359 remote_ost_nodsh && skip "remote OST with nodsh"
14360 remote_mds_nodsh && skip "remote MDS with nodsh"
14361 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14362 skip_env "MDS doesn't support rename stats"
14364 local testdir=$DIR/${tdir}/stats_testdir
14366 mkdir -p $DIR/${tdir}
14369 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14370 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14372 # verify mdt stats first.
14373 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14374 check_stats $SINGLEMDS "mkdir" 1
14376 # clear "open" from "lfs mkdir" above
14377 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14378 touch ${testdir}/${tfile} || error "touch failed"
14379 check_stats $SINGLEMDS "open" 1
14380 check_stats $SINGLEMDS "close" 1
14381 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14382 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14383 check_stats $SINGLEMDS "mknod" 2
14385 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14386 check_stats $SINGLEMDS "unlink" 1
14387 rm -f ${testdir}/${tfile} || error "file remove failed"
14388 check_stats $SINGLEMDS "unlink" 2
14390 # remove working dir and check mdt stats again.
14391 rmdir ${testdir} || error "rmdir failed"
14392 check_stats $SINGLEMDS "rmdir" 1
14394 local testdir1=$DIR/${tdir}/stats_testdir1
14395 mkdir -p ${testdir}
14396 mkdir -p ${testdir1}
14397 touch ${testdir1}/test1
14398 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14399 check_stats $SINGLEMDS "crossdir_rename" 1
14401 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14402 check_stats $SINGLEMDS "samedir_rename" 1
14404 rm -rf $DIR/${tdir}
14406 run_test 133a "Verifying MDT stats ========================================"
14411 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14412 remote_ost_nodsh && skip "remote OST with nodsh"
14413 remote_mds_nodsh && skip "remote MDS with nodsh"
14415 local testdir=$DIR/${tdir}/stats_testdir
14417 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
14418 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
14419 touch ${testdir}/${tfile} || error "touch failed"
14420 cancel_lru_locks mdc
14423 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14424 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14426 # extra mdt stats verification.
14427 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14428 check_stats $SINGLEMDS "setattr" 1
14429 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14430 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14432 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14433 check_stats $SINGLEMDS "getattr" 1
14435 rm -rf $DIR/${tdir}
14437 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14438 # so the check below is not reliable
14439 [ $MDSCOUNT -eq 1 ] || return 0
14441 # Sleep to avoid a cached response.
14442 #define OBD_STATFS_CACHE_SECONDS 1
14444 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14445 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14446 $LFS df || error "lfs failed"
14447 check_stats $SINGLEMDS "statfs" 1
14449 # check aggregated statfs (LU-10018)
14450 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14452 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14455 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14456 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14458 check_stats $SINGLEMDS "statfs" 1
14460 # We want to check that the client didn't send OST_STATFS to
14461 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14462 # extra care is needed here.
14463 if remote_mds; then
14464 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14465 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14467 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14468 [ "$res" ] && error "OST got STATFS"
14473 run_test 133b "Verifying extra MDT stats =================================="
14476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14477 remote_ost_nodsh && skip "remote OST with nodsh"
14478 remote_mds_nodsh && skip "remote MDS with nodsh"
14480 local testdir=$DIR/$tdir/stats_testdir
14482 test_mkdir -p $testdir
14484 # verify obdfilter stats.
14485 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14487 cancel_lru_locks osc
14488 wait_delete_completed
14491 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14492 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14494 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14497 cancel_lru_locks osc
14498 check_stats ost1 "write" 1
14500 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14501 check_stats ost1 "read" 1
14503 > $testdir/$tfile || error "truncate failed"
14504 check_stats ost1 "punch" 1
14506 rm -f $testdir/$tfile || error "file remove failed"
14507 wait_delete_completed
14508 check_stats ost1 "destroy" 1
14512 run_test 133c "Verifying OST stats ========================================"
14519 while [ $value -ge 2 ]; do
14524 if [ $orig -gt $order ]; then
14532 local size=('K' 'M' 'G' 'T');
14534 local size_string=$value
14536 while [ $value -ge 1024 ]; do
14537 if [ $i -gt 3 ]; then
14538 #T is the biggest unit we get here, if that is bigger,
14540 size_string=${value}T
14543 value=$((value >> 10))
14544 if [ $value -lt 1024 ]; then
14545 size_string=${value}${size[$i]}
14554 get_rename_size() {
14556 local context=${2:-.}
14557 local sample=$(do_facet $SINGLEMDS $LCTL \
14558 get_param mdt.$FSNAME-MDT0000.rename_stats |
14559 grep -A1 $context |
14560 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14566 remote_ost_nodsh && skip "remote OST with nodsh"
14567 remote_mds_nodsh && skip "remote MDS with nodsh"
14568 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14569 skip_env "MDS doesn't support rename stats"
14571 local testdir1=$DIR/${tdir}/stats_testdir1
14572 local testdir2=$DIR/${tdir}/stats_testdir2
14573 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
14575 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14577 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
14578 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
14580 createmany -o $testdir1/test 512 || error "createmany failed"
14582 # check samedir rename size
14583 mv ${testdir1}/test0 ${testdir1}/test_0
14585 local testdir1_size=$(ls -l $DIR/${tdir} |
14586 awk '/stats_testdir1/ {print $5}')
14587 local testdir2_size=$(ls -l $DIR/${tdir} |
14588 awk '/stats_testdir2/ {print $5}')
14590 testdir1_size=$(order_2 $testdir1_size)
14591 testdir2_size=$(order_2 $testdir2_size)
14593 testdir1_size=$(size_in_KMGT $testdir1_size)
14594 testdir2_size=$(size_in_KMGT $testdir2_size)
14596 echo "source rename dir size: ${testdir1_size}"
14597 echo "target rename dir size: ${testdir2_size}"
14599 local cmd="do_facet $SINGLEMDS $LCTL "
14600 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14602 eval $cmd || error "$cmd failed"
14603 local samedir=$($cmd | grep 'same_dir')
14604 local same_sample=$(get_rename_size $testdir1_size)
14605 [ -z "$samedir" ] && error "samedir_rename_size count error"
14606 [[ $same_sample -eq 1 ]] ||
14607 error "samedir_rename_size error $same_sample"
14608 echo "Check same dir rename stats success"
14610 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14612 # check crossdir rename size
14613 mv ${testdir1}/test_0 ${testdir2}/test_0
14615 testdir1_size=$(ls -l $DIR/${tdir} |
14616 awk '/stats_testdir1/ {print $5}')
14617 testdir2_size=$(ls -l $DIR/${tdir} |
14618 awk '/stats_testdir2/ {print $5}')
14620 testdir1_size=$(order_2 $testdir1_size)
14621 testdir2_size=$(order_2 $testdir2_size)
14623 testdir1_size=$(size_in_KMGT $testdir1_size)
14624 testdir2_size=$(size_in_KMGT $testdir2_size)
14626 echo "source rename dir size: ${testdir1_size}"
14627 echo "target rename dir size: ${testdir2_size}"
14629 eval $cmd || error "$cmd failed"
14630 local crossdir=$($cmd | grep 'crossdir')
14631 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14632 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14633 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14634 [[ $src_sample -eq 1 ]] ||
14635 error "crossdir_rename_size error $src_sample"
14636 [[ $tgt_sample -eq 1 ]] ||
14637 error "crossdir_rename_size error $tgt_sample"
14638 echo "Check cross dir rename stats success"
14639 rm -rf $DIR/${tdir}
14641 run_test 133d "Verifying rename_stats ========================================"
14644 remote_mds_nodsh && skip "remote MDS with nodsh"
14645 remote_ost_nodsh && skip "remote OST with nodsh"
14646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14648 local testdir=$DIR/${tdir}/stats_testdir
14649 local ctr f0 f1 bs=32768 count=42 sum
14651 mkdir -p ${testdir} || error "mkdir failed"
14653 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14655 for ctr in {write,read}_bytes; do
14657 cancel_lru_locks osc
14659 do_facet ost1 $LCTL set_param -n \
14660 "obdfilter.*.exports.clear=clear"
14662 if [ $ctr = write_bytes ]; then
14664 f1=${testdir}/${tfile}
14666 f0=${testdir}/${tfile}
14670 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14673 cancel_lru_locks osc
14675 sum=$(do_facet ost1 $LCTL get_param \
14676 "obdfilter.*.exports.*.stats" |
14677 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14678 $1 == ctr { sum += $7 }
14679 END { printf("%0.0f", sum) }')
14681 if ((sum != bs * count)); then
14682 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14686 rm -rf $DIR/${tdir}
14688 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14691 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14692 skip "too old lustre for get_param -R ($facet_ver)"
14694 # verifying readability.
14695 $LCTL get_param -R '*' &> /dev/null
14697 # Verifing writability with badarea_io.
14698 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14699 local skipped_params='force_lbug|changelog_mask|daemon_file'
14700 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14701 egrep -v "$skipped_params" |
14702 xargs -n 1 find $proc_dirs -name |
14703 xargs -n 1 badarea_io ||
14704 error "client badarea_io failed"
14706 # remount the FS in case writes/reads /proc break the FS
14707 cleanup || error "failed to unmount"
14708 setup || error "failed to setup"
14710 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14713 remote_mds_nodsh && skip "remote MDS with nodsh"
14714 remote_ost_nodsh && skip "remote OST with nodsh"
14716 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14717 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14719 for facet in mds1 ost1; do
14720 local facet_ver=$(lustre_version_code $facet)
14721 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14722 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14724 log "$facet: too old lustre for get_param -R"
14726 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14727 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14728 tr -d = | egrep -v $skipped_params |
14729 xargs -n 1 find $proc_dirs -name |
14730 xargs -n 1 badarea_io" ||
14731 error "$facet badarea_io failed"
14733 skip_noexit "$facet: too old lustre for get_param -R"
14737 # remount the FS in case writes/reads /proc break the FS
14738 cleanup || error "failed to unmount"
14739 setup || error "failed to setup"
14741 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14744 remote_mds_nodsh && skip "remote MDS with nodsh"
14745 remote_ost_nodsh && skip "remote OST with nodsh"
14746 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14747 skip "Need MDS version at least 2.9.54"
14750 for facet in client mds1 ost1; do
14751 # Get the list of files that are missing the terminating newline
14752 local plist=$(do_facet $facet
14753 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14755 for ent in $plist; do
14756 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14757 awk -v FS='\v' -v RS='\v\v' \
14758 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14759 print FILENAME}'" 2>/dev/null)
14760 [ -z $missing ] || {
14761 do_facet $facet $LCTL get_param $ent | od -An -tx1
14762 error "file does not end with newline: $facet-$ent"
14767 run_test 133h "Proc files should end with newlines"
14770 remote_mds_nodsh && skip "remote MDS with nodsh"
14771 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14772 skip "Need MDS version at least 2.7.54"
14774 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14775 cancel_lru_locks mdc
14777 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14778 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14779 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14782 createmany -o $DIR/$tdir/f $nr ||
14783 error "failed to create $nr files in $DIR/$tdir"
14784 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14786 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14787 do_facet mds1 $LCTL set_param fail_loc=0x327
14788 do_facet mds1 $LCTL set_param fail_val=500
14791 echo "sleep 10 seconds ..."
14793 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14795 do_facet mds1 $LCTL set_param fail_loc=0
14796 do_facet mds1 $LCTL set_param fail_val=0
14797 [ $lck_cnt -lt $unused ] ||
14798 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14801 unlinkmany $DIR/$tdir/f $nr
14803 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14806 remote_mds_nodsh && skip "remote MDS with nodsh"
14807 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14808 skip "Need MDS version at least 2.7.54"
14810 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14811 cancel_lru_locks mdc
14813 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14814 ldlm.lock_reclaim_threshold_mb)
14815 # disable reclaim temporarily
14816 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14818 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14819 do_facet mds1 $LCTL set_param fail_loc=0x328
14820 do_facet mds1 $LCTL set_param fail_val=500
14822 $LCTL set_param debug=+trace
14825 createmany -o $DIR/$tdir/f $nr &
14826 local create_pid=$!
14828 echo "Sleep $TIMEOUT seconds ..."
14830 if ! ps -p $create_pid > /dev/null 2>&1; then
14831 do_facet mds1 $LCTL set_param fail_loc=0
14832 do_facet mds1 $LCTL set_param fail_val=0
14833 do_facet mds1 $LCTL set_param \
14834 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14835 error "createmany finished incorrectly!"
14837 do_facet mds1 $LCTL set_param fail_loc=0
14838 do_facet mds1 $LCTL set_param fail_val=0
14839 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14840 wait $create_pid || return 1
14842 unlinkmany $DIR/$tdir/f $nr
14844 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14847 remote_mds_nodsh && skip "remote MDS with nodsh"
14848 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14849 skip "Need MDS version at least 2.13.50"
14852 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14854 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14855 #set only one record at plain llog
14856 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14858 #fill already existed plain llog each 64767
14859 #wrapping whole catalog
14860 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14862 createmany -o $DIR/$tdir/$tfile_ 64700
14863 for (( i = 0; i < 64700; i = i + 2 ))
14865 rm $DIR/$tdir/$tfile_$i &
14866 rm $DIR/$tdir/$tfile_$((i + 1)) &
14871 #waiting osp synchronization
14872 wait_delete_completed
14874 run_test 135 "Race catalog processing"
14877 remote_mds_nodsh && skip "remote MDS with nodsh"
14878 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14879 skip "Need MDS version at least 2.13.50"
14882 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14883 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14884 #set only one record at plain llog
14885 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14886 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14888 #fill already existed 2 plain llogs each 64767
14889 #wrapping whole catalog
14890 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14891 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14892 wait_delete_completed
14894 createmany -o $DIR/$tdir/$tfile_ 10
14897 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14898 for (( i = 0; i < 10; i = i + 3 ))
14900 rm $DIR/$tdir/$tfile_$i &
14901 rm $DIR/$tdir/$tfile_$((i + 1)) &
14905 rm $DIR/$tdir/$tfile_$((i + 2)) &
14908 #waiting osp synchronization
14909 wait_delete_completed
14911 run_test 136 "Race catalog processing 2"
14913 test_140() { #bug-17379
14914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14916 test_mkdir $DIR/$tdir
14917 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14918 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14920 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14921 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14923 while i=$((i + 1)); do
14925 cd $i || error "Changing to $i"
14926 ln -s ../stat stat || error "Creating stat symlink"
14927 # Read the symlink until ELOOP present,
14928 # not LBUGing the system is considered success,
14929 # we didn't overrun the stack.
14930 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14931 if [ $ret -ne 0 ]; then
14932 if [ $ret -eq 40 ]; then
14935 error "Open stat symlink"
14941 echo "The symlink depth = $i"
14942 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14943 error "Invalid symlink depth"
14945 # Test recursive symlink
14946 ln -s symlink_self symlink_self
14947 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14948 echo "open symlink_self returns $ret"
14949 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14951 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14956 local TF="$TMP/$tfile"
14958 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14959 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14961 cancel_lru_locks $OSC
14962 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14963 remount_client $MOUNT
14965 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14968 $TRUNCATE $DIR/$tfile 6000
14969 cancel_lru_locks $OSC
14970 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14973 echo "12345" >>$DIR/$tfile
14974 cancel_lru_locks $OSC
14975 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14978 echo "12345" >>$DIR/$tfile
14979 cancel_lru_locks $OSC
14980 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14982 run_test 150a "truncate/append tests"
14985 check_set_fallocate_or_skip
14988 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14989 check_fallocate $DIR/$tfile || skip_eopnotsupp "fallocate failed"
14991 run_test 150b "Verify fallocate (prealloc) functionality"
14994 check_set_fallocate_or_skip
14997 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14998 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
15000 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15001 # precomputed md5sum for 20MB of zeroes
15002 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
15003 local sum=($(md5sum $DIR/$tfile))
15005 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
15007 check_set_fallocate 1
15010 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
15011 sum=($(md5sum $DIR/$tfile))
15013 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
15015 run_test 150bb "Verify fallocate modes both zero space"
15018 check_set_fallocate_or_skip
15019 local striping="-c2"
15021 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15022 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
15023 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
15024 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15025 local want=$((OSTCOUNT * 1048576))
15027 # Must allocate all requested space, not more than 5% extra
15028 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15029 error "bytes $bytes is not $want"
15033 echo "verify fallocate on PFL file"
15035 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15037 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
15038 error "Create $DIR/$tfile failed"
15039 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
15040 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
15041 want=$((512 * 1048576))
15043 # Must allocate all requested space, not more than 5% extra
15044 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15045 error "bytes $bytes is not $want"
15047 run_test 150c "Verify fallocate Size and Blocks"
15050 check_set_fallocate_or_skip
15051 local striping="-c2"
15053 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
15055 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15056 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
15057 error "setstripe failed"
15058 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
15059 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
15060 local want=$((OSTCOUNT * 1048576))
15062 # Must allocate all requested space, not more than 5% extra
15063 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
15064 error "bytes $bytes is not $want"
15066 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
15069 check_set_fallocate_or_skip
15073 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15074 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15075 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15077 # Find OST with Minimum Size
15078 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15079 sort -un | head -1)
15081 # Get 100MB per OST of the available space to reduce run time
15082 # else 60% of the available space if we are running SLOW tests
15083 if [ $SLOW == "no" ]; then
15084 local space=$((1024 * 100 * OSTCOUNT))
15086 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
15089 fallocate -l${space}k $DIR/$tfile ||
15090 error "fallocate ${space}k $DIR/$tfile failed"
15091 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
15093 # get size immediately after fallocate. This should be correctly
15095 local size=$(stat -c '%s' $DIR/$tfile)
15096 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
15098 # Sleep for a while for statfs to get updated. And not pull from cache.
15101 echo "df after fallocate:"
15104 (( size / 1024 == space )) || error "size $size != requested $space"
15105 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
15106 error "used $used < space $space"
15108 rm $DIR/$tfile || error "rm failed"
15110 wait_delete_completed
15112 echo "df after unlink:"
15115 run_test 150e "Verify 60% of available OST space consumed by fallocate"
15120 local want_size_before=20480 # in bytes
15121 local want_blocks_before=40 # 512 sized blocks
15122 local want_blocks_after=24 # 512 sized blocks
15123 local length=$(((want_blocks_before - want_blocks_after) * 512))
15125 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15126 skip "need at least 2.14.0 for fallocate punch"
15128 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15129 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15132 check_set_fallocate_or_skip
15133 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15135 [[ "x$DOM" == "xyes" ]] &&
15136 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
15138 echo "Verify fallocate punch: Range within the file range"
15139 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15140 error "dd failed for bs 4096 and count 5"
15142 # Call fallocate with punch range which is within the file range
15143 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
15144 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
15145 # client must see changes immediately after fallocate
15146 size=$(stat -c '%s' $DIR/$tfile)
15147 blocks=$(stat -c '%b' $DIR/$tfile)
15149 # Verify punch worked.
15150 (( blocks == want_blocks_after )) ||
15151 error "punch failed: blocks $blocks != $want_blocks_after"
15153 (( size == want_size_before )) ||
15154 error "punch failed: size $size != $want_size_before"
15156 # Verify there is hole in file
15157 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
15158 # precomputed md5sum
15159 local expect="4a9a834a2db02452929c0a348273b4aa"
15161 cksum=($(md5sum $DIR/$tfile))
15162 [[ "${cksum[0]}" == "$expect" ]] ||
15163 error "unexpected MD5SUM after punch: ${cksum[0]}"
15165 # Start second sub-case for fallocate punch.
15166 echo "Verify fallocate punch: Range overlapping and less than blocksize"
15167 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
15168 error "dd failed for bs 4096 and count 5"
15170 # Punch range less than block size will have no change in block count
15171 want_blocks_after=40 # 512 sized blocks
15173 # Punch overlaps two blocks and less than blocksize
15174 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
15175 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
15176 size=$(stat -c '%s' $DIR/$tfile)
15177 blocks=$(stat -c '%b' $DIR/$tfile)
15179 # Verify punch worked.
15180 (( blocks == want_blocks_after )) ||
15181 error "punch failed: blocks $blocks != $want_blocks_after"
15183 (( size == want_size_before )) ||
15184 error "punch failed: size $size != $want_size_before"
15186 # Verify if range is really zero'ed out. We expect Zeros.
15187 # precomputed md5sum
15188 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
15189 cksum=($(md5sum $DIR/$tfile))
15190 [[ "${cksum[0]}" == "$expect" ]] ||
15191 error "unexpected MD5SUM after punch: ${cksum[0]}"
15193 run_test 150f "Verify fallocate punch functionality"
15201 local BS=4096 # Block size in bytes
15203 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
15204 skip "need at least 2.14.0 for fallocate punch"
15206 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
15207 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15210 check_set_fallocate_or_skip
15211 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15213 if [[ "x$DOM" == "xyes" ]]; then
15214 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
15215 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
15217 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15218 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15221 # Get 100MB per OST of the available space to reduce run time
15222 # else 60% of the available space if we are running SLOW tests
15223 if [ $SLOW == "no" ]; then
15224 space=$((1024 * 100 * OSTCOUNT))
15226 # Find OST with Minimum Size
15227 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15228 sort -un | head -1)
15229 echo "min size OST: $space"
15230 space=$(((space * 60)/100 * OSTCOUNT))
15232 # space in 1k units, round to 4k blocks
15233 local blkcount=$((space * 1024 / $BS))
15235 echo "Verify fallocate punch: Very large Range"
15236 fallocate -l${space}k $DIR/$tfile ||
15237 error "fallocate ${space}k $DIR/$tfile failed"
15238 # write 1M at the end, start and in the middle
15239 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
15240 error "dd failed: bs $BS count 256"
15241 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
15242 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
15243 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
15244 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
15247 size=$(stat -c '%s' $DIR/$tfile)
15249 # gather punch length.
15250 local punch_size=$((size - (BS * 2)))
15252 echo "punch_size = $punch_size"
15253 echo "size - punch_size: $((size - punch_size))"
15254 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
15256 # Call fallocate to punch all except 2 blocks. We leave the
15257 # first and the last block
15258 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
15259 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
15260 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
15262 size_after=$(stat -c '%s' $DIR/$tfile)
15263 blocks_after=$(stat -c '%b' $DIR/$tfile)
15265 # Verify punch worked.
15266 # Size should be kept
15267 (( size == size_after )) ||
15268 error "punch failed: size $size != $size_after"
15270 # two 4k data blocks to remain plus possible 1 extra extent block
15271 (( blocks_after <= ((BS / 512) * 3) )) ||
15272 error "too many blocks remains: $blocks_after"
15274 # Verify that file has hole between the first and the last blocks
15275 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
15276 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
15278 echo "Hole at [$hole_start, $hole_end)"
15279 (( hole_start == BS )) ||
15280 error "no hole at offset $BS after punch"
15282 (( hole_end == BS + punch_size )) ||
15283 error "data at offset $hole_end < $((BS + punch_size))"
15285 run_test 150g "Verify fallocate punch on large range"
15287 #LU-2902 roc_hit was not able to read all values from lproc
15288 function roc_hit_init() {
15289 local list=$(comma_list $(osts_nodes))
15290 local dir=$DIR/$tdir-check
15291 local file=$dir/$tfile
15297 #use setstripe to do a write to every ost
15298 for i in $(seq 0 $((OSTCOUNT-1))); do
15299 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
15300 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
15301 idx=$(printf %04x $i)
15302 BEFORE=$(get_osd_param $list *OST*$idx stats |
15303 awk '$1 == "cache_access" {sum += $7}
15304 END { printf("%0.0f", sum) }')
15306 cancel_lru_locks osc
15307 cat $file >/dev/null
15309 AFTER=$(get_osd_param $list *OST*$idx stats |
15310 awk '$1 == "cache_access" {sum += $7}
15311 END { printf("%0.0f", sum) }')
15313 echo BEFORE:$BEFORE AFTER:$AFTER
15314 if ! let "AFTER - BEFORE == 4"; then
15316 error "roc_hit is not safe to use"
15324 function roc_hit() {
15325 local list=$(comma_list $(osts_nodes))
15326 echo $(get_osd_param $list '' stats |
15327 awk '$1 == "cache_hit" {sum += $7}
15328 END { printf("%0.0f", sum) }')
15331 function set_cache() {
15334 if [ "$2" == "off" ]; then
15337 local list=$(comma_list $(osts_nodes))
15338 set_osd_param $list '' $1_cache_enable $on
15340 cancel_lru_locks osc
15344 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15345 remote_ost_nodsh && skip "remote OST with nodsh"
15348 local list=$(comma_list $(osts_nodes))
15350 # check whether obdfilter is cache capable at all
15351 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
15352 skip "not cache-capable obdfilter"
15355 # check cache is enabled on all obdfilters
15356 if get_osd_param $list '' read_cache_enable | grep 0; then
15357 skip "oss cache is disabled"
15360 set_osd_param $list '' writethrough_cache_enable 1
15362 # check write cache is enabled on all obdfilters
15363 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
15364 skip "oss write cache is NOT enabled"
15369 #define OBD_FAIL_OBD_NO_LRU 0x609
15370 do_nodes $list $LCTL set_param fail_loc=0x609
15372 # pages should be in the case right after write
15373 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15376 local BEFORE=$(roc_hit)
15377 cancel_lru_locks osc
15378 cat $DIR/$tfile >/dev/null
15379 local AFTER=$(roc_hit)
15381 do_nodes $list $LCTL set_param fail_loc=0
15383 if ! let "AFTER - BEFORE == CPAGES"; then
15384 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15387 cancel_lru_locks osc
15388 # invalidates OST cache
15389 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15390 set_osd_param $list '' read_cache_enable 0
15391 cat $DIR/$tfile >/dev/null
15393 # now data shouldn't be found in the cache
15395 cancel_lru_locks osc
15396 cat $DIR/$tfile >/dev/null
15398 if let "AFTER - BEFORE != 0"; then
15399 error "IN CACHE: before: $BEFORE, after: $AFTER"
15402 set_osd_param $list '' read_cache_enable 1
15405 run_test 151 "test cache on oss and controls ==============================="
15408 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15410 local TF="$TMP/$tfile"
15412 # simulate ENOMEM during write
15413 #define OBD_FAIL_OST_NOMEM 0x226
15414 lctl set_param fail_loc=0x80000226
15415 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15417 sync || error "sync failed"
15418 lctl set_param fail_loc=0
15420 # discard client's cache
15421 cancel_lru_locks osc
15423 # simulate ENOMEM during read
15424 lctl set_param fail_loc=0x80000226
15425 cmp $TF $DIR/$tfile || error "cmp failed"
15426 lctl set_param fail_loc=0
15430 run_test 152 "test read/write with enomem ============================"
15433 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15435 run_test 153 "test if fdatasync does not crash ======================="
15437 dot_lustre_fid_permission_check() {
15439 local ffid=$MOUNT/.lustre/fid/$fid
15442 echo "stat fid $fid"
15443 stat $ffid || error "stat $ffid failed."
15444 echo "touch fid $fid"
15445 touch $ffid || error "touch $ffid failed."
15446 echo "write to fid $fid"
15447 cat /etc/hosts > $ffid || error "write $ffid failed."
15448 echo "read fid $fid"
15449 diff /etc/hosts $ffid || error "read $ffid failed."
15450 echo "append write to fid $fid"
15451 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15452 echo "rename fid $fid"
15453 mv $ffid $test_dir/$tfile.1 &&
15454 error "rename $ffid to $tfile.1 should fail."
15455 touch $test_dir/$tfile.1
15456 mv $test_dir/$tfile.1 $ffid &&
15457 error "rename $tfile.1 to $ffid should fail."
15458 rm -f $test_dir/$tfile.1
15459 echo "truncate fid $fid"
15460 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15461 echo "link fid $fid"
15462 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15463 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15464 echo "setfacl fid $fid"
15465 setfacl -R -m u:$USER0:rwx $ffid ||
15466 error "setfacl $ffid failed"
15467 echo "getfacl fid $fid"
15468 getfacl $ffid || error "getfacl $ffid failed."
15470 echo "unlink fid $fid"
15471 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15472 echo "mknod fid $fid"
15473 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15475 fid=[0xf00000400:0x1:0x0]
15476 ffid=$MOUNT/.lustre/fid/$fid
15478 echo "stat non-exist fid $fid"
15479 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15480 echo "write to non-exist fid $fid"
15481 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15482 echo "link new fid $fid"
15483 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15485 mkdir -p $test_dir/$tdir
15486 touch $test_dir/$tdir/$tfile
15487 fid=$($LFS path2fid $test_dir/$tdir)
15490 error "error: could not get fid for $test_dir/$dir/$tfile."
15492 ffid=$MOUNT/.lustre/fid/$fid
15495 ls $ffid || error "ls $ffid failed."
15496 echo "touch $fid/$tfile.1"
15497 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15499 echo "touch $MOUNT/.lustre/fid/$tfile"
15500 touch $MOUNT/.lustre/fid/$tfile && \
15501 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15503 echo "setxattr to $MOUNT/.lustre/fid"
15504 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15506 echo "listxattr for $MOUNT/.lustre/fid"
15507 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15509 echo "delxattr from $MOUNT/.lustre/fid"
15510 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15512 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15513 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15514 error "touch invalid fid should fail."
15516 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15517 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15518 error "touch non-normal fid should fail."
15520 echo "rename $tdir to $MOUNT/.lustre/fid"
15521 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15522 error "rename to $MOUNT/.lustre/fid should fail."
15524 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15526 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15527 local new_obf_mode=777
15529 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15530 chmod $new_obf_mode $DIR/.lustre/fid ||
15531 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15533 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15534 [ $obf_mode -eq $new_obf_mode ] ||
15535 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15537 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15538 chmod $old_obf_mode $DIR/.lustre/fid ||
15539 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15542 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15543 fid=$($LFS path2fid $test_dir/$tfile-2)
15545 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15547 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15548 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15549 error "create lov data thru .lustre failed"
15551 echo "cp /etc/passwd $test_dir/$tfile-2"
15552 cp /etc/passwd $test_dir/$tfile-2 ||
15553 error "copy to $test_dir/$tfile-2 failed."
15554 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15555 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15556 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15558 rm -rf $test_dir/tfile.lnk
15559 rm -rf $test_dir/$tfile-2
15563 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15564 skip "Need MDS version at least 2.4.1"
15566 local tf=$DIR/$tfile
15569 local fid=$($LFS path2fid $tf)
15570 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15572 # check that we get the same pathname back
15575 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15576 echo "$rootpath $fid"
15577 found=$($LFS fid2path $rootpath "$fid")
15578 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15579 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15582 # check wrong root path format
15583 rootpath=$MOUNT"_wrong"
15584 found=$($LFS fid2path $rootpath "$fid")
15585 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15587 run_test 154A "lfs path2fid and fid2path basic checks"
15590 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15591 skip "Need MDS version at least 2.4.1"
15593 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15594 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15595 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15596 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15598 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15599 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15601 # check that we get the same pathname
15602 echo "PFID: $PFID, name: $name"
15603 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15604 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15605 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15606 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15608 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15610 run_test 154B "verify the ll_decode_linkea tool"
15613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15614 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15615 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
15616 skip "Need MDS version at least 2.2.51"
15617 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15619 cp /etc/hosts $DIR/$tfile
15621 fid=$($LFS path2fid $DIR/$tfile)
15623 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15625 dot_lustre_fid_permission_check "$fid" $DIR ||
15626 error "dot lustre permission check $fid failed"
15628 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15630 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15632 touch $MOUNT/.lustre/file &&
15633 error "creation is not allowed under .lustre"
15635 mkdir $MOUNT/.lustre/dir &&
15636 error "mkdir is not allowed under .lustre"
15640 run_test 154a "Open-by-FID"
15643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15644 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15645 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15646 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15647 skip "Need MDS version at least 2.2.51"
15649 local remote_dir=$DIR/$tdir/remote_dir
15653 mkdir -p $DIR/$tdir
15654 $LFS mkdir -i $MDTIDX $remote_dir ||
15655 error "create remote directory failed"
15657 cp /etc/hosts $remote_dir/$tfile
15659 fid=$($LFS path2fid $remote_dir/$tfile)
15661 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15663 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15664 error "dot lustre permission check $fid failed"
15667 run_test 154b "Open-by-FID for remote directory"
15670 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15671 skip "Need MDS version at least 2.4.1"
15673 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15674 local FID1=$($LFS path2fid $DIR/$tfile.1)
15675 local FID2=$($LFS path2fid $DIR/$tfile.2)
15676 local FID3=$($LFS path2fid $DIR/$tfile.3)
15679 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15680 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15681 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15683 [ "$FID" = "${!want}" ] ||
15684 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15688 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15690 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15691 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15695 run_test 154c "lfs path2fid and fid2path multiple arguments"
15698 remote_mds_nodsh && skip "remote MDS with nodsh"
15699 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15700 skip "Need MDS version at least 2.5.53"
15702 if remote_mds; then
15703 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15707 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15714 local fid=$($LFS path2fid $DIR/$tfile)
15717 cmd="exec $fd<$DIR/$tfile"
15719 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15720 echo "$fid_list" | grep "$fid"
15723 cmd="exec $fd>/dev/null"
15725 if [ $rc -ne 0 ]; then
15726 error "FID $fid not found in open files list $fid_list"
15729 run_test 154d "Verify open file fid"
15733 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15734 skip "Need MDS version at least 2.6.50"
15736 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15737 error ".lustre returned by readdir"
15740 run_test 154e ".lustre is not returned by readdir"
15743 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15745 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15746 mkdir_on_mdt0 $DIR/$tdir
15747 # test dirs inherit from its stripe
15748 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15749 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15750 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15751 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15754 # get fid of parents
15755 local FID0=$($LFS path2fid $DIR/$tdir)
15756 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15757 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15758 local FID3=$($LFS path2fid $DIR)
15760 # check that path2fid --parents returns expected <parent_fid>/name
15761 # 1) test for a directory (single parent)
15762 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15763 [ "$parent" == "$FID0/foo1" ] ||
15764 error "expected parent: $FID0/foo1, got: $parent"
15766 # 2) test for a file with nlink > 1 (multiple parents)
15767 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
15768 echo "$parent" | grep -F "$FID1/$tfile" ||
15769 error "$FID1/$tfile not returned in parent list"
15770 echo "$parent" | grep -F "$FID2/link" ||
15771 error "$FID2/link not returned in parent list"
15773 # 3) get parent by fid
15774 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15775 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15776 echo "$parent" | grep -F "$FID1/$tfile" ||
15777 error "$FID1/$tfile not returned in parent list (by fid)"
15778 echo "$parent" | grep -F "$FID2/link" ||
15779 error "$FID2/link not returned in parent list (by fid)"
15781 # 4) test for entry in root directory
15782 parent=$($LFS path2fid --parents $DIR/f)
15783 echo "$parent" | grep -F "$FID3/f" ||
15784 error "$FID3/f not returned in parent list"
15786 # 5) test it on root directory
15787 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15788 error "$MOUNT should not have parents"
15790 # enable xattr caching and check that linkea is correctly updated
15791 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15792 save_lustre_params client "llite.*.xattr_cache" > $save
15793 lctl set_param llite.*.xattr_cache 1
15795 # 6.1) linkea update on rename
15796 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15798 # get parents by fid
15799 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15800 # foo1 should no longer be returned in parent list
15801 echo "$parent" | grep -F "$FID1" &&
15802 error "$FID1 should no longer be in parent list"
15803 # the new path should appear
15804 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15805 error "$FID2/$tfile.moved is not in parent list"
15807 # 6.2) linkea update on unlink
15808 rm -f $DIR/$tdir/foo2/link
15809 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15810 # foo2/link should no longer be returned in parent list
15811 echo "$parent" | grep -F "$FID2/link" &&
15812 error "$FID2/link should no longer be in parent list"
15816 restore_lustre_params < $save
15819 run_test 154f "get parent fids by reading link ea"
15823 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15824 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15825 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15826 skip "Need MDS version at least 2.6.92"
15828 mkdir_on_mdt0 $DIR/$tdir
15829 llapi_fid_test -d $DIR/$tdir
15831 run_test 154g "various llapi FID tests"
15833 test_155_small_load() {
15834 local temp=$TMP/$tfile
15835 local file=$DIR/$tfile
15837 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15838 error "dd of=$temp bs=6096 count=1 failed"
15840 cancel_lru_locks $OSC
15841 cmp $temp $file || error "$temp $file differ"
15843 $TRUNCATE $temp 6000
15844 $TRUNCATE $file 6000
15845 cmp $temp $file || error "$temp $file differ (truncate1)"
15847 echo "12345" >>$temp
15848 echo "12345" >>$file
15849 cmp $temp $file || error "$temp $file differ (append1)"
15851 echo "12345" >>$temp
15852 echo "12345" >>$file
15853 cmp $temp $file || error "$temp $file differ (append2)"
15859 test_155_big_load() {
15860 remote_ost_nodsh && skip "remote OST with nodsh"
15862 local temp=$TMP/$tfile
15863 local file=$DIR/$tfile
15866 local cache_size=$(do_facet ost$((MAXI+1)) \
15867 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15869 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
15871 if [ -z "$cache_size" ]; then
15874 local large_file_size=$((cache_size * 2))
15876 echo "OSS cache size: $cache_size KB"
15877 echo "Large file size: $large_file_size KB"
15879 [ $MAXV -le $large_file_size ] &&
15880 skip_env "max available OST size needs > $large_file_size KB"
15882 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15884 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15885 error "dd of=$temp bs=$large_file_size count=1k failed"
15888 cancel_lru_locks osc
15889 cmp $temp $file || error "$temp $file differ"
15895 save_writethrough() {
15896 local facets=$(get_facets OST)
15898 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15904 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15906 save_writethrough $p
15909 set_cache writethrough on
15910 test_155_small_load
15911 restore_lustre_params < $p
15914 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15919 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15921 save_writethrough $p
15924 set_cache writethrough off
15925 test_155_small_load
15926 restore_lustre_params < $p
15929 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15934 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15936 save_writethrough $p
15939 set_cache writethrough on
15940 test_155_small_load
15941 restore_lustre_params < $p
15944 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15947 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15949 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15951 save_writethrough $p
15954 set_cache writethrough off
15955 test_155_small_load
15956 restore_lustre_params < $p
15959 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15964 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15966 save_writethrough $p
15969 set_cache writethrough on
15971 restore_lustre_params < $p
15974 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15977 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15979 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15981 save_writethrough $p
15984 set_cache writethrough off
15986 restore_lustre_params < $p
15989 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15992 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15994 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15996 save_writethrough $p
15999 set_cache writethrough on
16001 restore_lustre_params < $p
16004 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
16007 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16009 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16011 save_writethrough $p
16014 set_cache writethrough off
16016 restore_lustre_params < $p
16019 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
16022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16023 remote_ost_nodsh && skip "remote OST with nodsh"
16024 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
16025 skip "stats not implemented on old servers"
16026 [ "$ost1_FSTYPE" = "zfs" ] &&
16027 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
16032 local file="$DIR/$tfile"
16033 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16035 save_writethrough $p
16038 log "Turn on read and write cache"
16040 set_cache writethrough on
16042 log "Write data and read it back."
16043 log "Read should be satisfied from the cache."
16044 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16046 cancel_lru_locks osc
16047 cat $file >/dev/null
16049 if ! let "AFTER - BEFORE == CPAGES"; then
16050 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
16052 log "cache hits: before: $BEFORE, after: $AFTER"
16055 log "Read again; it should be satisfied from the cache."
16057 cancel_lru_locks osc
16058 cat $file >/dev/null
16060 if ! let "AFTER - BEFORE == CPAGES"; then
16061 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
16063 log "cache hits:: before: $BEFORE, after: $AFTER"
16066 log "Turn off the read cache and turn on the write cache"
16068 set_cache writethrough on
16070 log "Read again; it should be satisfied from the cache."
16072 cancel_lru_locks osc
16073 cat $file >/dev/null
16075 if ! let "AFTER - BEFORE == CPAGES"; then
16076 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
16078 log "cache hits:: before: $BEFORE, after: $AFTER"
16081 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16082 # > 2.12.56 uses pagecache if cached
16083 log "Read again; it should not be satisfied from the cache."
16085 cancel_lru_locks osc
16086 cat $file >/dev/null
16088 if ! let "AFTER - BEFORE == 0"; then
16089 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
16091 log "cache hits:: before: $BEFORE, after: $AFTER"
16095 log "Write data and read it back."
16096 log "Read should be satisfied from the cache."
16097 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16099 cancel_lru_locks osc
16100 cat $file >/dev/null
16102 if ! let "AFTER - BEFORE == CPAGES"; then
16103 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
16105 log "cache hits:: before: $BEFORE, after: $AFTER"
16108 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
16109 # > 2.12.56 uses pagecache if cached
16110 log "Read again; it should not be satisfied from the cache."
16112 cancel_lru_locks osc
16113 cat $file >/dev/null
16115 if ! let "AFTER - BEFORE == 0"; then
16116 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
16118 log "cache hits:: before: $BEFORE, after: $AFTER"
16122 log "Turn off read and write cache"
16124 set_cache writethrough off
16126 log "Write data and read it back"
16127 log "It should not be satisfied from the cache."
16129 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16130 cancel_lru_locks osc
16132 cat $file >/dev/null
16134 if ! let "AFTER - BEFORE == 0"; then
16135 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
16137 log "cache hits:: before: $BEFORE, after: $AFTER"
16140 log "Turn on the read cache and turn off the write cache"
16142 set_cache writethrough off
16144 log "Write data and read it back"
16145 log "It should not be satisfied from the cache."
16147 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
16149 cancel_lru_locks osc
16150 cat $file >/dev/null
16152 if ! let "AFTER - BEFORE == 0"; then
16153 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
16155 log "cache hits:: before: $BEFORE, after: $AFTER"
16158 log "Read again; it should be satisfied from the cache."
16160 cancel_lru_locks osc
16161 cat $file >/dev/null
16163 if ! let "AFTER - BEFORE == CPAGES"; then
16164 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
16166 log "cache hits:: before: $BEFORE, after: $AFTER"
16169 restore_lustre_params < $p
16172 run_test 156 "Verification of tunables"
16175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16176 remote_mds_nodsh && skip "remote MDS with nodsh"
16177 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16178 skip "Need MDS version at least 2.2.0"
16180 changelog_register || error "changelog_register failed"
16181 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16182 changelog_users $SINGLEMDS | grep -q $cl_user ||
16183 error "User $cl_user not found in changelog_users"
16185 mkdir_on_mdt0 $DIR/$tdir
16188 test_mkdir -p $DIR/$tdir/pics/2008/zachy
16189 changelog_clear 0 || error "changelog_clear failed"
16190 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
16191 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
16192 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16193 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16194 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16195 rm $DIR/$tdir/pics/desktop.jpg
16197 echo "verifying changelog mask"
16198 changelog_chmask "-MKDIR"
16199 changelog_chmask "-CLOSE"
16201 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
16202 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
16204 changelog_chmask "+MKDIR"
16205 changelog_chmask "+CLOSE"
16207 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
16208 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
16210 MKDIRS=$(changelog_dump | grep -c "MKDIR")
16211 CLOSES=$(changelog_dump | grep -c "CLOSE")
16212 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
16213 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
16216 echo "verifying target fid"
16217 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
16218 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
16219 [ "$fidc" == "$fidf" ] ||
16220 error "changelog '$tfile' fid $fidc != file fid $fidf"
16221 echo "verifying parent fid"
16222 # The FID returned from the Changelog may be the directory shard on
16223 # a different MDT, and not the FID returned by path2fid on the parent.
16224 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
16225 # since this is what will matter when recreating this file in the tree.
16226 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
16227 local pathp=$($LFS fid2path $MOUNT "$fidp")
16228 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
16229 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
16231 echo "getting records for $cl_user"
16232 changelog_users $SINGLEMDS
16233 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
16235 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
16236 error "changelog_clear failed"
16237 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
16238 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
16239 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
16240 error "user index expect $user_rec1 + $nclr != $user_rec2"
16242 local min0_rec=$(changelog_users $SINGLEMDS |
16243 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
16244 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
16245 awk '{ print $1; exit; }')
16247 changelog_dump | tail -n 5
16248 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
16249 [ $first_rec == $((min0_rec + 1)) ] ||
16250 error "first index should be $min0_rec + 1 not $first_rec"
16252 # LU-3446 changelog index reset on MDT restart
16253 local cur_rec1=$(changelog_users $SINGLEMDS |
16254 awk '/^current.index:/ { print $NF }')
16255 changelog_clear 0 ||
16256 error "clear all changelog records for $cl_user failed"
16257 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
16258 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
16259 error "Fail to start $SINGLEMDS"
16260 local cur_rec2=$(changelog_users $SINGLEMDS |
16261 awk '/^current.index:/ { print $NF }')
16262 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
16263 [ $cur_rec1 == $cur_rec2 ] ||
16264 error "current index should be $cur_rec1 not $cur_rec2"
16266 echo "verifying users from this test are deregistered"
16267 changelog_deregister || error "changelog_deregister failed"
16268 changelog_users $SINGLEMDS | grep -q $cl_user &&
16269 error "User '$cl_user' still in changelog_users"
16271 # lctl get_param -n mdd.*.changelog_users
16272 # current_index: 144
16273 # ID index (idle seconds)
16274 # cl3 144 (2) mask=<list>
16275 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
16276 # this is the normal case where all users were deregistered
16277 # make sure no new records are added when no users are present
16278 local last_rec1=$(changelog_users $SINGLEMDS |
16279 awk '/^current.index:/ { print $NF }')
16280 touch $DIR/$tdir/chloe
16281 local last_rec2=$(changelog_users $SINGLEMDS |
16282 awk '/^current.index:/ { print $NF }')
16283 echo "verify changelogs are off: $last_rec1 == $last_rec2"
16284 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
16286 # any changelog users must be leftovers from a previous test
16287 changelog_users $SINGLEMDS
16288 echo "other changelog users; can't verify off"
16291 run_test 160a "changelog sanity"
16293 test_160b() { # LU-3587
16294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16295 remote_mds_nodsh && skip "remote MDS with nodsh"
16296 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16297 skip "Need MDS version at least 2.2.0"
16299 changelog_register || error "changelog_register failed"
16300 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16301 changelog_users $SINGLEMDS | grep -q $cl_user ||
16302 error "User '$cl_user' not found in changelog_users"
16304 local longname1=$(str_repeat a 255)
16305 local longname2=$(str_repeat b 255)
16308 echo "creating very long named file"
16309 touch $longname1 || error "create of '$longname1' failed"
16310 echo "renaming very long named file"
16311 mv $longname1 $longname2
16313 changelog_dump | grep RENME | tail -n 5
16316 run_test 160b "Verify that very long rename doesn't crash in changelog"
16319 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16320 remote_mds_nodsh && skip "remote MDS with nodsh"
16322 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16323 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16324 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16325 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16329 # Registration step
16330 changelog_register || error "changelog_register failed"
16333 mkdir -p $DIR/$tdir
16334 $MCREATE $DIR/$tdir/foo_160c
16335 changelog_chmask "-TRUNC"
16336 $TRUNCATE $DIR/$tdir/foo_160c 200
16337 changelog_chmask "+TRUNC"
16338 $TRUNCATE $DIR/$tdir/foo_160c 199
16339 changelog_dump | tail -n 5
16340 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
16341 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
16343 run_test 160c "verify that changelog log catch the truncate event"
16346 remote_mds_nodsh && skip "remote MDS with nodsh"
16347 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16348 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16349 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
16350 skip "Need MDS version at least 2.7.60"
16352 # Registration step
16353 changelog_register || error "changelog_register failed"
16355 mkdir -p $DIR/$tdir/migrate_dir
16356 changelog_clear 0 || error "changelog_clear failed"
16358 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
16359 changelog_dump | tail -n 5
16360 local migrates=$(changelog_dump | grep -c "MIGRT")
16361 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
16363 run_test 160d "verify that changelog log catch the migrate event"
16366 remote_mds_nodsh && skip "remote MDS with nodsh"
16369 changelog_register || error "changelog_register failed"
16371 local MDT0=$(facet_svc $SINGLEMDS)
16374 # No user (expect fail)
16375 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
16377 if [ $rc -eq 0 ]; then
16378 error "Should fail without user"
16379 elif [ $rc -ne 4 ]; then
16380 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16383 # Delete a future user (expect fail)
16384 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16386 if [ $rc -eq 0 ]; then
16387 error "Deleted non-existant user cl77"
16388 elif [ $rc -ne 2 ]; then
16389 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16392 # Clear to a bad index (1 billion should be safe)
16393 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16396 if [ $rc -eq 0 ]; then
16397 error "Successfully cleared to invalid CL index"
16398 elif [ $rc -ne 22 ]; then
16399 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16402 run_test 160e "changelog negative testing (should return errors)"
16405 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16406 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16407 skip "Need MDS version at least 2.10.56"
16409 local mdts=$(comma_list $(mdts_nodes))
16412 changelog_register || error "first changelog_register failed"
16413 changelog_register || error "second changelog_register failed"
16415 declare -A cl_user1
16416 declare -A cl_user2
16421 # generate some changelog records to accumulate on each MDT
16422 # use all_char because created files should be evenly distributed
16423 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16424 error "test_mkdir $tdir failed"
16425 log "$(date +%s): creating first files"
16426 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16427 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16428 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16431 # check changelogs have been generated
16432 local start=$SECONDS
16433 local idle_time=$((MDSCOUNT * 5 + 5))
16434 local nbcl=$(changelog_dump | wc -l)
16435 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16437 for param in "changelog_max_idle_time=$idle_time" \
16439 "changelog_min_gc_interval=2" \
16440 "changelog_min_free_cat_entries=3"; do
16441 local MDT0=$(facet_svc $SINGLEMDS)
16442 local var="${param%=*}"
16443 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16445 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16446 do_nodes $mdts $LCTL set_param mdd.*.$param
16449 # force cl_user2 to be idle (1st part), but also cancel the
16450 # cl_user1 records so that it is not evicted later in the test.
16451 local sleep1=$((idle_time / 2))
16452 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16455 # simulate changelog catalog almost full
16456 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16457 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16459 for i in $(seq $MDSCOUNT); do
16460 cl_users=(${CL_USERS[mds$i]})
16461 cl_user1[mds$i]="${cl_users[0]}"
16462 cl_user2[mds$i]="${cl_users[1]}"
16464 [ -n "${cl_user1[mds$i]}" ] ||
16465 error "mds$i: no user registered"
16466 [ -n "${cl_user2[mds$i]}" ] ||
16467 error "mds$i: only ${cl_user2[mds$i]} is registered"
16469 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16470 [ -n "$user_rec1" ] ||
16471 error "mds$i: User ${cl_user1[mds$i]} not registered"
16472 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16473 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16474 [ -n "$user_rec2" ] ||
16475 error "mds$i: User ${cl_user1[mds$i]} not registered"
16476 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16477 "$user_rec1 + 2 == $user_rec2"
16478 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16479 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16480 "$user_rec1 + 2, but is $user_rec2"
16481 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16482 [ -n "$user_rec2" ] ||
16483 error "mds$i: User ${cl_user2[mds$i]} not registered"
16484 [ $user_rec1 == $user_rec2 ] ||
16485 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16486 "$user_rec1, but is $user_rec2"
16489 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16490 local sleep2=$((idle_time - (SECONDS - start) + 1))
16491 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16494 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16495 # cl_user1 should be OK because it recently processed records.
16496 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16497 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16498 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16499 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16502 # ensure gc thread is done
16503 for i in $(mdts_nodes); do
16504 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16505 error "$i: GC-thread not done"
16509 for (( i = 1; i <= MDSCOUNT; i++ )); do
16510 # check cl_user1 still registered
16511 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16512 error "mds$i: User ${cl_user1[mds$i]} not registered"
16513 # check cl_user2 unregistered
16514 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16515 error "mds$i: User ${cl_user2[mds$i]} still registered"
16517 # check changelogs are present and starting at $user_rec1 + 1
16518 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16519 [ -n "$user_rec1" ] ||
16520 error "mds$i: User ${cl_user1[mds$i]} not registered"
16521 first_rec=$($LFS changelog $(facet_svc mds$i) |
16522 awk '{ print $1; exit; }')
16524 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16525 [ $((user_rec1 + 1)) == $first_rec ] ||
16526 error "mds$i: rec $first_rec != $user_rec1 + 1"
16529 run_test 160f "changelog garbage collect (timestamped users)"
16532 remote_mds_nodsh && skip "remote MDS with nodsh"
16533 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16534 skip "Need MDS version at least 2.14.55"
16536 local mdts=$(comma_list $(mdts_nodes))
16539 changelog_register || error "first changelog_register failed"
16540 changelog_register || error "second changelog_register failed"
16542 declare -A cl_user1
16543 declare -A cl_user2
16548 # generate some changelog records to accumulate on each MDT
16549 # use all_char because created files should be evenly distributed
16550 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16551 error "test_mkdir $tdir failed"
16552 for ((i = 0; i < MDSCOUNT; i++)); do
16553 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16554 error "create $DIR/$tdir/d$i.1 failed"
16557 # check changelogs have been generated
16558 local nbcl=$(changelog_dump | wc -l)
16559 (( $nbcl > 0 )) || error "no changelogs found"
16561 # reduce the max_idle_indexes value to make sure we exceed it
16562 for param in "changelog_max_idle_indexes=2" \
16564 "changelog_min_gc_interval=2"; do
16565 local MDT0=$(facet_svc $SINGLEMDS)
16566 local var="${param%=*}"
16567 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16569 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16570 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16571 error "unable to set mdd.*.$param"
16574 local start=$SECONDS
16575 for i in $(seq $MDSCOUNT); do
16576 cl_users=(${CL_USERS[mds$i]})
16577 cl_user1[mds$i]="${cl_users[0]}"
16578 cl_user2[mds$i]="${cl_users[1]}"
16580 [ -n "${cl_user1[mds$i]}" ] ||
16581 error "mds$i: user1 is not registered"
16582 [ -n "${cl_user2[mds$i]}" ] ||
16583 error "mds$i: only ${cl_user1[mds$i]} is registered"
16585 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16586 [ -n "$user_rec1" ] ||
16587 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16588 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16589 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16590 [ -n "$user_rec2" ] ||
16591 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16592 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16593 "$user_rec1 + 2 == $user_rec2"
16594 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16595 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16596 "expected $user_rec1 + 2, but is $user_rec2"
16597 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16598 [ -n "$user_rec2" ] ||
16599 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16600 [ $user_rec1 == $user_rec2 ] ||
16601 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16602 "expected $user_rec1, but is $user_rec2"
16605 # ensure we are past the previous changelog_min_gc_interval set above
16606 local sleep2=$((start + 2 - SECONDS))
16607 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16608 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16609 # cl_user1 should be OK because it recently processed records.
16610 for ((i = 0; i < MDSCOUNT; i++)); do
16611 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16612 error "create $DIR/$tdir/d$i.3 failed"
16615 # ensure gc thread is done
16616 for i in $(mdts_nodes); do
16617 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16618 error "$i: GC-thread not done"
16622 for (( i = 1; i <= MDSCOUNT; i++ )); do
16623 # check cl_user1 still registered
16624 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16625 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16626 # check cl_user2 unregistered
16627 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16628 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16630 # check changelogs are present and starting at $user_rec1 + 1
16631 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16632 [ -n "$user_rec1" ] ||
16633 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16634 first_rec=$($LFS changelog $(facet_svc mds$i) |
16635 awk '{ print $1; exit; }')
16637 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16638 [ $((user_rec1 + 1)) == $first_rec ] ||
16639 error "mds$i: rec $first_rec != $user_rec1 + 1"
16642 run_test 160g "changelog garbage collect on idle records"
16645 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16646 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16647 skip "Need MDS version at least 2.10.56"
16649 local mdts=$(comma_list $(mdts_nodes))
16652 changelog_register || error "first changelog_register failed"
16653 changelog_register || error "second changelog_register failed"
16655 declare -A cl_user1
16656 declare -A cl_user2
16661 # generate some changelog records to accumulate on each MDT
16662 # use all_char because created files should be evenly distributed
16663 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16664 error "test_mkdir $tdir failed"
16665 for ((i = 0; i < MDSCOUNT; i++)); do
16666 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16667 error "create $DIR/$tdir/d$i.1 failed"
16670 # check changelogs have been generated
16671 local nbcl=$(changelog_dump | wc -l)
16672 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16674 for param in "changelog_max_idle_time=10" \
16676 "changelog_min_gc_interval=2"; do
16677 local MDT0=$(facet_svc $SINGLEMDS)
16678 local var="${param%=*}"
16679 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16681 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16682 do_nodes $mdts $LCTL set_param mdd.*.$param
16685 # force cl_user2 to be idle (1st part)
16688 for i in $(seq $MDSCOUNT); do
16689 cl_users=(${CL_USERS[mds$i]})
16690 cl_user1[mds$i]="${cl_users[0]}"
16691 cl_user2[mds$i]="${cl_users[1]}"
16693 [ -n "${cl_user1[mds$i]}" ] ||
16694 error "mds$i: no user registered"
16695 [ -n "${cl_user2[mds$i]}" ] ||
16696 error "mds$i: only ${cl_user2[mds$i]} is registered"
16698 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16699 [ -n "$user_rec1" ] ||
16700 error "mds$i: User ${cl_user1[mds$i]} not registered"
16701 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16702 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16703 [ -n "$user_rec2" ] ||
16704 error "mds$i: User ${cl_user1[mds$i]} not registered"
16705 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16706 "$user_rec1 + 2 == $user_rec2"
16707 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16708 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16709 "$user_rec1 + 2, but is $user_rec2"
16710 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16711 [ -n "$user_rec2" ] ||
16712 error "mds$i: User ${cl_user2[mds$i]} not registered"
16713 [ $user_rec1 == $user_rec2 ] ||
16714 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16715 "$user_rec1, but is $user_rec2"
16718 # force cl_user2 to be idle (2nd part) and to reach
16719 # changelog_max_idle_time
16722 # force each GC-thread start and block then
16723 # one per MDT/MDD, set fail_val accordingly
16724 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16725 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16727 # generate more changelogs to trigger fail_loc
16728 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16729 error "create $DIR/$tdir/${tfile}bis failed"
16731 # stop MDT to stop GC-thread, should be done in back-ground as it will
16732 # block waiting for the thread to be released and exit
16733 declare -A stop_pids
16734 for i in $(seq $MDSCOUNT); do
16736 stop_pids[mds$i]=$!
16739 for i in $(mdts_nodes); do
16742 local facets=$(facets_up_on_host $i)
16744 for facet in ${facets//,/ }; do
16745 if [[ $facet == mds* ]]; then
16749 # ensure each MDS's gc threads are still present and all in "R"
16750 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16751 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16752 error "$i: expected $nb GC-thread"
16754 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16756 error "$i: GC-thread not found in R-state"
16757 # check umounts of each MDT on MDS have reached kthread_stop()
16758 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16759 error "$i: expected $nb umount"
16761 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16762 error "$i: umount not found in D-state"
16765 # release all GC-threads
16766 do_nodes $mdts $LCTL set_param fail_loc=0
16768 # wait for MDT stop to complete
16769 for i in $(seq $MDSCOUNT); do
16770 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16774 # may try to check if any orphan changelog records are present
16775 # via ldiskfs/zfs and llog_reader...
16777 # re-start/mount MDTs
16778 for i in $(seq $MDSCOUNT); do
16779 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16780 error "Fail to start mds$i"
16784 for i in $(seq $MDSCOUNT); do
16785 # check cl_user1 still registered
16786 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16787 error "mds$i: User ${cl_user1[mds$i]} not registered"
16788 # check cl_user2 unregistered
16789 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16790 error "mds$i: User ${cl_user2[mds$i]} still registered"
16792 # check changelogs are present and starting at $user_rec1 + 1
16793 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16794 [ -n "$user_rec1" ] ||
16795 error "mds$i: User ${cl_user1[mds$i]} not registered"
16796 first_rec=$($LFS changelog $(facet_svc mds$i) |
16797 awk '{ print $1; exit; }')
16799 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16800 [ $((user_rec1 + 1)) == $first_rec ] ||
16801 error "mds$i: first index should be $user_rec1 + 1, " \
16802 "but is $first_rec"
16805 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16810 local mdts=$(comma_list $(mdts_nodes))
16812 changelog_register || error "first changelog_register failed"
16814 # generate some changelog records to accumulate on each MDT
16815 # use all_char because created files should be evenly distributed
16816 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16817 error "test_mkdir $tdir failed"
16818 for ((i = 0; i < MDSCOUNT; i++)); do
16819 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16820 error "create $DIR/$tdir/d$i.1 failed"
16823 # check changelogs have been generated
16824 local nbcl=$(changelog_dump | wc -l)
16825 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16827 # simulate race between register and unregister
16828 # XXX as fail_loc is set per-MDS, with DNE configs the race
16829 # simulation will only occur for one MDT per MDS and for the
16830 # others the normal race scenario will take place
16831 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16832 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16833 do_nodes $mdts $LCTL set_param fail_val=1
16835 # unregister 1st user
16836 changelog_deregister &
16838 # wait some time for deregister work to reach race rdv
16840 # register 2nd user
16841 changelog_register || error "2nd user register failed"
16843 wait $pid1 || error "1st user deregister failed"
16847 declare -A LAST_REC
16848 for i in $(seq $MDSCOUNT); do
16849 if changelog_users mds$i | grep "^cl"; then
16850 # make sure new records are added with one user present
16851 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16852 awk '/^current.index:/ { print $NF }')
16854 error "mds$i has no user registered"
16858 # generate more changelog records to accumulate on each MDT
16859 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16860 error "create $DIR/$tdir/${tfile}bis failed"
16862 for i in $(seq $MDSCOUNT); do
16863 last_rec=$(changelog_users $SINGLEMDS |
16864 awk '/^current.index:/ { print $NF }')
16865 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16866 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16867 error "changelogs are off on mds$i"
16870 run_test 160i "changelog user register/unregister race"
16873 remote_mds_nodsh && skip "remote MDS with nodsh"
16874 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16875 skip "Need MDS version at least 2.12.56"
16877 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16878 stack_trap "umount $MOUNT2" EXIT
16880 changelog_register || error "first changelog_register failed"
16881 stack_trap "changelog_deregister" EXIT
16883 # generate some changelog
16884 # use all_char because created files should be evenly distributed
16885 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16886 error "mkdir $tdir failed"
16887 for ((i = 0; i < MDSCOUNT; i++)); do
16888 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16889 error "create $DIR/$tdir/d$i.1 failed"
16892 # open the changelog device
16893 exec 3>/dev/changelog-$FSNAME-MDT0000
16894 stack_trap "exec 3>&-" EXIT
16895 exec 4</dev/changelog-$FSNAME-MDT0000
16896 stack_trap "exec 4<&-" EXIT
16898 # umount the first lustre mount
16900 stack_trap "mount_client $MOUNT" EXIT
16902 # read changelog, which may or may not fail, but should not crash
16906 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16907 changelog_users $SINGLEMDS | grep -q $cl_user ||
16908 error "User $cl_user not found in changelog_users"
16910 printf 'clear:'$cl_user':0' >&3
16912 run_test 160j "client can be umounted while its chanangelog is being used"
16915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16916 remote_mds_nodsh && skip "remote MDS with nodsh"
16918 mkdir -p $DIR/$tdir/1/1
16920 changelog_register || error "changelog_register failed"
16921 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16923 changelog_users $SINGLEMDS | grep -q $cl_user ||
16924 error "User '$cl_user' not found in changelog_users"
16925 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16926 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16927 rmdir $DIR/$tdir/1/1 & sleep 1
16929 touch $DIR/$tdir/2/2
16930 rm -rf $DIR/$tdir/2
16935 changelog_dump | grep rmdir || error "rmdir not recorded"
16937 run_test 160k "Verify that changelog records are not lost"
16939 # Verifies that a file passed as a parameter has recently had an operation
16940 # performed on it that has generated an MTIME changelog which contains the
16941 # correct parent FID. As files might reside on a different MDT from the
16942 # parent directory in DNE configurations, the FIDs are translated to paths
16943 # before being compared, which should be identical
16944 compare_mtime_changelog() {
16952 mdtidx=$($LFS getstripe --mdt-index $file)
16953 mdtidx=$(printf "%04x" $mdtidx)
16955 # Obtain the parent FID from the MTIME changelog
16956 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16957 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16959 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16960 [ -z "$cl_fid" ] && error "parent FID not present"
16962 # Verify that the path for the parent FID is the same as the path for
16963 # the test directory
16964 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16968 [[ "${pdir%/}" == "$dir" ]] ||
16969 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16973 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16975 remote_mds_nodsh && skip "remote MDS with nodsh"
16976 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16977 skip "Need MDS version at least 2.13.55"
16981 changelog_register || error "changelog_register failed"
16982 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16984 changelog_users $SINGLEMDS | grep -q $cl_user ||
16985 error "User '$cl_user' not found in changelog_users"
16987 # Clear some types so that MTIME changelogs are generated
16988 changelog_chmask "-CREAT"
16989 changelog_chmask "-CLOSE"
16991 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16993 # Test CL_MTIME during setattr
16994 touch $DIR/$tdir/$tfile
16995 compare_mtime_changelog $DIR/$tdir/$tfile
16997 # Test CL_MTIME during close
16998 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16999 compare_mtime_changelog $DIR/$tdir/${tfile}_2
17001 run_test 160l "Verify that MTIME changelog records contain the parent FID"
17004 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17005 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17006 skip "Need MDS version at least 2.14.51"
17013 changelog_register || error "first changelog_register failed"
17014 changelog_register || error "second changelog_register failed"
17016 cl_users=(${CL_USERS[mds1]})
17017 cl_user1="${cl_users[0]}"
17018 cl_user2="${cl_users[1]}"
17019 # generate some changelog records to accumulate on MDT0
17020 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17021 createmany -m $DIR/$tdir/$tfile 50 ||
17022 error "create $DIR/$tdir/$tfile failed"
17023 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17026 # check changelogs have been generated
17027 local nbcl=$(changelog_dump | wc -l)
17028 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17030 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
17031 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
17033 __changelog_clear mds1 $cl_user1 +10
17034 __changelog_clear mds1 $cl_user2 0 &
17037 __changelog_clear mds1 $cl_user1 0 ||
17038 error "fail to cancel record for $cl_user1"
17040 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17042 run_test 160m "Changelog clear race"
17045 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17046 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17047 skip "Need MDS version at least 2.14.51"
17056 changelog_register || error "first changelog_register failed"
17058 cl_users=(${CL_USERS[mds1]})
17059 cl_user1="${cl_users[0]}"
17061 # generate some changelog records to accumulate on MDT0
17062 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17063 first_rec=$(changelog_users $SINGLEMDS |
17064 awk '/^current.index:/ { print $NF }')
17065 while (( last_rec < (( first_rec + 65000)) )); do
17066 createmany -m $DIR/$tdir/$tfile 10000 ||
17067 error "create $DIR/$tdir/$tfile failed"
17069 for i in $(seq 0 10000); do
17070 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
17074 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
17075 error "unlinkmany failed unlink"
17076 last_rec=$(changelog_users $SINGLEMDS |
17077 awk '/^current.index:/ { print $NF }')
17078 echo last record $last_rec
17079 (( last_rec == 0 )) && error "no changelog found"
17082 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
17083 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
17085 __changelog_clear mds1 $cl_user1 0 &
17088 __changelog_clear mds1 $cl_user1 0 ||
17089 error "fail to cancel record for $cl_user1"
17091 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
17093 run_test 160n "Changelog destroy race"
17096 local mdt="$(facet_svc $SINGLEMDS)"
17098 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17099 remote_mds_nodsh && skip "remote MDS with nodsh"
17100 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
17101 skip "Need MDS version at least 2.14.52"
17103 changelog_register --user test_160o -m unlnk+close+open ||
17104 error "changelog_register failed"
17106 do_facet $SINGLEMDS $LCTL --device $mdt \
17107 changelog_register -u "Tt3_-#" &&
17108 error "bad symbols in name should fail"
17110 do_facet $SINGLEMDS $LCTL --device $mdt \
17111 changelog_register -u test_160o &&
17112 error "the same name registration should fail"
17114 do_facet $SINGLEMDS $LCTL --device $mdt \
17115 changelog_register -u test_160toolongname &&
17116 error "too long name registration should fail"
17118 changelog_chmask "MARK+HSM"
17119 lctl get_param mdd.*.changelog*mask
17120 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17121 changelog_users $SINGLEMDS | grep -q $cl_user ||
17122 error "User $cl_user not found in changelog_users"
17124 echo $cl_user | grep -q test_160o ||
17125 error "User $cl_user has no specific name 'test160o'"
17128 changelog_clear 0 || error "changelog_clear failed"
17129 # generate some changelog records to accumulate on MDT0
17130 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17131 touch $DIR/$tdir/$tfile # open 1
17133 OPENS=$(changelog_dump | grep -c "OPEN")
17134 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
17136 # must be no MKDIR it wasn't set as user mask
17137 MKDIR=$(changelog_dump | grep -c "MKDIR")
17138 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
17140 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
17141 mdd.$mdt.changelog_current_mask -n)
17142 # register maskless user
17143 changelog_register || error "changelog_register failed"
17144 # effective mask should be not changed because it is not minimal
17145 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17146 mdd.$mdt.changelog_current_mask -n)
17147 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
17148 # set server mask to minimal value
17149 changelog_chmask "MARK"
17150 # check effective mask again, should be treated as DEFMASK now
17151 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17152 mdd.$mdt.changelog_current_mask -n)
17153 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17155 do_facet $SINGLEMDS $LCTL --device $mdt \
17156 changelog_deregister -u test_160o ||
17157 error "cannot deregister by name"
17159 run_test 160o "changelog user name and mask"
17162 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17163 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
17164 skip "Need MDS version at least 2.14.51"
17165 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
17171 changelog_register || error "first changelog_register failed"
17173 cl_users=(${CL_USERS[mds1]})
17174 cl_user1="${cl_users[0]}"
17176 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
17177 createmany -m $DIR/$tdir/$tfile 50 ||
17178 error "create $DIR/$tdir/$tfile failed"
17179 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
17182 # check changelogs have been generated
17183 entry_count=$(changelog_dump | wc -l)
17184 ((entry_count != 0)) || error "no changelog entries found"
17186 # remove changelog_users and check that orphan entries are removed
17188 local dev=$(mdsdevname 1)
17189 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
17190 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
17191 entry_count=$(changelog_dump | wc -l)
17192 ((entry_count == 0)) ||
17193 error "found $entry_count changelog entries, expected none"
17195 run_test 160p "Changelog orphan cleanup with no users"
17198 local mdt="$(facet_svc $SINGLEMDS)"
17201 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
17202 remote_mds_nodsh && skip "remote MDS with nodsh"
17203 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
17204 skip "Need MDS version at least 2.14.54"
17206 # set server mask to minimal value like server init does
17207 changelog_chmask "MARK"
17208 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
17209 error "changelog_register failed"
17210 # check effective mask again, should be treated as DEFMASK now
17211 mask=$(do_facet $SINGLEMDS $LCTL get_param \
17212 mdd.$mdt.changelog_current_mask -n)
17213 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
17214 error "changelog_deregister failed"
17215 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17217 run_test 160q "changelog effective mask is DEFMASK if not set"
17220 remote_mds_nodsh && skip "remote MDS with nodsh"
17221 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
17222 skip "Need MDS version at least 2.14.55"
17224 local mdts=$(comma_list $(mdts_nodes))
17226 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
17227 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
17228 fail_val=$((24 * 3600 * 10))
17230 # Create a user which is 10 days old
17231 changelog_register || error "first changelog_register failed"
17233 declare -A cl_user1
17236 # generate some changelog records to accumulate on each MDT
17237 # use all_char because created files should be evenly distributed
17238 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17239 error "test_mkdir $tdir failed"
17240 for ((i = 0; i < MDSCOUNT; i++)); do
17241 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17242 error "create $DIR/$tdir/d$i.1 failed"
17245 # check changelogs have been generated
17246 local nbcl=$(changelog_dump | wc -l)
17247 (( nbcl > 0 )) || error "no changelogs found"
17249 # reduce the max_idle_indexes value to make sure we exceed it
17250 for param in "changelog_max_idle_indexes=2097446912" \
17251 "changelog_max_idle_time=2592000" \
17253 "changelog_min_gc_interval=2"; do
17254 local MDT0=$(facet_svc $SINGLEMDS)
17255 local var="${param%=*}"
17256 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17258 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17259 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17260 error "unable to set mdd.*.$param"
17263 local start=$SECONDS
17264 for i in $(seq $MDSCOUNT); do
17265 cl_users=(${CL_USERS[mds$i]})
17266 cl_user1[mds$i]="${cl_users[0]}"
17268 [[ -n "${cl_user1[mds$i]}" ]] ||
17269 error "mds$i: no user registered"
17272 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
17273 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
17275 # ensure we are past the previous changelog_min_gc_interval set above
17276 local sleep2=$((start + 2 - SECONDS))
17277 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17279 # Generate one more changelog to trigger GC
17280 for ((i = 0; i < MDSCOUNT; i++)); do
17281 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
17282 error "create $DIR/$tdir/d$i.3 failed"
17285 # ensure gc thread is done
17286 for node in $(mdts_nodes); do
17287 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
17288 error "$node: GC-thread not done"
17291 do_nodes $mdts $LCTL set_param fail_loc=0
17293 for (( i = 1; i <= MDSCOUNT; i++ )); do
17294 # check cl_user1 is purged
17295 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
17296 error "mds$i: User ${cl_user1[mds$i]} is registered"
17300 run_test 160s "changelog garbage collect on idle records * time"
17303 remote_mds_nodsh && skip "remote MDS with nodsh"
17304 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
17305 skip "Need MDS version at least 2.15.50"
17307 local MDT0=$(facet_svc $SINGLEMDS)
17313 changelog_register --user user1 -m all ||
17314 error "user1 failed to register"
17316 mkdir_on_mdt0 $DIR/$tdir
17317 # create default overstripe to maximize changelog size
17318 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
17319 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
17320 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17322 # user2 consumes less records so less space
17323 changelog_register --user user2 || error "user2 failed to register"
17324 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
17325 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
17327 # check changelogs have been generated
17328 local nbcl=$(changelog_dump | wc -l)
17329 (( nbcl > 0 )) || error "no changelogs found"
17331 # reduce the changelog_min_gc_interval to force check
17332 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
17333 local var="${param%=*}"
17334 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17336 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
17337 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
17338 error "unable to set mdd.*.$param"
17342 cl_users=(${CL_USERS[mds1]})
17343 cl_user1="${cl_users[0]}"
17344 cl_user2="${cl_users[1]}"
17346 [[ -n $cl_user1 ]] ||
17347 error "mds1: user #1 isn't registered"
17348 [[ -n $cl_user2 ]] ||
17349 error "mds1: user #2 isn't registered"
17351 # ensure we are past the previous changelog_min_gc_interval set above
17352 local sleep2=$((start + 2 - SECONDS))
17353 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17355 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
17356 do_facet mds1 $LCTL set_param fail_loc=0x018c \
17357 fail_val=$(((llog_size1 + llog_size2) / 2))
17359 # Generate more changelog to trigger GC
17360 createmany -o $DIR/$tdir/u3_ 4 ||
17361 error "create failed for more files"
17363 # ensure gc thread is done
17364 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
17365 error "mds1: GC-thread not done"
17367 do_facet mds1 $LCTL set_param fail_loc=0
17369 # check cl_user1 is purged
17370 changelog_users mds1 | grep -q "$cl_user1" &&
17371 error "User $cl_user1 is registered"
17372 # check cl_user2 is not purged
17373 changelog_users mds1 | grep -q "$cl_user2" ||
17374 error "User $cl_user2 is not registered"
17376 run_test 160t "changelog garbage collect on lack of space"
17379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17381 test_mkdir -c1 $DIR/$tdir
17382 cp /etc/hosts $DIR/$tdir/$tfile
17383 test_mkdir -c1 $DIR/$tdir/foo1
17384 test_mkdir -c1 $DIR/$tdir/foo2
17385 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
17386 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
17387 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
17388 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
17389 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
17390 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17391 $LFS fid2path $DIR $FID
17392 error "bad link ea"
17395 rm $DIR/$tdir/foo2/zachary
17397 rm $DIR/$tdir/foo2/thor
17399 rm $DIR/$tdir/$tfile
17401 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
17402 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
17403 { $LFS fid2path $DIR $FID; error "bad link rename"; }
17404 rm $DIR/$tdir/foo2/maggie
17407 local longname=$tfile.avg_len_is_thirty_two_
17408 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
17409 error_noexit 'failed to unlink many hardlinks'" EXIT
17410 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
17411 error "failed to hardlink many files"
17412 links=$($LFS fid2path $DIR $FID | wc -l)
17413 echo -n "${links}/1000 links in link EA"
17414 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
17416 run_test 161a "link ea sanity"
17419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17420 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
17423 local remote_dir=$DIR/$tdir/remote_dir
17425 mkdir -p $DIR/$tdir
17426 $LFS mkdir -i $MDTIDX $remote_dir ||
17427 error "create remote directory failed"
17429 cp /etc/hosts $remote_dir/$tfile
17430 mkdir -p $remote_dir/foo1
17431 mkdir -p $remote_dir/foo2
17432 ln $remote_dir/$tfile $remote_dir/foo1/sofia
17433 ln $remote_dir/$tfile $remote_dir/foo2/zachary
17434 ln $remote_dir/$tfile $remote_dir/foo1/luna
17435 ln $remote_dir/$tfile $remote_dir/foo2/thor
17437 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
17439 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17440 $LFS fid2path $DIR $FID
17441 error "bad link ea"
17444 rm $remote_dir/foo2/zachary
17446 rm $remote_dir/foo2/thor
17448 rm $remote_dir/$tfile
17450 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
17451 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
17452 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
17453 $LFS fid2path $DIR $FID
17454 error "bad link rename"
17456 rm $remote_dir/foo2/maggie
17459 local longname=filename_avg_len_is_thirty_two_
17460 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17461 error "failed to hardlink many files"
17462 links=$($LFS fid2path $DIR $FID | wc -l)
17463 echo -n "${links}/1000 links in link EA"
17464 [[ ${links} -gt 60 ]] ||
17465 error "expected at least 60 links in link EA"
17466 unlinkmany $remote_dir/foo2/$longname 1000 ||
17467 error "failed to unlink many hardlinks"
17469 run_test 161b "link ea sanity under remote directory"
17472 remote_mds_nodsh && skip "remote MDS with nodsh"
17473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17474 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17475 skip "Need MDS version at least 2.1.5"
17477 # define CLF_RENAME_LAST 0x0001
17478 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17479 changelog_register || error "changelog_register failed"
17482 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17483 touch $DIR/$tdir/foo_161c
17484 touch $DIR/$tdir/bar_161c
17485 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17486 changelog_dump | grep RENME | tail -n 5
17487 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17488 changelog_clear 0 || error "changelog_clear failed"
17489 if [ x$flags != "x0x1" ]; then
17490 error "flag $flags is not 0x1"
17493 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17494 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17495 touch $DIR/$tdir/foo_161c
17496 touch $DIR/$tdir/bar_161c
17497 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17498 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17499 changelog_dump | grep RENME | tail -n 5
17500 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17501 changelog_clear 0 || error "changelog_clear failed"
17502 if [ x$flags != "x0x0" ]; then
17503 error "flag $flags is not 0x0"
17505 echo "rename overwrite a target having nlink > 1," \
17506 "changelog record has flags of $flags"
17508 # rename doesn't overwrite a target (changelog flag 0x0)
17509 touch $DIR/$tdir/foo_161c
17510 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17511 changelog_dump | grep RENME | tail -n 5
17512 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17513 changelog_clear 0 || error "changelog_clear failed"
17514 if [ x$flags != "x0x0" ]; then
17515 error "flag $flags is not 0x0"
17517 echo "rename doesn't overwrite a target," \
17518 "changelog record has flags of $flags"
17520 # define CLF_UNLINK_LAST 0x0001
17521 # unlink a file having nlink = 1 (changelog flag 0x1)
17522 rm -f $DIR/$tdir/foo2_161c
17523 changelog_dump | grep UNLNK | tail -n 5
17524 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17525 changelog_clear 0 || error "changelog_clear failed"
17526 if [ x$flags != "x0x1" ]; then
17527 error "flag $flags is not 0x1"
17529 echo "unlink a file having nlink = 1," \
17530 "changelog record has flags of $flags"
17532 # unlink a file having nlink > 1 (changelog flag 0x0)
17533 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17534 rm -f $DIR/$tdir/foobar_161c
17535 changelog_dump | grep UNLNK | tail -n 5
17536 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17537 changelog_clear 0 || error "changelog_clear failed"
17538 if [ x$flags != "x0x0" ]; then
17539 error "flag $flags is not 0x0"
17541 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17543 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17546 remote_mds_nodsh && skip "remote MDS with nodsh"
17547 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17552 changelog_register || error "changelog_register failed"
17554 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17555 # interfer with $MOUNT/.lustre/fid/ access
17557 [[ $? -eq 0 ]] || error "mkdir failed"
17559 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17560 $LCTL set_param fail_loc=0x8000140c
17562 $LCTL set_param fail_val=5
17565 echo foofoo > $DIR/$tdir/$tfile &
17568 # wait for create to be delayed
17572 [[ $? -eq 0 ]] || error "create should be blocked"
17574 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17575 stack_trap "rm -f $tempfile"
17576 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17577 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17578 # some delay may occur during ChangeLog publishing and file read just
17579 # above, that could allow file write to happen finally
17580 [[ -s $tempfile ]] && echo "file should be empty"
17582 $LCTL set_param fail_loc=0
17585 [[ $? -eq 0 ]] || error "create failed"
17587 run_test 161d "create with concurrent .lustre/fid access"
17590 local expected="$1"
17595 path=$($LFS fid2path "$@")
17598 if [ $rc -ne 0 ]; then
17599 error "path looked up of '$expected' failed: rc=$rc"
17600 elif [ "$path" != "$expected" ]; then
17601 error "path looked up '$path' instead of '$expected'"
17603 echo "FID '$fid' resolves to path '$path' as expected"
17607 test_162a() { # was test_162
17608 test_mkdir -p -c1 $DIR/$tdir/d2
17609 touch $DIR/$tdir/d2/$tfile
17610 touch $DIR/$tdir/d2/x1
17611 touch $DIR/$tdir/d2/x2
17612 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17613 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17615 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17616 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17619 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17620 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17621 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17623 # softlink to wrong file
17624 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17625 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17626 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17629 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17630 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17631 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17632 # fid2path dir/fsname should both work
17633 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17634 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17636 # hardlink count: check that there are 2 links
17637 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17638 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17640 # hardlink indexing: remove the first link
17641 rm $DIR/$tdir/d2/p/q/r/hlink
17642 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17644 run_test 162a "path lookup sanity"
17647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17648 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17651 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17652 error "create striped dir failed"
17654 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17655 tail -n 1 | awk '{print $2}')
17656 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17658 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17659 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17662 for ((i=0;i<5;i++)); do
17663 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17664 error "get fid for f$i failed"
17665 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17667 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17668 error "get fid for d$i failed"
17669 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17674 run_test 162b "striped directory path lookup sanity"
17676 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17678 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17679 skip "Need MDS version at least 2.7.51"
17681 local lpath=$tdir.local
17682 local rpath=$tdir.remote
17684 test_mkdir $DIR/$lpath
17685 test_mkdir $DIR/$rpath
17687 for ((i = 0; i <= 101; i++)); do
17690 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17691 error "get fid for local directory $DIR/$lpath failed"
17692 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17695 test_mkdir $DIR/$rpath
17696 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17697 error "get fid for remote directory $DIR/$rpath failed"
17698 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17703 run_test 162c "fid2path works with paths 100 or more directories deep"
17705 oalr_event_count() {
17709 awk -v name="${FSNAME}-OST0000" \
17710 -v event="${event}" \
17711 '$1 == "TRACE" && $2 == event && $3 == name' \
17716 oalr_expect_event_count() {
17719 local expect="${3}"
17722 count=$(oalr_event_count "${event}" "${trace}")
17723 if ((count == expect)); then
17727 error_noexit "${event} event count was '${count}', expected ${expect}"
17733 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17735 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17739 sync # Flush previous IOs so we can count log entries.
17740 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17741 stack_trap cleanup_165 EXIT
17745 local trace="/tmp/${tfile}.trace"
17749 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17750 skip "OFD access log unsupported"
17753 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17756 do_facet ost1 ofd_access_log_reader --list
17759 do_facet ost1 killall -TERM ofd_access_log_reader
17763 if ((rc != 0)); then
17764 error "ofd_access_log_reader exited with rc = '${rc}'"
17767 # Parse trace file for discovery events:
17768 oalr_expect_event_count alr_log_add "${trace}" 1
17769 oalr_expect_event_count alr_log_eof "${trace}" 1
17770 oalr_expect_event_count alr_log_free "${trace}" 1
17772 run_test 165a "ofd access log discovery"
17775 local trace="/tmp/${tfile}.trace"
17776 local file="${DIR}/${tfile}"
17785 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17786 skip "OFD access log unsupported"
17789 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17792 do_facet ost1 ofd_access_log_reader --list
17794 lfs setstripe -c 1 -i 0 "${file}"
17795 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17796 error "cannot create '${file}'"
17799 do_facet ost1 killall -TERM ofd_access_log_reader
17803 if ((rc != 0)); then
17804 error "ofd_access_log_reader exited with rc = '${rc}'"
17807 oalr_expect_event_count alr_log_entry "${trace}" 1
17809 pfid1=$($LFS path2fid "${file}")
17811 # 1 2 3 4 5 6 7 8 9 10
17812 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
17813 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17815 echo "entry = '${entry[*]}'" >&2
17818 if [[ "${pfid1}" != "${pfid2}" ]]; then
17819 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17823 if ((size != 1048576)); then
17824 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
17828 if [[ "${flags}" != "w" ]]; then
17829 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
17832 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17835 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
17836 error "cannot read '${file}'"
17839 do_facet ost1 killall -TERM ofd_access_log_reader
17843 if ((rc != 0)); then
17844 error "ofd_access_log_reader exited with rc = '${rc}'"
17847 oalr_expect_event_count alr_log_entry "${trace}" 1
17849 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17850 echo "entry = '${entry[*]}'" >&2
17853 if [[ "${pfid1}" != "${pfid2}" ]]; then
17854 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17858 if ((size != 524288)); then
17859 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
17863 if [[ "${flags}" != "r" ]]; then
17864 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
17867 run_test 165b "ofd access log entries are produced and consumed"
17870 local trace="/tmp/${tfile}.trace"
17871 local file="${DIR}/${tdir}/${tfile}"
17873 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17874 skip "OFD access log unsupported"
17876 test_mkdir "${DIR}/${tdir}"
17879 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17882 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
17884 # 4096 / 64 = 64. Create twice as many entries.
17885 for ((i = 0; i < 128; i++)); do
17886 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
17887 error "cannot create file"
17892 do_facet ost1 killall -TERM ofd_access_log_reader
17895 if ((rc != 0)); then
17896 error "ofd_access_log_reader exited with rc = '${rc}'"
17899 unlinkmany "${file}-%d" 128
17901 run_test 165c "full ofd access logs do not block IOs"
17903 oal_get_read_count() {
17906 # STATS lustre-OST0001 alr_read_count 1
17908 do_facet ost1 cat "${stats}" |
17909 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
17910 END { print count; }'
17913 oal_expect_read_count() {
17918 # Ask ofd_access_log_reader to write stats.
17919 do_facet ost1 killall -USR1 ofd_access_log_reader
17921 # Allow some time for things to happen.
17924 count=$(oal_get_read_count "${stats}")
17925 if ((count == expect)); then
17929 error_noexit "bad read count, got ${count}, expected ${expect}"
17930 do_facet ost1 cat "${stats}" >&2
17935 local stats="/tmp/${tfile}.stats"
17936 local file="${DIR}/${tdir}/${tfile}"
17937 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
17939 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17940 skip "OFD access log unsupported"
17942 test_mkdir "${DIR}/${tdir}"
17945 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
17948 lfs setstripe -c 1 -i 0 "${file}"
17950 do_facet ost1 lctl set_param "${param}=rw"
17951 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17952 error "cannot create '${file}'"
17953 oal_expect_read_count "${stats}" 1
17955 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17956 error "cannot read '${file}'"
17957 oal_expect_read_count "${stats}" 2
17959 do_facet ost1 lctl set_param "${param}=r"
17960 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17961 error "cannot create '${file}'"
17962 oal_expect_read_count "${stats}" 2
17964 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17965 error "cannot read '${file}'"
17966 oal_expect_read_count "${stats}" 3
17968 do_facet ost1 lctl set_param "${param}=w"
17969 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17970 error "cannot create '${file}'"
17971 oal_expect_read_count "${stats}" 4
17973 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17974 error "cannot read '${file}'"
17975 oal_expect_read_count "${stats}" 4
17977 do_facet ost1 lctl set_param "${param}=0"
17978 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17979 error "cannot create '${file}'"
17980 oal_expect_read_count "${stats}" 4
17982 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17983 error "cannot read '${file}'"
17984 oal_expect_read_count "${stats}" 4
17986 do_facet ost1 killall -TERM ofd_access_log_reader
17989 if ((rc != 0)); then
17990 error "ofd_access_log_reader exited with rc = '${rc}'"
17993 run_test 165d "ofd_access_log mask works"
17996 local stats="/tmp/${tfile}.stats"
17997 local file0="${DIR}/${tdir}-0/${tfile}"
17998 local file1="${DIR}/${tdir}-1/${tfile}"
18000 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18001 skip "OFD access log unsupported"
18003 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18005 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
18006 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
18008 lfs setstripe -c 1 -i 0 "${file0}"
18009 lfs setstripe -c 1 -i 0 "${file1}"
18012 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
18015 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
18016 error "cannot create '${file0}'"
18018 oal_expect_read_count "${stats}" 0
18020 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
18021 error "cannot create '${file1}'"
18023 oal_expect_read_count "${stats}" 1
18025 do_facet ost1 killall -TERM ofd_access_log_reader
18028 if ((rc != 0)); then
18029 error "ofd_access_log_reader exited with rc = '${rc}'"
18032 run_test 165e "ofd_access_log MDT index filter works"
18035 local trace="/tmp/${tfile}.trace"
18040 do_facet ost1 timeout 60 ofd_access_log_reader \
18041 --exit-on-close --debug=- --trace=- > "${trace}" &
18048 if ((rc != 0)); then
18049 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
18054 run_test 165f "ofd_access_log_reader --exit-on-close works"
18057 # do directio so as not to populate the page cache
18058 log "creating a 10 Mb file"
18059 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
18060 error "multiop failed while creating a file"
18061 log "starting reads"
18062 dd if=$DIR/$tfile of=/dev/null bs=4096 &
18063 log "truncating the file"
18064 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
18065 error "multiop failed while truncating the file"
18067 kill %+ || true # reads might have finished
18068 echo "wait until dd is finished"
18070 log "removing the temporary file"
18071 rm -rf $DIR/$tfile || error "tmp file removal failed"
18073 run_test 169 "parallel read and truncate should not deadlock"
18076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18078 $LCTL clear # bug 18514
18079 $LCTL debug_daemon start $TMP/${tfile}_log_good
18081 $LCTL debug_daemon stop
18082 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
18083 error "sed failed to read log_good"
18085 $LCTL debug_daemon start $TMP/${tfile}_log_good
18087 $LCTL debug_daemon stop
18089 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
18090 error "lctl df log_bad failed"
18092 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18093 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18095 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
18096 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
18098 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
18099 error "bad_line good_line1 good_line2 are empty"
18101 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18102 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
18103 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
18105 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
18106 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
18107 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
18109 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
18110 error "bad_line_new good_line_new are empty"
18112 local expected_good=$((good_line1 + good_line2*2))
18114 rm -f $TMP/${tfile}*
18115 # LU-231, short malformed line may not be counted into bad lines
18116 if [ $bad_line -ne $bad_line_new ] &&
18117 [ $bad_line -ne $((bad_line_new - 1)) ]; then
18118 error "expected $bad_line bad lines, but got $bad_line_new"
18122 if [ $expected_good -ne $good_line_new ]; then
18123 error "expected $expected_good good lines, but got $good_line_new"
18128 run_test 170 "test lctl df to handle corrupted log ====================="
18130 test_171() { # bug20592
18131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18133 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
18134 $LCTL set_param fail_loc=0x50e
18135 $LCTL set_param fail_val=3000
18136 multiop_bg_pause $DIR/$tfile O_s || true
18138 kill -USR1 $MULTIPID
18142 if dmesg | grep "recursive fault"; then
18143 error "caught a recursive fault"
18145 $LCTL set_param fail_loc=0
18148 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
18152 #define OBD_FAIL_OBD_CLEANUP 0x60e
18153 $LCTL set_param fail_loc=0x60e
18154 umount $MOUNT || error "umount $MOUNT failed"
18155 stack_trap "mount_client $MOUNT"
18157 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
18158 error "no client OBDs are remained"
18160 $LCTL dl | while read devno state type name foo; do
18163 $LCTL --device $name cleanup
18164 $LCTL --device $name detach
18167 # skip server devices
18172 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
18173 $LCTL dl | egrep " osc | lov | lmv | mdc "
18174 error "some client OBDs are still remained"
18178 run_test 172 "manual device removal with lctl cleanup/detach ======"
18180 # it would be good to share it with obdfilter-survey/iokit-libecho code
18181 setup_obdecho_osc () {
18184 local obdfilter_name=$2
18185 echo "Creating new osc for $obdfilter_name on $ost_nid"
18186 # make sure we can find loopback nid
18187 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
18189 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
18190 ${obdfilter_name}_osc_UUID || rc=2; }
18191 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
18192 ${obdfilter_name}_UUID $ost_nid || rc=3; }
18196 cleanup_obdecho_osc () {
18197 local obdfilter_name=$1
18198 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
18199 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
18206 local pages=${3:-64}
18211 local obd_size=$(get_obd_size $node $OBD)
18212 local page_size=$(get_page_size $node)
18213 if [[ -n "$obd_size" ]]; then
18214 local new_count=$((obd_size / (pages * page_size / 1024)))
18215 [[ $new_count -ge $count ]] || count=$new_count
18218 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
18219 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
18221 if [ $rc -eq 0 ]; then
18222 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
18223 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
18225 echo "New object id is $id"
18226 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
18228 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
18229 "test_brw $count w v $pages $id" || rc=4; }
18230 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
18232 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
18233 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
18234 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
18235 { do_facet $node "$LCTL --device ec detach" || rc=6; }
18236 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
18241 skip "obdecho on osc is no longer supported"
18243 run_test 180a "test obdecho on osc"
18246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18247 remote_ost_nodsh && skip "remote OST with nodsh"
18249 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18250 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18251 error "failed to load module obdecho"
18253 local target=$(do_facet ost1 $LCTL dl |
18254 awk '/obdfilter/ { print $4; exit; }')
18256 if [ -n "$target" ]; then
18257 obdecho_test $target ost1 || error "obdecho_test failed with $?"
18259 do_facet ost1 $LCTL dl
18260 error "there is no obdfilter target on ost1"
18263 run_test 180b "test obdecho directly on obdfilter"
18265 test_180c() { # LU-2598
18266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18267 remote_ost_nodsh && skip "remote OST with nodsh"
18268 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
18269 skip "Need MDS version at least 2.4.0"
18271 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
18272 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
18273 error "failed to load module obdecho"
18275 local target=$(do_facet ost1 $LCTL dl |
18276 awk '/obdfilter/ { print $4; exit; }')
18278 if [ -n "$target" ]; then
18279 local pages=16384 # 64MB bulk I/O RPC size
18281 obdecho_test "$target" ost1 "$pages" ||
18282 error "obdecho_test with pages=$pages failed with $?"
18284 do_facet ost1 $LCTL dl
18285 error "there is no obdfilter target on ost1"
18288 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
18290 test_181() { # bug 22177
18291 test_mkdir $DIR/$tdir
18292 # create enough files to index the directory
18293 createmany -o $DIR/$tdir/foobar 4000
18294 # print attributes for debug purpose
18297 multiop_bg_pause $DIR/$tdir D_Sc || return 1
18299 # remove the files & current working dir
18300 unlinkmany $DIR/$tdir/foobar 4000
18302 kill -USR1 $MULTIPID
18304 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
18307 run_test 181 "Test open-unlinked dir ========================"
18313 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18315 $LCTL set_param mdc.*.rpc_stats=clear
18317 for (( i = 0; i < $tcount; i++ )) ; do
18318 mkdir $DIR/$tdir/$i
18321 for (( i = 0; i < $tcount; i++ )) ; do
18322 createmany -o $DIR/$tdir/$i/f- $fcount &
18326 for (( i = 0; i < $tcount; i++ )) ; do
18327 unlinkmany $DIR/$tdir/$i/f- $fcount &
18331 $LCTL get_param mdc.*.rpc_stats
18335 run_test 182a "Test parallel modify metadata operations from mdc"
18338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18339 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18346 do_facet mds1 $LCTL list_param \
18347 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
18348 skip "MDS lacks parallel RPC handling"
18350 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18352 rpc_count=$(do_facet mds1 $LCTL get_param -n \
18353 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
18356 createmany -i 0 -d $DIR/$tdir/t- $tcount
18358 for (( i = 0; i < $tcount; i++ )) ; do
18359 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18363 delta=$((etime - stime))
18364 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
18367 for (( i = 0; i < $tcount; i++ )) ; do
18368 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
18372 delta=$((etime - stime))
18373 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
18377 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18379 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
18382 createmany -i 0 -d $DIR/$tdir/t- $tcount
18384 for (( i = 0; i < $tcount; i++ )) ; do
18385 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18389 delta=$((etime - stime))
18390 echo "Time for file creation $delta sec for 1 RPC sent at a time"
18393 for (( i = 0; i < $tcount; i++ )) ; do
18394 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
18398 delta=$((etime - stime))
18399 echo "Time for file removal $delta sec for 1 RPC sent at a time"
18401 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
18403 run_test 182b "Test parallel modify metadata operations from osp"
18405 test_183() { # LU-2275
18406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18407 remote_mds_nodsh && skip "remote MDS with nodsh"
18408 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
18409 skip "Need MDS version at least 2.3.56"
18411 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18412 echo aaa > $DIR/$tdir/$tfile
18414 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
18415 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
18417 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
18418 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
18420 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18422 # Flush negative dentry cache
18423 touch $DIR/$tdir/$tfile
18425 # We are not checking for any leaked references here, they'll
18426 # become evident next time we do cleanup with module unload.
18429 run_test 183 "No crash or request leak in case of strange dispositions ========"
18431 # test suite 184 is for LU-2016, LU-2017
18433 check_swap_layouts_support
18435 dir0=$DIR/$tdir/$testnum
18436 test_mkdir -p -c1 $dir0
18441 $LFS setstripe -c1 $file1
18443 $LFS setstripe -c2 $file2
18445 gen1=$($LFS getstripe -g $file1)
18446 gen2=$($LFS getstripe -g $file2)
18448 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
18449 gen=$($LFS getstripe -g $file1)
18450 [[ $gen1 != $gen ]] ||
18451 error "Layout generation on $file1 does not change"
18452 gen=$($LFS getstripe -g $file2)
18453 [[ $gen2 != $gen ]] ||
18454 error "Layout generation on $file2 does not change"
18456 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
18457 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18459 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
18461 run_test 184a "Basic layout swap"
18464 check_swap_layouts_support
18466 dir0=$DIR/$tdir/$testnum
18467 mkdir -p $dir0 || error "creating dir $dir0"
18474 $LFS setstripe -c1 $file1
18475 $LFS setstripe -c2 $file2
18476 $LFS setstripe -c1 $file3
18477 chown $RUNAS_ID $file3
18478 gen1=$($LFS getstripe -g $file1)
18479 gen2=$($LFS getstripe -g $file2)
18481 $LFS swap_layouts $dir1 $dir2 &&
18482 error "swap of directories layouts should fail"
18483 $LFS swap_layouts $dir1 $file1 &&
18484 error "swap of directory and file layouts should fail"
18485 $RUNAS $LFS swap_layouts $file1 $file2 &&
18486 error "swap of file we cannot write should fail"
18487 $LFS swap_layouts $file1 $file3 &&
18488 error "swap of file with different owner should fail"
18489 /bin/true # to clear error code
18491 run_test 184b "Forbidden layout swap (will generate errors)"
18494 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18495 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18496 check_swap_layouts_support
18497 check_swap_layout_no_dom $DIR
18499 local dir0=$DIR/$tdir/$testnum
18500 mkdir -p $dir0 || error "creating dir $dir0"
18502 local ref1=$dir0/ref1
18503 local ref2=$dir0/ref2
18504 local file1=$dir0/file1
18505 local file2=$dir0/file2
18506 # create a file large enough for the concurrent test
18507 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18508 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18509 echo "ref file size: ref1($(stat -c %s $ref1))," \
18510 "ref2($(stat -c %s $ref2))"
18513 dd if=$ref1 of=$file1 bs=16k &
18516 # Make sure dd starts to copy file, but wait at most 5 seconds
18518 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18520 $LFS swap_layouts $file1 $file2
18523 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18524 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18526 # how many bytes copied before swapping layout
18527 local copied=$(stat -c %s $file2)
18528 local remaining=$(stat -c %s $ref1)
18529 remaining=$((remaining - copied))
18530 echo "Copied $copied bytes before swapping layout..."
18532 cmp -n $copied $file1 $ref2 | grep differ &&
18533 error "Content mismatch [0, $copied) of ref2 and file1"
18534 cmp -n $copied $file2 $ref1 ||
18535 error "Content mismatch [0, $copied) of ref1 and file2"
18536 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18537 error "Content mismatch [$copied, EOF) of ref1 and file1"
18540 rm -f $ref1 $ref2 $file1 $file2
18542 run_test 184c "Concurrent write and layout swap"
18545 check_swap_layouts_support
18546 check_swap_layout_no_dom $DIR
18547 [ -z "$(which getfattr 2>/dev/null)" ] &&
18548 skip_env "no getfattr command"
18550 local file1=$DIR/$tdir/$tfile-1
18551 local file2=$DIR/$tdir/$tfile-2
18552 local file3=$DIR/$tdir/$tfile-3
18556 mkdir -p $DIR/$tdir
18557 touch $file1 || error "create $file1 failed"
18558 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18559 error "create $file2 failed"
18560 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18561 error "create $file3 failed"
18562 lovea1=$(get_layout_param $file1)
18564 $LFS swap_layouts $file2 $file3 ||
18565 error "swap $file2 $file3 layouts failed"
18566 $LFS swap_layouts $file1 $file2 ||
18567 error "swap $file1 $file2 layouts failed"
18569 lovea2=$(get_layout_param $file2)
18572 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18574 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18575 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18577 run_test 184d "allow stripeless layouts swap"
18580 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18581 skip "Need MDS version at least 2.6.94"
18582 check_swap_layouts_support
18583 check_swap_layout_no_dom $DIR
18584 [ -z "$(which getfattr 2>/dev/null)" ] &&
18585 skip_env "no getfattr command"
18587 local file1=$DIR/$tdir/$tfile-1
18588 local file2=$DIR/$tdir/$tfile-2
18589 local file3=$DIR/$tdir/$tfile-3
18592 mkdir -p $DIR/$tdir
18593 touch $file1 || error "create $file1 failed"
18594 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18595 error "create $file2 failed"
18596 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18597 error "create $file3 failed"
18599 $LFS swap_layouts $file1 $file2 ||
18600 error "swap $file1 $file2 layouts failed"
18602 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18603 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18605 echo 123 > $file1 || error "Should be able to write into $file1"
18607 $LFS swap_layouts $file1 $file3 ||
18608 error "swap $file1 $file3 layouts failed"
18610 echo 123 > $file1 || error "Should be able to write into $file1"
18612 rm -rf $file1 $file2 $file3
18614 run_test 184e "Recreate layout after stripeless layout swaps"
18617 # Create a file with name longer than sizeof(struct stat) ==
18618 # 144 to see if we can get chars from the file name to appear
18619 # in the returned striping. Note that 'f' == 0x66.
18620 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18622 mkdir -p $DIR/$tdir
18623 mcreate $DIR/$tdir/$file
18624 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18625 error "IOC_MDC_GETFILEINFO returned garbage striping"
18628 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18630 test_185() { # LU-2441
18631 # LU-3553 - no volatile file support in old servers
18632 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18633 skip "Need MDS version at least 2.3.60"
18635 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18636 touch $DIR/$tdir/spoo
18637 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18638 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18639 error "cannot create/write a volatile file"
18640 [ "$FILESET" == "" ] &&
18641 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18642 error "FID is still valid after close"
18644 multiop_bg_pause $DIR/$tdir vVw4096_c
18651 # assume that the next FID for this client is sequential, since stdout
18652 # is unfortunately eaten by multiop_bg_pause
18653 local n=$((${fidv[1]} + 1))
18654 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18655 if [ "$FILESET" == "" ]; then
18656 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18657 error "FID is missing before close"
18659 kill -USR1 $multi_pid
18660 # 1 second delay, so if mtime change we will see it
18662 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18663 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18665 run_test 185 "Volatile file support"
18667 function create_check_volatile() {
18671 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18674 local FID=$(cat /tmp/${tfile}.fid)
18675 [ "$FID" == "" ] && error "can't get FID for volatile"
18676 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18677 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18678 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18682 cancel_lru_locks mdc # flush opencache
18683 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18688 # LU-12516 - volatile creation via .lustre
18689 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18690 skip "Need MDS version at least 2.3.55"
18692 create_check_volatile 0
18693 [ $MDSCOUNT -lt 2 ] && return 0
18696 create_check_volatile 1
18700 run_test 185a "Volatile file creation in .lustre/fid/"
18703 remote_mds_nodsh && skip "remote MDS with nodsh"
18704 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18705 skip "Need MDS version at least 2.3.0"
18707 local dir0=$DIR/$tdir/$testnum
18708 mkdir -p $dir0 || error "creating dir $dir0"
18710 local file=$dir0/file1
18711 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18712 local dv1=$($LFS data_version $file)
18713 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18714 local dv2=$($LFS data_version $file)
18715 [[ $dv1 != $dv2 ]] ||
18716 error "data version did not change on write $dv1 == $dv2"
18721 run_test 187a "Test data version change"
18724 remote_mds_nodsh && skip "remote MDS with nodsh"
18725 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18726 skip "Need MDS version at least 2.3.0"
18728 local dir0=$DIR/$tdir/$testnum
18729 mkdir -p $dir0 || error "creating dir $dir0"
18731 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18732 [[ ${DV[0]} != ${DV[1]} ]] ||
18733 error "data version did not change on write"\
18734 " ${DV[0]} == ${DV[1]}"
18739 run_test 187b "Test data version change on volatile file"
18742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18743 remote_mgs_nodsh && skip "remote MGS with nodsh"
18744 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18746 local POOL=${POOL:-cea1}
18747 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18748 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18751 local last_ost=$(($OSTCOUNT - 1))
18753 local ost_list=$(seq $first_ost $ost_step $last_ost)
18754 local ost_range="$first_ost $last_ost $ost_step"
18755 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18756 local file_dir=$POOL_ROOT/file_tst
18757 local subdir=$test_path/subdir
18761 # former test_200a test_200b
18762 pool_add $POOL || { rc=$? ; break; }
18763 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
18764 # former test_200c test_200d
18765 mkdir -p $test_path
18766 pool_set_dir $POOL $test_path || { rc=$? ; break; }
18767 pool_check_dir $POOL $test_path || { rc=$? ; break; }
18769 pool_check_dir $POOL $subdir || { rc=$? ; break; }
18770 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
18771 || { rc=$? ; break; }
18772 # former test_200e test_200f
18773 local files=$((OSTCOUNT*3))
18774 pool_alloc_files $POOL $test_path $files "$ost_list" \
18775 || { rc=$? ; break; }
18776 pool_create_files $POOL $file_dir $files "$ost_list" \
18777 || { rc=$? ; break; }
18778 # former test_200g test_200h
18779 pool_lfs_df $POOL || { rc=$? ; break; }
18780 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
18782 # former test_201a test_201b test_201c
18783 pool_remove_first_target $POOL || { rc=$? ; break; }
18785 local f=$test_path/$tfile
18786 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
18787 pool_remove $POOL $f || { rc=$? ; break; }
18795 run_test 200 "OST pools"
18797 # usage: default_attr <count | size | offset>
18799 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
18802 # usage: check_default_stripe_attr
18803 check_default_stripe_attr() {
18804 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
18807 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
18809 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
18813 error "unknown getstripe attr '$1'"
18816 [ $ACTUAL == $EXPECTED ] ||
18817 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
18821 test_mkdir $DIR/$tdir
18822 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
18824 check_default_stripe_attr --stripe-count
18825 check_default_stripe_attr --stripe-size
18826 check_default_stripe_attr --stripe-index
18828 run_test 204a "Print default stripe attributes"
18831 test_mkdir $DIR/$tdir
18832 $LFS setstripe --stripe-count 1 $DIR/$tdir
18834 check_default_stripe_attr --stripe-size
18835 check_default_stripe_attr --stripe-index
18837 run_test 204b "Print default stripe size and offset"
18840 test_mkdir $DIR/$tdir
18841 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18843 check_default_stripe_attr --stripe-count
18844 check_default_stripe_attr --stripe-index
18846 run_test 204c "Print default stripe count and offset"
18849 test_mkdir $DIR/$tdir
18850 $LFS setstripe --stripe-index 0 $DIR/$tdir
18852 check_default_stripe_attr --stripe-count
18853 check_default_stripe_attr --stripe-size
18855 run_test 204d "Print default stripe count and size"
18858 test_mkdir $DIR/$tdir
18859 $LFS setstripe -d $DIR/$tdir
18861 check_default_stripe_attr --stripe-count --raw
18862 check_default_stripe_attr --stripe-size --raw
18863 check_default_stripe_attr --stripe-index --raw
18865 run_test 204e "Print raw stripe attributes"
18868 test_mkdir $DIR/$tdir
18869 $LFS setstripe --stripe-count 1 $DIR/$tdir
18871 check_default_stripe_attr --stripe-size --raw
18872 check_default_stripe_attr --stripe-index --raw
18874 run_test 204f "Print raw stripe size and offset"
18877 test_mkdir $DIR/$tdir
18878 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18880 check_default_stripe_attr --stripe-count --raw
18881 check_default_stripe_attr --stripe-index --raw
18883 run_test 204g "Print raw stripe count and offset"
18886 test_mkdir $DIR/$tdir
18887 $LFS setstripe --stripe-index 0 $DIR/$tdir
18889 check_default_stripe_attr --stripe-count --raw
18890 check_default_stripe_attr --stripe-size --raw
18892 run_test 204h "Print raw stripe count and size"
18894 # Figure out which job scheduler is being used, if any,
18895 # or use a fake one
18896 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
18897 JOBENV=SLURM_JOB_ID
18898 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
18900 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
18902 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
18903 JOBENV=LOADL_STEP_ID
18904 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
18907 $LCTL list_param jobid_name > /dev/null 2>&1
18908 if [ $? -eq 0 ]; then
18914 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
18916 verify_jobstats() {
18921 # we don't really need to clear the stats for this test to work, since each
18922 # command has a unique jobid, but it makes debugging easier if needed.
18923 # for facet in $facets; do
18924 # local dev=$(convert_facet2label $facet)
18925 # # clear old jobstats
18926 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
18929 # use a new JobID for each test, or we might see an old one
18930 [ "$JOBENV" = "FAKE_JOBID" ] &&
18931 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
18933 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
18935 [ "$JOBENV" = "nodelocal" ] && {
18936 FAKE_JOBID=id.$testnum.%e.$RANDOM
18937 $LCTL set_param jobid_name=$FAKE_JOBID
18938 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
18941 log "Test: ${cmd[*]}"
18942 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
18944 if [ $JOBENV = "FAKE_JOBID" ]; then
18945 FAKE_JOBID=$JOBVAL ${cmd[*]}
18950 # all files are created on OST0000
18951 for facet in $facets; do
18952 local stats="*.$(convert_facet2label $facet).job_stats"
18954 # strip out libtool wrappers for in-tree executables
18955 if (( $(do_facet $facet lctl get_param $stats |
18956 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
18957 do_facet $facet lctl get_param $stats
18958 error "No jobstats for $JOBVAL found on $facet::$stats"
18964 local new_jobenv=$1
18966 set_persistent_param_and_check client "jobid_var" \
18967 "$FSNAME.sys.jobid_var" $new_jobenv
18970 test_205a() { # Job stats
18971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18972 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
18973 skip "Need MDS version with at least 2.7.1"
18974 remote_mgs_nodsh && skip "remote MGS with nodsh"
18975 remote_mds_nodsh && skip "remote MDS with nodsh"
18976 remote_ost_nodsh && skip "remote OST with nodsh"
18977 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
18978 skip "Server doesn't support jobstats"
18979 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
18981 local old_jobenv=$($LCTL get_param -n jobid_var)
18982 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
18984 if [[ $PERM_CMD == *"set_param -P"* ]]; then
18985 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
18987 stack_trap "do_facet mgs $PERM_CMD \
18988 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
18992 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
18993 mdt.*.job_cleanup_interval | head -n 1)
18994 local new_interval=5
18995 do_facet $SINGLEMDS \
18996 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
18997 stack_trap "do_facet $SINGLEMDS \
18998 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
18999 local start=$SECONDS
19003 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
19004 verify_jobstats "$cmd" "$SINGLEMDS"
19006 cmd="rmdir $DIR/$tdir"
19007 verify_jobstats "$cmd" "$SINGLEMDS"
19008 # mkdir on secondary MDT
19009 if [ $MDSCOUNT -gt 1 ]; then
19010 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
19011 verify_jobstats "$cmd" "mds2"
19014 cmd="mknod $DIR/$tfile c 1 3"
19015 verify_jobstats "$cmd" "$SINGLEMDS"
19017 cmd="rm -f $DIR/$tfile"
19018 verify_jobstats "$cmd" "$SINGLEMDS"
19019 # create all files on OST0000 so verify_jobstats can find OST stats
19021 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
19022 verify_jobstats "$cmd" "$SINGLEMDS"
19024 cmd="touch $DIR/$tfile"
19025 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19027 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
19028 verify_jobstats "$cmd" "ost1"
19030 cancel_lru_locks osc
19031 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
19032 verify_jobstats "$cmd" "ost1"
19034 cmd="$TRUNCATE $DIR/$tfile 0"
19035 verify_jobstats "$cmd" "$SINGLEMDS ost1"
19037 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
19038 verify_jobstats "$cmd" "$SINGLEMDS"
19039 # jobstats expiry - sleep until old stats should be expired
19040 local left=$((new_interval + 5 - (SECONDS - start)))
19041 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
19042 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
19044 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
19045 verify_jobstats "$cmd" "$SINGLEMDS"
19046 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
19047 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
19049 # Ensure that jobid are present in changelog (if supported by MDS)
19050 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
19051 changelog_dump | tail -10
19052 jobids=$(changelog_dump | tail -9 | grep -c "j=")
19053 [ $jobids -eq 9 ] ||
19054 error "Wrong changelog jobid count $jobids != 9"
19058 jobstats_set $JOBENV
19060 changelog_dump | grep $tfile
19061 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
19062 [ $jobids -eq 0 ] ||
19063 error "Unexpected jobids when jobid_var=$JOBENV"
19066 # test '%j' access to environment variable - if supported
19067 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
19068 JOBENV="JOBCOMPLEX"
19069 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19071 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19074 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
19075 JOBENV="JOBCOMPLEX"
19076 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
19078 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19081 # test '%j' access to per-session jobid - if supported
19082 if lctl list_param jobid_this_session > /dev/null 2>&1
19084 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
19085 lctl set_param jobid_this_session=$USER
19087 JOBENV="JOBCOMPLEX"
19088 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
19090 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
19093 run_test 205a "Verify job stats"
19095 # LU-13117, LU-13597
19097 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
19098 skip "Need MDS version at least 2.13.54.91"
19100 local job_stats="mdt.*.job_stats"
19101 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
19103 do_facet mds1 $LCTL set_param $job_stats=clear
19105 # Setting jobid_var to USER might not be supported
19106 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
19107 $LCTL set_param jobid_var=USER || true
19108 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
19109 $LCTL set_param jobid_name="%j.%e.%u"
19111 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
19112 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
19113 { do_facet mds1 $LCTL get_param $job_stats;
19114 error "Unexpected jobid found"; }
19115 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
19116 { do_facet mds1 $LCTL get_param $job_stats;
19117 error "wrong job_stats format found"; }
19119 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
19120 echo "MDS does not yet escape jobid" && return 0
19121 $LCTL set_param jobid_var=TEST205b
19122 env -i TEST205b="has sp" touch $DIR/$tfile.2
19123 do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
19124 { do_facet mds1 $LCTL get_param $job_stats;
19125 error "jobid not escaped"; }
19127 run_test 205b "Verify job stats jobid and output format"
19131 $LCTL set_param llite.*.stats=0
19132 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
19133 $LCTL get_param llite.*.stats
19134 $LCTL get_param llite.*.stats | grep \
19135 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
19136 error "wrong client stats format found"
19138 run_test 205c "Verify client stats format"
19140 # LU-1480, LU-1773 and LU-1657
19142 mkdir -p $DIR/$tdir
19143 $LFS setstripe -c -1 $DIR/$tdir
19144 #define OBD_FAIL_LOV_INIT 0x1403
19145 $LCTL set_param fail_loc=0xa0001403
19146 $LCTL set_param fail_val=1
19147 touch $DIR/$tdir/$tfile || true
19149 run_test 206 "fail lov_init_raid0() doesn't lbug"
19152 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19153 local fsz=`stat -c %s $DIR/$tfile`
19154 cancel_lru_locks mdc
19156 # do not return layout in getattr intent
19157 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
19158 $LCTL set_param fail_loc=0x170
19159 local sz=`stat -c %s $DIR/$tfile`
19161 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
19165 run_test 207a "can refresh layout at glimpse"
19168 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
19169 local cksum=`md5sum $DIR/$tfile`
19170 local fsz=`stat -c %s $DIR/$tfile`
19171 cancel_lru_locks mdc
19172 cancel_lru_locks osc
19174 # do not return layout in getattr intent
19175 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
19176 $LCTL set_param fail_loc=0x171
19178 # it will refresh layout after the file is opened but before read issues
19179 echo checksum is "$cksum"
19180 echo "$cksum" |md5sum -c --quiet || error "file differs"
19184 run_test 207b "can refresh layout at open"
19187 # FIXME: in this test suite, only RD lease is used. This is okay
19188 # for now as only exclusive open is supported. After generic lease
19189 # is done, this test suite should be revised. - Jinshan
19191 remote_mds_nodsh && skip "remote MDS with nodsh"
19192 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
19193 skip "Need MDS version at least 2.4.52"
19195 echo "==== test 1: verify get lease work"
19196 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
19198 echo "==== test 2: verify lease can be broken by upcoming open"
19199 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19203 $MULTIOP $DIR/$tfile oO_RDWR:c
19204 kill -USR1 $PID && wait $PID || error "break lease error"
19206 echo "==== test 3: verify lease can't be granted if an open already exists"
19207 $MULTIOP $DIR/$tfile oO_RDWR:_c &
19211 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
19212 kill -USR1 $PID && wait $PID || error "open file error"
19214 echo "==== test 4: lease can sustain over recovery"
19215 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
19221 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
19223 echo "==== test 5: lease broken can't be regained by replay"
19224 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
19228 # open file to break lease and then recovery
19229 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
19232 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
19236 run_test 208 "Exclusive open"
19239 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
19240 skip_env "must have disp_stripe"
19243 sync; sleep 5; sync;
19245 echo 3 > /proc/sys/vm/drop_caches
19246 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19247 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19248 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19250 # open/close 500 times
19251 for i in $(seq 500); do
19255 echo 3 > /proc/sys/vm/drop_caches
19256 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
19257 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
19258 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
19260 echo "before: $req_before, after: $req_after"
19261 [ $((req_after - req_before)) -ge 300 ] &&
19262 error "open/close requests are not freed"
19265 run_test 209 "read-only open/close requests should be freed promptly"
19270 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
19274 $LFS getstripe $DIR/$tfile
19276 wait $pid || error "multiop failed"
19278 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
19282 $LFS getstripe $DIR/$tfile
19284 wait $pid || error "multiop failed"
19286 run_test 210 "lfs getstripe does not break leases"
19290 size=$((size % 8192 + 1))
19291 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
19292 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
19293 rm -f $DIR/f212 $DIR/f212.xyz
19295 run_test 212 "Sendfile test ============================================"
19298 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
19299 cancel_lru_locks osc
19300 lctl set_param fail_loc=0x8000040f
19301 # generate a read lock
19302 cat $DIR/$tfile > /dev/null
19303 # write to the file, it will try to cancel the above read lock.
19304 cat /etc/hosts >> $DIR/$tfile
19306 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
19308 test_214() { # for bug 20133
19309 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
19310 for (( i=0; i < 340; i++ )) ; do
19311 touch $DIR/$tdir/d214c/a$i
19314 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
19315 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
19316 ls $DIR/d214c || error "ls $DIR/d214c failed"
19317 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
19318 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
19320 run_test 214 "hash-indexed directory test - bug 20133"
19322 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
19323 create_lnet_proc_files() {
19324 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
19327 # counterpart of create_lnet_proc_files
19328 remove_lnet_proc_files() {
19329 rm -f $TMP/lnet_$1.sys
19332 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19333 # 3rd arg as regexp for body
19334 check_lnet_proc_stats() {
19335 local l=$(cat "$TMP/lnet_$1" |wc -l)
19336 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
19338 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
19341 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19342 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
19343 # optional and can be regexp for 2nd line (lnet.routes case)
19344 check_lnet_proc_entry() {
19345 local blp=2 # blp stands for 'position of 1st line of body'
19346 [ -z "$5" ] || blp=3 # lnet.routes case
19348 local l=$(cat "$TMP/lnet_$1" |wc -l)
19349 # subtracting one from $blp because the body can be empty
19350 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
19352 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
19353 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
19355 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
19356 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
19358 # bail out if any unexpected line happened
19359 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
19360 [ "$?" != 0 ] || error "$2 misformatted"
19363 test_215() { # for bugs 18102, 21079, 21517
19364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19366 local N='(0|[1-9][0-9]*)' # non-negative numeric
19367 local P='[1-9][0-9]*' # positive numeric
19368 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
19369 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
19370 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
19371 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
19373 local L1 # regexp for 1st line
19374 local L2 # regexp for 2nd line (optional)
19375 local BR # regexp for the rest (body)
19377 # lnet.stats should look as 11 space-separated non-negative numerics
19378 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
19379 create_lnet_proc_files "stats"
19380 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
19381 remove_lnet_proc_files "stats"
19383 # lnet.routes should look like this:
19384 # Routing disabled/enabled
19385 # net hops priority state router
19386 # where net is a string like tcp0, hops > 0, priority >= 0,
19387 # state is up/down,
19388 # router is a string like 192.168.1.1@tcp2
19389 L1="^Routing (disabled|enabled)$"
19390 L2="^net +hops +priority +state +router$"
19391 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
19392 create_lnet_proc_files "routes"
19393 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
19394 remove_lnet_proc_files "routes"
19396 # lnet.routers should look like this:
19397 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
19398 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
19399 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
19400 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
19401 L1="^ref +rtr_ref +alive +router$"
19402 BR="^$P +$P +(up|down) +$NID$"
19403 create_lnet_proc_files "routers"
19404 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
19405 remove_lnet_proc_files "routers"
19407 # lnet.peers should look like this:
19408 # nid refs state last max rtr min tx min queue
19409 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
19410 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
19411 # numeric (0 or >0 or <0), queue >= 0.
19412 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
19413 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
19414 create_lnet_proc_files "peers"
19415 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
19416 remove_lnet_proc_files "peers"
19418 # lnet.buffers should look like this:
19419 # pages count credits min
19420 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
19421 L1="^pages +count +credits +min$"
19422 BR="^ +$N +$N +$I +$I$"
19423 create_lnet_proc_files "buffers"
19424 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
19425 remove_lnet_proc_files "buffers"
19427 # lnet.nis should look like this:
19428 # nid status alive refs peer rtr max tx min
19429 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
19430 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
19431 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
19432 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
19433 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
19434 create_lnet_proc_files "nis"
19435 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
19436 remove_lnet_proc_files "nis"
19438 # can we successfully write to lnet.stats?
19439 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
19441 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
19443 test_216() { # bug 20317
19444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19445 remote_ost_nodsh && skip "remote OST with nodsh"
19448 local facets=$(get_facets OST)
19449 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19451 save_lustre_params client "osc.*.contention_seconds" > $p
19452 save_lustre_params $facets \
19453 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
19454 save_lustre_params $facets \
19455 "ldlm.namespaces.filter-*.contended_locks" >> $p
19456 save_lustre_params $facets \
19457 "ldlm.namespaces.filter-*.contention_seconds" >> $p
19458 clear_stats osc.*.osc_stats
19460 # agressive lockless i/o settings
19461 do_nodes $(comma_list $(osts_nodes)) \
19462 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
19463 ldlm.namespaces.filter-*.contended_locks=0 \
19464 ldlm.namespaces.filter-*.contention_seconds=60"
19465 lctl set_param -n osc.*.contention_seconds=60
19467 $DIRECTIO write $DIR/$tfile 0 10 4096
19468 $CHECKSTAT -s 40960 $DIR/$tfile
19470 # disable lockless i/o
19471 do_nodes $(comma_list $(osts_nodes)) \
19472 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
19473 ldlm.namespaces.filter-*.contended_locks=32 \
19474 ldlm.namespaces.filter-*.contention_seconds=0"
19475 lctl set_param -n osc.*.contention_seconds=0
19476 clear_stats osc.*.osc_stats
19478 dd if=/dev/zero of=$DIR/$tfile count=0
19479 $CHECKSTAT -s 0 $DIR/$tfile
19481 restore_lustre_params <$p
19485 run_test 216 "check lockless direct write updates file size and kms correctly"
19487 test_217() { # bug 22430
19488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19493 for node in $(nodes_list); do
19494 nid=$(host_nids_address $node $NETTYPE)
19495 if [[ $nid = *-* ]] ; then
19496 echo "lctl ping $(h2nettype $nid)"
19497 lctl ping $(h2nettype $nid)
19499 echo "skipping $node (no hyphen detected)"
19503 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19506 # do directio so as not to populate the page cache
19507 log "creating a 10 Mb file"
19508 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19509 log "starting reads"
19510 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19511 log "truncating the file"
19512 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19514 kill %+ || true # reads might have finished
19515 echo "wait until dd is finished"
19517 log "removing the temporary file"
19518 rm -rf $DIR/$tfile || error "tmp file removal failed"
19520 run_test 218 "parallel read and truncate should not deadlock"
19523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19525 # write one partial page
19526 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19527 # set no grant so vvp_io_commit_write will do sync write
19528 $LCTL set_param fail_loc=0x411
19529 # write a full page at the end of file
19530 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19532 $LCTL set_param fail_loc=0
19533 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19534 $LCTL set_param fail_loc=0x411
19535 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19538 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19539 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19541 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19543 test_220() { #LU-325
19544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19545 remote_ost_nodsh && skip "remote OST with nodsh"
19546 remote_mds_nodsh && skip "remote MDS with nodsh"
19547 remote_mgs_nodsh && skip "remote MGS with nodsh"
19551 # create on MDT0000 so the last_id and next_id are correct
19552 mkdir_on_mdt0 $DIR/$tdir
19553 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19557 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19558 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19559 osp.$mdtosc_proc1.prealloc_last_id)
19560 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19561 osp.$mdtosc_proc1.prealloc_next_id)
19565 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19566 #define OBD_FAIL_OST_ENOINO 0x229
19567 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19568 create_pool $FSNAME.$TESTNAME || return 1
19569 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19571 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19573 MDSOBJS=$((last_id - next_id))
19574 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19576 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19577 echo "OST still has $count kbytes free"
19579 echo "create $MDSOBJS files @next_id..."
19580 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19582 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19583 osp.$mdtosc_proc1.prealloc_last_id)
19584 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19585 osp.$mdtosc_proc1.prealloc_next_id)
19587 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19592 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19593 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19595 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19596 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19597 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19598 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19599 echo "unlink $MDSOBJS files @$next_id..."
19600 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19602 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19607 dd if=`which date` of=$MOUNT/date oflag=sync
19608 chmod +x $MOUNT/date
19610 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19611 $LCTL set_param fail_loc=0x80001401
19613 $MOUNT/date > /dev/null
19616 run_test 221 "make sure fault and truncate race to not cause OOM"
19619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19622 test_mkdir $DIR/$tdir
19623 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19624 createmany -o $DIR/$tdir/$tfile 10
19625 cancel_lru_locks mdc
19626 cancel_lru_locks osc
19627 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19628 $LCTL set_param fail_loc=0x31a
19629 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19630 $LCTL set_param fail_loc=0
19633 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19636 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19639 test_mkdir $DIR/$tdir
19640 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19641 createmany -o $DIR/$tdir/$tfile 10
19642 cancel_lru_locks mdc
19643 cancel_lru_locks osc
19644 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19645 $LCTL set_param fail_loc=0x31a
19646 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19647 $LCTL set_param fail_loc=0
19649 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
19652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19655 test_mkdir $DIR/$tdir
19656 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19657 createmany -o $DIR/$tdir/$tfile 10
19658 cancel_lru_locks mdc
19659 cancel_lru_locks osc
19660 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
19661 $LCTL set_param fail_loc=0x31b
19662 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
19663 $LCTL set_param fail_loc=0
19666 run_test 223 "osc reenqueue if without AGL lock granted ======================="
19668 test_224a() { # LU-1039, MRP-303
19669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19670 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
19671 $LCTL set_param fail_loc=0x508
19672 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
19673 $LCTL set_param fail_loc=0
19676 run_test 224a "Don't panic on bulk IO failure"
19678 test_224bd_sub() { # LU-1039, MRP-303
19679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19683 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
19685 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19687 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
19688 cancel_lru_locks osc
19690 stack_trap "set_checksums $ORIG_CSUM" EXIT
19691 local at_max_saved=0
19693 # adaptive timeouts may prevent seeing the issue
19694 if at_is_enabled; then
19695 at_max_saved=$(at_max_get mds)
19696 at_max_set 0 mds client
19697 stack_trap "at_max_set $at_max_saved mds client" EXIT
19700 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
19701 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
19702 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
19704 do_facet ost1 $LCTL set_param fail_loc=0
19705 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
19710 test_224bd_sub 3 error "dd failed"
19712 run_test 224b "Don't panic on bulk IO failure"
19714 test_224c() { # LU-6441
19715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19716 remote_mds_nodsh && skip "remote MDS with nodsh"
19718 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19719 save_writethrough $p
19720 set_cache writethrough on
19722 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
19723 local at_max=$($LCTL get_param -n at_max)
19724 local timeout=$($LCTL get_param -n timeout)
19725 local test_at="at_max"
19726 local param_at="$FSNAME.sys.at_max"
19727 local test_timeout="timeout"
19728 local param_timeout="$FSNAME.sys.timeout"
19730 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
19732 set_persistent_param_and_check client "$test_at" "$param_at" 0
19733 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
19735 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
19736 do_facet ost1 "$LCTL set_param fail_loc=0x520"
19737 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19738 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
19740 do_facet ost1 "$LCTL set_param fail_loc=0"
19742 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
19743 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
19746 $LCTL set_param -n $pages_per_rpc
19747 restore_lustre_params < $p
19750 run_test 224c "Don't hang if one of md lost during large bulk RPC"
19752 test_224d() { # LU-11169
19753 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
19755 run_test 224d "Don't corrupt data on bulk IO timeout"
19757 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
19759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19760 if [ -z ${MDSSURVEY} ]; then
19761 skip_env "mds-survey not found"
19763 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19764 skip "Need MDS version at least 2.2.51"
19766 local mds=$(facet_host $SINGLEMDS)
19767 local target=$(do_nodes $mds 'lctl dl' |
19768 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19770 local cmd1="file_count=1000 thrhi=4"
19771 local cmd2="dir_count=2 layer=mdd stripe_count=0"
19772 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19773 local cmd="$cmd1 $cmd2 $cmd3"
19775 rm -f ${TMP}/mds_survey*
19777 eval $cmd || error "mds-survey with zero-stripe failed"
19778 cat ${TMP}/mds_survey*
19779 rm -f ${TMP}/mds_survey*
19781 run_test 225a "Metadata survey sanity with zero-stripe"
19784 if [ -z ${MDSSURVEY} ]; then
19785 skip_env "mds-survey not found"
19787 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19788 skip "Need MDS version at least 2.2.51"
19789 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19790 remote_mds_nodsh && skip "remote MDS with nodsh"
19791 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
19792 skip_env "Need to mount OST to test"
19795 local mds=$(facet_host $SINGLEMDS)
19796 local target=$(do_nodes $mds 'lctl dl' |
19797 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19799 local cmd1="file_count=1000 thrhi=4"
19800 local cmd2="dir_count=2 layer=mdd stripe_count=1"
19801 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19802 local cmd="$cmd1 $cmd2 $cmd3"
19804 rm -f ${TMP}/mds_survey*
19806 eval $cmd || error "mds-survey with stripe_count failed"
19807 cat ${TMP}/mds_survey*
19808 rm -f ${TMP}/mds_survey*
19810 run_test 225b "Metadata survey sanity with stripe_count = 1"
19812 mcreate_path2fid () {
19818 local path=$DIR/$tdir/$name
19823 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
19824 error "cannot create $desc"
19826 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
19828 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
19830 fid_path=$($LFS fid2path $MOUNT $fid)
19832 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
19834 [ "$path" == "$fid_path" ] ||
19835 error "fid2path returned $fid_path, expected $path"
19837 echo "pass with $path and $fid"
19842 mkdir -p $DIR/$tdir
19844 mcreate_path2fid 0010666 0 0 fifo "FIFO"
19845 mcreate_path2fid 0020666 1 3 null "character special file (null)"
19846 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
19847 mcreate_path2fid 0040666 0 0 dir "directory"
19848 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
19849 mcreate_path2fid 0100666 0 0 file "regular file"
19850 mcreate_path2fid 0120666 0 0 link "symbolic link"
19851 mcreate_path2fid 0140666 0 0 sock "socket"
19853 run_test 226a "call path2fid and fid2path on files of all type"
19856 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19861 mkdir -p $DIR/$tdir
19862 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
19863 error "create remote directory failed"
19864 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
19865 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
19866 "character special file (null)"
19867 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
19868 "character special file (no device)"
19869 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
19870 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
19871 "block special file (loop)"
19872 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
19873 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
19874 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
19876 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
19879 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19880 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
19881 skip "Need MDS version at least 2.13.55"
19883 local submnt=/mnt/submnt
19884 local srcfile=/etc/passwd
19885 local dstfile=$submnt/passwd
19891 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
19892 error "create remote directory failed"
19893 mkdir -p $submnt || error "create $submnt failed"
19894 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
19895 error "mount $submnt failed"
19896 stack_trap "umount $submnt" EXIT
19898 cp $srcfile $dstfile
19899 fid=$($LFS path2fid $dstfile)
19900 path=$($LFS fid2path $submnt "$fid")
19901 [ "$path" = "$dstfile" ] ||
19902 error "fid2path $submnt $fid failed ($path != $dstfile)"
19904 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
19906 # LU-1299 Executing or running ldd on a truncated executable does not
19907 # cause an out-of-memory condition.
19909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19910 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
19912 dd if=$(which date) of=$MOUNT/date bs=1k count=1
19913 chmod +x $MOUNT/date
19915 $MOUNT/date > /dev/null
19916 ldd $MOUNT/date > /dev/null
19919 run_test 227 "running truncated executable does not cause OOM"
19921 # LU-1512 try to reuse idle OI blocks
19923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19924 remote_mds_nodsh && skip "remote MDS with nodsh"
19925 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19927 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19928 local myDIR=$DIR/$tdir
19931 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19932 $LCTL set_param fail_loc=0x80001002
19933 createmany -o $myDIR/t- 10000
19934 $LCTL set_param fail_loc=0
19935 # The guard is current the largest FID holder
19937 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19939 local IDX=$(($SEQ % 64))
19941 do_facet $SINGLEMDS sync
19942 # Make sure journal flushed.
19944 local blk1=$(do_facet $SINGLEMDS \
19945 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19946 grep Blockcount | awk '{print $4}')
19948 # Remove old files, some OI blocks will become idle.
19949 unlinkmany $myDIR/t- 10000
19950 # Create new files, idle OI blocks should be reused.
19951 createmany -o $myDIR/t- 2000
19952 do_facet $SINGLEMDS sync
19953 # Make sure journal flushed.
19955 local blk2=$(do_facet $SINGLEMDS \
19956 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19957 grep Blockcount | awk '{print $4}')
19959 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19961 run_test 228a "try to reuse idle OI blocks"
19964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19965 remote_mds_nodsh && skip "remote MDS with nodsh"
19966 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19968 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19969 local myDIR=$DIR/$tdir
19972 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19973 $LCTL set_param fail_loc=0x80001002
19974 createmany -o $myDIR/t- 10000
19975 $LCTL set_param fail_loc=0
19976 # The guard is current the largest FID holder
19978 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19980 local IDX=$(($SEQ % 64))
19982 do_facet $SINGLEMDS sync
19983 # Make sure journal flushed.
19985 local blk1=$(do_facet $SINGLEMDS \
19986 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19987 grep Blockcount | awk '{print $4}')
19989 # Remove old files, some OI blocks will become idle.
19990 unlinkmany $myDIR/t- 10000
19993 stop $SINGLEMDS || error "Fail to stop MDT."
19995 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
19996 error "Fail to start MDT."
19998 df $MOUNT || error "Fail to df."
19999 # Create new files, idle OI blocks should be reused.
20000 createmany -o $myDIR/t- 2000
20001 do_facet $SINGLEMDS sync
20002 # Make sure journal flushed.
20004 local blk2=$(do_facet $SINGLEMDS \
20005 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20006 grep Blockcount | awk '{print $4}')
20008 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20010 run_test 228b "idle OI blocks can be reused after MDT restart"
20014 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20015 remote_mds_nodsh && skip "remote MDS with nodsh"
20016 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20018 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
20019 local myDIR=$DIR/$tdir
20022 #define OBD_FAIL_SEQ_EXHAUST 0x1002
20023 $LCTL set_param fail_loc=0x80001002
20024 # 20000 files can guarantee there are index nodes in the OI file
20025 createmany -o $myDIR/t- 20000
20026 $LCTL set_param fail_loc=0
20027 # The guard is current the largest FID holder
20029 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
20031 local IDX=$(($SEQ % 64))
20033 do_facet $SINGLEMDS sync
20034 # Make sure journal flushed.
20036 local blk1=$(do_facet $SINGLEMDS \
20037 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20038 grep Blockcount | awk '{print $4}')
20040 # Remove old files, some OI blocks will become idle.
20041 unlinkmany $myDIR/t- 20000
20043 # The OI file should become empty now
20045 # Create new files, idle OI blocks should be reused.
20046 createmany -o $myDIR/t- 2000
20047 do_facet $SINGLEMDS sync
20048 # Make sure journal flushed.
20050 local blk2=$(do_facet $SINGLEMDS \
20051 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
20052 grep Blockcount | awk '{print $4}')
20054 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
20056 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
20058 test_229() { # LU-2482, LU-3448
20059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20060 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20061 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
20062 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
20066 # Create a file with a released layout and stripe count 2.
20067 $MULTIOP $DIR/$tfile H2c ||
20068 error "failed to create file with released layout"
20070 $LFS getstripe -v $DIR/$tfile
20072 local pattern=$($LFS getstripe -L $DIR/$tfile)
20073 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
20075 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
20077 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
20078 stat $DIR/$tfile || error "failed to stat released file"
20080 chown $RUNAS_ID $DIR/$tfile ||
20081 error "chown $RUNAS_ID $DIR/$tfile failed"
20083 chgrp $RUNAS_ID $DIR/$tfile ||
20084 error "chgrp $RUNAS_ID $DIR/$tfile failed"
20086 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
20087 rm $DIR/$tfile || error "failed to remove released file"
20089 run_test 229 "getstripe/stat/rm/attr changes work on released files"
20092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20093 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20094 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20095 skip "Need MDS version at least 2.11.52"
20099 test_mkdir $DIR/$tdir
20100 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
20101 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
20102 [ $mdt_idx -ne 0 ] &&
20103 error "create local directory on wrong MDT $mdt_idx"
20105 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
20106 error "create remote directory failed"
20107 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
20108 [ $mdt_idx -ne $MDTIDX ] &&
20109 error "create remote directory on wrong MDT $mdt_idx"
20111 createmany -o $DIR/$tdir/test_230/t- 10 ||
20112 error "create files on remote directory failed"
20113 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
20114 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
20115 rm -r $DIR/$tdir || error "unlink remote directory failed"
20117 run_test 230a "Create remote directory and files under the remote directory"
20120 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20121 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20122 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20123 skip "Need MDS version at least 2.11.52"
20131 local migrate_dir=$DIR/$tdir/migrate_dir
20132 local other_dir=$DIR/$tdir/other_dir
20134 test_mkdir $DIR/$tdir
20135 test_mkdir -i0 -c1 $migrate_dir
20136 test_mkdir -i0 -c1 $other_dir
20137 for ((i=0; i<10; i++)); do
20138 mkdir -p $migrate_dir/dir_${i}
20139 createmany -o $migrate_dir/dir_${i}/f 10 ||
20140 error "create files under remote dir failed $i"
20143 cp /etc/passwd $migrate_dir/$tfile
20144 cp /etc/passwd $other_dir/$tfile
20145 chattr +SAD $migrate_dir
20146 chattr +SAD $migrate_dir/$tfile
20148 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20149 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20150 local old_dir_mode=$(stat -c%f $migrate_dir)
20151 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
20153 mkdir -p $migrate_dir/dir_default_stripe2
20154 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
20155 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
20157 mkdir -p $other_dir
20158 ln $migrate_dir/$tfile $other_dir/luna
20159 ln $migrate_dir/$tfile $migrate_dir/sofia
20160 ln $other_dir/$tfile $migrate_dir/david
20161 ln -s $migrate_dir/$tfile $other_dir/zachary
20162 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
20163 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
20169 for len in 58 59 60; do
20170 lnktgt=$(str_repeat 'l' $len)
20171 touch $migrate_dir/$lnktgt
20172 ln -s $lnktgt $migrate_dir/${len}char_ln
20176 for len in 4094 4095; do
20177 lnktgt=$(str_repeat 'l' $len)
20178 ln -s $lnktgt $migrate_dir/${len}char_ln
20182 for len in 254 255; do
20183 touch $migrate_dir/$(str_repeat 'l' $len)
20186 $LFS migrate -m $MDTIDX $migrate_dir ||
20187 error "fails on migrating remote dir to MDT1"
20189 echo "migratate to MDT1, then checking.."
20190 for ((i = 0; i < 10; i++)); do
20191 for file in $(find $migrate_dir/dir_${i}); do
20192 mdt_index=$($LFS getstripe -m $file)
20193 # broken symlink getstripe will fail
20194 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20195 error "$file is not on MDT${MDTIDX}"
20199 # the multiple link file should still in MDT0
20200 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
20201 [ $mdt_index == 0 ] ||
20202 error "$file is not on MDT${MDTIDX}"
20204 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20205 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20206 error " expect $old_dir_flag get $new_dir_flag"
20208 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20209 [ "$old_file_flag" = "$new_file_flag" ] ||
20210 error " expect $old_file_flag get $new_file_flag"
20212 local new_dir_mode=$(stat -c%f $migrate_dir)
20213 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20214 error "expect mode $old_dir_mode get $new_dir_mode"
20216 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20217 [ "$old_file_mode" = "$new_file_mode" ] ||
20218 error "expect mode $old_file_mode get $new_file_mode"
20220 diff /etc/passwd $migrate_dir/$tfile ||
20221 error "$tfile different after migration"
20223 diff /etc/passwd $other_dir/luna ||
20224 error "luna different after migration"
20226 diff /etc/passwd $migrate_dir/sofia ||
20227 error "sofia different after migration"
20229 diff /etc/passwd $migrate_dir/david ||
20230 error "david different after migration"
20232 diff /etc/passwd $other_dir/zachary ||
20233 error "zachary different after migration"
20235 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20236 error "${tfile}_ln different after migration"
20238 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20239 error "${tfile}_ln_other different after migration"
20241 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
20242 [ $stripe_count = 2 ] ||
20243 error "dir strpe_count $d != 2 after migration."
20245 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
20246 [ $stripe_count = 2 ] ||
20247 error "file strpe_count $d != 2 after migration."
20249 #migrate back to MDT0
20252 $LFS migrate -m $MDTIDX $migrate_dir ||
20253 error "fails on migrating remote dir to MDT0"
20255 echo "migrate back to MDT0, checking.."
20256 for file in $(find $migrate_dir); do
20257 mdt_index=$($LFS getstripe -m $file)
20258 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
20259 error "$file is not on MDT${MDTIDX}"
20262 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
20263 [ "$old_dir_flag" = "$new_dir_flag" ] ||
20264 error " expect $old_dir_flag get $new_dir_flag"
20266 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
20267 [ "$old_file_flag" = "$new_file_flag" ] ||
20268 error " expect $old_file_flag get $new_file_flag"
20270 local new_dir_mode=$(stat -c%f $migrate_dir)
20271 [ "$old_dir_mode" = "$new_dir_mode" ] ||
20272 error "expect mode $old_dir_mode get $new_dir_mode"
20274 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
20275 [ "$old_file_mode" = "$new_file_mode" ] ||
20276 error "expect mode $old_file_mode get $new_file_mode"
20278 diff /etc/passwd ${migrate_dir}/$tfile ||
20279 error "$tfile different after migration"
20281 diff /etc/passwd ${other_dir}/luna ||
20282 error "luna different after migration"
20284 diff /etc/passwd ${migrate_dir}/sofia ||
20285 error "sofia different after migration"
20287 diff /etc/passwd ${other_dir}/zachary ||
20288 error "zachary different after migration"
20290 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20291 error "${tfile}_ln different after migration"
20293 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20294 error "${tfile}_ln_other different after migration"
20296 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
20297 [ $stripe_count = 2 ] ||
20298 error "dir strpe_count $d != 2 after migration."
20300 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
20301 [ $stripe_count = 2 ] ||
20302 error "file strpe_count $d != 2 after migration."
20304 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20306 run_test 230b "migrate directory"
20309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20310 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20311 remote_mds_nodsh && skip "remote MDS with nodsh"
20312 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20313 skip "Need MDS version at least 2.11.52"
20319 local migrate_dir=$DIR/$tdir/migrate_dir
20321 #If migrating directory fails in the middle, all entries of
20322 #the directory is still accessiable.
20323 test_mkdir $DIR/$tdir
20324 test_mkdir -i0 -c1 $migrate_dir
20325 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
20327 createmany -o $migrate_dir/f $total ||
20328 error "create files under ${migrate_dir} failed"
20330 # fail after migrating top dir, and this will fail only once, so the
20331 # first sub file migration will fail (currently f3), others succeed.
20332 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
20333 do_facet mds1 lctl set_param fail_loc=0x1801
20334 local t=$(ls $migrate_dir | wc -l)
20335 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
20336 error "migrate should fail"
20337 local u=$(ls $migrate_dir | wc -l)
20338 [ "$u" == "$t" ] || error "$u != $t during migration"
20340 # add new dir/file should succeed
20341 mkdir $migrate_dir/dir ||
20342 error "mkdir failed under migrating directory"
20343 touch $migrate_dir/file ||
20344 error "create file failed under migrating directory"
20346 # add file with existing name should fail
20347 for file in $migrate_dir/f*; do
20348 stat $file > /dev/null || error "stat $file failed"
20349 $OPENFILE -f O_CREAT:O_EXCL $file &&
20350 error "open(O_CREAT|O_EXCL) $file should fail"
20351 $MULTIOP $file m && error "create $file should fail"
20352 touch $DIR/$tdir/remote_dir/$tfile ||
20353 error "touch $tfile failed"
20354 ln $DIR/$tdir/remote_dir/$tfile $file &&
20355 error "link $file should fail"
20356 mdt_index=$($LFS getstripe -m $file)
20357 if [ $mdt_index == 0 ]; then
20358 # file failed to migrate is not allowed to rename to
20359 mv $DIR/$tdir/remote_dir/$tfile $file &&
20360 error "rename to $file should fail"
20362 mv $DIR/$tdir/remote_dir/$tfile $file ||
20363 error "rename to $file failed"
20365 echo hello >> $file || error "write $file failed"
20368 # resume migration with different options should fail
20369 $LFS migrate -m 0 $migrate_dir &&
20370 error "migrate -m 0 $migrate_dir should fail"
20372 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
20373 error "migrate -c 2 $migrate_dir should fail"
20375 # resume migration should succeed
20376 $LFS migrate -m $MDTIDX $migrate_dir ||
20377 error "migrate $migrate_dir failed"
20379 echo "Finish migration, then checking.."
20380 for file in $(find $migrate_dir); do
20381 mdt_index=$($LFS getstripe -m $file)
20382 [ $mdt_index == $MDTIDX ] ||
20383 error "$file is not on MDT${MDTIDX}"
20386 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20388 run_test 230c "check directory accessiblity if migration failed"
20391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20392 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20393 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20394 skip "Need MDS version at least 2.11.52"
20396 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
20398 local migrate_dir=$DIR/$tdir/migrate_dir
20408 old_index=$((RANDOM % MDSCOUNT))
20409 old_count=$((MDSCOUNT - old_index))
20410 new_index=$((RANDOM % MDSCOUNT))
20411 new_count=$((MDSCOUNT - new_index))
20412 new_hash=1 # for all_char
20414 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
20415 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
20417 test_mkdir $DIR/$tdir
20418 test_mkdir -i $old_index -c $old_count $migrate_dir
20420 for ((i=0; i<100; i++)); do
20421 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
20422 createmany -o $migrate_dir/dir_${i}/f 100 ||
20423 error "create files under remote dir failed $i"
20426 echo -n "Migrate from MDT$old_index "
20427 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
20428 echo -n "to MDT$new_index"
20429 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
20432 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
20433 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
20434 error "migrate remote dir error"
20436 echo "Finish migration, then checking.."
20437 for file in $(find $migrate_dir -maxdepth 1); do
20438 mdt_index=$($LFS getstripe -m $file)
20439 if [ $mdt_index -lt $new_index ] ||
20440 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
20441 error "$file is on MDT$mdt_index"
20445 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20447 run_test 230d "check migrate big directory"
20450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20451 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20452 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20453 skip "Need MDS version at least 2.11.52"
20460 mkdir_on_mdt0 $DIR/$tdir
20461 mkdir $DIR/$tdir/migrate_dir
20462 mkdir $DIR/$tdir/other_dir
20463 touch $DIR/$tdir/migrate_dir/a
20464 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
20465 ls $DIR/$tdir/other_dir
20467 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20468 error "migrate dir fails"
20470 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20471 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20473 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20474 [ $mdt_index == 0 ] || error "a is not on MDT0"
20476 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20477 error "migrate dir fails"
20479 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20480 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20482 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20483 [ $mdt_index == 1 ] || error "a is not on MDT1"
20485 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20486 [ $mdt_index == 1 ] || error "b is not on MDT1"
20488 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20489 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20491 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20493 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20495 run_test 230e "migrate mulitple local link files"
20498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20499 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20500 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20501 skip "Need MDS version at least 2.11.52"
20506 mkdir -p $DIR/$tdir
20507 mkdir $DIR/$tdir/migrate_dir
20508 $LFS mkdir -i1 $DIR/$tdir/other_dir
20509 touch $DIR/$tdir/migrate_dir/a
20510 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20511 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20512 ls $DIR/$tdir/other_dir
20514 # a should be migrated to MDT1, since no other links on MDT0
20515 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20516 error "#1 migrate dir fails"
20517 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20518 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20519 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20520 [ $mdt_index == 1 ] || error "a is not on MDT1"
20522 # a should stay on MDT1, because it is a mulitple link file
20523 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20524 error "#2 migrate dir fails"
20525 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20526 [ $mdt_index == 1 ] || error "a is not on MDT1"
20528 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20529 error "#3 migrate dir fails"
20531 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20532 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20533 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20535 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20536 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20538 # a should be migrated to MDT0, since no other links on MDT1
20539 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20540 error "#4 migrate dir fails"
20541 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20542 [ $mdt_index == 0 ] || error "a is not on MDT0"
20544 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20546 run_test 230f "migrate mulitple remote link files"
20549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20550 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20551 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20552 skip "Need MDS version at least 2.11.52"
20554 mkdir -p $DIR/$tdir/migrate_dir
20556 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20557 error "migrating dir to non-exist MDT succeeds"
20560 run_test 230g "migrate dir to non-exist MDT"
20563 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20564 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20565 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20566 skip "Need MDS version at least 2.11.52"
20570 mkdir -p $DIR/$tdir/migrate_dir
20572 $LFS migrate -m1 $DIR &&
20573 error "migrating mountpoint1 should fail"
20575 $LFS migrate -m1 $DIR/$tdir/.. &&
20576 error "migrating mountpoint2 should fail"
20579 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20580 error "migrating $tdir/migrate_dir/.. should fail"
20584 run_test 230h "migrate .. and root"
20587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20588 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20589 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20590 skip "Need MDS version at least 2.11.52"
20592 mkdir -p $DIR/$tdir/migrate_dir
20594 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20595 error "migration fails with a tailing slash"
20597 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20598 error "migration fails with two tailing slashes"
20600 run_test 230i "lfs migrate -m tolerates trailing slashes"
20603 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20604 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20605 skip "Need MDS version at least 2.11.52"
20607 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20608 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20609 error "create $tfile failed"
20610 cat /etc/passwd > $DIR/$tdir/$tfile
20612 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20614 cmp /etc/passwd $DIR/$tdir/$tfile ||
20615 error "DoM file mismatch after migration"
20617 run_test 230j "DoM file data not changed after dir migration"
20620 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20621 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20622 skip "Need MDS version at least 2.11.56"
20625 local files_on_starting_mdt=0
20627 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20628 $LFS getdirstripe $DIR/$tdir
20629 for i in $(seq $total); do
20630 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20631 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20632 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20635 echo "$files_on_starting_mdt files on MDT0"
20637 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20638 $LFS getdirstripe $DIR/$tdir
20640 files_on_starting_mdt=0
20641 for i in $(seq $total); do
20642 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20643 error "file $tfile.$i mismatch after migration"
20644 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20645 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20648 echo "$files_on_starting_mdt files on MDT1 after migration"
20649 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20651 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20652 $LFS getdirstripe $DIR/$tdir
20654 files_on_starting_mdt=0
20655 for i in $(seq $total); do
20656 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20657 error "file $tfile.$i mismatch after 2nd migration"
20658 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20659 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20662 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
20663 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
20667 run_test 230k "file data not changed after dir migration"
20670 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20671 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20672 skip "Need MDS version at least 2.11.56"
20674 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
20675 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
20676 error "create files under remote dir failed $i"
20677 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20679 run_test 230l "readdir between MDTs won't crash"
20682 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20683 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20684 skip "Need MDS version at least 2.11.56"
20687 local mig_dir=$DIR/$tdir/migrate_dir
20688 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20692 echo "Creating files and dirs with xattrs"
20693 test_mkdir $DIR/$tdir
20694 test_mkdir -i0 -c1 $mig_dir
20696 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
20697 error "cannot set xattr attr1 on dir"
20698 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
20699 error "cannot set xattr attr2 on dir"
20700 touch $mig_dir/dir/f0
20701 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
20702 error "cannot set xattr attr1 on file"
20703 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
20704 error "cannot set xattr attr2 on file"
20705 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20706 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20707 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
20708 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20709 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
20710 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20711 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
20712 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20713 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
20715 echo "Migrating to MDT1"
20716 $LFS migrate -m $MDTIDX $mig_dir ||
20717 error "fails on migrating dir to MDT1"
20719 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20720 echo "Checking xattrs"
20721 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20722 [ "$val" = $longstr ] ||
20723 error "expecting xattr1 $longstr on dir, found $val"
20724 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20725 [ "$val" = $shortstr ] ||
20726 error "expecting xattr2 $shortstr on dir, found $val"
20727 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20728 [ "$val" = $longstr ] ||
20729 error "expecting xattr1 $longstr on file, found $val"
20730 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20731 [ "$val" = $shortstr ] ||
20732 error "expecting xattr2 $shortstr on file, found $val"
20734 run_test 230m "xattrs not changed after dir migration"
20737 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20738 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
20739 skip "Need MDS version at least 2.13.53"
20741 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
20742 cat /etc/hosts > $DIR/$tdir/$tfile
20743 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
20744 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
20746 cmp /etc/hosts $DIR/$tdir/$tfile ||
20747 error "File data mismatch after migration"
20749 run_test 230n "Dir migration with mirrored file"
20752 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
20753 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
20754 skip "Need MDS version at least 2.13.52"
20756 local mdts=$(comma_list $(mdts_nodes))
20758 local restripe_status
20762 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20764 # in case "crush" hash type is not set
20765 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20767 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20768 mdt.*MDT0000.enable_dir_restripe)
20769 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20770 stack_trap "do_nodes $mdts $LCTL set_param \
20771 mdt.*.enable_dir_restripe=$restripe_status"
20774 createmany -m $DIR/$tdir/f 100 ||
20775 error "create files under remote dir failed $i"
20776 createmany -d $DIR/$tdir/d 100 ||
20777 error "create dirs under remote dir failed $i"
20779 for i in $(seq 2 $MDSCOUNT); do
20780 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20781 $LFS setdirstripe -c $i $DIR/$tdir ||
20782 error "split -c $i $tdir failed"
20783 wait_update $HOSTNAME \
20784 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
20785 error "dir split not finished"
20786 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20787 awk '/migrate/ {sum += $2} END { print sum }')
20788 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
20789 # delta is around total_files/stripe_count
20790 (( $delta < 200 / (i - 1) + 4 )) ||
20791 error "$delta files migrated >= $((200 / (i - 1) + 4))"
20794 run_test 230o "dir split"
20797 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20798 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20799 skip "Need MDS version at least 2.13.52"
20801 local mdts=$(comma_list $(mdts_nodes))
20803 local restripe_status
20807 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20809 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20811 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20812 mdt.*MDT0000.enable_dir_restripe)
20813 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20814 stack_trap "do_nodes $mdts $LCTL set_param \
20815 mdt.*.enable_dir_restripe=$restripe_status"
20817 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
20818 createmany -m $DIR/$tdir/f 100 ||
20819 error "create files under remote dir failed"
20820 createmany -d $DIR/$tdir/d 100 ||
20821 error "create dirs under remote dir failed"
20823 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
20824 local mdt_hash="crush"
20826 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20827 $LFS setdirstripe -c $c $DIR/$tdir ||
20828 error "split -c $c $tdir failed"
20829 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
20830 mdt_hash="$mdt_hash,fixed"
20831 elif [ $c -eq 1 ]; then
20834 wait_update $HOSTNAME \
20835 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
20836 error "dir merge not finished"
20837 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20838 awk '/migrate/ {sum += $2} END { print sum }')
20839 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
20840 # delta is around total_files/stripe_count
20841 (( delta < 200 / c + 4 )) ||
20842 error "$delta files migrated >= $((200 / c + 4))"
20845 run_test 230p "dir merge"
20848 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
20849 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20850 skip "Need MDS version at least 2.13.52"
20852 local mdts=$(comma_list $(mdts_nodes))
20853 local saved_threshold=$(do_facet mds1 \
20854 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
20855 local saved_delta=$(do_facet mds1 \
20856 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
20857 local threshold=100
20860 local stripe_count=0
20865 # test with fewer files on ZFS
20866 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
20868 stack_trap "do_nodes $mdts $LCTL set_param \
20869 mdt.*.dir_split_count=$saved_threshold"
20870 stack_trap "do_nodes $mdts $LCTL set_param \
20871 mdt.*.dir_split_delta=$saved_delta"
20872 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
20873 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
20874 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
20875 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
20876 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
20877 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20879 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20880 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20882 create=$((threshold * 3 / 2))
20883 while [ $stripe_count -lt $MDSCOUNT ]; do
20884 createmany -m $DIR/$tdir/f $total $create ||
20885 error "create sub files failed"
20886 stat $DIR/$tdir > /dev/null
20887 total=$((total + create))
20888 stripe_count=$((stripe_count + delta))
20889 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
20891 wait_update $HOSTNAME \
20892 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
20893 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
20895 wait_update $HOSTNAME \
20896 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
20897 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
20899 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
20900 echo "$nr_files/$total files on MDT$stripe_index after split"
20901 # allow 10% margin of imbalance with crush hash
20902 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
20903 error "$nr_files files on MDT$stripe_index after split"
20905 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
20906 [ $nr_files -eq $total ] ||
20907 error "total sub files $nr_files != $total"
20910 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
20912 echo "fixed layout directory won't auto split"
20913 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
20914 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
20915 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
20916 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
20917 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
20919 run_test 230q "dir auto split"
20922 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
20923 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20924 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
20925 skip "Need MDS version at least 2.13.54"
20927 # maximum amount of local locks:
20928 # parent striped dir - 2 locks
20929 # new stripe in parent to migrate to - 1 lock
20930 # source and target - 2 locks
20931 # Total 5 locks for regular file
20932 mkdir -p $DIR/$tdir
20933 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
20934 touch $DIR/$tdir/dir1/eee
20936 # create 4 hardlink for 4 more locks
20937 # Total: 9 locks > RS_MAX_LOCKS (8)
20938 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
20939 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
20940 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
20941 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
20942 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
20943 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
20944 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
20945 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
20947 cancel_lru_locks mdc
20949 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
20950 error "migrate dir fails"
20952 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20954 run_test 230r "migrate with too many local locks"
20957 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
20958 skip "Need MDS version at least 2.14.52"
20960 local mdts=$(comma_list $(mdts_nodes))
20961 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
20962 mdt.*MDT0000.enable_dir_restripe)
20964 stack_trap "do_nodes $mdts $LCTL set_param \
20965 mdt.*.enable_dir_restripe=$restripe_status"
20969 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
20970 test_mkdir $DIR/$tdir
20971 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
20972 error "$LFS mkdir should return EEXIST if target exists"
20976 run_test 230s "lfs mkdir should return -EEXIST if target exists"
20980 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20981 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
20982 skip "Need MDS version at least 2.14.50"
20984 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
20985 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
20986 $LFS project -p 1 -s $DIR/$tdir ||
20987 error "set $tdir project id failed"
20988 $LFS project -p 2 -s $DIR/$tdir/subdir ||
20989 error "set subdir project id failed"
20990 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
20992 run_test 230t "migrate directory with project ID set"
20996 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20997 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20998 skip "Need MDS version at least 2.14.53"
21002 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21003 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
21004 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
21005 for i in $(seq 0 $((MDSCOUNT - 1))); do
21006 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
21007 echo "$count dirs migrated to MDT$i"
21009 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21010 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
21012 run_test 230u "migrate directory by QOS"
21016 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
21017 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
21018 skip "Need MDS version at least 2.14.53"
21022 mkdir $DIR/$tdir || error "mkdir $tdir failed"
21023 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
21024 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
21025 for i in $(seq 0 $((MDSCOUNT - 1))); do
21026 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
21027 echo "$count subdirs migrated to MDT$i"
21028 (( i == 3 )) && (( count > 0 )) &&
21029 error "subdir shouldn't be migrated to MDT3"
21031 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
21032 (( count == 3 )) || error "dirs migrated to $count MDTs"
21034 run_test 230v "subdir migrated to the MDT where its parent is located"
21037 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21038 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21039 skip "Need MDS version at least 2.15.0"
21041 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21042 createmany -o $DIR/$tdir/f 10 || error "create files failed"
21043 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
21045 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
21046 error "migrate failed"
21048 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
21049 error "$tdir stripe count mismatch"
21051 for i in $(seq 0 9); do
21052 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
21053 error "d$i is striped"
21056 run_test 230w "non-recursive mode dir migration"
21059 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
21060 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
21061 skip "Need MDS version at least 2.15.0"
21063 mkdir -p $DIR/$tdir || error "mkdir failed"
21064 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
21066 local mdt_name=$(mdtname_from_index 0)
21067 local low=$(do_facet mds2 $LCTL get_param -n \
21068 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
21069 local high=$(do_facet mds2 $LCTL get_param -n \
21070 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
21071 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
21072 local maxage=$(do_facet mds2 $LCTL get_param -n \
21073 osp.*$mdt_name-osp-MDT0001.maxage)
21075 stack_trap "do_facet mds2 $LCTL set_param -n \
21076 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
21077 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
21078 stack_trap "do_facet mds2 $LCTL set_param -n \
21079 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
21081 do_facet mds2 $LCTL set_param -n \
21082 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
21083 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
21085 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
21086 error "migrate $tdir should fail"
21088 do_facet mds2 $LCTL set_param -n \
21089 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
21090 do_facet mds2 $LCTL set_param -n \
21091 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
21093 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
21094 error "migrate failed"
21095 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
21096 error "$tdir stripe count mismatch"
21098 run_test 230x "dir migration check space"
21102 # For simplicity this test assumes that max_pages_per_rpc
21103 # is the same across all OSCs
21104 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
21105 local bulk_size=$((max_pages * PAGE_SIZE))
21106 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
21109 mkdir -p $DIR/$tdir
21110 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
21111 error "failed to set stripe with -S ${brw_size}M option"
21113 # clear the OSC stats
21114 $LCTL set_param osc.*.stats=0 &>/dev/null
21117 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
21118 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
21119 oflag=direct &>/dev/null || error "dd failed"
21121 sync; sleep 1; sync # just to be safe
21122 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
21123 if [ x$nrpcs != "x1" ]; then
21124 $LCTL get_param osc.*.stats
21125 error "found $nrpcs ost_write RPCs, not 1 as expected"
21129 # Drop the OSC cache, otherwise we will read from it
21130 cancel_lru_locks osc
21132 # clear the OSC stats
21133 $LCTL set_param osc.*.stats=0 &>/dev/null
21135 # Client reads $bulk_size.
21136 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
21137 iflag=direct &>/dev/null || error "dd failed"
21139 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
21140 if [ x$nrpcs != "x1" ]; then
21141 $LCTL get_param osc.*.stats
21142 error "found $nrpcs ost_read RPCs, not 1 as expected"
21145 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
21148 mkdir -p $DIR/$tdir
21150 for i in {0..1023}; do
21151 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
21152 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
21153 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
21157 run_test 231b "must not assert on fully utilized OST request buffer"
21160 mkdir -p $DIR/$tdir
21161 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21163 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21164 do_facet ost1 $LCTL set_param fail_loc=0x31c
21166 # ignore dd failure
21167 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
21169 do_facet ost1 $LCTL set_param fail_loc=0
21170 umount_client $MOUNT || error "umount failed"
21171 mount_client $MOUNT || error "mount failed"
21172 stop ost1 || error "cannot stop ost1"
21173 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21175 run_test 232a "failed lock should not block umount"
21178 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
21179 skip "Need MDS version at least 2.10.58"
21181 mkdir -p $DIR/$tdir
21182 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
21183 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
21185 cancel_lru_locks osc
21187 #define OBD_FAIL_LDLM_OST_LVB 0x31c
21188 do_facet ost1 $LCTL set_param fail_loc=0x31c
21191 $LFS data_version $DIR/$tdir/$tfile || true
21193 do_facet ost1 $LCTL set_param fail_loc=0
21194 umount_client $MOUNT || error "umount failed"
21195 mount_client $MOUNT || error "mount failed"
21196 stop ost1 || error "cannot stop ost1"
21197 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
21199 run_test 232b "failed data version lock should not block umount"
21202 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
21203 skip "Need MDS version at least 2.3.64"
21204 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21206 local fid=$($LFS path2fid $MOUNT)
21208 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21209 error "cannot access $MOUNT using its FID '$fid'"
21211 run_test 233a "checking that OBF of the FS root succeeds"
21214 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
21215 skip "Need MDS version at least 2.5.90"
21216 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
21218 local fid=$($LFS path2fid $MOUNT/.lustre)
21220 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21221 error "cannot access $MOUNT/.lustre using its FID '$fid'"
21223 fid=$($LFS path2fid $MOUNT/.lustre/fid)
21224 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
21225 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
21227 run_test 233b "checking that OBF of the FS .lustre succeeds"
21230 local p="$TMP/sanityN-$TESTNAME.parameters"
21231 save_lustre_params client "llite.*.xattr_cache" > $p
21232 lctl set_param llite.*.xattr_cache 1 ||
21233 skip_env "xattr cache is not supported"
21235 mkdir -p $DIR/$tdir || error "mkdir failed"
21236 touch $DIR/$tdir/$tfile || error "touch failed"
21237 # OBD_FAIL_LLITE_XATTR_ENOMEM
21238 $LCTL set_param fail_loc=0x1405
21239 getfattr -n user.attr $DIR/$tdir/$tfile &&
21240 error "getfattr should have failed with ENOMEM"
21241 $LCTL set_param fail_loc=0x0
21244 restore_lustre_params < $p
21247 run_test 234 "xattr cache should not crash on ENOMEM"
21250 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
21251 skip "Need MDS version at least 2.4.52"
21253 flock_deadlock $DIR/$tfile
21258 124) error "process hangs on a deadlock"
21260 *) error "error executing flock_deadlock $DIR/$tfile"
21264 run_test 235 "LU-1715: flock deadlock detection does not work properly"
21268 check_swap_layouts_support
21270 local ref1=/etc/passwd
21271 local ref2=/etc/group
21272 local file1=$DIR/$tdir/f1
21273 local file2=$DIR/$tdir/f2
21275 test_mkdir -c1 $DIR/$tdir
21276 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
21277 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
21278 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
21279 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
21280 local fd=$(free_fd)
21281 local cmd="exec $fd<>$file2"
21284 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
21285 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
21288 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
21293 run_test 236 "Layout swap on open unlinked file"
21295 # LU-4659 linkea consistency
21297 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
21298 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
21299 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
21300 skip "Need MDS version at least 2.5.58 or 2.5.2+"
21303 ln $DIR/$tfile $DIR/$tfile.lnk
21304 touch $DIR/$tfile.new
21305 mv $DIR/$tfile.new $DIR/$tfile
21306 local fid1=$($LFS path2fid $DIR/$tfile)
21307 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
21308 local path1=$($LFS fid2path $FSNAME "$fid1")
21309 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
21310 local path2=$($LFS fid2path $FSNAME "$fid2")
21311 [ $tfile.lnk == $path2 ] ||
21312 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
21315 run_test 238 "Verify linkea consistency"
21317 test_239A() { # was test_239
21318 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
21319 skip "Need MDS version at least 2.5.60"
21321 local list=$(comma_list $(mdts_nodes))
21323 mkdir -p $DIR/$tdir
21324 createmany -o $DIR/$tdir/f- 5000
21325 unlinkmany $DIR/$tdir/f- 5000
21326 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
21327 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
21328 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
21329 osp.*MDT*.sync_in_flight" | calc_sum)
21330 [ "$changes" -eq 0 ] || error "$changes not synced"
21332 run_test 239A "osp_sync test"
21334 test_239a() { #LU-5297
21335 remote_mds_nodsh && skip "remote MDS with nodsh"
21338 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
21339 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
21340 chgrp $RUNAS_GID $DIR/$tfile
21341 wait_delete_completed
21343 run_test 239a "process invalid osp sync record correctly"
21345 test_239b() { #LU-5297
21346 remote_mds_nodsh && skip "remote MDS with nodsh"
21349 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
21350 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
21351 chgrp $RUNAS_GID $DIR/$tfile1
21352 wait_delete_completed
21353 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21355 chgrp $RUNAS_GID $DIR/$tfile2
21356 wait_delete_completed
21358 run_test 239b "process osp sync record with ENOMEM error correctly"
21361 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21362 remote_mds_nodsh && skip "remote MDS with nodsh"
21364 mkdir -p $DIR/$tdir
21366 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
21367 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
21368 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
21369 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
21371 umount_client $MOUNT || error "umount failed"
21372 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
21373 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
21374 mount_client $MOUNT || error "failed to mount client"
21376 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
21377 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
21379 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
21385 for LOOP in $(seq $count); do
21386 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
21387 cancel_lru_locks $OSC || true
21395 for LOOP in $(seq $1); do
21396 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
21401 test_241a() { # was test_241
21402 local bsize=$PAGE_SIZE
21404 (( bsize < 40960 )) && bsize=40960
21405 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21407 cancel_lru_locks $OSC
21408 test_241_bio 1000 $bsize &
21410 test_241_dio 1000 $bsize
21413 run_test 241a "bio vs dio"
21416 local bsize=$PAGE_SIZE
21418 (( bsize < 40960 )) && bsize=40960
21419 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21421 test_241_dio 1000 $bsize &
21423 test_241_dio 1000 $bsize
21426 run_test 241b "dio vs dio"
21429 remote_mds_nodsh && skip "remote MDS with nodsh"
21431 mkdir_on_mdt0 $DIR/$tdir
21432 touch $DIR/$tdir/$tfile
21434 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
21435 do_facet mds1 lctl set_param fail_loc=0x105
21436 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
21438 do_facet mds1 lctl set_param fail_loc=0
21439 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
21441 run_test 242 "mdt_readpage failure should not cause directory unreadable"
21445 test_mkdir $DIR/$tdir
21446 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
21448 run_test 243 "various group lock tests"
21452 test_mkdir $DIR/$tdir
21453 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
21454 sendfile_grouplock $DIR/$tdir/$tfile || \
21455 error "sendfile+grouplock failed"
21458 run_test 244a "sendfile with group lock tests"
21462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
21465 local size=$((1024*1024))
21467 test_mkdir $DIR/$tdir
21468 for i in $(seq 1 $threads); do
21469 local file=$DIR/$tdir/file_$((i / 10))
21470 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
21473 for i in $(seq 1 $threads); do
21477 run_test 244b "multi-threaded write with group lock"
21480 local flagname="multi_mod_rpcs"
21481 local connect_data_name="max_mod_rpcs"
21484 # check if multiple modify RPCs flag is set
21485 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
21486 grep "connect_flags:")
21489 echo "$out" | grep -qw $flagname
21490 if [ $? -ne 0 ]; then
21491 echo "connect flag $flagname is not set"
21495 # check if multiple modify RPCs data is set
21496 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
21499 echo "$out" | grep -qw $connect_data_name ||
21500 error "import should have connect data $connect_data_name"
21502 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
21505 local flagname="multi_mod_rpcs"
21506 local connect_data_name="max_mod_rpcs"
21509 remote_mds_nodsh && skip "remote MDS with nodsh"
21510 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
21512 # check if multiple modify RPCs flag is set
21513 out=$(do_facet mds1 \
21514 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
21515 grep "connect_flags:")
21518 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
21520 # check if multiple modify RPCs data is set
21521 out=$(do_facet mds1 \
21522 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21524 [[ "$out" =~ $connect_data_name ]] ||
21527 error "missing connect data $connect_data_name"
21530 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21536 umount_client $submount
21541 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21543 skip_env "Fileset feature is not supported"
21545 local submount=${MOUNT}_$tdir
21548 mkdir -p $submount || error "mkdir $submount failed"
21549 FILESET="$FILESET/$tdir" mount_client $submount ||
21550 error "mount $submount failed"
21551 trap "cleanup_247 $submount" EXIT
21552 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21553 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21554 error "read $MOUNT/$tdir/$tfile failed"
21555 cleanup_247 $submount
21557 run_test 247a "mount subdir as fileset"
21560 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21561 skip_env "Fileset feature is not supported"
21563 local submount=${MOUNT}_$tdir
21565 rm -rf $MOUNT/$tdir
21566 mkdir -p $submount || error "mkdir $submount failed"
21568 FILESET="$FILESET/$tdir" mount_client $submount &&
21569 error "mount $submount should fail"
21572 run_test 247b "mount subdir that dose not exist"
21575 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21576 skip_env "Fileset feature is not supported"
21578 local submount=${MOUNT}_$tdir
21580 mkdir -p $MOUNT/$tdir/dir1
21581 mkdir -p $submount || error "mkdir $submount failed"
21582 trap "cleanup_247 $submount" EXIT
21583 FILESET="$FILESET/$tdir" mount_client $submount ||
21584 error "mount $submount failed"
21585 local fid=$($LFS path2fid $MOUNT/)
21586 $LFS fid2path $submount $fid && error "fid2path should fail"
21587 cleanup_247 $submount
21589 run_test 247c "running fid2path outside subdirectory root"
21592 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21593 skip "Fileset feature is not supported"
21595 local submount=${MOUNT}_$tdir
21597 mkdir -p $MOUNT/$tdir/dir1
21598 mkdir -p $submount || error "mkdir $submount failed"
21599 FILESET="$FILESET/$tdir" mount_client $submount ||
21600 error "mount $submount failed"
21601 trap "cleanup_247 $submount" EXIT
21603 local td=$submount/dir1
21604 local fid=$($LFS path2fid $td)
21605 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21607 # check that we get the same pathname back
21610 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21611 echo "$rootpath $fid"
21612 found=$($LFS fid2path $rootpath "$fid")
21613 [ -n "$found" ] || error "fid2path should succeed"
21614 [ "$found" == "$td" ] || error "fid2path $found != $td"
21616 # check wrong root path format
21617 rootpath=$submount"_wrong"
21618 found=$($LFS fid2path $rootpath "$fid")
21619 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21621 cleanup_247 $submount
21623 run_test 247d "running fid2path inside subdirectory root"
21627 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21629 skip "Fileset feature is not supported"
21631 local submount=${MOUNT}_$tdir
21634 mkdir -p $submount || error "mkdir $submount failed"
21635 FILESET="$FILESET/.." mount_client $submount &&
21636 error "mount $submount should fail"
21639 run_test 247e "mount .. as fileset"
21642 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21643 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
21644 skip "Need at least version 2.13.52"
21645 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21646 skip "Need at least version 2.14.50"
21647 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21649 skip "Fileset feature is not supported"
21651 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21652 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21653 error "mkdir remote failed"
21654 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21655 error "mkdir remote/subdir failed"
21656 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21657 error "mkdir striped failed"
21658 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
21660 local submount=${MOUNT}_$tdir
21662 mkdir -p $submount || error "mkdir $submount failed"
21663 stack_trap "rmdir $submount"
21667 local fileset=$FILESET
21668 local mdts=$(comma_list $(mdts_nodes))
21670 stat=$(do_facet mds1 $LCTL get_param -n \
21671 mdt.*MDT0000.enable_remote_subdir_mount)
21672 stack_trap "do_nodes $mdts $LCTL set_param \
21673 mdt.*.enable_remote_subdir_mount=$stat"
21675 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
21676 stack_trap "umount_client $submount"
21677 FILESET="$fileset/$tdir/remote" mount_client $submount &&
21678 error "mount remote dir $dir should fail"
21680 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
21681 $tdir/striped/. ; do
21682 FILESET="$fileset/$dir" mount_client $submount ||
21683 error "mount $dir failed"
21684 umount_client $submount
21687 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
21688 FILESET="$fileset/$tdir/remote" mount_client $submount ||
21689 error "mount $tdir/remote failed"
21691 run_test 247f "mount striped or remote directory as fileset"
21694 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
21695 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21696 skip "Need at least version 2.14.50"
21698 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
21699 error "mkdir $tdir failed"
21700 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
21702 local submount=${MOUNT}_$tdir
21704 mkdir -p $submount || error "mkdir $submount failed"
21705 stack_trap "rmdir $submount"
21707 FILESET="$fileset/$tdir" mount_client $submount ||
21708 error "mount $dir failed"
21709 stack_trap "umount $submount"
21711 local mdts=$(comma_list $(mdts_nodes))
21715 stat $submount > /dev/null
21716 cancel_lru_locks $MDC
21717 stat $submount > /dev/null
21718 stat $submount/$tfile > /dev/null
21719 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
21720 stat $submount/$tfile > /dev/null
21721 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
21722 awk '/getattr/ {sum += $2} END {print sum}')
21724 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
21726 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
21729 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
21730 [ -z "$fast_read_sav" ] && skip "no fast read support"
21732 # create a large file for fast read verification
21733 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
21735 # make sure the file is created correctly
21736 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
21737 { rm -f $DIR/$tfile; skip "file creation error"; }
21739 echo "Test 1: verify that fast read is 4 times faster on cache read"
21741 # small read with fast read enabled
21742 $LCTL set_param -n llite.*.fast_read=1
21743 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21744 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21745 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21746 # small read with fast read disabled
21747 $LCTL set_param -n llite.*.fast_read=0
21748 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21749 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21750 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21752 # verify that fast read is 4 times faster for cache read
21753 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
21754 error_not_in_vm "fast read was not 4 times faster: " \
21755 "$t_fast vs $t_slow"
21757 echo "Test 2: verify the performance between big and small read"
21758 $LCTL set_param -n llite.*.fast_read=1
21760 # 1k non-cache read
21761 cancel_lru_locks osc
21762 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21763 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21764 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21766 # 1M non-cache read
21767 cancel_lru_locks osc
21768 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21769 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21770 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21772 # verify that big IO is not 4 times faster than small IO
21773 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
21774 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
21776 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
21779 run_test 248a "fast read verification"
21782 # Default short_io_bytes=16384, try both smaller and larger sizes.
21783 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
21784 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
21785 echo "bs=53248 count=113 normal buffered write"
21786 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
21787 error "dd of initial data file failed"
21788 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
21790 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
21791 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
21792 error "dd with sync normal writes failed"
21793 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
21795 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
21796 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
21797 error "dd with sync small writes failed"
21798 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
21800 cancel_lru_locks osc
21802 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
21803 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
21804 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
21805 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
21806 iflag=direct || error "dd with O_DIRECT small read failed"
21807 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
21808 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
21809 error "compare $TMP/$tfile.1 failed"
21811 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
21812 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
21814 # just to see what the maximum tunable value is, and test parsing
21815 echo "test invalid parameter 2MB"
21816 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
21817 error "too-large short_io_bytes allowed"
21818 echo "test maximum parameter 512KB"
21819 # if we can set a larger short_io_bytes, run test regardless of version
21820 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
21821 # older clients may not allow setting it this large, that's OK
21822 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
21823 skip "Need at least client version 2.13.50"
21824 error "medium short_io_bytes failed"
21826 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21827 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
21829 echo "test large parameter 64KB"
21830 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
21831 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21833 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
21834 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
21835 error "dd with sync large writes failed"
21836 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
21838 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
21839 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
21840 num=$((113 * 4096 / PAGE_SIZE))
21841 echo "bs=$size count=$num oflag=direct large write $tfile.3"
21842 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
21843 error "dd with O_DIRECT large writes failed"
21844 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
21845 error "compare $DIR/$tfile.3 failed"
21847 cancel_lru_locks osc
21849 echo "bs=$size count=$num iflag=direct large read $tfile.2"
21850 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
21851 error "dd with O_DIRECT large read failed"
21852 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
21853 error "compare $TMP/$tfile.2 failed"
21855 echo "bs=$size count=$num iflag=direct large read $tfile.3"
21856 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
21857 error "dd with O_DIRECT large read failed"
21858 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
21859 error "compare $TMP/$tfile.3 failed"
21861 run_test 248b "test short_io read and write for both small and large sizes"
21863 test_249() { # LU-7890
21864 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
21865 skip "Need at least version 2.8.54"
21868 $LFS setstripe -c 1 $DIR/$tfile
21869 # Offset 2T == 4k * 512M
21870 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
21871 error "dd to 2T offset failed"
21873 run_test 249 "Write above 2T file size"
21876 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
21877 && skip "no 16TB file size limit on ZFS"
21879 $LFS setstripe -c 1 $DIR/$tfile
21880 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
21881 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
21882 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
21883 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
21884 conv=notrunc,fsync && error "append succeeded"
21887 run_test 250 "Write above 16T limit"
21890 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
21892 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
21893 #Skip once - writing the first stripe will succeed
21894 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21895 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
21896 error "short write happened"
21898 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21899 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
21900 error "short read happened"
21904 run_test 251 "Handling short read and write correctly"
21907 remote_mds_nodsh && skip "remote MDS with nodsh"
21908 remote_ost_nodsh && skip "remote OST with nodsh"
21909 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
21910 skip_env "ldiskfs only test"
21920 # check lr_reader on OST0000
21922 dev=$(facet_device $tgt)
21923 out=$(do_facet $tgt $LR_READER $dev)
21924 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21926 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
21927 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
21928 error "Invalid uuid returned by $LR_READER on target $tgt"
21929 echo -e "uuid returned by $LR_READER is '$uuid'\n"
21931 # check lr_reader -c on MDT0000
21933 dev=$(facet_device $tgt)
21934 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
21935 skip "$LR_READER does not support additional options"
21937 out=$(do_facet $tgt $LR_READER -c $dev)
21938 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21940 num=$(echo "$out" | grep -c "mdtlov")
21941 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
21942 error "Invalid number of mdtlov clients returned by $LR_READER"
21943 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
21945 # check lr_reader -cr on MDT0000
21946 out=$(do_facet $tgt $LR_READER -cr $dev)
21947 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21949 echo "$out" | grep -q "^reply_data:$" ||
21950 error "$LR_READER should have returned 'reply_data' section"
21951 num=$(echo "$out" | grep -c "client_generation")
21952 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
21954 run_test 252 "check lr_reader tool"
21957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21958 remote_mds_nodsh && skip "remote MDS with nodsh"
21959 remote_mgs_nodsh && skip "remote MGS with nodsh"
21963 local ost_name=$(ostname_from_index $ostidx)
21966 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
21967 do_facet $SINGLEMDS $LCTL get_param -n \
21968 osp.$mdtosc_proc1.reserved_mb_high ||
21969 skip "remote MDS does not support reserved_mb_high"
21973 wait_delete_completed
21976 pool_add $TESTNAME || error "Pool creation failed"
21977 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
21979 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
21980 error "Setstripe failed"
21982 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
21984 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
21986 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
21988 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21989 osp.$mdtosc_proc1.prealloc_status)
21990 echo "prealloc_status $oa_status"
21992 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
21993 error "File creation should fail"
21995 #object allocation was stopped, but we still able to append files
21996 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
21997 oflag=append || error "Append failed"
21999 rm -f $DIR/$tdir/$tfile.0
22001 # For this test, we want to delete the files we created to go out of
22002 # space but leave the watermark, so we remain nearly out of space
22003 ost_watermarks_enospc_delete_files $tfile $ostidx
22005 wait_delete_completed
22009 for i in $(seq 10 12); do
22010 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
22011 2>/dev/null || error "File creation failed after rm"
22014 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
22015 osp.$mdtosc_proc1.prealloc_status)
22016 echo "prealloc_status $oa_status"
22018 if (( oa_status != 0 )); then
22019 error "Object allocation still disable after rm"
22022 run_test 253 "Check object allocation limit"
22025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22026 remote_mds_nodsh && skip "remote MDS with nodsh"
22028 local mdt=$(facet_svc $SINGLEMDS)
22030 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
22031 skip "MDS does not support changelog_size"
22035 changelog_register || error "changelog_register failed"
22037 changelog_clear 0 || error "changelog_clear failed"
22039 local size1=$(do_facet $SINGLEMDS \
22040 $LCTL get_param -n mdd.$mdt.changelog_size)
22041 echo "Changelog size $size1"
22044 $LFS mkdir -i 0 $DIR/$tdir
22046 mkdir -p $DIR/$tdir/pics/2008/zachy
22047 touch $DIR/$tdir/pics/2008/zachy/timestamp
22048 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
22049 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
22050 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
22051 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
22052 rm $DIR/$tdir/pics/desktop.jpg
22054 local size2=$(do_facet $SINGLEMDS \
22055 $LCTL get_param -n mdd.$mdt.changelog_size)
22056 echo "Changelog size after work $size2"
22058 (( $size2 > $size1 )) ||
22059 error "new Changelog size=$size2 less than old size=$size1"
22061 run_test 254 "Check changelog size"
22068 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
22069 awk -F: '{print $2}' | grep $type > /dev/null
22070 if [ $? -ne 0 ]; then
22080 lfs ladvise -a willread $file > /dev/null 2>&1
22081 if [ $? -eq 0 ]; then
22085 lfs ladvise -a willread $file 2>&1 |
22086 grep "Inappropriate ioctl for device" > /dev/null
22087 if [ $? -eq 0 ]; then
22094 bc <<<"scale=2; ($1 - $2) * 100 / $2"
22097 # run a random read IO workload
22098 # usage: random_read_iops <filename> <filesize> <iosize>
22099 random_read_iops() {
22102 local iosize=${3:-4096}
22104 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
22105 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
22108 drop_file_oss_cache() {
22112 $LFS ladvise -a dontneed $file 2>/dev/null ||
22113 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
22116 ladvise_willread_performance()
22119 local average_origin=0
22120 local average_cache=0
22121 local average_ladvise=0
22123 for ((i = 1; i <= $repeat; i++)); do
22124 echo "Iter $i/$repeat: reading without willread hint"
22125 cancel_lru_locks osc
22126 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22127 local speed_origin=$(random_read_iops $DIR/$tfile $size)
22128 echo "Iter $i/$repeat: uncached speed: $speed_origin"
22129 average_origin=$(bc <<<"$average_origin + $speed_origin")
22131 cancel_lru_locks osc
22132 local speed_cache=$(random_read_iops $DIR/$tfile $size)
22133 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
22134 average_cache=$(bc <<<"$average_cache + $speed_cache")
22136 cancel_lru_locks osc
22137 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
22138 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
22139 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
22140 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
22141 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
22143 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
22144 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
22145 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
22147 speedup_cache=$(percent $average_cache $average_origin)
22148 speedup_ladvise=$(percent $average_ladvise $average_origin)
22150 echo "Average uncached read: $average_origin"
22151 echo "Average speedup with OSS cached read: " \
22152 "$average_cache = +$speedup_cache%"
22153 echo "Average speedup with ladvise willread: " \
22154 "$average_ladvise = +$speedup_ladvise%"
22156 local lowest_speedup=20
22157 if (( ${average_cache%.*} < $lowest_speedup )); then
22158 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
22159 " got $average_cache%. Skipping ladvise willread check."
22163 # the test won't work on ZFS until it supports 'ladvise dontneed', but
22164 # it is still good to run until then to exercise 'ladvise willread'
22165 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22166 [ "$ost1_FSTYPE" = "zfs" ] &&
22167 echo "osd-zfs does not support dontneed or drop_caches" &&
22170 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
22171 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
22172 error_not_in_vm "Speedup with willread is less than " \
22173 "$lowest_speedup%, got $average_ladvise%"
22177 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22178 skip "lustre < 2.8.54 does not support ladvise "
22179 remote_ost_nodsh && skip "remote OST with nodsh"
22181 stack_trap "rm -f $DIR/$tfile"
22182 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
22184 ladvise_no_type willread $DIR/$tfile &&
22185 skip "willread ladvise is not supported"
22187 ladvise_no_ioctl $DIR/$tfile &&
22188 skip "ladvise ioctl is not supported"
22191 local size=$((size_mb * 1048576))
22192 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22193 error "dd to $DIR/$tfile failed"
22195 lfs ladvise -a willread $DIR/$tfile ||
22196 error "Ladvise failed with no range argument"
22198 lfs ladvise -a willread -s 0 $DIR/$tfile ||
22199 error "Ladvise failed with no -l or -e argument"
22201 lfs ladvise -a willread -e 1 $DIR/$tfile ||
22202 error "Ladvise failed with only -e argument"
22204 lfs ladvise -a willread -l 1 $DIR/$tfile ||
22205 error "Ladvise failed with only -l argument"
22207 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
22208 error "End offset should not be smaller than start offset"
22210 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
22211 error "End offset should not be equal to start offset"
22213 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
22214 error "Ladvise failed with overflowing -s argument"
22216 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
22217 error "Ladvise failed with overflowing -e argument"
22219 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
22220 error "Ladvise failed with overflowing -l argument"
22222 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
22223 error "Ladvise succeeded with conflicting -l and -e arguments"
22225 echo "Synchronous ladvise should wait"
22227 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
22228 do_nodes $(comma_list $(osts_nodes)) \
22229 $LCTL set_param fail_val=$delay fail_loc=0x237
22231 local start_ts=$SECONDS
22232 lfs ladvise -a willread $DIR/$tfile ||
22233 error "Ladvise failed with no range argument"
22234 local end_ts=$SECONDS
22235 local inteval_ts=$((end_ts - start_ts))
22237 if [ $inteval_ts -lt $(($delay - 1)) ]; then
22238 error "Synchronous advice didn't wait reply"
22241 echo "Asynchronous ladvise shouldn't wait"
22242 local start_ts=$SECONDS
22243 lfs ladvise -a willread -b $DIR/$tfile ||
22244 error "Ladvise failed with no range argument"
22245 local end_ts=$SECONDS
22246 local inteval_ts=$((end_ts - start_ts))
22248 if [ $inteval_ts -gt $(($delay / 2)) ]; then
22249 error "Asynchronous advice blocked"
22252 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
22253 ladvise_willread_performance
22255 run_test 255a "check 'lfs ladvise -a willread'"
22261 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
22265 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
22266 skip "lustre < 2.8.54 does not support ladvise "
22267 remote_ost_nodsh && skip "remote OST with nodsh"
22269 stack_trap "rm -f $DIR/$tfile"
22270 lfs setstripe -c 1 -i 0 $DIR/$tfile
22272 ladvise_no_type dontneed $DIR/$tfile &&
22273 skip "dontneed ladvise is not supported"
22275 ladvise_no_ioctl $DIR/$tfile &&
22276 skip "ladvise ioctl is not supported"
22278 ! $LFS ladvise -a dontneed $DIR/$tfile &&
22279 [ "$ost1_FSTYPE" = "zfs" ] &&
22280 skip "zfs-osd does not support 'ladvise dontneed'"
22283 local size=$((size_mb * 1048576))
22284 # In order to prevent disturbance of other processes, only check 3/4
22285 # of the memory usage
22286 local kibibytes=$((size_mb * 1024 * 3 / 4))
22288 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
22289 error "dd to $DIR/$tfile failed"
22291 #force write to complete before dropping OST cache & checking memory
22294 local total=$(facet_meminfo ost1 MemTotal)
22295 echo "Total memory: $total KiB"
22297 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
22298 local before_read=$(facet_meminfo ost1 Cached)
22299 echo "Cache used before read: $before_read KiB"
22301 lfs ladvise -a willread $DIR/$tfile ||
22302 error "Ladvise willread failed"
22303 local after_read=$(facet_meminfo ost1 Cached)
22304 echo "Cache used after read: $after_read KiB"
22306 lfs ladvise -a dontneed $DIR/$tfile ||
22307 error "Ladvise dontneed again failed"
22308 local no_read=$(facet_meminfo ost1 Cached)
22309 echo "Cache used after dontneed ladvise: $no_read KiB"
22311 if [ $total -lt $((before_read + kibibytes)) ]; then
22312 echo "Memory is too small, abort checking"
22316 if [ $((before_read + kibibytes)) -gt $after_read ]; then
22317 error "Ladvise willread should use more memory" \
22318 "than $kibibytes KiB"
22321 if [ $((no_read + kibibytes)) -gt $after_read ]; then
22322 error "Ladvise dontneed should release more memory" \
22323 "than $kibibytes KiB"
22326 run_test 255b "check 'lfs ladvise -a dontneed'"
22329 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
22330 skip "lustre < 2.10.50 does not support lockahead"
22332 local ost1_imp=$(get_osc_import_name client ost1)
22333 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22341 test_mkdir -p $DIR/$tdir
22342 $LFS setstripe -i 0 -c 1 $DIR/$tdir
22344 #test 10 returns only success/failure
22346 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22348 if [ $rc -eq 255 ]; then
22349 error "Ladvise test${i} failed, ${rc}"
22352 #test 11 counts lock enqueue requests, all others count new locks
22354 count=$(do_facet ost1 \
22355 $LCTL get_param -n ost.OSS.ost.stats)
22356 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
22358 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22360 if [ $rc -eq 255 ]; then
22361 error "Ladvise test${i} failed, ${rc}"
22364 new_count=$(do_facet ost1 \
22365 $LCTL get_param -n ost.OSS.ost.stats)
22366 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
22367 awk '{ print $2 }')
22369 difference="$((new_count - count))"
22370 if [ $difference -ne $rc ]; then
22371 error "Ladvise test${i}, bad enqueue count, returned " \
22372 "${rc}, actual ${difference}"
22375 for i in $(seq 12 21); do
22376 # If we do not do this, we run the risk of having too many
22377 # locks and starting lock cancellation while we are checking
22379 cancel_lru_locks osc
22381 count=$($LCTL get_param -n \
22382 ldlm.namespaces.$imp_name.lock_unused_count)
22384 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22386 if [ $rc -eq 255 ]; then
22387 error "Ladvise test ${i} failed, ${rc}"
22390 new_count=$($LCTL get_param -n \
22391 ldlm.namespaces.$imp_name.lock_unused_count)
22392 difference="$((new_count - count))"
22394 # Test 15 output is divided by 100 to map down to valid return
22395 if [ $i -eq 15 ]; then
22399 if [ $difference -ne $rc ]; then
22400 error "Ladvise test ${i}, bad lock count, returned " \
22401 "${rc}, actual ${difference}"
22405 #test 22 returns only success/failure
22407 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22409 if [ $rc -eq 255 ]; then
22410 error "Ladvise test${i} failed, ${rc}"
22413 run_test 255c "suite of ladvise lockahead tests"
22416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22417 remote_mds_nodsh && skip "remote MDS with nodsh"
22418 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22419 changelog_users $SINGLEMDS | grep "^cl" &&
22420 skip "active changelog user"
22426 mdt_dev=$(facet_device $SINGLEMDS)
22429 changelog_register || error "changelog_register failed"
22432 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
22434 changelog_clear 0 || error "changelog_clear failed"
22437 touch $DIR/$tdir/{1..10}
22440 stop $SINGLEMDS || error "Fail to stop MDT"
22443 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
22444 error "Fail to start MDT"
22446 #after mount new plainllog is used
22447 touch $DIR/$tdir/{11..19}
22448 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
22449 stack_trap "rm -f $tmpfile"
22450 cat_sl=$(do_facet $SINGLEMDS "sync; \
22451 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22452 llog_reader $tmpfile | grep -c type=1064553b")
22453 do_facet $SINGLEMDS llog_reader $tmpfile
22455 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
22457 changelog_clear 0 || error "changelog_clear failed"
22459 cat_sl=$(do_facet $SINGLEMDS "sync; \
22460 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22461 llog_reader $tmpfile | grep -c type=1064553b")
22463 if (( cat_sl == 2 )); then
22464 error "Empty plain llog was not deleted from changelog catalog"
22465 elif (( cat_sl != 1 )); then
22466 error "Active plain llog shouldn't be deleted from catalog"
22469 run_test 256 "Check llog delete for empty and not full state"
22472 remote_mds_nodsh && skip "remote MDS with nodsh"
22473 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22474 skip "Need MDS version at least 2.8.55"
22476 test_mkdir $DIR/$tdir
22478 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
22479 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
22482 #define OBD_FAIL_MDS_XATTR_REP 0x161
22483 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22484 local facet=mds$((mdtidx + 1))
22485 set_nodes_failloc $(facet_active_host $facet) 0x80000161
22486 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
22488 stop $facet || error "stop MDS failed"
22489 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
22490 error "start MDS fail"
22491 wait_recovery_complete $facet
22493 run_test 257 "xattr locks are not lost"
22495 # Verify we take the i_mutex when security requires it
22497 #define OBD_FAIL_IMUTEX_SEC 0x141c
22498 $LCTL set_param fail_loc=0x141c
22500 chmod u+s $DIR/$tfile
22501 chmod a+rwx $DIR/$tfile
22502 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22504 if [ $RC -ne 0 ]; then
22505 error "error, failed to take i_mutex, rc=$?"
22509 run_test 258a "verify i_mutex security behavior when suid attributes is set"
22511 # Verify we do NOT take the i_mutex in the normal case
22513 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
22514 $LCTL set_param fail_loc=0x141d
22517 chmod a+rw $DIR/$tfile
22518 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22520 if [ $RC -ne 0 ]; then
22521 error "error, took i_mutex unnecessarily, rc=$?"
22526 run_test 258b "verify i_mutex security behavior"
22529 local file=$DIR/$tfile
22533 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22535 stack_trap "rm -f $file" EXIT
22537 wait_delete_completed
22538 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22539 echo "before: $before"
22541 $LFS setstripe -i 0 -c 1 $file
22542 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22544 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22545 echo "after write: $after"
22547 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22548 do_facet ost1 $LCTL set_param fail_loc=0x2301
22550 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22551 echo "after truncate: $after"
22554 do_facet ost1 $LCTL set_param fail_loc=0
22555 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22557 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22558 echo "after restart: $after"
22559 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22560 error "missing truncate?"
22564 run_test 259 "crash at delayed truncate"
22567 #define OBD_FAIL_MDC_CLOSE 0x806
22568 $LCTL set_param fail_loc=0x80000806
22572 run_test 260 "Check mdc_close fail"
22574 ### Data-on-MDT sanity tests ###
22576 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22577 skip "Need MDS version at least 2.10.55 for DoM"
22580 local dom=$DIR/$tdir/dom_file
22581 local tmp=$DIR/$tdir/tmp_file
22583 mkdir_on_mdt0 $DIR/$tdir
22585 # basic checks for DoM component creation
22586 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22587 error "Can set MDT layout to non-first entry"
22589 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22590 error "Can define multiple entries as MDT layout"
22592 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22594 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22595 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22596 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22598 local mdtidx=$($LFS getstripe -m $dom)
22599 local mdtname=MDT$(printf %04x $mdtidx)
22600 local facet=mds$((mdtidx + 1))
22601 local space_check=1
22603 # Skip free space checks with ZFS
22604 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22608 local size_tmp=$((65536 * 3))
22609 local mdtfree1=$(do_facet $facet \
22610 lctl get_param -n osd*.*$mdtname.kbytesfree)
22612 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22613 # check also direct IO along write
22614 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22615 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22617 cmp $tmp $dom || error "file data is different"
22618 [ $(stat -c%s $dom) == $size_tmp ] ||
22619 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22620 if [ $space_check == 1 ]; then
22621 local mdtfree2=$(do_facet $facet \
22622 lctl get_param -n osd*.*$mdtname.kbytesfree)
22624 # increase in usage from by $size_tmp
22625 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22626 error "MDT free space wrong after write: " \
22627 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22631 local size_dom=10000
22633 $TRUNCATE $dom $size_dom
22634 [ $(stat -c%s $dom) == $size_dom ] ||
22635 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22636 if [ $space_check == 1 ]; then
22637 mdtfree1=$(do_facet $facet \
22638 lctl get_param -n osd*.*$mdtname.kbytesfree)
22639 # decrease in usage from $size_tmp to new $size_dom
22640 [ $(($mdtfree1 - $mdtfree2)) -ge \
22641 $(((size_tmp - size_dom) / 1024)) ] ||
22642 error "MDT free space is wrong after truncate: " \
22643 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22649 size_dom=$((size_dom + size_tmp))
22650 [ $(stat -c%s $dom) == $size_dom ] ||
22651 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22652 if [ $space_check == 1 ]; then
22653 mdtfree2=$(do_facet $facet \
22654 lctl get_param -n osd*.*$mdtname.kbytesfree)
22655 # increase in usage by $size_tmp from previous
22656 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22657 error "MDT free space is wrong after append: " \
22658 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22663 if [ $space_check == 1 ]; then
22664 mdtfree1=$(do_facet $facet \
22665 lctl get_param -n osd*.*$mdtname.kbytesfree)
22666 # decrease in usage by $size_dom from previous
22667 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
22668 error "MDT free space is wrong after removal: " \
22669 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
22672 # combined striping
22673 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
22674 error "Can't create DoM + OST striping"
22676 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
22677 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22678 # check also direct IO along write
22679 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22681 cmp $tmp $dom || error "file data is different"
22682 [ $(stat -c%s $dom) == $size_tmp ] ||
22683 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22688 run_test 270a "DoM: basic functionality tests"
22691 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22692 skip "Need MDS version at least 2.10.55"
22694 local dom=$DIR/$tdir/dom_file
22695 local max_size=1048576
22697 mkdir -p $DIR/$tdir
22698 $LFS setstripe -E $max_size -L mdt $dom
22700 # truncate over the limit
22701 $TRUNCATE $dom $(($max_size + 1)) &&
22702 error "successful truncate over the maximum size"
22703 # write over the limit
22704 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
22705 error "successful write over the maximum size"
22706 # append over the limit
22707 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
22708 echo "12345" >> $dom && error "successful append over the maximum size"
22713 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
22716 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22717 skip "Need MDS version at least 2.10.55"
22719 mkdir -p $DIR/$tdir
22720 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22722 # check files inherit DoM EA
22723 touch $DIR/$tdir/first
22724 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
22725 error "bad pattern"
22726 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
22727 error "bad stripe count"
22728 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
22729 error "bad stripe size"
22731 # check directory inherits DoM EA and uses it as default
22732 mkdir $DIR/$tdir/subdir
22733 touch $DIR/$tdir/subdir/second
22734 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
22735 error "bad pattern in sub-directory"
22736 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
22737 error "bad stripe count in sub-directory"
22738 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
22739 error "bad stripe size in sub-directory"
22742 run_test 270c "DoM: DoM EA inheritance tests"
22745 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22746 skip "Need MDS version at least 2.10.55"
22748 mkdir -p $DIR/$tdir
22749 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22751 # inherit default DoM striping
22752 mkdir $DIR/$tdir/subdir
22753 touch $DIR/$tdir/subdir/f1
22755 # change default directory striping
22756 $LFS setstripe -c 1 $DIR/$tdir/subdir
22757 touch $DIR/$tdir/subdir/f2
22758 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
22759 error "wrong default striping in file 2"
22760 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
22761 error "bad pattern in file 2"
22764 run_test 270d "DoM: change striping from DoM to RAID0"
22767 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22768 skip "Need MDS version at least 2.10.55"
22770 mkdir -p $DIR/$tdir/dom
22771 mkdir -p $DIR/$tdir/norm
22774 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
22775 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
22777 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
22778 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
22780 # find DoM files by layout
22781 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
22782 [ $NUM -eq $DOMFILES ] ||
22783 error "lfs find -L: found $NUM, expected $DOMFILES"
22784 echo "Test 1: lfs find 20 DOM files by layout: OK"
22786 # there should be 1 dir with default DOM striping
22787 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
22789 error "lfs find -L: found $NUM, expected 1 dir"
22790 echo "Test 2: lfs find 1 DOM dir by layout: OK"
22792 # find DoM files by stripe size
22793 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
22794 [ $NUM -eq $DOMFILES ] ||
22795 error "lfs find -S: found $NUM, expected $DOMFILES"
22796 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
22798 # find files by stripe offset except DoM files
22799 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
22800 [ $NUM -eq $NORMFILES ] ||
22801 error "lfs find -i: found $NUM, expected $NORMFILES"
22802 echo "Test 5: lfs find no DOM files by stripe index: OK"
22805 run_test 270e "DoM: lfs find with DoM files test"
22808 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22809 skip "Need MDS version at least 2.10.55"
22811 local mdtname=${FSNAME}-MDT0000-mdtlov
22812 local dom=$DIR/$tdir/dom_file
22813 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
22814 lod.$mdtname.dom_stripesize)
22815 local dom_limit=131072
22817 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
22818 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22819 lod.$mdtname.dom_stripesize)
22820 [ ${dom_limit} -eq ${dom_current} ] ||
22821 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
22823 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22824 $LFS setstripe -d $DIR/$tdir
22825 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
22826 error "Can't set directory default striping"
22828 # exceed maximum stripe size
22829 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22830 error "Can't create file with $((dom_limit * 2)) DoM stripe"
22831 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
22832 error "Able to create DoM component size more than LOD limit"
22834 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22835 dom_current=$(do_facet mds1 $LCTL get_param -n \
22836 lod.$mdtname.dom_stripesize)
22837 [ 0 -eq ${dom_current} ] ||
22838 error "Can't set zero DoM stripe limit"
22841 # attempt to create DoM file on server with disabled DoM should
22842 # remove DoM entry from layout and be succeed
22843 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
22844 error "Can't create DoM file (DoM is disabled)"
22845 [ $($LFS getstripe -L $dom) == "mdt" ] &&
22846 error "File has DoM component while DoM is disabled"
22849 # attempt to create DoM file with only DoM stripe should return error
22850 $LFS setstripe -E $dom_limit -L mdt $dom &&
22851 error "Able to create DoM-only file while DoM is disabled"
22853 # too low values to be aligned with smallest stripe size 64K
22854 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
22855 dom_current=$(do_facet mds1 $LCTL get_param -n \
22856 lod.$mdtname.dom_stripesize)
22857 [ 30000 -eq ${dom_current} ] &&
22858 error "Can set too small DoM stripe limit"
22860 # 64K is a minimal stripe size in Lustre, expect limit of that size
22861 [ 65536 -eq ${dom_current} ] ||
22862 error "Limit is not set to 64K but ${dom_current}"
22864 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
22865 dom_current=$(do_facet mds1 $LCTL get_param -n \
22866 lod.$mdtname.dom_stripesize)
22868 [ 2147483648 -eq ${dom_current} ] &&
22869 error "Can set too large DoM stripe limit"
22871 do_facet mds1 $LCTL set_param -n \
22872 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
22873 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22874 error "Can't create DoM component size after limit change"
22875 do_facet mds1 $LCTL set_param -n \
22876 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
22877 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
22878 error "Can't create DoM file after limit decrease"
22879 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
22880 error "Can create big DoM component after limit decrease"
22881 touch ${dom}_def ||
22882 error "Can't create file with old default layout"
22884 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
22887 run_test 270f "DoM: maximum DoM stripe size checks"
22890 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22891 skip "Need MDS version at least 2.13.52"
22892 local dom=$DIR/$tdir/$tfile
22894 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22895 local lodname=${FSNAME}-MDT0000-mdtlov
22897 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22898 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
22899 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
22900 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22902 local dom_limit=1024
22903 local dom_threshold="50%"
22905 $LFS setstripe -d $DIR/$tdir
22906 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
22907 error "Can't set directory default striping"
22909 do_facet mds1 $LCTL set_param -n \
22910 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
22911 # set 0 threshold and create DOM file to change tunable stripesize
22912 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
22913 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22914 error "Failed to create $dom file"
22915 # now tunable dom_cur_stripesize should reach maximum
22916 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22917 lod.${lodname}.dom_stripesize_cur_kb)
22918 [[ $dom_current == $dom_limit ]] ||
22919 error "Current DOM stripesize is not maximum"
22922 # set threshold for further tests
22923 do_facet mds1 $LCTL set_param -n \
22924 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
22925 echo "DOM threshold is $dom_threshold free space"
22928 # Spoof bfree to exceed threshold
22929 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
22930 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
22931 for spfree in 40 20 0 15 30 55; do
22932 do_facet mds1 $LCTL set_param -n fail_val=$spfree
22933 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22934 error "Failed to create $dom file"
22935 dom_def=$(do_facet mds1 $LCTL get_param -n \
22936 lod.${lodname}.dom_stripesize_cur_kb)
22937 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
22938 [[ $dom_def != $dom_current ]] ||
22939 error "Default stripe size was not changed"
22940 if (( spfree > 0 )) ; then
22941 dom_set=$($LFS getstripe -S $dom)
22942 (( dom_set == dom_def * 1024 )) ||
22943 error "DOM component size is still old"
22945 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22946 error "DoM component is set with no free space"
22949 dom_current=$dom_def
22952 run_test 270g "DoM: default DoM stripe size depends on free space"
22955 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22956 skip "Need MDS version at least 2.13.53"
22958 local mdtname=${FSNAME}-MDT0000-mdtlov
22959 local dom=$DIR/$tdir/$tfile
22960 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22962 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
22963 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22965 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22966 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
22967 error "can't create OST file"
22968 # mirrored file with DOM entry in the second mirror
22969 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
22970 error "can't create mirror with DoM component"
22972 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22974 # DOM component in the middle and has other enries in the same mirror,
22975 # should succeed but lost DoM component
22976 $LFS setstripe --copy=${dom}_1 $dom ||
22977 error "Can't create file from OST|DOM mirror layout"
22978 # check new file has no DoM layout after all
22979 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22980 error "File has DoM component while DoM is disabled"
22982 run_test 270h "DoM: DoM stripe removal when disabled on server"
22985 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
22986 skip "Need MDS version at least 2.14.54"
22989 # DoM with plain layout
22990 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
22991 error "default plain layout with DoM must fail"
22992 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
22993 error "setstripe plain file layout with DoM must fail"
22994 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
22995 error "default DoM layout with bad striping must fail"
22996 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
22997 error "setstripe to DoM layout with bad striping must fail"
23000 run_test 270i "DoM: setting invalid DoM striping should fail"
23003 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23004 skip "Need MDS version at least 2.10.55"
23006 local dom=$DIR/$tdir/dom
23008 mkdir -p $DIR/$tdir
23010 $LFS setstripe -E 1024K -L mdt $dom
23012 lctl set_param -n mdc.*.stats=clear
23013 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23014 cat $dom > /dev/null
23015 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
23016 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
23020 run_test 271a "DoM: data is cached for read after write"
23023 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23024 skip "Need MDS version at least 2.10.55"
23026 local dom=$DIR/$tdir/dom
23028 mkdir -p $DIR/$tdir
23030 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23032 lctl set_param -n mdc.*.stats=clear
23033 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
23034 cancel_lru_locks mdc
23035 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
23036 # second stat to check size is cached on client
23037 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
23038 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23039 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
23042 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
23045 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23046 skip "Need MDS version at least 2.10.55"
23048 local dom=$DIR/$tdir/dom
23050 mkdir -p $DIR/$tdir
23052 $LFS setstripe -E 1024K -L mdt -E EOF $dom
23054 lctl set_param -n mdc.*.stats=clear
23055 lctl set_param -n osc.*.stats=clear
23056 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
23057 cancel_lru_locks mdc
23058 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23059 # second stat to check size is cached on client
23060 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
23061 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
23062 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
23063 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
23064 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
23067 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
23073 local mdt=MDT$(printf %04x $mdtidx)
23075 if [ -z $param ]; then
23076 lctl get_param -n mdc.*$mdt*.stats
23078 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
23083 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
23084 skip "Need MDS version at least 2.10.55"
23086 local dom=$DIR/$tdir/dom
23088 mkdir -p $DIR/$tdir
23090 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23092 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
23093 local facet=mds$((mdtidx + 1))
23095 cancel_lru_locks mdc
23096 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
23097 createmany -o $dom 1000
23098 lctl set_param -n mdc.*.stats=clear
23099 smalliomany -w $dom 1000 200
23100 get_mdc_stats $mdtidx
23101 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23102 # Each file has 1 open, 1 IO enqueues, total 2000
23103 # but now we have also +1 getxattr for security.capability, total 3000
23104 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
23105 unlinkmany $dom 1000
23107 cancel_lru_locks mdc
23108 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
23109 createmany -o $dom 1000
23110 lctl set_param -n mdc.*.stats=clear
23111 smalliomany -w $dom 1000 200
23112 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
23113 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
23114 # for OPEN and IO lock.
23115 [ $((enq - enq_2)) -ge 1000 ] ||
23116 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
23117 unlinkmany $dom 1000
23120 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
23122 cleanup_271def_tests() {
23128 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23129 skip "Need MDS version at least 2.10.57"
23131 local dom=$DIR/$tdir/dom
23132 local tmp=$TMP/$tfile
23133 trap "cleanup_271def_tests $tmp" EXIT
23135 mkdir -p $DIR/$tdir
23137 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23139 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23141 cancel_lru_locks mdc
23142 dd if=/dev/urandom of=$tmp bs=1000 count=1
23143 dd if=$tmp of=$dom bs=1000 count=1
23144 cancel_lru_locks mdc
23146 cat /etc/hosts >> $tmp
23147 lctl set_param -n mdc.*.stats=clear
23149 # append data to the same file it should update local page
23150 echo "Append to the same page"
23151 cat /etc/hosts >> $dom
23152 local num=$(get_mdc_stats $mdtidx ost_read)
23153 local ra=$(get_mdc_stats $mdtidx req_active)
23154 local rw=$(get_mdc_stats $mdtidx req_waittime)
23156 [ -z $num ] || error "$num READ RPC occured"
23157 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23161 cmp $tmp $dom || error "file miscompare"
23163 cancel_lru_locks mdc
23164 lctl set_param -n mdc.*.stats=clear
23166 echo "Open and read file"
23167 cat $dom > /dev/null
23168 local num=$(get_mdc_stats $mdtidx ost_read)
23169 local ra=$(get_mdc_stats $mdtidx req_active)
23170 local rw=$(get_mdc_stats $mdtidx req_waittime)
23172 [ -z $num ] || error "$num READ RPC occured"
23173 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23177 cmp $tmp $dom || error "file miscompare"
23181 run_test 271d "DoM: read on open (1K file in reply buffer)"
23184 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
23185 skip "Need MDS version at least 2.10.57"
23187 local dom=$DIR/$tdir/dom
23188 local tmp=$TMP/$tfile
23189 trap "cleanup_271def_tests $tmp" EXIT
23191 mkdir -p $DIR/$tdir
23193 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
23195 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
23197 cancel_lru_locks mdc
23198 dd if=/dev/urandom of=$tmp bs=265000 count=1
23199 dd if=$tmp of=$dom bs=265000 count=1
23200 cancel_lru_locks mdc
23201 cat /etc/hosts >> $tmp
23202 lctl set_param -n mdc.*.stats=clear
23204 echo "Append to the same page"
23205 cat /etc/hosts >> $dom
23206 local num=$(get_mdc_stats $mdtidx ost_read)
23207 local ra=$(get_mdc_stats $mdtidx req_active)
23208 local rw=$(get_mdc_stats $mdtidx req_waittime)
23210 [ -z $num ] || error "$num READ RPC occured"
23211 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23215 cmp $tmp $dom || error "file miscompare"
23217 cancel_lru_locks mdc
23218 lctl set_param -n mdc.*.stats=clear
23220 echo "Open and read file"
23221 cat $dom > /dev/null
23222 local num=$(get_mdc_stats $mdtidx ost_read)
23223 local ra=$(get_mdc_stats $mdtidx req_active)
23224 local rw=$(get_mdc_stats $mdtidx req_waittime)
23226 [ -z $num ] && num=0
23227 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
23228 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
23232 cmp $tmp $dom || error "file miscompare"
23236 run_test 271f "DoM: read on open (200K file and read tail)"
23239 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
23240 skip "Skipping due to old client or server version"
23242 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
23244 $CHECKSTAT -t file $DIR1/$tfile
23246 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
23249 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
23250 $LCTL set_param fail_loc=0x80000314
23251 rm $DIR1/$tfile || error "Unlink fails"
23253 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
23254 [ $RC -eq 0 ] || error "Failed write to stale object"
23256 run_test 271g "Discard DoM data vs client flush race"
23259 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23260 skip "Need MDS version at least 2.11.50"
23262 local dom=$DIR/$tdir/dom
23263 mkdir -p $DIR/$tdir
23265 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
23266 dd if=/dev/urandom of=$dom bs=512K count=1 ||
23267 error "failed to write data into $dom"
23268 local old_md5=$(md5sum $dom)
23270 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
23271 error "failed to migrate to the same DoM component"
23273 local new_md5=$(md5sum $dom)
23275 [ "$old_md5" == "$new_md5" ] ||
23276 error "md5sum differ: $old_md5, $new_md5"
23278 [ $($LFS getstripe -c $dom) -eq 2 ] ||
23279 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
23281 run_test 272a "DoM migration: new layout with the same DOM component"
23284 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23285 skip "Need MDS version at least 2.11.50"
23287 local dom=$DIR/$tdir/dom
23288 mkdir -p $DIR/$tdir
23289 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23291 local mdtidx=$($LFS getstripe -m $dom)
23292 local mdtname=MDT$(printf %04x $mdtidx)
23293 local facet=mds$((mdtidx + 1))
23295 local mdtfree1=$(do_facet $facet \
23296 lctl get_param -n osd*.*$mdtname.kbytesfree)
23297 dd if=/dev/urandom of=$dom bs=2M count=1 ||
23298 error "failed to write data into $dom"
23299 local old_md5=$(md5sum $dom)
23300 cancel_lru_locks mdc
23301 local mdtfree1=$(do_facet $facet \
23302 lctl get_param -n osd*.*$mdtname.kbytesfree)
23304 $LFS migrate -c2 $dom ||
23305 error "failed to migrate to the new composite layout"
23306 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23307 error "MDT stripe was not removed"
23309 cancel_lru_locks mdc
23310 local new_md5=$(md5sum $dom)
23311 [ "$old_md5" == "$new_md5" ] ||
23312 error "$old_md5 != $new_md5"
23314 # Skip free space checks with ZFS
23315 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23316 local mdtfree2=$(do_facet $facet \
23317 lctl get_param -n osd*.*$mdtname.kbytesfree)
23318 [ $mdtfree2 -gt $mdtfree1 ] ||
23319 error "MDT space is not freed after migration"
23323 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
23326 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23327 skip "Need MDS version at least 2.11.50"
23329 local dom=$DIR/$tdir/$tfile
23330 mkdir -p $DIR/$tdir
23331 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23333 local mdtidx=$($LFS getstripe -m $dom)
23334 local mdtname=MDT$(printf %04x $mdtidx)
23335 local facet=mds$((mdtidx + 1))
23337 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23338 error "failed to write data into $dom"
23339 local old_md5=$(md5sum $dom)
23340 cancel_lru_locks mdc
23341 local mdtfree1=$(do_facet $facet \
23342 lctl get_param -n osd*.*$mdtname.kbytesfree)
23344 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
23345 error "failed to migrate to the new composite layout"
23346 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
23347 error "MDT stripe was not removed"
23349 cancel_lru_locks mdc
23350 local new_md5=$(md5sum $dom)
23351 [ "$old_md5" == "$new_md5" ] ||
23352 error "$old_md5 != $new_md5"
23354 # Skip free space checks with ZFS
23355 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23356 local mdtfree2=$(do_facet $facet \
23357 lctl get_param -n osd*.*$mdtname.kbytesfree)
23358 [ $mdtfree2 -gt $mdtfree1 ] ||
23359 error "MDS space is not freed after migration"
23363 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
23366 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23367 skip "Need MDS version at least 2.12.55"
23369 local dom=$DIR/$tdir/$tfile
23370 mkdir -p $DIR/$tdir
23371 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23373 local mdtidx=$($LFS getstripe -m $dom)
23374 local mdtname=MDT$(printf %04x $mdtidx)
23375 local facet=mds$((mdtidx + 1))
23377 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23378 error "failed to write data into $dom"
23379 local old_md5=$(md5sum $dom)
23380 cancel_lru_locks mdc
23381 local mdtfree1=$(do_facet $facet \
23382 lctl get_param -n osd*.*$mdtname.kbytesfree)
23384 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
23385 error "failed mirroring to the new composite layout"
23386 $LFS mirror resync $dom ||
23387 error "failed mirror resync"
23388 $LFS mirror split --mirror-id 1 -d $dom ||
23389 error "failed mirror split"
23391 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23392 error "MDT stripe was not removed"
23394 cancel_lru_locks mdc
23395 local new_md5=$(md5sum $dom)
23396 [ "$old_md5" == "$new_md5" ] ||
23397 error "$old_md5 != $new_md5"
23399 # Skip free space checks with ZFS
23400 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23401 local mdtfree2=$(do_facet $facet \
23402 lctl get_param -n osd*.*$mdtname.kbytesfree)
23403 [ $mdtfree2 -gt $mdtfree1 ] ||
23404 error "MDS space is not freed after DOM mirror deletion"
23408 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
23411 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23412 skip "Need MDS version at least 2.12.55"
23414 local dom=$DIR/$tdir/$tfile
23415 mkdir -p $DIR/$tdir
23416 $LFS setstripe -c 2 $dom
23418 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23419 error "failed to write data into $dom"
23420 local old_md5=$(md5sum $dom)
23423 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
23424 error "failed mirroring to the DOM layout"
23425 $LFS mirror resync $dom ||
23426 error "failed mirror resync"
23427 $LFS mirror split --mirror-id 1 -d $dom ||
23428 error "failed mirror split"
23430 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23431 error "MDT stripe wasn't set"
23434 local new_md5=$(md5sum $dom)
23435 [ "$old_md5" == "$new_md5" ] ||
23436 error "$old_md5 != $new_md5"
23440 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
23443 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23444 skip "Need MDS version at least 2.12.55"
23446 local dom=$DIR/$tdir/$tfile
23447 mkdir -p $DIR/$tdir
23448 $LFS setstripe -c 2 $dom
23450 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23451 error "failed to write data into $dom"
23452 local old_md5=$(md5sum $dom)
23455 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
23456 error "failed migrating to the DOM file"
23458 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23459 error "MDT stripe wasn't set"
23462 local new_md5=$(md5sum $dom)
23463 [ "$old_md5" != "$new_md5" ] &&
23464 error "$old_md5 != $new_md5"
23468 run_test 272f "DoM migration: OST-striped file to DOM file"
23471 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23472 skip "Need MDS version at least 2.11.50"
23474 # Layout swap cannot be done if either file has DOM component,
23475 # this will never be supported, migration should be used instead
23477 local dom=$DIR/$tdir/$tfile
23478 mkdir -p $DIR/$tdir
23480 $LFS setstripe -c2 ${dom}_plain
23481 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
23482 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
23483 error "can swap layout with DoM component"
23484 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
23485 error "can swap layout with DoM component"
23487 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
23488 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
23489 error "can swap layout with DoM component"
23490 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
23491 error "can swap layout with DoM component"
23494 run_test 273a "DoM: layout swapping should fail with DOM"
23497 mkdir -p $DIR/$tdir
23498 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
23500 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
23501 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
23503 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
23505 run_test 273b "DoM: race writeback and object destroy"
23508 remote_ost_nodsh && skip "remote OST with nodsh"
23509 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
23510 skip "Need OST version >= 2.10.57"
23512 local file=$DIR/$tfile
23515 oss=$(comma_list $(osts_nodes))
23517 dd if=/dev/urandom of=$file bs=1M count=2 ||
23518 error "failed to create a file"
23519 cancel_lru_locks osc
23522 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23523 error "failed to read a file"
23525 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
23526 $LCTL set_param fail_loc=0x8000031f
23528 cancel_lru_locks osc &
23531 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23532 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23533 #IO takes another lock, but matches the PENDING one
23534 #and places it to the IO RPC
23535 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23536 error "failed to read a file with PENDING lock"
23538 run_test 275 "Read on a canceled duplicate lock"
23541 remote_ost_nodsh && skip "remote OST with nodsh"
23544 do_facet ost1 "(while true; do \
23545 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23546 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23549 for LOOP in $(seq 20); do
23551 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23554 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23555 rm $TMP/sanity_276_pid"
23557 run_test 276 "Race between mount and obd_statfs"
23560 $LCTL set_param ldlm.namespaces.*.lru_size=0
23561 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23562 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23563 grep ^used_mb | awk '{print $2}')
23564 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23565 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23566 oflag=direct conv=notrunc
23567 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23568 grep ^used_mb | awk '{print $2}')
23569 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23571 run_test 277 "Direct IO shall drop page cache"
23574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23576 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23577 skip "needs the same host for mdt1 mdt2" && return
23582 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23583 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23589 echo "Starting MDTs"
23590 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23592 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23594 do_facet mds2 $LCTL set_param fail_loc=0
23596 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23597 wait_recovery_complete mds2
23599 run_test 278 "Race starting MDS between MDTs stop/start"
23602 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23603 skip "Need MGS version at least 2.13.52"
23604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23605 combined_mgs_mds || skip "needs combined MGS/MDT"
23607 umount_client $MOUNT
23608 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23609 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23611 mount_client $MOUNT &
23613 stop mgs || error "stop mgs failed"
23614 #for a race mgs would crash
23615 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23616 # make sure we unmount client before remounting
23618 umount_client $MOUNT
23619 mount_client $MOUNT || error "mount client failed"
23621 run_test 280 "Race between MGS umount and client llog processing"
23623 cleanup_test_300() {
23627 test_striped_dir() {
23632 mkdir -p $DIR/$tdir
23634 SAVE_UMASK=$(umask)
23635 trap cleanup_test_300 RETURN EXIT
23637 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23638 $DIR/$tdir/striped_dir ||
23639 error "set striped dir error"
23641 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23642 [ "$mode" = "755" ] || error "expect 755 got $mode"
23644 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23645 error "getdirstripe failed"
23646 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23647 if [ "$stripe_count" != "2" ]; then
23648 error "1:stripe_count is $stripe_count, expect 2"
23650 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23651 if [ "$stripe_count" != "2" ]; then
23652 error "2:stripe_count is $stripe_count, expect 2"
23655 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
23656 if [ "$stripe_index" != "$mdt_index" ]; then
23657 error "stripe_index is $stripe_index, expect $mdt_index"
23660 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23661 error "nlink error after create striped dir"
23663 mkdir $DIR/$tdir/striped_dir/a
23664 mkdir $DIR/$tdir/striped_dir/b
23666 stat $DIR/$tdir/striped_dir/a ||
23667 error "create dir under striped dir failed"
23668 stat $DIR/$tdir/striped_dir/b ||
23669 error "create dir under striped dir failed"
23671 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
23672 error "nlink error after mkdir"
23674 rmdir $DIR/$tdir/striped_dir/a
23675 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
23676 error "nlink error after rmdir"
23678 rmdir $DIR/$tdir/striped_dir/b
23679 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23680 error "nlink error after rmdir"
23682 chattr +i $DIR/$tdir/striped_dir
23683 createmany -o $DIR/$tdir/striped_dir/f 10 &&
23684 error "immutable flags not working under striped dir!"
23685 chattr -i $DIR/$tdir/striped_dir
23687 rmdir $DIR/$tdir/striped_dir ||
23688 error "rmdir striped dir error"
23696 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23697 skip "skipped for lustre < 2.7.0"
23698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23699 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23701 test_striped_dir 0 || error "failed on striped dir on MDT0"
23702 test_striped_dir 1 || error "failed on striped dir on MDT0"
23704 run_test 300a "basic striped dir sanity test"
23707 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23708 skip "skipped for lustre < 2.7.0"
23709 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23710 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23717 test_mkdir $DIR/$tdir || error "mkdir fail"
23718 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23719 error "set striped dir error"
23720 for i in {0..9}; do
23721 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
23723 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
23724 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
23725 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
23727 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
23728 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
23729 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
23733 run_test 300b "check ctime/mtime for striped dir"
23736 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23737 skip "skipped for lustre < 2.7.0"
23738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23739 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23743 mkdir_on_mdt0 $DIR/$tdir
23744 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
23745 error "set striped dir error"
23747 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
23748 error "chown striped dir failed"
23750 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
23751 error "create 5k files failed"
23753 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
23755 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
23759 run_test 300c "chown && check ls under striped directory"
23762 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23763 skip "skipped for lustre < 2.7.0"
23764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23765 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23770 mkdir -p $DIR/$tdir
23771 $LFS setstripe -c 2 $DIR/$tdir
23773 #local striped directory
23774 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23775 error "set striped dir error"
23776 #look at the directories for debug purposes
23778 $LFS getdirstripe $DIR/$tdir
23779 ls -l $DIR/$tdir/striped_dir
23780 $LFS getdirstripe $DIR/$tdir/striped_dir
23781 createmany -o $DIR/$tdir/striped_dir/f 10 ||
23782 error "create 10 files failed"
23784 #remote striped directory
23785 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
23786 error "set striped dir error"
23787 #look at the directories for debug purposes
23789 $LFS getdirstripe $DIR/$tdir
23790 ls -l $DIR/$tdir/remote_striped_dir
23791 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
23792 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
23793 error "create 10 files failed"
23795 for file in $(find $DIR/$tdir); do
23796 stripe_count=$($LFS getstripe -c $file)
23797 [ $stripe_count -eq 2 ] ||
23798 error "wrong stripe $stripe_count for $file"
23803 run_test 300d "check default stripe under striped directory"
23806 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23807 skip "Need MDS version at least 2.7.55"
23808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23809 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23814 mkdir -p $DIR/$tdir
23816 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23817 error "set striped dir error"
23819 touch $DIR/$tdir/striped_dir/a
23820 touch $DIR/$tdir/striped_dir/b
23821 touch $DIR/$tdir/striped_dir/c
23823 mkdir $DIR/$tdir/striped_dir/dir_a
23824 mkdir $DIR/$tdir/striped_dir/dir_b
23825 mkdir $DIR/$tdir/striped_dir/dir_c
23827 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
23828 error "set striped adir under striped dir error"
23830 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
23831 error "set striped bdir under striped dir error"
23833 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
23834 error "set striped cdir under striped dir error"
23836 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
23837 error "rename dir under striped dir fails"
23839 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
23840 error "rename dir under different stripes fails"
23842 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
23843 error "rename file under striped dir should succeed"
23845 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
23846 error "rename dir under striped dir should succeed"
23850 run_test 300e "check rename under striped directory"
23853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23854 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23855 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23856 skip "Need MDS version at least 2.7.55"
23862 mkdir -p $DIR/$tdir
23864 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23865 error "set striped dir error"
23867 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
23868 error "set striped dir error"
23870 touch $DIR/$tdir/striped_dir/a
23871 mkdir $DIR/$tdir/striped_dir/dir_a
23872 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
23873 error "create striped dir under striped dir fails"
23875 touch $DIR/$tdir/striped_dir1/b
23876 mkdir $DIR/$tdir/striped_dir1/dir_b
23877 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
23878 error "create striped dir under striped dir fails"
23880 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
23881 error "rename dir under different striped dir should fail"
23883 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
23884 error "rename striped dir under diff striped dir should fail"
23886 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
23887 error "rename file under diff striped dirs fails"
23891 run_test 300f "check rename cross striped directory"
23893 test_300_check_default_striped_dir()
23896 local default_count=$2
23897 local default_index=$3
23900 local dir_stripe_index
23903 echo "checking $dirname $default_count $default_index"
23904 $LFS setdirstripe -D -c $default_count -i $default_index \
23905 -H all_char $DIR/$tdir/$dirname ||
23906 error "set default stripe on striped dir error"
23907 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
23908 [ $stripe_count -eq $default_count ] ||
23909 error "expect $default_count get $stripe_count for $dirname"
23911 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
23912 [ $stripe_index -eq $default_index ] ||
23913 error "expect $default_index get $stripe_index for $dirname"
23915 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
23916 error "create dirs failed"
23918 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
23919 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
23920 for dir in $(find $DIR/$tdir/$dirname/*); do
23921 stripe_count=$($LFS getdirstripe -c $dir)
23922 (( $stripe_count == $default_count )) ||
23923 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
23924 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
23925 error "stripe count $default_count != $stripe_count for $dir"
23927 stripe_index=$($LFS getdirstripe -i $dir)
23928 [ $default_index -eq -1 ] ||
23929 [ $stripe_index -eq $default_index ] ||
23930 error "$stripe_index != $default_index for $dir"
23932 #check default stripe
23933 stripe_count=$($LFS getdirstripe -D -c $dir)
23934 [ $stripe_count -eq $default_count ] ||
23935 error "default count $default_count != $stripe_count for $dir"
23937 stripe_index=$($LFS getdirstripe -D -i $dir)
23938 [ $stripe_index -eq $default_index ] ||
23939 error "default index $default_index != $stripe_index for $dir"
23941 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
23945 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23946 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23947 skip "Need MDS version at least 2.7.55"
23953 mkdir_on_mdt0 $DIR/$tdir
23954 mkdir $DIR/$tdir/normal_dir
23956 #Checking when client cache stripe index
23957 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
23958 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
23959 error "create striped_dir failed"
23961 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
23962 error "create dir0 fails"
23963 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
23964 [ $stripe_index -eq 0 ] ||
23965 error "dir0 expect index 0 got $stripe_index"
23967 mkdir $DIR/$tdir/striped_dir/dir1 ||
23968 error "create dir1 fails"
23969 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
23970 [ $stripe_index -eq 1 ] ||
23971 error "dir1 expect index 1 got $stripe_index"
23973 #check default stripe count/stripe index
23974 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
23975 test_300_check_default_striped_dir normal_dir 1 0
23976 test_300_check_default_striped_dir normal_dir -1 1
23977 test_300_check_default_striped_dir normal_dir 2 -1
23979 #delete default stripe information
23980 echo "delete default stripeEA"
23981 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
23982 error "set default stripe on striped dir error"
23984 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
23985 for dir in $(find $DIR/$tdir/normal_dir/*); do
23986 stripe_count=$($LFS getdirstripe -c $dir)
23987 [ $stripe_count -eq 0 ] ||
23988 error "expect 1 get $stripe_count for $dir"
23991 run_test 300g "check default striped directory for normal directory"
23994 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23995 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23996 skip "Need MDS version at least 2.7.55"
24002 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24003 error "set striped dir error"
24005 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
24006 test_300_check_default_striped_dir striped_dir 1 0
24007 test_300_check_default_striped_dir striped_dir -1 1
24008 test_300_check_default_striped_dir striped_dir 2 -1
24010 #delete default stripe information
24011 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
24012 error "set default stripe on striped dir error"
24014 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
24015 for dir in $(find $DIR/$tdir/striped_dir/*); do
24016 stripe_count=$($LFS getdirstripe -c $dir)
24017 [ $stripe_count -eq 0 ] ||
24018 error "expect 1 get $stripe_count for $dir"
24021 run_test 300h "check default striped directory for striped directory"
24024 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
24025 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
24026 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
24027 skip "Need MDS version at least 2.7.55"
24034 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24035 error "set striped dir error"
24037 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24038 error "create files under striped dir failed"
24040 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
24041 error "set striped hashdir error"
24043 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
24044 error "create dir0 under hash dir failed"
24045 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
24046 error "create dir1 under hash dir failed"
24047 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
24048 error "create dir2 under hash dir failed"
24050 # unfortunately, we need to umount to clear dir layout cache for now
24051 # once we fully implement dir layout, we can drop this
24052 umount_client $MOUNT || error "umount failed"
24053 mount_client $MOUNT || error "mount failed"
24055 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
24056 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
24057 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
24059 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
24060 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
24061 error "create crush2 dir $tdir/hashdir/d3 failed"
24062 $LFS find -H crush2 $DIR/$tdir/hashdir
24063 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
24064 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
24066 # mkdir with an invalid hash type (hash=fail_val) from client
24067 # should be replaced on MDS with a valid (default) hash type
24068 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24069 $LCTL set_param fail_loc=0x1901 fail_val=99
24070 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
24072 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
24073 local expect=$(do_facet mds1 \
24074 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
24075 [[ $hash == $expect ]] ||
24076 error "d99 hash '$hash' != expected hash '$expect'"
24079 #set the stripe to be unknown hash type on read
24080 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
24081 $LCTL set_param fail_loc=0x1901 fail_val=99
24082 for ((i = 0; i < 10; i++)); do
24083 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
24084 error "stat f-$i failed"
24085 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
24088 touch $DIR/$tdir/striped_dir/f0 &&
24089 error "create under striped dir with unknown hash should fail"
24091 $LCTL set_param fail_loc=0
24093 umount_client $MOUNT || error "umount failed"
24094 mount_client $MOUNT || error "mount failed"
24098 run_test 300i "client handle unknown hash type striped directory"
24101 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24103 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24104 skip "Need MDS version at least 2.7.55"
24111 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
24112 $LCTL set_param fail_loc=0x1702
24113 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
24114 error "set striped dir error"
24116 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
24117 error "create files under striped dir failed"
24119 $LCTL set_param fail_loc=0
24121 rm -rf $DIR/$tdir || error "unlink striped dir fails"
24125 run_test 300j "test large update record"
24128 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24129 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24130 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24131 skip "Need MDS version at least 2.7.55"
24133 # this test needs a huge transaction
24135 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24136 osd*.$FSNAME-MDT0000.kbytestotal")
24137 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
24144 #define OBD_FAIL_LARGE_STRIPE 0x1703
24145 $LCTL set_param fail_loc=0x1703
24146 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
24147 error "set striped dir error"
24148 $LCTL set_param fail_loc=0
24150 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24151 error "getstripeddir fails"
24152 rm -rf $DIR/$tdir/striped_dir ||
24153 error "unlink striped dir fails"
24157 run_test 300k "test large striped directory"
24160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24161 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24162 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24163 skip "Need MDS version at least 2.7.55"
24167 test_mkdir -p $DIR/$tdir/striped_dir
24168 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
24169 error "chown $RUNAS_ID failed"
24170 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
24171 error "set default striped dir failed"
24173 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
24174 $LCTL set_param fail_loc=0x80000158
24175 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
24177 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
24178 [ $stripe_index -eq 1 ] ||
24179 error "expect 1 get $stripe_index for $dir"
24181 run_test 300l "non-root user to create dir under striped dir with stale layout"
24184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24185 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
24186 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24187 skip "Need MDS version at least 2.7.55"
24189 mkdir -p $DIR/$tdir/striped_dir
24190 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
24191 error "set default stripes dir error"
24193 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
24195 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
24196 [ $stripe_count -eq 0 ] ||
24197 error "expect 0 get $stripe_count for a"
24199 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
24200 error "set default stripes dir error"
24202 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
24204 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
24205 [ $stripe_count -eq 0 ] ||
24206 error "expect 0 get $stripe_count for b"
24208 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
24209 error "set default stripes dir error"
24211 mkdir $DIR/$tdir/striped_dir/c &&
24212 error "default stripe_index is invalid, mkdir c should fails"
24214 rm -rf $DIR/$tdir || error "rmdir fails"
24216 run_test 300m "setstriped directory on single MDT FS"
24219 local list=$(comma_list $(mdts_nodes))
24222 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24227 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24228 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24229 skip "Need MDS version at least 2.7.55"
24230 remote_mds_nodsh && skip "remote MDS with nodsh"
24233 local list=$(comma_list $(mdts_nodes))
24235 trap cleanup_300n RETURN EXIT
24236 mkdir -p $DIR/$tdir
24237 chmod 777 $DIR/$tdir
24238 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
24239 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24240 error "create striped dir succeeds with gid=0"
24242 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24243 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
24244 error "create striped dir fails with gid=-1"
24246 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24247 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
24248 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
24249 error "set default striped dir succeeds with gid=0"
24252 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
24253 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
24254 error "set default striped dir fails with gid=-1"
24257 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
24258 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
24259 error "create test_dir fails"
24260 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
24261 error "create test_dir1 fails"
24262 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
24263 error "create test_dir2 fails"
24266 run_test 300n "non-root user to create dir under striped dir with default EA"
24269 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24270 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24271 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24272 skip "Need MDS version at least 2.7.55"
24277 mkdir -p $DIR/$tdir
24279 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
24280 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
24281 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
24282 skip "not enough free inodes $numfree1 $numfree2"
24285 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
24286 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
24287 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
24288 skip "not enough free space $numfree1 $numfree2"
24291 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
24292 error "setdirstripe fails"
24294 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
24295 error "create dirs fails"
24297 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
24298 ls $DIR/$tdir/striped_dir > /dev/null ||
24299 error "ls striped dir fails"
24300 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
24301 error "unlink big striped dir fails"
24303 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
24306 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24307 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24308 remote_mds_nodsh && skip "remote MDS with nodsh"
24310 mkdir_on_mdt0 $DIR/$tdir
24312 #define OBD_FAIL_OUT_ENOSPC 0x1704
24313 do_facet mds2 lctl set_param fail_loc=0x80001704
24314 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
24315 && error "create striped directory should fail"
24317 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
24319 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
24322 run_test 300p "create striped directory without space"
24325 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24326 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
24328 local fd=$(free_fd)
24329 local cmd="exec $fd<$tdir"
24331 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
24334 trap "eval $cmd" EXIT
24335 cd $tdir || error "cd $tdir fails"
24336 rmdir ../$tdir || error "rmdir $tdir fails"
24337 mkdir local_dir && error "create dir succeeds"
24338 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
24342 run_test 300q "create remote directory under orphan directory"
24345 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24346 skip "Need MDS version at least 2.7.55" && return
24347 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24351 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
24352 error "set striped dir error"
24354 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24355 error "getstripeddir fails"
24358 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
24359 awk '/lmv_stripe_count:/ { print $2 }')
24361 [ $MDSCOUNT -ne $stripe_count ] &&
24362 error "wrong stripe count $stripe_count expected $MDSCOUNT"
24364 rm -rf $DIR/$tdir/striped_dir ||
24365 error "unlink striped dir fails"
24367 run_test 300r "test -1 striped directory"
24369 test_300s_helper() {
24372 local stripe_dir=$DIR/$tdir/striped_dir.$count
24374 $LFS mkdir -c $count $stripe_dir ||
24375 error "lfs mkdir -c error"
24377 $LFS getdirstripe $stripe_dir ||
24378 error "lfs getdirstripe fails"
24381 stripe_count=$($LFS getdirstripe $stripe_dir |
24382 awk '/lmv_stripe_count:/ { print $2 }')
24384 [ $count -ne $stripe_count ] &&
24385 error_noexit "bad stripe count $stripe_count expected $count"
24388 dupe_stripes=$($LFS getdirstripe $stripe_dir |
24389 awk '/0x/ {count[$1] += 1}; END {
24390 for (idx in count) {
24391 if (count[idx]>1) {
24392 print "index " idx " count " count[idx]
24397 if [[ -n "$dupe_stripes" ]] ; then
24398 lfs getdirstripe $stripe_dir
24399 error_noexit "Dupe MDT above: $dupe_stripes "
24402 rm -rf $stripe_dir ||
24403 error_noexit "unlink $stripe_dir fails"
24407 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24408 skip "Need MDS version at least 2.7.55" && return
24409 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24412 for count in $(seq 2 $MDSCOUNT); do
24413 test_300s_helper $count
24416 run_test 300s "test lfs mkdir -c without -i"
24419 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
24420 skip "need MDS 2.14.55 or later"
24421 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
24423 local testdir="$DIR/$tdir/striped_dir"
24424 local dir1=$testdir/dir1
24425 local dir2=$testdir/dir2
24429 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
24430 error "failed to set default stripe count for $testdir"
24433 local stripe_count=$($LFS getdirstripe -c $dir1)
24435 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
24437 local max_count=$((MDSCOUNT - 1))
24438 local mdts=$(comma_list $(mdts_nodes))
24440 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
24441 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
24444 stripe_count=$($LFS getdirstripe -c $dir2)
24446 (( $stripe_count == $max_count )) || error "wrong stripe count"
24448 run_test 300t "test max_mdt_stripecount"
24450 prepare_remote_file() {
24451 mkdir $DIR/$tdir/src_dir ||
24452 error "create remote source failed"
24454 cp /etc/hosts $DIR/$tdir/src_dir/a ||
24455 error "cp to remote source failed"
24456 touch $DIR/$tdir/src_dir/a
24458 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
24459 error "create remote target dir failed"
24461 touch $DIR/$tdir/tgt_dir/b
24463 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
24464 error "rename dir cross MDT failed!"
24466 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
24467 error "src_child still exists after rename"
24469 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
24470 error "missing file(a) after rename"
24472 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
24473 error "diff after rename"
24477 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24480 local remote_file=$DIR/$tdir/tgt_dir/b
24482 mkdir -p $DIR/$tdir
24484 prepare_remote_file || error "prepare remote file failed"
24487 $OPENUNLINK $remote_file $remote_file ||
24488 error "openunlink $remote_file failed"
24489 $CHECKSTAT -a $remote_file || error "$remote_file exists"
24491 run_test 310a "open unlink remote file"
24494 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24497 local remote_file=$DIR/$tdir/tgt_dir/b
24499 mkdir -p $DIR/$tdir
24501 prepare_remote_file || error "prepare remote file failed"
24503 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24504 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
24505 $CHECKSTAT -t file $remote_file || error "check file failed"
24507 run_test 310b "unlink remote file with multiple links while open"
24510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24511 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
24513 local remote_file=$DIR/$tdir/tgt_dir/b
24515 mkdir -p $DIR/$tdir
24517 prepare_remote_file || error "prepare remote file failed"
24519 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24520 multiop_bg_pause $remote_file O_uc ||
24521 error "mulitop failed for remote file"
24523 $MULTIOP $DIR/$tfile Ouc
24524 kill -USR1 $MULTIPID
24527 run_test 310c "open-unlink remote file with multiple links"
24531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24532 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24533 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
24534 skip "lustre < 2.8.54 does not contain LU-4825 fix"
24535 remote_mds_nodsh && skip "remote MDS with nodsh"
24537 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24538 local mdts=$(comma_list $(mdts_nodes))
24540 mkdir -p $DIR/$tdir
24541 $LFS setstripe -i 0 -c 1 $DIR/$tdir
24542 createmany -o $DIR/$tdir/$tfile. 1000
24544 # statfs data is not real time, let's just calculate it
24545 old_iused=$((old_iused + 1000))
24547 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24548 osp.*OST0000*MDT0000.create_count")
24549 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24550 osp.*OST0000*MDT0000.max_create_count")
24551 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24553 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24554 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24555 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24557 unlinkmany $DIR/$tdir/$tfile. 1000
24559 do_nodes $mdts "$LCTL set_param -n \
24560 osp.*OST0000*.max_create_count=$max_count"
24561 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24562 do_nodes $mdts "$LCTL set_param -n \
24563 osp.*OST0000*.create_count=$count"
24564 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24565 grep "=0" && error "create_count is zero"
24568 for i in $(seq 120); do
24569 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24570 # system may be too busy to destroy all objs in time, use
24571 # a somewhat small value to not fail autotest
24572 [ $((old_iused - new_iused)) -gt 400 ] && break
24576 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24577 [ $((old_iused - new_iused)) -gt 400 ] ||
24578 error "objs not destroyed after unlink"
24580 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24587 local vdevdir=$(dirname $(facet_vdevice $ost))
24588 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24589 local zfs_zapid=$(do_facet $ost $cmd |
24590 grep -w "/O/0/d$((objid%32))" -C 5 |
24591 awk '/Object/{getline; print $1}')
24592 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24593 awk "/$objid = /"'{printf $3}')
24598 zfs_object_blksz() {
24602 local vdevdir=$(dirname $(facet_vdevice $ost))
24603 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24604 local blksz=$(do_facet $ost $cmd $objid |
24605 awk '/dblk/{getline; printf $4}')
24607 case "${blksz: -1}" in
24608 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24609 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24616 test_312() { # LU-4856
24617 remote_ost_nodsh && skip "remote OST with nodsh"
24618 [ "$ost1_FSTYPE" = "zfs" ] ||
24619 skip_env "the test only applies to zfs"
24621 local max_blksz=$(do_facet ost1 \
24622 $ZFS get -p recordsize $(facet_device ost1) |
24623 awk '!/VALUE/{print $3}')
24625 # to make life a little bit easier
24626 $LFS mkdir -c 1 -i 0 $DIR/$tdir
24627 $LFS setstripe -c 1 -i 0 $DIR/$tdir
24629 local tf=$DIR/$tdir/$tfile
24631 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24633 # Get ZFS object id
24634 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24635 # block size change by sequential overwrite
24638 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24639 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24641 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
24642 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
24646 # block size change by sequential append write
24647 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24648 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24649 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24652 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24653 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24654 oflag=sync conv=notrunc
24656 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24657 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
24658 error "blksz error, actual $blksz, " \
24659 "expected: 2 * $count * $PAGE_SIZE"
24665 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24666 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24668 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
24669 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24670 [ $blksz -eq $PAGE_SIZE ] ||
24671 error "blksz error: $blksz, expected: $PAGE_SIZE"
24673 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
24674 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24675 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
24677 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
24678 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24679 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
24681 run_test 312 "make sure ZFS adjusts its block size by write pattern"
24684 remote_ost_nodsh && skip "remote OST with nodsh"
24686 local file=$DIR/$tfile
24689 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
24691 # define OBD_FAIL_TGT_RCVD_EIO 0x720
24692 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24693 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
24694 error "write should failed"
24695 do_facet ost1 "$LCTL set_param fail_loc=0"
24698 run_test 313 "io should fail after last_rcvd update fail"
24701 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24703 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
24704 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24706 wait_delete_completed
24707 do_facet ost1 "$LCTL set_param fail_loc=0"
24709 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
24711 test_315() { # LU-618
24712 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
24714 local file=$DIR/$tfile
24717 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
24718 error "multiop file write failed"
24719 $MULTIOP $file oO_RDONLY:r4063232_c &
24724 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
24727 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
24730 run_test 315 "read should be accounted"
24733 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24734 large_xattr_enabled || skip "ea_inode feature disabled"
24736 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
24737 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
24738 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
24739 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
24741 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
24743 run_test 316 "lfs migrate of file with large_xattr enabled"
24746 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
24747 skip "Need MDS version at least 2.11.53"
24748 if [ "$ost1_FSTYPE" == "zfs" ]; then
24749 skip "LU-10370: no implementation for ZFS"
24753 local grant_blk_size
24755 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
24756 awk '/grant_block_size:/ { print $2; exit; }')
24758 # Create File of size 5M. Truncate it to below size's and verify
24761 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
24762 error "Create file $DIR/$tfile failed"
24763 stack_trap "rm -f $DIR/$tfile" EXIT
24765 for trunc_sz in 2097152 4097 4000 509 0; do
24766 $TRUNCATE $DIR/$tfile $trunc_sz ||
24767 error "truncate $tfile to $trunc_sz failed"
24768 local sz=$(stat --format=%s $DIR/$tfile)
24769 local blk=$(stat --format=%b $DIR/$tfile)
24770 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
24771 grant_blk_size) * 8))
24773 if [[ $blk -ne $trunc_blk ]]; then
24774 $(which stat) $DIR/$tfile
24775 error "Expected Block $trunc_blk got $blk for $tfile"
24778 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24779 error "Expected Size $trunc_sz got $sz for $tfile"
24784 # Create file with a hole and write actual 65536 bytes which aligned
24785 # with 4K and 64K PAGE_SIZE. Block count must be 128.
24788 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
24789 error "Create file : $DIR/$tfile"
24792 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
24793 # blocks. The block count must drop to 8.
24795 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
24796 ((bs - grant_blk_size) + 1)))
24797 $TRUNCATE $DIR/$tfile $trunc_sz ||
24798 error "truncate $tfile to $trunc_sz failed"
24800 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
24801 sz=$(stat --format=%s $DIR/$tfile)
24802 blk=$(stat --format=%b $DIR/$tfile)
24804 if [[ $blk -ne $trunc_bsz ]]; then
24805 $(which stat) $DIR/$tfile
24806 error "Expected Block $trunc_bsz got $blk for $tfile"
24809 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24810 error "Expected Size $trunc_sz got $sz for $tfile"
24812 run_test 317 "Verify blocks get correctly update after truncate"
24815 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
24816 local old_max_active=$($LCTL get_param -n \
24817 ${llite_name}.max_read_ahead_async_active \
24820 $LCTL set_param llite.*.max_read_ahead_async_active=256
24821 local max_active=$($LCTL get_param -n \
24822 ${llite_name}.max_read_ahead_async_active \
24824 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
24826 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
24827 error "set max_read_ahead_async_active should succeed"
24829 $LCTL set_param llite.*.max_read_ahead_async_active=512
24830 max_active=$($LCTL get_param -n \
24831 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
24832 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
24834 # restore @max_active
24835 [ $old_max_active -ne 0 ] && $LCTL set_param \
24836 llite.*.max_read_ahead_async_active=$old_max_active
24838 local old_threshold=$($LCTL get_param -n \
24839 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24840 local max_per_file_mb=$($LCTL get_param -n \
24841 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
24843 local invalid=$(($max_per_file_mb + 1))
24845 llite.*.read_ahead_async_file_threshold_mb=$invalid\
24846 && error "set $invalid should fail"
24848 local valid=$(($invalid - 1))
24850 llite.*.read_ahead_async_file_threshold_mb=$valid ||
24851 error "set $valid should succeed"
24852 local threshold=$($LCTL get_param -n \
24853 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24854 [ $threshold -eq $valid ] || error \
24855 "expect threshold $valid got $threshold"
24857 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
24859 run_test 318 "Verify async readahead tunables"
24862 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24864 local before=$(date +%s)
24866 local mdir=$DIR/$tdir
24867 local file=$mdir/xxx
24869 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
24872 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
24873 $LCTL set_param fail_val=5 fail_loc=0x8000032c
24874 $LFS migrate -m1 $mdir &
24877 dd if=$file of=/dev/null
24879 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
24880 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
24882 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
24884 run_test 319 "lost lease lock on migrate error"
24886 test_398a() { # LU-4198
24887 local ost1_imp=$(get_osc_import_name client ost1)
24888 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24891 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24892 $LCTL set_param ldlm.namespaces.*.lru_size=clear
24894 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
24895 # request a new lock on client
24896 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24898 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24899 #local lock_count=$($LCTL get_param -n \
24900 # ldlm.namespaces.$imp_name.lru_size)
24901 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
24903 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24905 # no lock cached, should use lockless DIO and not enqueue new lock
24906 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
24908 error "dio write failed"
24909 lock_count=$($LCTL get_param -n \
24910 ldlm.namespaces.$imp_name.lru_size)
24911 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
24913 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24915 # no lock cached, should use locked DIO append
24916 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
24917 conv=notrunc || error "DIO append failed"
24918 lock_count=$($LCTL get_param -n \
24919 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
24920 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
24922 run_test 398a "direct IO should cancel lock otherwise lockless"
24924 test_398b() { # LU-4198
24925 which fio || skip_env "no fio installed"
24926 $LFS setstripe -c -1 -S 1M $DIR/$tfile
24929 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
24932 # Single page, multiple pages, stripe size, 4*stripe size
24933 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
24934 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
24935 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
24936 --numjobs=$njobs --fallocate=none \
24937 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24938 --filename=$DIR/$tfile &
24941 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
24942 fio --name=rand-rw --rw=randrw --bs=$bsize \
24943 --numjobs=$njobs --fallocate=none \
24944 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24945 --filename=$DIR/$tfile || true
24949 evict=$(do_facet client $LCTL get_param \
24950 osc.$FSNAME-OST*-osc-*/state |
24951 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
24953 [ -z "$evict" ] || [[ $evict -le $before ]] ||
24954 (do_facet client $LCTL get_param \
24955 osc.$FSNAME-OST*-osc-*/state;
24956 error "eviction happened: $evict before:$before")
24960 run_test 398b "DIO and buffer IO race"
24962 test_398c() { # LU-4198
24963 local ost1_imp=$(get_osc_import_name client ost1)
24964 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24967 which fio || skip_env "no fio installed"
24969 saved_debug=$($LCTL get_param -n debug)
24970 $LCTL set_param debug=0
24972 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
24973 ((size /= 1024)) # by megabytes
24974 ((size /= 2)) # write half of the OST at most
24975 [ $size -gt 40 ] && size=40 #reduce test time anyway
24977 $LFS setstripe -c 1 $DIR/$tfile
24979 # it seems like ldiskfs reserves more space than necessary if the
24980 # writing blocks are not mapped, so it extends the file firstly
24981 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
24982 cancel_lru_locks osc
24984 # clear and verify rpc_stats later
24985 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
24988 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
24989 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
24990 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24991 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24992 --filename=$DIR/$tfile
24993 [ $? -eq 0 ] || error "fio write error"
24995 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
24996 error "Locks were requested while doing AIO"
24998 # get the percentage of 1-page I/O
24999 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
25000 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
25002 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
25004 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
25005 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
25006 --numjobs=$njobs --fallocate=none --ioengine=libaio \
25007 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
25008 --filename=$DIR/$tfile
25009 [ $? -eq 0 ] || error "fio mixed read write error"
25011 echo "AIO with large block size ${size}M"
25012 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
25013 --numjobs=1 --fallocate=none --ioengine=libaio \
25014 --iodepth=16 --allow_file_create=0 --size=${size}M \
25015 --filename=$DIR/$tfile
25016 [ $? -eq 0 ] || error "fio large block size failed"
25019 $LCTL set_param debug="$saved_debug"
25021 run_test 398c "run fio to test AIO"
25023 test_398d() { # LU-13846
25024 which aiocp || skip_env "no aiocp installed"
25025 local aio_file=$DIR/$tfile.aio
25027 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25029 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
25030 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
25031 stack_trap "rm -f $DIR/$tfile $aio_file"
25033 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
25035 # make sure we don't crash and fail properly
25036 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25037 error "aio not aligned with PAGE SIZE should fail"
25039 rm -f $DIR/$tfile $aio_file
25041 run_test 398d "run aiocp to verify block size > stripe size"
25044 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
25045 touch $DIR/$tfile.new
25046 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
25048 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
25050 test_398f() { # LU-14687
25051 which aiocp || skip_env "no aiocp installed"
25052 local aio_file=$DIR/$tfile.aio
25054 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
25056 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
25057 stack_trap "rm -f $DIR/$tfile $aio_file"
25059 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25060 $LCTL set_param fail_loc=0x1418
25061 # make sure we don't crash and fail properly
25062 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
25063 error "aio with page allocation failure succeeded"
25064 $LCTL set_param fail_loc=0
25065 diff $DIR/$tfile $aio_file
25066 [[ $? != 0 ]] || error "no diff after failed aiocp"
25068 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
25070 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
25071 # stripe and i/o size must be > stripe size
25072 # Old style synchronous DIO waits after submitting each chunk, resulting in a
25073 # single RPC in flight. This test shows async DIO submission is working by
25074 # showing multiple RPCs in flight.
25075 test_398g() { # LU-13798
25076 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25078 # We need to do some i/o first to acquire enough grant to put our RPCs
25079 # in flight; otherwise a new connection may not have enough grant
25081 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25082 error "parallel dio failed"
25083 stack_trap "rm -f $DIR/$tfile"
25085 # Reduce RPC size to 1M to avoid combination in to larger RPCs
25086 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25087 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25088 stack_trap "$LCTL set_param -n $pages_per_rpc"
25090 # Recreate file so it's empty
25092 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
25093 #Pause rpc completion to guarantee we see multiple rpcs in flight
25094 #define OBD_FAIL_OST_BRW_PAUSE_BULK
25095 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
25096 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25099 $LCTL set_param osc.*.rpc_stats=c
25101 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25102 error "parallel dio failed"
25103 stack_trap "rm -f $DIR/$tfile"
25105 $LCTL get_param osc.*-OST0000-*.rpc_stats
25106 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25107 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25108 grep "8:" | awk '{print $8}')
25109 # We look at the "8 rpcs in flight" field, and verify A) it is present
25110 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
25111 # as expected for an 8M DIO to a file with 1M stripes.
25112 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
25114 # Verify turning off parallel dio works as expected
25116 $LCTL set_param osc.*.rpc_stats=c
25117 $LCTL set_param llite.*.parallel_dio=0
25118 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
25120 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
25121 error "dio with parallel dio disabled failed"
25123 # Ideally, we would see only one RPC in flight here, but there is an
25124 # unavoidable race between i/o completion and RPC in flight counting,
25125 # so while only 1 i/o is in flight at a time, the RPC in flight counter
25126 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
25127 # So instead we just verify it's always < 8.
25128 $LCTL get_param osc.*-OST0000-*.rpc_stats
25129 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
25130 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
25131 grep '^$' -B1 | grep . | awk '{print $1}')
25132 [ $ret != "8:" ] ||
25133 error "we should see fewer than 8 RPCs in flight (saw $ret)"
25135 run_test 398g "verify parallel dio async RPC submission"
25137 test_398h() { # LU-13798
25138 local dio_file=$DIR/$tfile.dio
25140 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25142 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25143 stack_trap "rm -f $DIR/$tfile $dio_file"
25145 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
25146 error "parallel dio failed"
25147 diff $DIR/$tfile $dio_file
25148 [[ $? == 0 ]] || error "file diff after aiocp"
25150 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
25152 test_398i() { # LU-13798
25153 local dio_file=$DIR/$tfile.dio
25155 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
25157 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25158 stack_trap "rm -f $DIR/$tfile $dio_file"
25160 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
25161 $LCTL set_param fail_loc=0x1418
25162 # make sure we don't crash and fail properly
25163 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
25164 error "parallel dio page allocation failure succeeded"
25165 diff $DIR/$tfile $dio_file
25166 [[ $? != 0 ]] || error "no diff after failed aiocp"
25168 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
25170 test_398j() { # LU-13798
25171 # Stripe size > RPC size but less than i/o size tests split across
25172 # stripes and RPCs for individual i/o op
25173 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
25175 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
25176 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
25177 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
25178 stack_trap "$LCTL set_param -n $pages_per_rpc"
25180 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25181 error "parallel dio write failed"
25182 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
25184 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
25185 error "parallel dio read failed"
25186 diff $DIR/$tfile $DIR/$tfile.2
25187 [[ $? == 0 ]] || error "file diff after parallel dio read"
25189 run_test 398j "test parallel dio where stripe size > rpc_size"
25191 test_398k() { # LU-13798
25192 wait_delete_completed
25195 # 4 stripe file; we will cause out of space on OST0
25196 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25198 # Fill OST0 (if it's not too large)
25199 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25201 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25202 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25204 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25205 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25206 error "dd should fill OST0"
25207 stack_trap "rm -f $DIR/$tfile.1"
25209 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
25213 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
25214 error "file is not 0 bytes in size"
25216 # dd above should not succeed, but don't error until here so we can
25217 # get debug info above
25219 error "parallel dio write with enospc succeeded"
25220 stack_trap "rm -f $DIR/$tfile"
25222 run_test 398k "test enospc on first stripe"
25224 test_398l() { # LU-13798
25225 wait_delete_completed
25228 # 4 stripe file; we will cause out of space on OST0
25229 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
25230 # happens on the second i/o chunk we issue
25231 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
25233 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
25234 stack_trap "rm -f $DIR/$tfile"
25236 # Fill OST0 (if it's not too large)
25237 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
25239 if [[ $ORIGFREE -gt $MAXFREE ]]; then
25240 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
25242 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
25243 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
25244 error "dd should fill OST0"
25245 stack_trap "rm -f $DIR/$tfile.1"
25247 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
25249 stack_trap "rm -f $DIR/$tfile.2"
25251 # Check that short write completed as expected
25252 ls -la $DIR/$tfile.2
25253 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
25254 error "file is not 1M in size"
25256 # dd above should not succeed, but don't error until here so we can
25257 # get debug info above
25259 error "parallel dio write with enospc succeeded"
25261 # Truncate source file to same length as output file and diff them
25262 $TRUNCATE $DIR/$tfile 1048576
25263 diff $DIR/$tfile $DIR/$tfile.2
25264 [[ $? == 0 ]] || error "data incorrect after short write"
25266 run_test 398l "test enospc on intermediate stripe/RPC"
25268 test_398m() { # LU-13798
25269 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
25271 # Set up failure on OST0, the first stripe:
25272 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
25273 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
25274 # So this fail_val specifies OST0
25275 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
25276 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25278 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25279 error "parallel dio write with failure on first stripe succeeded"
25280 stack_trap "rm -f $DIR/$tfile"
25281 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25283 # Place data in file for read
25284 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25285 error "parallel dio write failed"
25287 # Fail read on OST0, first stripe
25288 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25289 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
25290 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25291 error "parallel dio read with error on first stripe succeeded"
25292 rm -f $DIR/$tfile.2
25293 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25295 # Switch to testing on OST1, second stripe
25296 # Clear file contents, maintain striping
25298 # Set up failure on OST1, second stripe:
25299 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
25300 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
25302 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
25303 error "parallel dio write with failure on first stripe succeeded"
25304 stack_trap "rm -f $DIR/$tfile"
25305 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
25307 # Place data in file for read
25308 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
25309 error "parallel dio write failed"
25311 # Fail read on OST1, second stripe
25312 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
25313 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
25314 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
25315 error "parallel dio read with error on first stripe succeeded"
25316 rm -f $DIR/$tfile.2
25317 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
25319 run_test 398m "test RPC failures with parallel dio"
25321 # Parallel submission of DIO should not cause problems for append, but it's
25322 # important to verify.
25323 test_398n() { # LU-13798
25324 $LFS setstripe -C 2 -S 1M $DIR/$tfile
25326 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
25327 error "dd to create source file failed"
25328 stack_trap "rm -f $DIR/$tfile"
25330 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
25331 error "parallel dio write with failure on second stripe succeeded"
25332 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
25333 diff $DIR/$tfile $DIR/$tfile.1
25334 [[ $? == 0 ]] || error "data incorrect after append"
25337 run_test 398n "test append with parallel DIO"
25340 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
25342 run_test 398o "right kms with DIO"
25345 local read_write=$1
25346 if [ "$read_write" = "write" ]; then
25347 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
25348 elif [ "$read_write" = "read" ]; then
25349 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
25351 error "argument error"
25354 # turn off debug for performance testing
25355 local saved_debug=$($LCTL get_param -n debug)
25356 $LCTL set_param debug=0
25358 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25360 # get ost1 size - $FSNAME-OST0000
25361 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
25362 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
25363 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
25365 if [ "$read_write" = "read" ]; then
25366 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
25369 local start_time=$(date +%s.%N)
25370 $dd_cmd bs=1M count=$blocks oflag=sync ||
25371 error "real dd $read_write error"
25372 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
25374 if [ "$read_write" = "write" ]; then
25378 # define OBD_FAIL_OST_FAKE_RW 0x238
25379 do_facet ost1 $LCTL set_param fail_loc=0x238
25381 local start_time=$(date +%s.%N)
25382 $dd_cmd bs=1M count=$blocks oflag=sync ||
25383 error "fake dd $read_write error"
25384 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
25386 if [ "$read_write" = "write" ]; then
25388 cancel_lru_locks osc
25389 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
25390 error "$tfile size not $blocks MB"
25392 do_facet ost1 $LCTL set_param fail_loc=0
25394 echo "fake $read_write $duration_fake vs. normal $read_write" \
25395 "$duration in seconds"
25396 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
25397 error_not_in_vm "fake write is slower"
25399 $LCTL set_param -n debug="$saved_debug"
25402 test_399a() { # LU-7655 for OST fake write
25403 remote_ost_nodsh && skip "remote OST with nodsh"
25407 run_test 399a "fake write should not be slower than normal write"
25409 test_399b() { # LU-8726 for OST fake read
25410 remote_ost_nodsh && skip "remote OST with nodsh"
25411 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
25412 skip_env "ldiskfs only test"
25417 run_test 399b "fake read should not be slower than normal read"
25419 test_400a() { # LU-1606, was conf-sanity test_74
25420 if ! which $CC > /dev/null 2>&1; then
25421 skip_env "$CC is not installed"
25424 local extra_flags=''
25425 local out=$TMP/$tfile
25426 local prefix=/usr/include/lustre
25429 # Oleg removes c files in his test rig so test if any c files exist
25430 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
25431 skip_env "Needed c test files are missing"
25433 if ! [[ -d $prefix ]]; then
25434 # Assume we're running in tree and fixup the include path.
25435 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
25436 extra_flags+=" -L$LUSTRE/utils/.lib"
25439 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
25440 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
25441 error "client api broken"
25445 run_test 400a "Lustre client api program can compile and link"
25447 test_400b() { # LU-1606, LU-5011
25449 local out=$TMP/$tfile
25450 local prefix=/usr/include/linux/lustre
25452 # We use a hard coded prefix so that this test will not fail
25453 # when run in tree. There are headers in lustre/include/lustre/
25454 # that are not packaged (like lustre_idl.h) and have more
25455 # complicated include dependencies (like config.h and lnet/types.h).
25456 # Since this test about correct packaging we just skip them when
25457 # they don't exist (see below) rather than try to fixup cppflags.
25459 if ! which $CC > /dev/null 2>&1; then
25460 skip_env "$CC is not installed"
25463 for header in $prefix/*.h; do
25464 if ! [[ -f "$header" ]]; then
25468 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
25469 continue # lustre_ioctl.h is internal header
25472 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
25473 error "cannot compile '$header'"
25477 run_test 400b "packaged headers can be compiled"
25479 test_401a() { #LU-7437
25480 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
25481 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
25483 #count the number of parameters by "list_param -R"
25484 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
25485 #count the number of parameters by listing proc files
25486 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
25487 echo "proc_dirs='$proc_dirs'"
25488 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
25489 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
25492 [ $params -eq $procs ] ||
25493 error "found $params parameters vs. $procs proc files"
25495 # test the list_param -D option only returns directories
25496 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
25497 #count the number of parameters by listing proc directories
25498 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
25501 [ $params -eq $procs ] ||
25502 error "found $params parameters vs. $procs proc files"
25504 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
25507 # jobid_var may not allow arbitrary values, so use jobid_name
25509 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25510 local testname=jobid_name tmp='testing%p'
25512 local testname=jobid_var tmp=testing
25515 local save=$($LCTL get_param -n $testname)
25517 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
25518 error "no error returned when setting bad parameters"
25520 local jobid_new=$($LCTL get_param -n foe $testname baz)
25521 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
25523 $LCTL set_param -n fog=bam $testname=$save bat=fog
25524 local jobid_old=$($LCTL get_param -n foe $testname bag)
25525 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
25527 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
25530 # jobid_var may not allow arbitrary values, so use jobid_name
25532 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25533 local testname=jobid_name
25535 local testname=jobid_var
25538 local jobid_var_old=$($LCTL get_param -n $testname)
25539 local jobid_var_new
25541 $LCTL set_param $testname= &&
25542 error "no error returned for 'set_param a='"
25544 jobid_var_new=$($LCTL get_param -n $testname)
25545 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25546 error "$testname was changed by setting without value"
25548 $LCTL set_param $testname &&
25549 error "no error returned for 'set_param a'"
25551 jobid_var_new=$($LCTL get_param -n $testname)
25552 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25553 error "$testname was changed by setting without value"
25555 run_test 401c "Verify 'lctl set_param' without value fails in either format."
25558 # jobid_var may not allow arbitrary values, so use jobid_name
25560 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25561 local testname=jobid_name new_value='foo=bar%p'
25563 local testname=jobid_var new_valuie=foo=bar
25566 local jobid_var_old=$($LCTL get_param -n $testname)
25567 local jobid_var_new
25569 $LCTL set_param $testname=$new_value ||
25570 error "'set_param a=b' did not accept a value containing '='"
25572 jobid_var_new=$($LCTL get_param -n $testname)
25573 [[ "$jobid_var_new" == "$new_value" ]] ||
25574 error "'set_param a=b' failed on a value containing '='"
25576 # Reset the $testname to test the other format
25577 $LCTL set_param $testname=$jobid_var_old
25578 jobid_var_new=$($LCTL get_param -n $testname)
25579 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25580 error "failed to reset $testname"
25582 $LCTL set_param $testname $new_value ||
25583 error "'set_param a b' did not accept a value containing '='"
25585 jobid_var_new=$($LCTL get_param -n $testname)
25586 [[ "$jobid_var_new" == "$new_value" ]] ||
25587 error "'set_param a b' failed on a value containing '='"
25589 $LCTL set_param $testname $jobid_var_old
25590 jobid_var_new=$($LCTL get_param -n $testname)
25591 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25592 error "failed to reset $testname"
25594 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25596 test_401e() { # LU-14779
25597 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25598 error "lctl list_param MGC* failed"
25599 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25600 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25601 error "lctl get_param lru_size failed"
25603 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25606 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25607 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25608 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25609 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25610 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25611 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25612 remote_mds_nodsh && skip "remote MDS with nodsh"
25614 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25615 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25616 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25617 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25618 echo "Touch failed - OK"
25620 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25623 local file1=$DIR/$tfile.1
25624 local file2=$DIR/$tfile.2
25625 local tfile=$TMP/$tfile
25627 rm -f $file1 $file2 $tfile
25632 # 30 sec OBD_TIMEOUT in ll_getattr()
25633 # right before populating st_nlink
25634 $LCTL set_param fail_loc=0x80001409
25635 stat -c %h $file1 > $tfile &
25637 # create an alias, drop all locks and reclaim the dentry
25639 cancel_lru_locks mdc
25640 cancel_lru_locks osc
25641 sysctl -w vm.drop_caches=2
25645 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25647 rm -f $tfile $file1 $file2
25649 run_test 403 "i_nlink should not drop to zero due to aliasing"
25651 test_404() { # LU-6601
25652 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
25653 skip "Need server version newer than 2.8.52"
25654 remote_mds_nodsh && skip "remote MDS with nodsh"
25656 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
25657 awk '/osp .*-osc-MDT/ { print $4}')
25660 for osp in $mosps; do
25661 echo "Deactivate: " $osp
25662 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
25663 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25664 awk -vp=$osp '$4 == p { print $2 }')
25665 [ $stat = IN ] || {
25666 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25667 error "deactivate error"
25669 echo "Activate: " $osp
25670 do_facet $SINGLEMDS $LCTL --device %$osp activate
25671 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25672 awk -vp=$osp '$4 == p { print $2 }')
25673 [ $stat = UP ] || {
25674 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25675 error "activate error"
25679 run_test 404 "validate manual {de}activated works properly for OSPs"
25682 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
25683 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
25684 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
25685 skip "Layout swap lock is not supported"
25687 check_swap_layouts_support
25688 check_swap_layout_no_dom $DIR
25690 test_mkdir $DIR/$tdir
25691 swap_lock_test -d $DIR/$tdir ||
25692 error "One layout swap locked test failed"
25694 run_test 405 "Various layout swap lock tests"
25697 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25698 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
25699 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
25700 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25701 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
25702 skip "Need MDS version at least 2.8.50"
25704 local def_stripe_size=$($LFS getstripe -S $MOUNT)
25705 local test_pool=$TESTNAME
25707 pool_add $test_pool || error "pool_add failed"
25708 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
25709 error "pool_add_targets failed"
25711 save_layout_restore_at_exit $MOUNT
25713 # parent set default stripe count only, child will stripe from both
25714 # parent and fs default
25715 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
25716 error "setstripe $MOUNT failed"
25717 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
25718 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
25719 for i in $(seq 10); do
25720 local f=$DIR/$tdir/$tfile.$i
25721 touch $f || error "touch failed"
25722 local count=$($LFS getstripe -c $f)
25723 [ $count -eq $OSTCOUNT ] ||
25724 error "$f stripe count $count != $OSTCOUNT"
25725 local offset=$($LFS getstripe -i $f)
25726 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
25727 local size=$($LFS getstripe -S $f)
25728 [ $size -eq $((def_stripe_size * 2)) ] ||
25729 error "$f stripe size $size != $((def_stripe_size * 2))"
25730 local pool=$($LFS getstripe -p $f)
25731 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
25734 # change fs default striping, delete parent default striping, now child
25735 # will stripe from new fs default striping only
25736 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
25737 error "change $MOUNT default stripe failed"
25738 $LFS setstripe -c 0 $DIR/$tdir ||
25739 error "delete $tdir default stripe failed"
25740 for i in $(seq 11 20); do
25741 local f=$DIR/$tdir/$tfile.$i
25742 touch $f || error "touch $f failed"
25743 local count=$($LFS getstripe -c $f)
25744 [ $count -eq 1 ] || error "$f stripe count $count != 1"
25745 local offset=$($LFS getstripe -i $f)
25746 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
25747 local size=$($LFS getstripe -S $f)
25748 [ $size -eq $def_stripe_size ] ||
25749 error "$f stripe size $size != $def_stripe_size"
25750 local pool=$($LFS getstripe -p $f)
25751 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
25754 unlinkmany $DIR/$tdir/$tfile. 1 20
25756 local f=$DIR/$tdir/$tfile
25757 pool_remove_all_targets $test_pool $f
25758 pool_remove $test_pool $f
25760 run_test 406 "DNE support fs default striping"
25763 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25764 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
25765 skip "Need MDS version at least 2.8.55"
25766 remote_mds_nodsh && skip "remote MDS with nodsh"
25768 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
25769 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
25770 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
25771 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
25772 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
25774 #define OBD_FAIL_DT_TXN_STOP 0x2019
25775 for idx in $(seq $MDSCOUNT); do
25776 do_facet mds$idx "lctl set_param fail_loc=0x2019"
25778 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
25779 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
25780 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
25783 run_test 407 "transaction fail should cause operation fail"
25786 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
25788 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
25789 lctl set_param fail_loc=0x8000040a
25790 # let ll_prepare_partial_page() fail
25791 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
25795 # create at least 100 unused inodes so that
25796 # shrink_icache_memory(0) should not return 0
25797 touch $DIR/$tfile-{0..100}
25798 rm -f $DIR/$tfile-{0..100}
25801 echo 2 > /proc/sys/vm/drop_caches
25803 run_test 408 "drop_caches should not hang due to page leaks"
25807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25809 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
25810 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
25811 touch $DIR/$tdir/guard || error "(2) Fail to create"
25813 local PREFIX=$(str_repeat 'A' 128)
25814 echo "Create 1K hard links start at $(date)"
25815 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25816 error "(3) Fail to hard link"
25818 echo "Links count should be right although linkEA overflow"
25819 stat $DIR/$tdir/guard || error "(4) Fail to stat"
25820 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
25821 [ $linkcount -eq 1001 ] ||
25822 error "(5) Unexpected hard links count: $linkcount"
25824 echo "List all links start at $(date)"
25825 ls -l $DIR/$tdir/foo > /dev/null ||
25826 error "(6) Fail to list $DIR/$tdir/foo"
25828 echo "Unlink hard links start at $(date)"
25829 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25830 error "(7) Fail to unlink"
25831 echo "Unlink hard links finished at $(date)"
25833 run_test 409 "Large amount of cross-MDTs hard links on the same file"
25837 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
25838 skip "Need client version at least 2.9.59"
25839 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
25840 skip "Need MODULES build"
25842 # Create a file, and stat it from the kernel
25843 local testfile=$DIR/$tfile
25846 local run_id=$RANDOM
25847 local my_ino=$(stat --format "%i" $testfile)
25849 # Try to insert the module. This will always fail as the
25850 # module is designed to not be inserted.
25851 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
25854 # Anything but success is a test failure
25856 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
25857 error "no inode match"
25859 run_test 410 "Test inode number returned from kernel thread"
25861 cleanup_test411_cgroup() {
25867 local cg_basedir=/sys/fs/cgroup/memory
25869 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
25870 skip "no setup for cgroup"
25872 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
25873 error "test file creation failed"
25874 cancel_lru_locks osc
25876 # Create a very small memory cgroup to force a slab allocation error
25877 local cgdir=$cg_basedir/osc_slab_alloc
25878 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
25879 trap "cleanup_test411_cgroup $cgdir" EXIT
25880 echo 2M > $cgdir/memory.kmem.limit_in_bytes
25881 echo 1M > $cgdir/memory.limit_in_bytes
25883 # Should not LBUG, just be killed by oom-killer
25884 # dd will return 0 even allocation failure in some environment.
25885 # So don't check return value
25886 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
25887 cleanup_test411_cgroup $cgdir
25891 run_test 411 "Slab allocation error with cgroup does not LBUG"
25894 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
25895 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
25896 skip "Need server version at least 2.10.55"
25898 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
25899 error "mkdir failed"
25900 $LFS getdirstripe $DIR/$tdir
25901 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
25902 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
25903 error "expect $((MDSCOUT - 1)) get $stripe_index"
25904 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
25905 [ $stripe_count -eq 2 ] ||
25906 error "expect 2 get $stripe_count"
25908 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
25913 # subdirs should be on the same MDT as parent
25914 for i in $(seq 0 $((MDSCOUNT - 1))); do
25915 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
25916 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
25917 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
25918 (( index == i )) || error "mdt$i/sub on MDT$index"
25921 # stripe offset -1, ditto
25922 for i in {1..10}; do
25923 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
25924 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
25925 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
25926 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
25927 (( index == index2 )) ||
25928 error "qos$i on MDT$index, sub on MDT$index2"
25931 local testdir=$DIR/$tdir/inherit
25933 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
25936 testdir=$testdir/s$i
25937 mkdir $testdir || error "mkdir $testdir failed"
25938 index=$($LFS getstripe -m $testdir)
25939 (( index == 1 )) ||
25940 error "$testdir on MDT$index"
25943 # not inherit any more
25944 testdir=$testdir/s3
25945 mkdir $testdir || error "mkdir $testdir failed"
25946 getfattr -d -m dmv $testdir | grep dmv &&
25947 error "default LMV set on $testdir" || true
25949 run_test 412 "mkdir on specific MDTs"
25951 TEST413_COUNT=${TEST413_COUNT:-200}
25952 generate_uneven_mdts() {
25954 local lmv_qos_maxage
25955 local lod_qos_maxage
25965 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25966 $LCTL set_param lmv.*.qos_maxage=1
25967 stack_trap "$LCTL set_param \
25968 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
25969 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25970 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25971 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25972 lod.*.mdt_qos_maxage=1
25973 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25974 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
25977 echo "Check for uneven MDTs: "
25979 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25980 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25981 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25983 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25984 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25987 for ((i = 1; i < ${#ffree[@]}; i++)); do
25988 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25989 if [ $tmp -gt $max ]; then
25993 if [ $tmp -lt $min ]; then
25999 (( ${ffree[min_index]} > 0 )) ||
26000 skip "no free files in MDT$min_index"
26001 (( ${ffree[min_index]} < 10000000 )) ||
26002 skip "too many free files in MDT$min_index"
26004 # Check if we need to generate uneven MDTs
26005 local diff=$(((max - min) * 100 / min))
26006 local testdir=$DIR/$tdir-fillmdt
26010 while (( diff < threshold )); do
26012 # generate uneven MDTs, create till $threshold% diff
26013 echo -n "weight diff=$diff% must be > $threshold% ..."
26014 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
26015 testdir=$DIR/$tdir-fillmdt/$i
26016 [ -d $testdir ] && continue
26017 $LFS mkdir -i $min_index $testdir ||
26018 error "mkdir $testdir failed"
26019 $LFS setstripe -E 1M -L mdt $testdir ||
26020 error "setstripe $testdir failed"
26022 for ((F=0; F < TEST413_COUNT; F++)); do
26023 dd if=/dev/zero of=$testdir/f.$F bs=128K count=1 > \
26024 /dev/null 2>&1 || error "dd $F failed"
26026 sync; sleep 1; sync
26028 # wait for QOS to update
26029 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
26031 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
26032 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
26033 max=$(((${ffree[max_index]} >> 8) *
26034 (${bavail[max_index]} * bsize >> 16)))
26035 min=$(((${ffree[min_index]} >> 8) *
26036 (${bavail[min_index]} * bsize >> 16)))
26037 diff=$(((max - min) * 100 / min))
26041 echo "MDT filesfree available: ${ffree[*]}"
26042 echo "MDT blocks available: ${bavail[*]}"
26043 echo "weight diff=$diff%"
26048 local stripe_count=$2
26049 local mdts=$(comma_list $(mdts_nodes))
26052 local lmv_qos_prio_free
26053 local lmv_qos_threshold_rr
26054 local lmv_qos_maxage
26055 local lod_qos_prio_free
26056 local lod_qos_threshold_rr
26057 local lod_qos_maxage
26061 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
26062 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
26063 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26065 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
26066 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26067 stack_trap "$LCTL set_param \
26068 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
26069 stack_trap "$LCTL set_param \
26070 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
26071 stack_trap "$LCTL set_param \
26072 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26074 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
26075 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
26076 lod_qos_prio_free=${lod_qos_prio_free%%%}
26077 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
26078 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
26079 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
26080 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
26081 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
26082 stack_trap "do_nodes $mdts $LCTL set_param \
26083 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
26084 stack_trap "do_nodes $mdts $LCTL set_param \
26085 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
26086 stack_trap "do_nodes $mdts $LCTL set_param \
26087 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
26089 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26090 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
26092 testdir=$DIR/$tdir-s$stripe_count/rr
26094 local stripe_index=$($LFS getstripe -m $testdir)
26095 local test_mkdir_rr=true
26097 getfattr -d -m dmv -e hex $testdir | grep dmv
26098 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
26099 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
26100 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
26101 test_mkdir_rr=false
26106 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
26107 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
26109 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
26110 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
26111 eval $mkdir_cmd $testdir/subdir$i ||
26112 error "$mkdir_cmd subdir$i failed"
26115 for (( i = 0; i < $MDSCOUNT; i++ )); do
26116 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26117 echo "$count directories created on MDT$i"
26118 if $test_mkdir_rr; then
26119 (( $count == 100 )) ||
26120 error "subdirs are not evenly distributed"
26121 elif (( $i == $stripe_index )); then
26122 (( $count == 100 * MDSCOUNT )) ||
26123 error "$count subdirs created on MDT$i"
26125 (( $count == 0 )) ||
26126 error "$count subdirs created on MDT$i"
26129 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
26130 count=$($LFS getdirstripe $testdir/* |
26131 grep -c -P "^\s+$i\t")
26132 echo "$count stripes created on MDT$i"
26133 # deviation should < 5% of average
26134 (( $count >= 95 * stripe_count &&
26135 $count <= 105 * stripe_count)) ||
26136 error "stripes are not evenly distributed"
26141 echo "Check for uneven MDTs: "
26151 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26152 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26153 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26155 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26156 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26159 for ((i = 1; i < ${#ffree[@]}; i++)); do
26160 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26161 if [ $tmp -gt $max ]; then
26165 if [ $tmp -lt $min ]; then
26171 (( ${ffree[min_index]} > 0 )) ||
26172 skip "no free files in MDT$min_index"
26173 (( ${ffree[min_index]} < 10000000 )) ||
26174 skip "too many free files in MDT$min_index"
26176 echo "MDT filesfree available: ${ffree[*]}"
26177 echo "MDT blocks available: ${bavail[*]}"
26178 echo "weight diff=$(((max - min) * 100 / min))%"
26180 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
26182 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
26183 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
26184 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
26185 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
26186 # decrease statfs age, so that it can be updated in time
26187 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
26188 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
26192 testdir=$DIR/$tdir-s$stripe_count/qos
26195 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
26196 for (( i = 0; i < num * MDSCOUNT; i++ )); do
26197 eval $mkdir_cmd $testdir/subdir$i ||
26198 error "$mkdir_cmd subdir$i failed"
26202 for (( i = 0; i < $MDSCOUNT; i++ )); do
26203 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
26204 (( count > max )) && max=$count
26205 echo "$count directories created on MDT$i"
26208 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
26210 # D-value should > 10% of averge
26211 (( max - min > num / 10 )) ||
26212 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
26214 # ditto for stripes
26215 if (( stripe_count > 1 )); then
26217 for (( i = 0; i < $MDSCOUNT; i++ )); do
26218 count=$($LFS getdirstripe $testdir/* |
26219 grep -c -P "^\s+$i\t")
26220 (( count > max )) && max=$count
26221 echo "$count stripes created on MDT$i"
26224 min=$($LFS getdirstripe $testdir/* |
26225 grep -c -P "^\s+$min_index\t")
26226 (( max - min > num * stripe_count / 10 )) ||
26227 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
26239 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
26240 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
26241 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
26243 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
26245 for ((i = 1; i < ${#ffree[@]}; i++)); do
26246 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
26247 (( tmp < min )) && min=$tmp && min_index=$i
26254 [ $MDSCOUNT -lt 2 ] &&
26255 skip "We need at least 2 MDTs for this test"
26257 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26258 skip "Need server version at least 2.12.52"
26262 generate_uneven_mdts 100
26263 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26264 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
26265 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
26266 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
26267 error "mkdir failed"
26268 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
26271 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
26274 [ $MDSCOUNT -lt 2 ] &&
26275 skip "We need at least 2 MDTs for this test"
26277 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
26278 skip "Need server version at least 2.12.52"
26283 generate_uneven_mdts 100
26284 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
26285 testdir=$DIR/$tdir-s$stripe_count
26286 mkdir $testdir || error "mkdir $testdir failed"
26287 mkdir $testdir/rr || error "mkdir rr failed"
26288 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
26289 error "mkdir qos failed"
26290 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
26291 $testdir/rr || error "setdirstripe rr failed"
26292 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
26293 error "setdirstripe failed"
26294 test_qos_mkdir "mkdir" $stripe_count
26297 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
26300 (( $MDSCOUNT >= 2 )) ||
26301 skip "We need at least 2 MDTs for this test"
26303 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
26304 skip "Need server version at least 2.14.51"
26310 testdir=$DIR/${tdir}-s1
26311 mkdir $testdir || error "mkdir $testdir failed"
26312 mkdir $testdir/rr || error "mkdir rr failed"
26313 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
26314 # default max_inherit is -1, default max_inherit_rr is 0
26315 $LFS setdirstripe -D -c 1 $testdir/rr ||
26316 error "setdirstripe rr failed"
26317 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
26318 error "setdirstripe qos failed"
26319 test_qos_mkdir "mkdir" 1
26321 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
26322 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
26323 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
26324 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
26325 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
26327 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
26328 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
26329 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
26330 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
26331 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
26332 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
26333 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
26334 error "level2 shouldn't have default LMV" || true
26336 run_test 413c "mkdir with default LMV max inherit rr"
26339 (( MDSCOUNT >= 2 )) ||
26340 skip "We need at least 2 MDTs for this test"
26342 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
26343 skip "Need server version at least 2.14.51"
26345 local lmv_qos_threshold_rr
26347 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
26349 stack_trap "$LCTL set_param \
26350 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
26352 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26353 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
26354 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
26355 error "$tdir shouldn't have default LMV"
26356 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
26357 error "mkdir sub failed"
26359 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
26361 (( count == 100 )) || error "$count subdirs on MDT0"
26363 run_test 413d "inherit ROOT default LMV"
26366 (( MDSCOUNT >= 2 )) ||
26367 skip "We need at least 2 MDTs for this test"
26368 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26369 skip "Need server version at least 2.14.55"
26371 local testdir=$DIR/$tdir
26372 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
26374 local sub_max_inherit
26376 mkdir -p $testdir || error "failed to create $testdir"
26378 # set default max-inherit to -1 if stripe count is 0 or 1
26379 $LFS setdirstripe -D -c 1 $testdir ||
26380 error "failed to set default LMV"
26381 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26382 (( max_inherit == -1 )) ||
26383 error "wrong max_inherit value $max_inherit"
26385 # set default max_inherit to a fixed value if stripe count is not 0 or 1
26386 $LFS setdirstripe -D -c -1 $testdir ||
26387 error "failed to set default LMV"
26388 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26389 (( max_inherit > 0 )) ||
26390 error "wrong max_inherit value $max_inherit"
26392 # and the subdir will decrease the max_inherit by 1
26393 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
26394 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
26395 (( sub_max_inherit == max_inherit - 1)) ||
26396 error "wrong max-inherit of subdir $sub_max_inherit"
26398 # check specified --max-inherit and warning message
26399 stack_trap "rm -f $tmpfile"
26400 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
26401 error "failed to set default LMV"
26402 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26403 (( max_inherit == -1 )) ||
26404 error "wrong max_inherit value $max_inherit"
26406 # check the warning messages
26407 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
26408 error "failed to detect warning string"
26411 run_test 413e "check default max-inherit value"
26413 test_fs_dmv_inherit()
26415 local testdir=$DIR/$tdir
26422 mkdir $testdir || error "mkdir $testdir failed"
26423 count=$($LFS getdirstripe -D -c $testdir)
26424 (( count == 1 )) ||
26425 error "$testdir default LMV count mismatch $count != 1"
26426 inherit=$($LFS getdirstripe -D -X $testdir)
26427 (( inherit == 3 - i )) ||
26428 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
26429 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
26430 (( inherit_rr == 3 - i )) ||
26431 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
26432 testdir=$testdir/sub
26435 mkdir $testdir || error "mkdir $testdir failed"
26436 count=$($LFS getdirstripe -D -c $testdir)
26437 (( count == 0 )) ||
26438 error "$testdir default LMV count not zero: $count"
26442 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26444 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26445 skip "Need server version at least 2.14.55"
26447 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26448 error "dump $DIR default LMV failed"
26449 stack_trap "setfattr --restore=$TMP/dmv.ea"
26451 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26452 error "set $DIR default LMV failed"
26454 test_fs_dmv_inherit
26456 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
26459 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26461 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
26462 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26463 error "dump $DIR default LMV failed"
26464 stack_trap "setfattr --restore=$TMP/dmv.ea"
26466 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26467 error "set $DIR default LMV failed"
26469 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
26470 error "mount $MOUNT2 failed"
26471 stack_trap "umount_client $MOUNT2"
26473 local saved_DIR=$DIR
26477 stack_trap "export DIR=$saved_DIR"
26479 # first check filesystem-wide default LMV inheritance
26480 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
26482 # then check subdirs are spread to all MDTs
26483 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
26485 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
26487 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
26489 run_test 413g "enforce ROOT default LMV on subdir mount"
26492 (( MDSCOUNT >= 2 )) ||
26493 skip "We need at least 2 MDTs for this test"
26495 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
26496 skip "Need server version at least 2.15.50.6"
26498 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
26500 stack_trap "$LCTL set_param \
26501 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
26502 $LCTL set_param lmv.*.qos_maxage=1
26506 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
26507 local count=$((MDSCOUNT * 20))
26509 generate_uneven_mdts 50
26511 mkdir -p $dir || error "mkdir $dir failed"
26512 stack_trap "rm -rf $dir"
26513 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
26514 --max-inherit-rr=$rr_depth $dir
26516 for ((d=0; d < depth + 2; d++)); do
26518 for ((sub=0; sub < count; sub++)); do
26521 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
26522 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
26523 # subdirs within $rr_depth should be created round-robin
26524 if (( d < rr_depth )); then
26525 (( ${num[0]} != count )) ||
26526 error "all objects created on MDT ${num[1]}"
26532 run_test 413h "don't stick to parent for round-robin dirs"
26539 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
26540 unlinkmany $subdir/f. $TEST413_COUNT &
26544 for pid in $pids; do
26548 run_test 413z "413 test cleanup"
26551 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
26552 $LCTL set_param fail_loc=0x80000521
26553 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26556 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
26559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26560 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26561 skip "Need server version at least 2.11.52"
26571 # this test may be slow on ZFS
26572 [ "$mds1_FSTYPE" == "zfs" ] && total=50
26574 # though this test is designed for striped directory, let's test normal
26575 # directory too since lock is always saved as CoS lock.
26576 test_mkdir $DIR/$tdir || error "mkdir $tdir"
26577 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
26586 start_time=$(date +%s)
26587 for i in $(seq $total); do
26588 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
26591 end_time=$(date +%s)
26592 duration=$((end_time - start_time))
26594 kill -9 $setattr_pid
26596 echo "rename $total files took $duration sec"
26597 [ $duration -lt 100 ] || error "rename took $duration sec"
26599 run_test 415 "lock revoke is not missing"
26602 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26603 skip "Need server version at least 2.11.55"
26605 # define OBD_FAIL_OSD_TXN_START 0x19a
26606 do_facet mds1 lctl set_param fail_loc=0x19a
26608 lfs mkdir -c $MDSCOUNT $DIR/$tdir
26612 run_test 416 "transaction start failure won't cause system hung"
26616 do_nodes $(comma_list $(mdts_nodes)) \
26617 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
26618 do_nodes $(comma_list $(mdts_nodes)) \
26619 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
26620 do_nodes $(comma_list $(mdts_nodes)) \
26621 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
26625 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26626 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
26627 skip "Need MDS version at least 2.11.56"
26629 trap cleanup_417 RETURN EXIT
26631 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
26632 do_nodes $(comma_list $(mdts_nodes)) \
26633 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
26634 $LFS migrate -m 0 $DIR/$tdir.1 &&
26635 error "migrate dir $tdir.1 should fail"
26637 do_nodes $(comma_list $(mdts_nodes)) \
26638 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
26639 $LFS mkdir -i 1 $DIR/$tdir.2 &&
26640 error "create remote dir $tdir.2 should fail"
26642 do_nodes $(comma_list $(mdts_nodes)) \
26643 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
26644 $LFS mkdir -c 2 $DIR/$tdir.3 &&
26645 error "create striped dir $tdir.3 should fail"
26648 run_test 417 "disable remote dir, striped dir and dir migration"
26650 # Checks that the outputs of df [-i] and lfs df [-i] match
26652 # usage: check_lfs_df <blocks | inodes> <mountpoint>
26662 [ "$1" == "blocks" ] && inodes= || inodes="-i"
26664 for count in {1..100}; do
26665 do_nodes "$CLIENTS" \
26666 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26669 # read the lines of interest
26670 df_out=($(df -P $inodes $dir | tail -n +2)) ||
26671 error "df $inodes $dir | tail -n +2 failed"
26672 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
26673 error "lfs df $inodes $dir | grep summary: failed"
26675 # skip first substrings of each output as they are different
26676 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
26677 # compare the two outputs
26679 # skip "available" on MDT until LU-13997 is fixed.
26680 #for i in {1..5}; do
26681 for i in 1 2 4 5; do
26682 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
26690 lfs df $inodes $dir
26691 error "df and lfs df $1 output mismatch: " \
26692 "df ${inodes}: ${df_out[*]}, " \
26693 "lfs df ${inodes}: ${lfs_df_out[*]}"
26698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26700 local dir=$DIR/$tdir
26701 local numfiles=$((RANDOM % 4096 + 2))
26702 local numblocks=$((RANDOM % 256 + 1))
26704 wait_delete_completed
26707 # check block output
26708 check_lfs_df blocks $dir
26709 # check inode output
26710 check_lfs_df inodes $dir
26712 # create a single file and retest
26713 echo "Creating a single file and testing"
26714 createmany -o $dir/$tfile- 1 &>/dev/null ||
26715 error "creating 1 file in $dir failed"
26716 check_lfs_df blocks $dir
26717 check_lfs_df inodes $dir
26719 # create a random number of files
26720 echo "Creating $((numfiles - 1)) files and testing"
26721 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
26722 error "creating $((numfiles - 1)) files in $dir failed"
26724 # write a random number of blocks to the first test file
26725 echo "Writing $numblocks 4K blocks and testing"
26726 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
26727 count=$numblocks &>/dev/null ||
26728 error "dd to $dir/${tfile}-0 failed"
26731 check_lfs_df blocks $dir
26732 check_lfs_df inodes $dir
26734 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
26735 error "unlinking $numfiles files in $dir failed"
26737 run_test 418 "df and lfs df outputs match"
26741 local dir=$DIR/$tdir
26746 cancel_lru_locks mdc
26748 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
26749 $LCTL set_param fail_loc=0x1410
26751 $LCTL set_param fail_loc=0
26754 run_test 419 "Verify open file by name doesn't crash kernel"
26758 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
26759 skip "Need MDS version at least 2.12.53"
26761 local SAVE_UMASK=$(umask)
26762 local dir=$DIR/$tdir
26763 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
26767 mkdir -m03777 $dir/testdir
26768 ls -dn $dir/testdir
26769 # Need to remove trailing '.' when SELinux is enabled
26770 local dirperms=$(ls -dn $dir/testdir |
26771 awk '{ sub(/\.$/, "", $1); print $1}')
26772 [ $dirperms == "drwxrwsrwt" ] ||
26773 error "incorrect perms on $dir/testdir"
26775 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
26776 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
26777 ls -n $dir/testdir/testfile
26778 local fileperms=$(ls -n $dir/testdir/testfile |
26779 awk '{ sub(/\.$/, "", $1); print $1}')
26780 [ $fileperms == "-rwxr-xr-x" ] ||
26781 error "incorrect perms on $dir/testdir/testfile"
26785 run_test 420 "clear SGID bit on non-directories for non-members"
26792 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26793 skip "Need MDS version at least 2.12.54"
26795 test_mkdir $DIR/$tdir
26796 createmany -o $DIR/$tdir/f 3
26797 cnt=$(ls -1 $DIR/$tdir | wc -l)
26798 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26800 fid1=$(lfs path2fid $DIR/$tdir/f1)
26801 fid2=$(lfs path2fid $DIR/$tdir/f2)
26802 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
26804 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
26805 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
26807 cnt=$(ls -1 $DIR/$tdir | wc -l)
26808 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26810 rm -f $DIR/$tdir/f3 || error "can't remove f3"
26811 createmany -o $DIR/$tdir/f 3
26812 cnt=$(ls -1 $DIR/$tdir | wc -l)
26813 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26815 fid1=$(lfs path2fid $DIR/$tdir/f1)
26816 fid2=$(lfs path2fid $DIR/$tdir/f2)
26817 echo "remove using fsname $FSNAME"
26818 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
26820 cnt=$(ls -1 $DIR/$tdir | wc -l)
26821 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26823 run_test 421a "simple rm by fid"
26830 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26831 skip "Need MDS version at least 2.12.54"
26833 test_mkdir $DIR/$tdir
26834 createmany -o $DIR/$tdir/f 3
26835 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
26838 FID1=$(lfs path2fid $DIR/$tdir/f1)
26839 FID2=$(lfs path2fid $DIR/$tdir/f2)
26840 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
26842 kill -USR1 $MULTIPID
26845 cnt=$(ls $DIR/$tdir | wc -l)
26846 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
26848 run_test 421b "rm by fid on open file"
26854 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26855 skip "Need MDS version at least 2.12.54"
26857 test_mkdir $DIR/$tdir
26858 createmany -o $DIR/$tdir/f 3
26859 touch $DIR/$tdir/$tfile
26860 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
26861 cnt=$(ls -1 $DIR/$tdir | wc -l)
26862 [ $cnt != 184 ] && error "unexpected #files: $cnt"
26864 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
26865 $LFS rmfid $DIR $FID1 || error "rmfid failed"
26867 cnt=$(ls $DIR/$tdir | wc -l)
26868 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
26870 run_test 421c "rm by fid against hardlinked files"
26876 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26877 skip "Need MDS version at least 2.12.54"
26879 test_mkdir $DIR/$tdir
26880 createmany -o $DIR/$tdir/f 4097
26881 cnt=$(ls -1 $DIR/$tdir | wc -l)
26882 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
26884 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
26885 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26887 cnt=$(ls $DIR/$tdir | wc -l)
26889 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26891 run_test 421d "rmfid en masse"
26897 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26898 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26899 skip "Need MDS version at least 2.12.54"
26901 mkdir -p $DIR/$tdir
26902 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26903 createmany -o $DIR/$tdir/striped_dir/f 512
26904 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26905 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26907 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26908 sed "s/[/][^:]*://g")
26909 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26911 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26913 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26915 run_test 421e "rmfid in DNE"
26921 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26922 skip "Need MDS version at least 2.12.54"
26924 test_mkdir $DIR/$tdir
26926 cnt=$(ls -1 $DIR/$tdir | wc -l)
26927 [ $cnt != 1 ] && error "unexpected #files: $cnt"
26929 FID=$(lfs path2fid $DIR/$tdir/f)
26930 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
26931 # rmfid should fail
26932 cnt=$(ls -1 $DIR/$tdir | wc -l)
26933 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
26935 chmod a+rw $DIR/$tdir
26937 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
26938 # rmfid should fail
26939 cnt=$(ls -1 $DIR/$tdir | wc -l)
26940 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
26943 $RUNAS touch $DIR/$tdir/f
26944 FID=$(lfs path2fid $DIR/$tdir/f)
26945 echo "rmfid as root"
26946 $LFS rmfid $DIR $FID || error "rmfid as root failed"
26947 cnt=$(ls -1 $DIR/$tdir | wc -l)
26948 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
26951 $RUNAS touch $DIR/$tdir/f
26952 cnt=$(ls -1 $DIR/$tdir | wc -l)
26953 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
26954 FID=$(lfs path2fid $DIR/$tdir/f)
26955 # rmfid w/o user_fid2path mount option should fail
26956 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
26957 cnt=$(ls -1 $DIR/$tdir | wc -l)
26958 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
26960 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
26961 stack_trap "rmdir $tmpdir"
26962 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
26963 error "failed to mount client'"
26964 stack_trap "umount_client $tmpdir"
26966 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
26967 # rmfid should succeed
26968 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
26969 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
26971 # rmfid shouldn't allow to remove files due to dir's permission
26972 chmod a+rwx $tmpdir/$tdir
26973 touch $tmpdir/$tdir/f
26974 ls -la $tmpdir/$tdir
26975 FID=$(lfs path2fid $tmpdir/$tdir/f)
26976 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
26979 run_test 421f "rmfid checks permissions"
26985 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26986 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26987 skip "Need MDS version at least 2.12.54"
26989 mkdir -p $DIR/$tdir
26990 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26991 createmany -o $DIR/$tdir/striped_dir/f 512
26992 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26993 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26995 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26996 sed "s/[/][^:]*://g")
26998 rm -f $DIR/$tdir/striped_dir/f1*
26999 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
27000 removed=$((512 - cnt))
27002 # few files have been just removed, so we expect
27003 # rmfid to fail on their fids
27004 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
27005 [ $removed != $errors ] && error "$errors != $removed"
27007 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
27009 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
27011 run_test 421g "rmfid to return errors properly"
27014 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
27015 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
27016 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
27017 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
27018 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
27020 local amc=$(at_max_get client)
27021 local amo=$(at_max_get mds1)
27022 local timeout=`lctl get_param -n timeout`
27024 at_max_set 0 client
27027 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
27028 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
27029 fail_val=$(((2*timeout + 10)*1000))
27030 touch $DIR/$tdir/d3/file &
27032 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
27033 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
27034 fail_val=$((2*timeout + 5))
27035 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
27039 sleep $((2 * timeout))
27043 touch $DIR/$tdir/d2/file3
27044 touch $DIR/$tdir/d2/file4
27045 touch $DIR/$tdir/d2/file5
27048 at_max_set $amc client
27049 at_max_set $amo mds1
27051 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
27052 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
27053 error "Watchdog is always throttled"
27055 run_test 422 "kill a process with RPC in progress"
27068 # ensure statfs cache is expired
27071 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
27072 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
27076 run_test 423 "statfs should return a right data"
27079 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
27080 $LCTL set_param fail_loc=0x80000522
27081 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
27084 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
27087 test_mkdir -c -1 $DIR/$tdir
27088 $LFS setstripe -c -1 $DIR/$tdir
27090 lru_resize_disable "" 100
27091 stack_trap "lru_resize_enable" EXIT
27095 for i in $(seq $((MDSCOUNT * 125))); do
27096 local t=$DIR/$tdir/$tfile_$i
27098 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
27099 error_noexit "Create file $t"
27101 stack_trap "rm -rf $DIR/$tdir" EXIT
27103 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
27104 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
27105 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
27107 [ $lock_count -le $lru_size ] ||
27108 error "osc lock count $lock_count > lru size $lru_size"
27111 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
27112 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
27113 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
27115 [ $lock_count -le $lru_size ] ||
27116 error "mdc lock count $lock_count > lru size $lru_size"
27119 run_test 425 "lock count should not exceed lru size"
27122 splice-test -r $DIR/$tfile
27123 splice-test -rd $DIR/$tfile
27124 splice-test $DIR/$tfile
27125 splice-test -d $DIR/$tfile
27127 run_test 426 "splice test on Lustre"
27130 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
27131 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
27132 skip "Need MDS version at least 2.12.4"
27138 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
27139 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
27141 $LFS getdirstripe $DIR/$tdir/1/dir
27143 #first setfattr for creating updatelog
27144 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
27146 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
27147 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
27148 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
27149 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
27153 wait_recovery_complete mds2 $((2*TIMEOUT))
27155 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
27156 echo $log | grep "get update log failed" &&
27157 error "update log corruption is detected" || true
27159 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
27162 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27163 local cache_limit=$CACHE_MAX
27165 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
27166 $LCTL set_param -n llite.*.max_cached_mb=64
27169 $LFS setstripe -c 1 $DIR/$tdir
27170 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
27171 stack_trap "rm -f $DIR/$tdir/$tfile.*"
27173 for f in $(seq 4); do
27174 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
27178 cancel_lru_locks osc
27180 for f in $(seq 4); do
27181 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
27185 run_test 428 "large block size IO should not hang"
27187 test_429() { # LU-7915 / LU-10948
27188 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
27189 local testfile=$DIR/$tfile
27190 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
27196 $LCTL get_param $ll_opencache_threshold_count ||
27197 skip "client does not have opencache parameter"
27199 set_opencache $new_flag
27200 stack_trap "restore_opencache"
27201 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
27202 error "enable opencache failed"
27204 # drop MDC DLM locks
27205 cancel_lru_locks mdc
27206 # clear MDC RPC stats counters
27207 $LCTL set_param $mdc_rpcstats=clear
27209 # According to the current implementation, we need to run 3 times
27210 # open & close file to verify if opencache is enabled correctly.
27211 # 1st, RPCs are sent for lookup/open and open handle is released on
27213 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
27214 # so open handle won't be released thereafter.
27215 # 3rd, No RPC is sent out.
27216 $MULTIOP $testfile oc || error "multiop failed"
27217 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27218 echo "1st: $first_rpc RPCs in flight"
27220 $MULTIOP $testfile oc || error "multiop failed"
27221 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27222 echo "2nd: $second_rpc RPCs in flight"
27224 $MULTIOP $testfile oc || error "multiop failed"
27225 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
27226 echo "3rd: $third_rpc RPCs in flight"
27228 #verify no MDC RPC is sent
27229 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
27231 run_test 429 "verify if opencache flag on client side does work"
27237 # data at [200K, 400K)
27238 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
27239 error "256K->512K dd fails"
27241 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
27242 error "2M->3M dd fails"
27244 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
27245 error "4M->5M dd fails"
27246 echo "Data at 256K...512K, 2M...3M and 4M...5M"
27247 # start at first component hole #1
27248 printf "Seeking hole from 1000 ... "
27249 offset=$(lseek_test -l 1000 $file)
27251 [[ $offset == 1000 ]] || error "offset $offset != 1000"
27252 printf "Seeking data from 1000 ... "
27253 offset=$(lseek_test -d 1000 $file)
27255 [[ $offset == 262144 ]] || error "offset $offset != 262144"
27257 # start at first component data block
27258 printf "Seeking hole from 300000 ... "
27259 offset=$(lseek_test -l 300000 $file)
27261 [[ $offset == 524288 ]] || error "offset $offset != 524288"
27262 printf "Seeking data from 300000 ... "
27263 offset=$(lseek_test -d 300000 $file)
27265 [[ $offset == 300000 ]] || error "offset $offset != 300000"
27267 # start at the first component but beyond end of object size
27268 printf "Seeking hole from 1000000 ... "
27269 offset=$(lseek_test -l 1000000 $file)
27271 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27272 printf "Seeking data from 1000000 ... "
27273 offset=$(lseek_test -d 1000000 $file)
27275 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27277 # start at second component stripe 2 (empty file)
27278 printf "Seeking hole from 1500000 ... "
27279 offset=$(lseek_test -l 1500000 $file)
27281 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
27282 printf "Seeking data from 1500000 ... "
27283 offset=$(lseek_test -d 1500000 $file)
27285 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
27287 # start at second component stripe 1 (all data)
27288 printf "Seeking hole from 3000000 ... "
27289 offset=$(lseek_test -l 3000000 $file)
27291 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
27292 printf "Seeking data from 3000000 ... "
27293 offset=$(lseek_test -d 3000000 $file)
27295 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
27297 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
27298 error "2nd dd fails"
27299 echo "Add data block at 640K...1280K"
27301 # start at before new data block, in hole
27302 printf "Seeking hole from 600000 ... "
27303 offset=$(lseek_test -l 600000 $file)
27305 [[ $offset == 600000 ]] || error "offset $offset != 600000"
27306 printf "Seeking data from 600000 ... "
27307 offset=$(lseek_test -d 600000 $file)
27309 [[ $offset == 655360 ]] || error "offset $offset != 655360"
27311 # start at the first component new data block
27312 printf "Seeking hole from 1000000 ... "
27313 offset=$(lseek_test -l 1000000 $file)
27315 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27316 printf "Seeking data from 1000000 ... "
27317 offset=$(lseek_test -d 1000000 $file)
27319 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27321 # start at second component stripe 2, new data
27322 printf "Seeking hole from 1200000 ... "
27323 offset=$(lseek_test -l 1200000 $file)
27325 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
27326 printf "Seeking data from 1200000 ... "
27327 offset=$(lseek_test -d 1200000 $file)
27329 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
27331 # start beyond file end
27332 printf "Using offset > filesize ... "
27333 lseek_test -l 4000000 $file && error "lseek should fail"
27334 printf "Using offset > filesize ... "
27335 lseek_test -d 4000000 $file && error "lseek should fail"
27341 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
27342 skip "MDT does not support SEEK_HOLE"
27344 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27345 skip "OST does not support SEEK_HOLE"
27347 local file=$DIR/$tdir/$tfile
27349 mkdir -p $DIR/$tdir
27351 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
27352 # OST stripe #1 will have continuous data at [1M, 3M)
27353 # OST stripe #2 is empty
27354 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
27355 lseek_test_430 $file
27357 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
27358 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
27359 lseek_test_430 $file
27361 $LFS setstripe -c2 -S 512K $file
27362 echo "Two stripes, stripe size 512K"
27363 lseek_test_430 $file
27365 # FLR with stale mirror
27366 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
27368 echo "Mirrored file:"
27369 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
27370 echo "Plain 2 stripes 1M"
27371 lseek_test_430 $file
27374 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
27377 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27378 skip "OST does not support SEEK_HOLE"
27381 local file=$DIR/$tdir/$tfile
27383 mkdir -p $DIR/$tdir
27384 # Empty layout lseek should fail
27387 printf "Seeking hole from 0 ... "
27388 lseek_test -l 0 $file && error "lseek should fail"
27389 printf "Seeking data from 0 ... "
27390 lseek_test -d 0 $file && error "lseek should fail"
27394 $LFS setstripe -E 1M -c2 -E eof $file
27395 $TRUNCATE $file 1048576
27396 printf "Seeking hole from 1000000 ... "
27397 offset=$(lseek_test -l 1000000 $file)
27399 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27400 printf "Seeking data from 1000000 ... "
27401 lseek_test -d 1000000 $file && error "lseek should fail"
27404 # full component followed by non-inited one
27405 $LFS setstripe -E 1M -c2 -E eof $file
27406 dd if=/dev/urandom of=$file bs=1M count=1
27407 printf "Seeking hole from 1000000 ... "
27408 offset=$(lseek_test -l 1000000 $file)
27410 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27411 printf "Seeking hole from 1048576 ... "
27412 lseek_test -l 1048576 $file && error "lseek should fail"
27413 # init second component and truncate back
27414 echo "123" >> $file
27415 $TRUNCATE $file 1048576
27416 printf "Seeking hole from 1000000 ... "
27417 offset=$(lseek_test -l 1000000 $file)
27419 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27420 printf "Seeking hole from 1048576 ... "
27421 lseek_test -l 1048576 $file && error "lseek should fail"
27422 # boundary checks for big values
27423 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
27424 offset=$(lseek_test -d 0 $file.10g)
27425 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
27426 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
27427 offset=$(lseek_test -d 0 $file.100g)
27428 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
27431 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
27434 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27435 skip "OST does not support SEEK_HOLE"
27437 local file=$DIR/$tdir/$tfile
27440 mkdir -p $DIR/$tdir
27441 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
27443 # cp version 8.33+ prefers lseek over fiemap
27444 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
27446 time cp $file /dev/null
27447 (( SECONDS - start < 5 )) ||
27448 error "cp: too long runtime $((SECONDS - start))"
27451 # tar version 1.29+ supports SEEK_HOLE/DATA
27452 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
27454 time tar cS $file - | cat > /dev/null
27455 (( SECONDS - start < 5 )) ||
27456 error "tar: too long runtime $((SECONDS - start))"
27459 run_test 430c "lseek: external tools check"
27461 test_431() { # LU-14187
27462 local file=$DIR/$tdir/$tfile
27464 mkdir -p $DIR/$tdir
27465 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
27466 dd if=/dev/urandom of=$file bs=4k count=1
27467 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
27468 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
27469 #define OBD_FAIL_OST_RESTART_IO 0x251
27470 do_facet ost1 "$LCTL set_param fail_loc=0x251"
27471 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
27475 echo 3 > /proc/sys/vm/drop_caches
27476 diff $file $file.0 || error "data diff"
27478 run_test 431 "Restart transaction for IO"
27480 cleanup_test_432() {
27481 do_facet mgs $LCTL nodemap_activate 0
27482 wait_nm_sync active
27486 local tmpdir=$TMP/dir432
27488 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
27489 skip "Need MDS version at least 2.14.52"
27491 stack_trap cleanup_test_432 EXIT
27495 do_facet mgs $LCTL nodemap_activate 1
27496 wait_nm_sync active
27497 do_facet mgs $LCTL nodemap_modify --name default \
27498 --property admin --value 1
27499 do_facet mgs $LCTL nodemap_modify --name default \
27500 --property trusted --value 1
27501 cancel_lru_locks mdc
27502 wait_nm_sync default admin_nodemap
27503 wait_nm_sync default trusted_nodemap
27505 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
27506 grep -ci "Operation not permitted") -ne 0 ]; then
27507 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
27510 run_test 432 "mv dir from outside Lustre"
27513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27515 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
27516 skip "inode cache not supported"
27518 $LCTL set_param llite.*.inode_cache=0
27519 stack_trap "$LCTL set_param llite.*.inode_cache=1"
27525 cancel_lru_locks mdc
27526 test_mkdir $DIR/$tdir || error "mkdir $tdir"
27527 createmany -m $DIR/$tdir/f $count
27528 createmany -d $DIR/$tdir/d $count
27529 ls -l $DIR/$tdir > /dev/null
27530 stack_trap "rm -rf $DIR/$tdir"
27532 before=$(num_objects)
27533 cancel_lru_locks mdc
27534 after=$(num_objects)
27536 # sometimes even @before is less than 2 * count
27537 while (( before - after < count )); do
27539 after=$(num_objects)
27541 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
27542 if (( wait > 60 )); then
27543 error "inode slab grew from $before to $after"
27547 echo "lustre_inode_cache $before objs before lock cancel, $after after"
27549 run_test 433 "ldlm lock cancel releases dentries and inodes"
27552 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27553 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27554 skip "Need server version at least 2.9.55"
27556 start_full_debug_logging
27560 stop_full_debug_logging
27564 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27565 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27566 awk '/The barrier for/ { print $7 }')
27569 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
27574 barrier_expired() {
27577 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27578 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27579 awk '/will be expired/ { print $7 }')
27581 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
27590 echo "Start barrier_freeze at: $(date)"
27591 #define OBD_FAIL_BARRIER_DELAY 0x2202
27592 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27593 # Do not reduce barrier time - See LU-11873
27594 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
27597 local b_status=$(barrier_stat)
27598 echo "Got barrier status at: $(date)"
27599 [ "$b_status" = "'freezing_p1'" ] ||
27600 error "(1) unexpected barrier status $b_status"
27602 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27604 b_status=$(barrier_stat)
27605 [ "$b_status" = "'frozen'" ] ||
27606 error "(2) unexpected barrier status $b_status"
27608 local expired=$(barrier_expired)
27609 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
27610 sleep $((expired + 3))
27612 b_status=$(barrier_stat)
27613 [ "$b_status" = "'expired'" ] ||
27614 error "(3) unexpected barrier status $b_status"
27616 # Do not reduce barrier time - See LU-11873
27617 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
27618 error "(4) fail to freeze barrier"
27620 b_status=$(barrier_stat)
27621 [ "$b_status" = "'frozen'" ] ||
27622 error "(5) unexpected barrier status $b_status"
27624 echo "Start barrier_thaw at: $(date)"
27625 #define OBD_FAIL_BARRIER_DELAY 0x2202
27626 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27627 do_facet mgs $LCTL barrier_thaw $FSNAME &
27630 b_status=$(barrier_stat)
27631 echo "Got barrier status at: $(date)"
27632 [ "$b_status" = "'thawing'" ] ||
27633 error "(6) unexpected barrier status $b_status"
27635 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27637 b_status=$(barrier_stat)
27638 [ "$b_status" = "'thawed'" ] ||
27639 error "(7) unexpected barrier status $b_status"
27641 #define OBD_FAIL_BARRIER_FAILURE 0x2203
27642 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
27643 do_facet mgs $LCTL barrier_freeze $FSNAME
27645 b_status=$(barrier_stat)
27646 [ "$b_status" = "'failed'" ] ||
27647 error "(8) unexpected barrier status $b_status"
27649 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
27650 do_facet mgs $LCTL barrier_thaw $FSNAME
27654 run_test 801a "write barrier user interfaces and stat machine"
27659 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27660 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
27661 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
27662 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
27663 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
27665 cancel_lru_locks mdc
27667 # 180 seconds should be long enough
27668 do_facet mgs $LCTL barrier_freeze $FSNAME 180
27670 local b_status=$(barrier_stat)
27671 [ "$b_status" = "'frozen'" ] ||
27672 error "(6) unexpected barrier status $b_status"
27674 mkdir $DIR/$tdir/d0/d10 &
27677 touch $DIR/$tdir/d1/f13 &
27680 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
27683 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
27686 rm -f $DIR/$tdir/d4/f12 &
27689 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
27691 # To guarantee taht the 'stat' is not blocked
27692 b_status=$(barrier_stat)
27693 [ "$b_status" = "'frozen'" ] ||
27694 error "(8) unexpected barrier status $b_status"
27696 # let above commands to run at background
27699 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
27700 ps -p $touch_pid || error "(10) touch should be blocked"
27701 ps -p $ln_pid || error "(11) link should be blocked"
27702 ps -p $mv_pid || error "(12) rename should be blocked"
27703 ps -p $rm_pid || error "(13) unlink should be blocked"
27705 b_status=$(barrier_stat)
27706 [ "$b_status" = "'frozen'" ] ||
27707 error "(14) unexpected barrier status $b_status"
27709 do_facet mgs $LCTL barrier_thaw $FSNAME
27710 b_status=$(barrier_stat)
27711 [ "$b_status" = "'thawed'" ] ||
27712 error "(15) unexpected barrier status $b_status"
27714 wait $mkdir_pid || error "(16) mkdir should succeed"
27715 wait $touch_pid || error "(17) touch should succeed"
27716 wait $ln_pid || error "(18) link should succeed"
27717 wait $mv_pid || error "(19) rename should succeed"
27718 wait $rm_pid || error "(20) unlink should succeed"
27722 run_test 801b "modification will be blocked by write barrier"
27725 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27729 stop mds2 || error "(1) Fail to stop mds2"
27731 do_facet mgs $LCTL barrier_freeze $FSNAME 30
27733 local b_status=$(barrier_stat)
27734 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
27735 do_facet mgs $LCTL barrier_thaw $FSNAME
27736 error "(2) unexpected barrier status $b_status"
27739 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27740 error "(3) Fail to rescan barrier bitmap"
27742 # Do not reduce barrier time - See LU-11873
27743 do_facet mgs $LCTL barrier_freeze $FSNAME 20
27745 b_status=$(barrier_stat)
27746 [ "$b_status" = "'frozen'" ] ||
27747 error "(4) unexpected barrier status $b_status"
27749 do_facet mgs $LCTL barrier_thaw $FSNAME
27750 b_status=$(barrier_stat)
27751 [ "$b_status" = "'thawed'" ] ||
27752 error "(5) unexpected barrier status $b_status"
27754 local devname=$(mdsdevname 2)
27756 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
27758 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27759 error "(7) Fail to rescan barrier bitmap"
27763 run_test 801c "rescan barrier bitmap"
27765 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
27766 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
27767 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
27768 saved_MOUNT_OPTS=$MOUNT_OPTS
27774 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
27775 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
27776 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
27777 MOUNT_OPTS=$saved_MOUNT_OPTS
27782 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
27783 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27784 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27785 skip "Need server version at least 2.9.55"
27787 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
27789 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27791 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27792 error "(2) Fail to copy"
27794 trap cleanup_802a EXIT
27796 # sync by force before remount as readonly
27797 sync; sync_all_data; sleep 3; sync_all_data
27801 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
27802 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
27803 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
27805 echo "Mount the server as read only"
27806 setupall server_only || error "(3) Fail to start servers"
27808 echo "Mount client without ro should fail"
27809 mount_client $MOUNT &&
27810 error "(4) Mount client without 'ro' should fail"
27812 echo "Mount client with ro should succeed"
27813 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
27814 mount_client $MOUNT ||
27815 error "(5) Mount client with 'ro' should succeed"
27817 echo "Modify should be refused"
27818 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27820 echo "Read should be allowed"
27821 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27822 error "(7) Read should succeed under ro mode"
27826 run_test 802a "simulate readonly device"
27829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27830 remote_mds_nodsh && skip "remote MDS with nodsh"
27832 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
27833 skip "readonly option not available"
27835 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
27837 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27838 error "(2) Fail to copy"
27840 # write back all cached data before setting MDT to readonly
27844 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
27845 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
27847 echo "Modify should be refused"
27848 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27850 echo "Read should be allowed"
27851 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27852 error "(7) Read should succeed under ro mode"
27855 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
27857 run_test 802b "be able to set MDTs to readonly"
27860 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27861 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27862 skip "MDS needs to be newer than 2.10.54"
27864 mkdir_on_mdt0 $DIR/$tdir
27865 # Create some objects on all MDTs to trigger related logs objects
27866 for idx in $(seq $MDSCOUNT); do
27867 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
27868 $DIR/$tdir/dir${idx} ||
27869 error "Fail to create $DIR/$tdir/dir${idx}"
27872 wait_delete_completed # ensure old test cleanups are finished
27874 echo "before create:"
27876 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27878 for i in {1..10}; do
27879 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
27880 error "Fail to create $DIR/$tdir/foo$i"
27883 # sync ZFS-on-MDS to refresh statfs data
27884 wait_zfs_commit mds1
27886 echo "after create:"
27888 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27890 # allow for an llog to be cleaned up during the test
27891 [ $after_used -ge $((before_used + 10 - 1)) ] ||
27892 error "before ($before_used) + 10 > after ($after_used)"
27894 for i in {1..10}; do
27895 rm -rf $DIR/$tdir/foo$i ||
27896 error "Fail to remove $DIR/$tdir/foo$i"
27899 # sync ZFS-on-MDS to refresh statfs data
27900 wait_zfs_commit mds1
27901 wait_delete_completed
27902 sleep 3 # avoid MDT return cached statfs
27903 echo "after unlink:"
27905 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27907 # allow for an llog to be created during the test
27908 [ $after_used -le $((before_used + 1)) ] ||
27909 error "after ($after_used) > before ($before_used) + 1"
27911 run_test 803a "verify agent object for remote object"
27914 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27915 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
27916 skip "MDS needs to be newer than 2.13.56"
27917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27919 for i in $(seq 0 $((MDSCOUNT - 1))); do
27920 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
27928 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27929 for i in $(seq 0 $((MDSCOUNT - 1))); do
27930 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27931 awk '/getattr/ { print $2 }')
27932 before=$((before + tmp))
27934 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27935 for i in $(seq 0 $((MDSCOUNT - 1))); do
27936 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27937 awk '/getattr/ { print $2 }')
27938 after=$((after + tmp))
27941 [ $before -eq $after ] || error "getattr count $before != $after"
27943 run_test 803b "remote object can getattr from cache"
27946 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27947 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27948 skip "MDS needs to be newer than 2.10.54"
27949 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
27951 mkdir -p $DIR/$tdir
27952 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
27953 error "Fail to create $DIR/$tdir/dir0"
27955 local fid=$($LFS path2fid $DIR/$tdir/dir0)
27956 local dev=$(mdsdevname 2)
27958 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27959 grep ${fid} || error "NOT found agent entry for dir0"
27961 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
27962 error "Fail to create $DIR/$tdir/dir1"
27964 touch $DIR/$tdir/dir1/foo0 ||
27965 error "Fail to create $DIR/$tdir/dir1/foo0"
27966 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
27969 for idx in $(seq $MDSCOUNT); do
27970 dev=$(mdsdevname $idx)
27971 do_facet mds${idx} \
27972 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27973 grep ${fid} && rc=$idx
27976 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
27977 error "Fail to rename foo0 to foo1"
27978 if [ $rc -eq 0 ]; then
27979 for idx in $(seq $MDSCOUNT); do
27980 dev=$(mdsdevname $idx)
27981 do_facet mds${idx} \
27982 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27983 grep ${fid} && rc=$idx
27987 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
27988 error "Fail to rename foo1 to foo2"
27989 if [ $rc -eq 0 ]; then
27990 for idx in $(seq $MDSCOUNT); do
27991 dev=$(mdsdevname $idx)
27992 do_facet mds${idx} \
27993 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27994 grep ${fid} && rc=$idx
27998 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
28000 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
28001 error "Fail to link to $DIR/$tdir/dir1/foo2"
28002 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
28003 error "Fail to rename foo2 to foo0"
28004 unlink $DIR/$tdir/dir1/foo0 ||
28005 error "Fail to unlink $DIR/$tdir/dir1/foo0"
28006 rm -rf $DIR/$tdir/dir0 ||
28007 error "Fail to rm $DIR/$tdir/dir0"
28009 for idx in $(seq $MDSCOUNT); do
28013 dev=$(mdsdevname $idx)
28014 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
28016 start mds${idx} $dev $MDS_MOUNT_OPTS ||
28017 error "mount mds$idx failed"
28018 df $MOUNT > /dev/null 2>&1
28020 # e2fsck should not return error
28022 error "e2fsck detected error on MDT${idx}: rc=$rc"
28025 run_test 804 "verify agent entry for remote entry"
28028 do_facet $SINGLEMDS zfs set quota=$old $fsset
28029 unlinkmany $DIR/$tdir/f- 1000000
28034 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
28035 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
28036 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
28037 skip "netfree not implemented before 0.7"
28038 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
28039 skip "Need MDS version at least 2.10.57"
28046 local pref="osd-zfs.$FSNAME-MDT0000."
28048 # limit available space on MDS dataset to meet nospace issue
28049 # quickly. then ZFS 0.7.2 can use reserved space if asked
28050 # properly (using netfree flag in osd_declare_destroy()
28051 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
28052 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
28054 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
28055 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
28056 let "usedkb=usedkb-freekb"
28057 let "freekb=freekb/2"
28058 if let "freekb > 5000"; then
28061 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
28062 trap cleanup_805 EXIT
28063 mkdir_on_mdt0 $DIR/$tdir
28064 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
28065 error "Can't set PFL layout"
28066 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
28067 rm -rf $DIR/$tdir || error "not able to remove"
28068 do_facet $SINGLEMDS zfs set quota=$old $fsset
28071 run_test 805 "ZFS can remove from full fs"
28077 local expect=$(stat -c %s $file)
28079 check_lsom_size $1 $expect
28081 local blocks=$($LFS getsom -b $file)
28082 expect=$(stat -c %b $file)
28083 [[ $blocks == $expect ]] ||
28084 error "$file expected blocks: $expect, got: $blocks"
28092 cancel_lru_locks mdc
28094 size=$($LFS getsom -s $1)
28095 [[ $size == $expect ]] ||
28096 error "$file expected size: $expect, got: $size"
28100 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28101 skip "Need MDS version at least 2.11.52"
28105 touch $DIR/$tfile || error "touch $tfile failed"
28107 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
28108 save_lustre_params client "llite.*.xattr_cache" > $save
28109 lctl set_param llite.*.xattr_cache=0
28110 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
28112 # single-threaded write
28113 echo "Test SOM for single-threaded write"
28114 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
28115 error "write $tfile failed"
28116 check_lsom_size $DIR/$tfile $bs
28119 local size=$(($num * $bs))
28123 echo "Test SOM for single client multi-threaded($num) write"
28124 $TRUNCATE $DIR/$tfile 0
28125 for ((i = 0; i < $num; i++)); do
28126 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28128 offset=$((offset + $bs))
28130 for (( i=0; i < $num; i++ )); do
28133 check_lsom_size $DIR/$tfile $size
28135 $TRUNCATE $DIR/$tfile 0
28136 for ((i = 0; i < $num; i++)); do
28137 offset=$((offset - $bs))
28138 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28141 for (( i=0; i < $num; i++ )); do
28144 check_lsom_size $DIR/$tfile $size
28146 # multi-client writes
28147 num=$(get_node_count ${CLIENTS//,/ })
28148 size=$(($num * $bs))
28152 echo "Test SOM for multi-client ($num) writes"
28153 $TRUNCATE $DIR/$tfile 0
28154 for client in ${CLIENTS//,/ }; do
28155 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28158 offset=$((offset + $bs))
28160 for (( i=0; i < $num; i++ )); do
28163 check_lsom_size $DIR/$tfile $offset
28166 $TRUNCATE $DIR/$tfile 0
28167 for client in ${CLIENTS//,/ }; do
28168 offset=$((offset - $bs))
28169 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28173 for (( i=0; i < $num; i++ )); do
28176 check_lsom_size $DIR/$tfile $size
28179 echo "Test SOM for truncate"
28180 $TRUNCATE $DIR/$tfile 1048576
28181 check_lsom_size $DIR/$tfile 1048576
28182 $TRUNCATE $DIR/$tfile 1234
28183 check_lsom_size $DIR/$tfile 1234
28185 # verify SOM blocks count
28186 echo "Verify SOM block count"
28187 $TRUNCATE $DIR/$tfile 0
28188 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
28189 error "failed to write file $tfile"
28190 check_lsom_data $DIR/$tfile
28192 run_test 806 "Verify Lazy Size on MDS"
28195 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
28196 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
28197 skip "Need MDS version at least 2.11.52"
28199 # Registration step
28200 changelog_register || error "changelog_register failed"
28201 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
28202 changelog_users $SINGLEMDS | grep -q $cl_user ||
28203 error "User $cl_user not found in changelog_users"
28205 rm -rf $DIR/$tdir || error "rm $tdir failed"
28206 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
28207 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
28208 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
28209 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
28210 error "truncate $tdir/trunc failed"
28213 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
28214 error "write $tfile failed"
28216 # multi-client wirtes
28217 local num=$(get_node_count ${CLIENTS//,/ })
28221 echo "Test SOM for multi-client ($num) writes"
28222 touch $DIR/$tfile || error "touch $tfile failed"
28223 $TRUNCATE $DIR/$tfile 0
28224 for client in ${CLIENTS//,/ }; do
28225 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
28228 offset=$((offset + $bs))
28230 for (( i=0; i < $num; i++ )); do
28234 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
28235 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
28236 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
28237 check_lsom_data $DIR/$tdir/trunc
28238 check_lsom_data $DIR/$tdir/single_dd
28239 check_lsom_data $DIR/$tfile
28242 # Deregistration step
28243 changelog_deregister || error "changelog_deregister failed"
28245 run_test 807 "verify LSOM syncing tool"
28247 check_som_nologged()
28249 local lines=$($LFS changelog $FSNAME-MDT0000 |
28250 grep 'x=trusted.som' | wc -l)
28251 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
28255 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28256 skip "Need MDS version at least 2.11.55"
28258 # Registration step
28259 changelog_register || error "changelog_register failed"
28261 touch $DIR/$tfile || error "touch $tfile failed"
28264 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
28265 error "write $tfile failed"
28268 $TRUNCATE $DIR/$tfile 1234
28271 $TRUNCATE $DIR/$tfile 1048576
28274 # Deregistration step
28275 changelog_deregister || error "changelog_deregister failed"
28277 run_test 808 "Check trusted.som xattr not logged in Changelogs"
28282 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
28286 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
28287 skip "Need MDS version at least 2.11.56"
28289 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
28290 error "failed to create DoM-only file $DIR/$tfile"
28291 touch $DIR/$tfile || error "touch $tfile failed"
28292 check_som_nodata $DIR/$tfile
28294 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
28295 error "write $tfile failed"
28296 check_som_nodata $DIR/$tfile
28298 $TRUNCATE $DIR/$tfile 1234
28299 check_som_nodata $DIR/$tfile
28301 $TRUNCATE $DIR/$tfile 4097
28302 check_som_nodata $DIR/$file
28304 run_test 809 "Verify no SOM xattr store for DoM-only files"
28307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28308 $GSS && skip_env "could not run with gss"
28309 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
28310 skip "OST < 2.12.58 doesn't align checksum"
28313 stack_trap "set_checksums $ORIG_CSUM" EXIT
28314 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
28319 for csum in $CKSUM_TYPES; do
28320 #define OBD_FAIL_OSC_NO_GRANT 0x411
28321 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
28322 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
28324 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
28325 before=$(md5sum $DIR/$tfile)
28326 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
28327 after=$(md5sum $DIR/$tfile)
28328 [ "$before" == "$after" ] ||
28329 error "$csum: $before != $after bs=$1 seek=$2"
28333 run_test 810 "partial page writes on ZFS (LU-11663)"
28336 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28337 skip "OST < 2.12.51 doesn't support this fail_loc"
28339 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28340 # ensure ost1 is connected
28341 stat $DIR/$tfile >/dev/null || error "can't stat"
28342 wait_osc_import_state client ost1 FULL
28343 # no locks, no reqs to let the connection idle
28344 cancel_lru_locks osc
28346 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28347 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28348 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28349 wait_osc_import_state client ost1 CONNECTING
28350 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28352 stat $DIR/$tfile >/dev/null || error "can't stat file"
28354 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
28356 test_812b() { # LU-12378
28357 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
28358 skip "OST < 2.12.51 doesn't support this fail_loc"
28360 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
28361 # ensure ost1 is connected
28362 stat $DIR/$tfile >/dev/null || error "can't stat"
28363 wait_osc_import_state client ost1 FULL
28364 # no locks, no reqs to let the connection idle
28365 cancel_lru_locks osc
28367 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
28368 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
28369 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
28370 wait_osc_import_state client ost1 CONNECTING
28371 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
28373 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
28374 wait_osc_import_state client ost1 IDLE
28376 run_test 812b "do not drop no resend request for idle connect"
28381 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
28383 $LFS setstripe -c 1 -o 0 $DIR/$tfile
28384 $LFS getstripe $DIR/$tfile
28385 $LCTL set_param osc.*.idle_timeout=10
28386 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
28387 # ensure ost1 is connected
28388 stat $DIR/$tfile >/dev/null || error "can't stat"
28389 wait_osc_import_state client ost1 FULL
28390 # no locks, no reqs to let the connection idle
28391 cancel_lru_locks osc
28393 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
28394 $LCTL set_param fail_loc=0x80000533
28396 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
28398 run_test 812c "idle import vs lock enqueue race"
28401 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
28402 [ -z "$file_heat_sav" ] && skip "no file heat support"
28413 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
28414 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
28416 $LCTL set_param -n llite.*.file_heat=1
28417 echo "Turn on file heat"
28418 echo "Period second: $period_second, Decay percentage: $decay_pct"
28420 echo "QQQQ" > $DIR/$tfile
28421 echo "QQQQ" > $DIR/$tfile
28422 echo "QQQQ" > $DIR/$tfile
28423 cat $DIR/$tfile > /dev/null
28424 cat $DIR/$tfile > /dev/null
28425 cat $DIR/$tfile > /dev/null
28426 cat $DIR/$tfile > /dev/null
28428 local out=$($LFS heat_get $DIR/$tfile)
28430 $LFS heat_get $DIR/$tfile
28431 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28432 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28433 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28434 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28436 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
28437 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
28438 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
28439 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
28441 sleep $((period_second + 3))
28442 echo "Sleep $((period_second + 3)) seconds..."
28443 # The recursion formula to calculate the heat of the file f is as
28445 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
28446 # Where Hi is the heat value in the period between time points i*I and
28447 # (i+1)*I; Ci is the access count in the period; the symbol P refers
28448 # to the weight of Ci.
28449 out=$($LFS heat_get $DIR/$tfile)
28450 $LFS heat_get $DIR/$tfile
28451 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28452 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28453 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28454 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28456 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
28457 error "read sample ($readsample) is wrong"
28458 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
28459 error "write sample ($writesample) is wrong"
28460 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
28461 error "read bytes ($readbyte) is wrong"
28462 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
28463 error "write bytes ($writebyte) is wrong"
28465 echo "QQQQ" > $DIR/$tfile
28466 echo "QQQQ" > $DIR/$tfile
28467 echo "QQQQ" > $DIR/$tfile
28468 cat $DIR/$tfile > /dev/null
28469 cat $DIR/$tfile > /dev/null
28470 cat $DIR/$tfile > /dev/null
28471 cat $DIR/$tfile > /dev/null
28473 sleep $((period_second + 3))
28474 echo "Sleep $((period_second + 3)) seconds..."
28476 out=$($LFS heat_get $DIR/$tfile)
28477 $LFS heat_get $DIR/$tfile
28478 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28479 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28480 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28481 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28483 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
28484 4 * $decay_pct) / 100") -eq 1 ] ||
28485 error "read sample ($readsample1) is wrong"
28486 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
28487 3 * $decay_pct) / 100") -eq 1 ] ||
28488 error "write sample ($writesample1) is wrong"
28489 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
28490 20 * $decay_pct) / 100") -eq 1 ] ||
28491 error "read bytes ($readbyte1) is wrong"
28492 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
28493 15 * $decay_pct) / 100") -eq 1 ] ||
28494 error "write bytes ($writebyte1) is wrong"
28496 echo "Turn off file heat for the file $DIR/$tfile"
28497 $LFS heat_set -o $DIR/$tfile
28499 echo "QQQQ" > $DIR/$tfile
28500 echo "QQQQ" > $DIR/$tfile
28501 echo "QQQQ" > $DIR/$tfile
28502 cat $DIR/$tfile > /dev/null
28503 cat $DIR/$tfile > /dev/null
28504 cat $DIR/$tfile > /dev/null
28505 cat $DIR/$tfile > /dev/null
28507 out=$($LFS heat_get $DIR/$tfile)
28508 $LFS heat_get $DIR/$tfile
28509 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28510 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28511 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28512 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28514 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28515 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28516 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28517 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28519 echo "Trun on file heat for the file $DIR/$tfile"
28520 $LFS heat_set -O $DIR/$tfile
28522 echo "QQQQ" > $DIR/$tfile
28523 echo "QQQQ" > $DIR/$tfile
28524 echo "QQQQ" > $DIR/$tfile
28525 cat $DIR/$tfile > /dev/null
28526 cat $DIR/$tfile > /dev/null
28527 cat $DIR/$tfile > /dev/null
28528 cat $DIR/$tfile > /dev/null
28530 out=$($LFS heat_get $DIR/$tfile)
28531 $LFS heat_get $DIR/$tfile
28532 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28533 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28534 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28535 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28537 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
28538 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
28539 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
28540 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
28542 $LFS heat_set -c $DIR/$tfile
28543 $LCTL set_param -n llite.*.file_heat=0
28544 echo "Turn off file heat support for the Lustre filesystem"
28546 echo "QQQQ" > $DIR/$tfile
28547 echo "QQQQ" > $DIR/$tfile
28548 echo "QQQQ" > $DIR/$tfile
28549 cat $DIR/$tfile > /dev/null
28550 cat $DIR/$tfile > /dev/null
28551 cat $DIR/$tfile > /dev/null
28552 cat $DIR/$tfile > /dev/null
28554 out=$($LFS heat_get $DIR/$tfile)
28555 $LFS heat_get $DIR/$tfile
28556 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28557 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28558 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28559 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28561 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28562 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28563 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28564 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28566 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
28569 run_test 813 "File heat verfication"
28573 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
28574 echo -n y >> $DIR/$tfile
28575 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
28576 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
28578 run_test 814 "sparse cp works as expected (LU-12361)"
28582 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
28583 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
28585 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
28588 local ost1_imp=$(get_osc_import_name client ost1)
28589 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
28592 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28593 # ensure ost1 is connected
28595 stat $DIR/$tfile >/dev/null || error "can't stat"
28596 wait_osc_import_state client ost1 FULL
28597 # no locks, no reqs to let the connection idle
28598 cancel_lru_locks osc
28599 lru_resize_disable osc
28602 before=$($LCTL get_param -n \
28603 ldlm.namespaces.$imp_name.lru_size)
28605 wait_osc_import_state client ost1 IDLE
28606 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
28607 now=$($LCTL get_param -n \
28608 ldlm.namespaces.$imp_name.lru_size)
28609 [ $before == $now ] || error "lru_size changed $before != $now"
28611 run_test 816 "do not reset lru_resize on idle reconnect"
28615 exportfs -u localhost:$DIR/nfsexp
28620 systemctl restart nfs-server.service || skip "failed to restart nfsd"
28622 mkdir -p $DIR/nfsexp
28623 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
28624 error "failed to export nfs"
28626 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
28627 stack_trap cleanup_817 EXIT
28629 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
28630 error "failed to mount nfs to $tmpdir"
28632 cp /bin/true $tmpdir
28633 $DIR/nfsexp/true || error "failed to execute 'true' command"
28635 run_test 817 "nfsd won't cache write lock for exec file"
28638 test_mkdir -i0 -c1 $DIR/$tdir
28639 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
28640 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
28643 # restore osp-syn threads
28644 stack_trap "fail $SINGLEMDS"
28646 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
28647 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
28648 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
28649 error "start $SINGLEMDS failed"
28652 local testid=$(echo $TESTNAME | tr '_' ' ')
28654 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
28655 grep "run LFSCK" || error "run LFSCK is not suggested"
28657 run_test 818 "unlink with failed llog"
28660 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28661 cancel_lru_locks osc
28662 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28663 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28664 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
28667 run_test 819a "too big niobuf in read"
28670 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28671 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28672 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28673 cancel_lru_locks osc
28677 run_test 819b "too big niobuf in write"
28680 function test_820_start_ost() {
28683 for num in $(seq $OSTCOUNT); do
28684 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
28689 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28692 umount_client $MOUNT || error "umount failed"
28693 for num in $(seq $OSTCOUNT); do
28697 # mount client with no active OSTs
28698 # so that the client can't initialize max LOV EA size
28699 # from OSC notifications
28700 mount_client $MOUNT || error "mount failed"
28701 # delay OST starting to keep this 0 max EA size for a while
28702 test_820_start_ost &
28704 # create a directory on MDS2
28705 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
28706 error "Failed to create directory"
28707 # open intent should update default EA size
28708 # see mdc_update_max_ea_from_body()
28709 # notice this is the very first RPC to MDS2
28710 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
28713 # With SSK, this situation can lead to -EPERM being returned.
28714 # In that case, simply retry.
28715 if [ $ret -ne 0 ] && $SHARED_KEY; then
28716 if echo "$out" | grep -q "not permitted"; then
28717 cp /etc/services $DIR/$tdir/mds2
28721 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
28723 run_test 820 "update max EA from open intent"
28726 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28727 local OST_MAX_PRECREATE=20000
28729 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
28730 skip "Need MDS version at least 2.14.56"
28732 save_lustre_params mds1 \
28733 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28734 do_facet $SINGLEMDS "$LCTL set_param -n \
28735 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28736 do_facet $SINGLEMDS "$LCTL set_param -n \
28737 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
28739 stack_trap "restore_lustre_params < $p; rm $p"
28741 do_facet $SINGLEMDS "$LCTL set_param -n \
28742 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
28744 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28745 osp.$FSNAME-OST0000*MDT0000.create_count")
28746 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28747 osp.$FSNAME-OST0000*MDT0000.max_create_count")
28748 local expect_count=$(((($max/2)/256) * 256))
28750 log "setting create_count to 100200:"
28751 log " -result- count: $count with max: $max, expecting: $expect_count"
28753 [[ $count -eq expect_count ]] ||
28754 error "Create count not set to max precreate."
28756 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
28759 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
28760 skip "Need MDS version 2.14.56"
28762 local sync_changes=$(do_facet $SINGLEMDS \
28763 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28765 [ "$sync_changes" -gt 100 ] &&
28766 skip "Sync changes $sync_changes > 100 already"
28768 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28770 $LFS mkdir -i 0 $DIR/$tdir
28771 $LFS setstripe -c 1 -i 0 $DIR/$tdir
28773 save_lustre_params mds1 \
28774 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
28775 save_lustre_params mds1 \
28776 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
28778 do_facet mds1 "$LCTL set_param -n \
28779 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
28780 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
28781 stack_trap "restore_lustre_params < $p" EXIT
28783 createmany -o $DIR/$tdir/f- 1000
28784 unlinkmany $DIR/$tdir/f- 1000 &
28785 local UNLINK_PID=$!
28788 sync_changes=$(do_facet mds1 \
28789 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28790 # the check in the code is racy, fail the test
28791 # if the value above the limit by 10.
28792 [ $sync_changes -gt 110 ] && {
28793 kill -2 $UNLINK_PID
28795 error "osp changes throttling failed, $sync_changes>110"
28797 kill -0 $UNLINK_PID 2> /dev/null || break
28801 run_test 831 "throttling unlink/setattr queuing on OSP"
28804 # tests that do cleanup/setup should be run at the end
28808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28811 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
28812 $LCTL set_param fail_loc=0x903
28814 cancel_lru_locks MGC
28816 FAIL_ON_ERROR=true cleanup
28817 FAIL_ON_ERROR=true setup
28819 run_test 900 "umount should not race with any mgc requeue thread"
28821 # LUS-6253/LU-11185
28829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28831 # some get_param have a bug to handle dot in param name
28832 cancel_lru_locks MGC
28833 old=$(mount -t lustre | wc -l)
28841 while [ $old -ne $oldc ]; do
28842 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28845 if [ $count -ge $TIMEOUT ]; then
28846 error "too large timeout"
28849 umount_client $MOUNT || error "umount failed"
28850 mount_client $MOUNT || error "mount failed"
28851 cancel_lru_locks MGC
28852 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28854 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
28858 run_test 901 "don't leak a mgc lock on client umount"
28862 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
28863 skip "client does not have LU-13377 fix"
28864 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
28865 $LCTL set_param fail_loc=0x1415
28866 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28867 cancel_lru_locks osc
28870 run_test 902 "test short write doesn't hang lustre"
28874 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
28875 echo "blah" > $DIR/${tfile}-2
28876 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
28877 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
28878 $LCTL set_param fail_loc=0x417 fail_val=20
28880 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
28881 sleep 1 # To start the destroy
28882 wait_destroy_complete 150 || error "Destroy taking too long"
28883 cat $DIR/$tfile > /dev/null || error "Evicted"
28885 run_test 903 "Test long page discard does not cause evictions"
28888 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
28889 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
28890 grep -q project || skip "skip project quota not supported"
28892 local testfile="$DIR/$tdir/$tfile"
28893 local xattr="trusted.projid"
28895 local mdts=$(comma_list $(mdts_nodes))
28896 local saved=$(do_facet mds1 $LCTL get_param -n \
28897 osd-ldiskfs.*MDT0000.enable_projid_xattr)
28899 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
28900 stack_trap "do_nodes $mdts $LCTL set_param \
28901 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
28903 mkdir -p $DIR/$tdir
28905 #hide projid xattr on server
28906 $LFS project -p 1 $testfile ||
28907 error "set $testfile project id failed"
28908 getfattr -m - $testfile | grep $xattr &&
28909 error "do not show trusted.projid when disabled on server"
28910 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
28911 #should be hidden when projid is 0
28912 $LFS project -p 0 $testfile ||
28913 error "set $testfile project id failed"
28914 getfattr -m - $testfile | grep $xattr &&
28915 error "do not show trusted.projid with project ID 0"
28917 #still can getxattr explicitly
28918 projid=$(getfattr -n $xattr $testfile |
28919 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28920 [ $projid == "0" ] ||
28921 error "projid expected 0 not $projid"
28923 #set the projid via setxattr
28924 setfattr -n $xattr -v "1000" $testfile ||
28925 error "setattr failed with $?"
28926 projid=($($LFS project $testfile))
28927 [ ${projid[0]} == "1000" ] ||
28928 error "projid expected 1000 not $projid"
28930 #check the new projid via getxattr
28931 $LFS project -p 1001 $testfile ||
28932 error "set $testfile project id failed"
28933 getfattr -m - $testfile | grep $xattr ||
28934 error "should show trusted.projid when project ID != 0"
28935 projid=$(getfattr -n $xattr $testfile |
28936 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28937 [ $projid == "1001" ] ||
28938 error "projid expected 1001 not $projid"
28940 #try to set invalid projid
28941 setfattr -n $xattr -v "4294967295" $testfile &&
28942 error "set invalid projid should fail"
28944 #remove the xattr means setting projid to 0
28945 setfattr -x $xattr $testfile ||
28946 error "setfattr failed with $?"
28947 projid=($($LFS project $testfile))
28948 [ ${projid[0]} == "0" ] ||
28949 error "projid expected 0 not $projid"
28951 #should be hidden when parent has inherit flag and same projid
28952 $LFS project -srp 1002 $DIR/$tdir ||
28953 error "set $tdir project id failed"
28954 getfattr -m - $testfile | grep $xattr &&
28955 error "do not show trusted.projid with inherit flag"
28957 #still can getxattr explicitly
28958 projid=$(getfattr -n $xattr $testfile |
28959 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28960 [ $projid == "1002" ] ||
28961 error "projid expected 1002 not $projid"
28963 run_test 904 "virtual project ID xattr"
28967 (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
28968 skip "lustre < 2.8.54 does not support ladvise"
28970 remote_ost_nodsh && skip "remote OST with nodsh"
28971 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
28973 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
28975 #define OBD_FAIL_OST_OPCODE 0x253
28977 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
28978 $LFS ladvise -a willread $DIR/$tfile &&
28979 error "unexpected success of ladvise with fault injection"
28980 $LFS ladvise -a willread $DIR/$tfile |&
28981 grep -q "Operation not supported"
28982 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
28984 run_test 905 "bad or new opcode should not stuck client"
28987 grep -q io_uring_setup /proc/kallsyms ||
28988 skip "Client OS does not support io_uring I/O engine"
28989 io_uring_probe || skip "kernel does not support io_uring fully"
28990 which fio || skip_env "no fio installed"
28991 fio --enghelp | grep -q io_uring ||
28992 skip_env "fio does not support io_uring I/O engine"
28994 local file=$DIR/$tfile
28995 local ioengine="io_uring"
28999 fio --name=seqwrite --ioengine=$ioengine \
29000 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
29001 --iodepth=64 --size=$size --filename=$file --rw=write ||
29002 error "fio seqwrite $file failed"
29004 fio --name=seqread --ioengine=$ioengine \
29005 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
29006 --iodepth=64 --size=$size --filename=$file --rw=read ||
29007 error "fio seqread $file failed"
29009 rm -f $file || error "rm -f $file failed"
29011 run_test 906 "Simple test for io_uring I/O engine via fio"
29014 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
29015 check_and_cleanup_lustre
29016 if [ "$I_MOUNTED" != "yes" ]; then
29017 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true